3 " Maintainer:   Samir Benmendil <ram-z@chakra-project.org>
 
   6 if v:progname =~? "evim"
 
  11 " organize this file, never thought it'll get this big
 
  14 " pathogen.vim runtime path manipulation
 
  15 silent! call pathogen#infect()
 
  17 " Use Vim settings, rather than Vi settings (much better!).
 
  18 " This must be first, because it changes other options as a side effect.
 
  21 " allow backspacing over everything in insert mode
 
  22 set backspace=indent,eol,start
 
  25   set nobackup          " do not keep a backup file, use versions instead
 
  27   set backup            " keep a backup file
 
  28   set backupdir=$HOME/.vim/backupdir
 
  30 set history=50          " keep 50 lines of command line history
 
  31 set ruler               " show the cursor position all the time
 
  32 set showcmd             " display incomplete commands
 
  33 set incsearch           " do incremental searching
 
  34 set number              " show some linenumbers
 
  35 " viminfo defaults but save file in .vim
 
  36 set viminfo='100,<50,s10,h,n~/.vim/viminfo
 
  38 " For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
 
  39 " let &guioptions = substitute(&guioptions, "t", "", "g")
 
  41 " Don't use Ex mode, use Q for formatting
 
  44 " CTRL-U in insert mode deletes a lot.  Use CTRL-G u to first break undo,
 
  45 " so that you can undo CTRL-U after inserting a line break.
 
  46 inoremap <C-U> <C-G>u<C-U>
 
  49 nmap <F11> :set paste! paste?<CR>
 
  50 imap <F11> <C-o>:set paste!<CR>
 
  51 vmap <F11> <Esc>:set paste!<CR>gv
 
  54 " In many terminal emulators the mouse works just fine, thus enable it.
 
  56 "  "xterm mouse with middleclick paste
 
  57 "  nnoremap <MiddleMouse> i<MiddleMouse>
 
  58 "  vnoremap <MiddleMouse> s<MiddleMouse>
 
  62 "  "set ttymouse=xterm2
 
  65 " Switch syntax highlighting on, when the terminal has colors
 
  66 " Also switch on highlighting the last used search pattern.
 
  67 if &t_Co > 2 || has("gui_running")
 
  72 " Only do this part when compiled with support for autocommands.
 
  75   " Enable file type detection.
 
  76   " Use the default filetype settings, so that mail gets 'tw' set to 72,
 
  77   " 'cindent' is on in C files, etc.
 
  78   " Also load indent files, to automatically do language-dependent indenting.
 
  79   filetype plugin indent on
 
  81   " Put these in an autocmd group, so that we can delete them easily.
 
  85   " For all text files set 'textwidth' to 78 characters.
 
  86   autocmd FileType text setlocal textwidth=78
 
  88   " When editing a file, always jump to the last known cursor position.
 
  89   " Don't do it when the position is invalid or when inside an event handler
 
  90   " (happens when dropping a file on gvim).
 
  91   " Also don't do it when the mark is in the first line, that is the default
 
  92   " position when opening a file.
 
  93   " blacklist certain filetype, you can get a file type with :echo &ft
 
  94   let blacklist = ['gitcommit']
 
  96     \ if index(blacklist, &ft) < 0 && line("'\"") > 1 && line("'\"") <= line("$") |
 
  97     \   exe "normal! g`\"" |
 
 104   set autoindent                " always set autoindenting on
 
 106 endif " has("autocmd")
 
 108 " Convenient command to see the difference between the current buffer and the
 
 109 " file it was loaded from, thus the changes you made.
 
 110 " Only define it when not defined already.
 
 111 if !exists(":DiffOrig")
 
 112   command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
 
 113                   \ | wincmd p | diffthis
 
 116 " Ask what to do when closing unsaved documents
 
 119 " If using a dark background within the editing area and syntax highlighting
 
 120 " turn on this option as well
 
 123 " The following are commented out as they cause vim to behave a lot
 
 124 " differently from regular Vi. They are highly recommended though.
 
 125 set showcmd             " Show (partial) command in status line.
 
 126 set showmatch           " Show matching brackets.
 
 127 set ignorecase          " Do case insensitive matching
 
 128 set smartcase           " Do smart case matching
 
 129 set incsearch           " Incremental search
 
 130 set autowrite           " Automatically save before commands like :next and :make
 
 131 "set hidden             " Hide buffers when they are abandoned
 
 132 "set mouse=a            " Enable mouse usage (all modes)
 
 140 " show these chars for tabs and trailing spaces
 
 141 set list listchars=tab:»·,trail:·
 
 143 set pastetoggle=<F11>
 
 144 " split right when using :vsp
 
 147 set scrolloff=3             " keep at least 3 lines above/below
 
 148 " Press i to enter insert mode, and ii to exit.
 
 150 " Press `` to toggle insert and replace mode (no <Insert> key on Mac keyboard)
 
 153 " fold between {{{ }}}
 
 154 set foldmethod=marker
 
 155 set foldlevelstart=99
 
 156 " space will toggle current fold in normal mode, if not in a fold, normal
 
 158 nnoremap <silent> <Space> @=(foldlevel('.')?'za':"\<Space>")<CR>
 
 160 " save and restore folds
 
 161 autocmd BufWinLeave *.* mkview
 
 162 autocmd BufWinEnter *.* silent loadview
 
 164 " Jump to the next or previous line that has the same level or a lower
 
 165 " level of indentation than the current line.
 
 167 " exclusive (bool): true: Motion is exclusive
 
 168 " false: Motion is inclusive
 
 169 " fwd (bool): true: Go to next line
 
 170 " false: Go to previous line
 
 171 " lowerlevel (bool): true: Go to line with lower indentation level
 
 172 " false: Go to line with the same indentation level
 
 173 " skipblanks (bool): true: Skip blank lines
 
 174 " false: Don't skip blank lines
 
 175 function! NextIndent(exclusive, fwd, lowerlevel, skipblanks)
 
 177   let column = col('.')
 
 178   let lastline = line('$')
 
 179   let indent = indent(line)
 
 180   let stepvalue = a:fwd ? 1 : -1
 
 181   while (line > 0 && line <= lastline)
 
 182     let line = line + stepvalue
 
 183     if ( ! a:lowerlevel && indent(line) == indent ||
 
 184           \ a:lowerlevel && indent(line) < indent)
 
 185       if (! a:skipblanks || strlen(getline(line)) > 0)
 
 187           let line = line - stepvalue
 
 190         exe "normal " column . "|"
 
 197 " Moving back and forth between lines of same or lower indentation.
 
 198 nnoremap <silent> [l :call NextIndent(0, 0, 0, 1)<CR>
 
 199 nnoremap <silent> ]l :call NextIndent(0, 1, 0, 1)<CR>
 
 200 nnoremap <silent> [L :call NextIndent(0, 0, 1, 1)<CR>
 
 201 nnoremap <silent> ]L :call NextIndent(0, 1, 1, 1)<CR>
 
 202 vnoremap <silent> [l <Esc>:call NextIndent(0, 0, 0, 1)<CR>m'gv''
 
 203 vnoremap <silent> ]l <Esc>:call NextIndent(0, 1, 0, 1)<CR>m'gv''
 
 204 vnoremap <silent> [L <Esc>:call NextIndent(0, 0, 1, 1)<CR>m'gv''
 
 205 vnoremap <silent> ]L <Esc>:call NextIndent(0, 1, 1, 1)<CR>m'gv''
 
 206 onoremap <silent> [l :call NextIndent(0, 0, 0, 1)<CR>
 
 207 onoremap <silent> ]l :call NextIndent(0, 1, 0, 1)<CR>
 
 208 onoremap <silent> [L :call NextIndent(1, 0, 1, 1)<CR>
 
 209 onoremap <silent> ]L :call NextIndent(1, 1, 1, 1)<CR>