3 " Maintainer:   Samir Benmendil <samir.benmendil[at]gmail[dot]com>
 
   6 if v:progname =~? "evim"
 
  10 " Use Vim settings, rather than Vi settings (much better!).
 
  11 " This must be first, because it changes other options as a side effect.
 
  14 " pathogen.vim runtime path manipulation
 
  15 silent! call pathogen#infect()
 
  22 nmap <Leader>q :nohl<CR>
 
  26 " open/close NERDTree with \e
 
  27 nmap <Leader>e :NERDTreeToggle<CR>
 
  28 " <space> to open files/dirs
 
  29 let NERDTreeMapActivateNode='<space>'
 
  30 " open NERDTree if no files were selected
 
  31 autocmd vimenter * if !argc() | NERDTree | endif
 
  32 " close vim if only NERDTree is open
 
  33 autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
 
  37 let g:airline#extensions#tabline#enabled = 1
 
  41 :nmap <Leader>b :set expandtab tabstop=4 shiftwidth=4 softtabstop=4<CR>
 
  42 :nmap <Leader>B :set expandtab tabstop=8 shiftwidth=8 softtabstop=4<CR>
 
  43 :nmap <Leader>M :set noexpandtab tabstop=8 softtabstop=4 shiftwidth=4<CR>
 
  44 :nmap <Leader>m :set expandtab tabstop=2 shiftwidth=2 softtabstop=2<CR>
 
  49   set nobackup          " do not keep a backup file, use versions instead
 
  51   set backup            " keep a backup file
 
  52   set backupdir=$HOME/.vim/backupdir
 
  57 set background=dark            " Dark background, d'uh!
 
  58 set number                     " show some linenumbers
 
  59 set showmatch                  " Show matching brackets.
 
  60 set showbreak=▒▒                  " show these chars for wrapped lines
 
  61 set list listchars=tab:»·,trail:· " show these chars for tabs and trailing spaces
 
  65 set history=500                " keep 500 lines of command line history
 
  66 set ruler                      " show the cursor position all the time
 
  67 set confirm                    " Ask what to do when closing unsaved documents
 
  68 set showcmd                    " Show (partial) command in status line.
 
  69 set autowrite                  " Automatically save before commands like :next and :make
 
  70 "set hidden                    " Hide buffers when they are abandoned
 
  71 set splitright                 " split right when using :vsp
 
  72 set scrolloff=5                " keep at least n lines above/below
 
  73 set backspace=indent,eol,start " allow backspacing over everything in insert mode
 
  75 set viminfo='100,<50,s10,h,n~/.vim/viminfo " viminfo defaults but save file in .vim
 
  85 " Don't use Ex mode, use Q for formatting
 
  88 " CTRL-U in insert mode deletes a lot.  Use CTRL-G u to first break undo,
 
  89 " so that you can undo CTRL-U after inserting a line break.
 
  90 inoremap <C-U> <C-G>u<C-U>
 
  92 " Press `` to toggle insert and replace mode (no <Insert> key on Mac keyboard)
 
  97 nmap <F11> :set paste! paste?<CR>
 
  98 imap <F11> <C-o>:set paste!<CR>
 
  99 vmap <F11> <Esc>:set paste!<CR>gv
 
 100 set pastetoggle=<F11>
 
 104 " In many terminal emulators the mouse works just fine, thus enable it.
 
 106   "xterm mouse with middleclick paste
 
 107   nnoremap <MiddleMouse> i<MiddleMouse>
 
 108   vnoremap <MiddleMouse> s<MiddleMouse>
 
 117 " Switch syntax highlighting on, when the terminal has colors
 
 118 " Also switch on highlighting the last used search pattern.
 
 119 if &t_Co > 2 || has("gui_running")
 
 125 " Only do this part when compiled with support for autocommands.
 
 127   " Enable file type detection.
 
 128   " Use the default filetype settings, so that mail gets 'tw' set to 72,
 
 129   " 'cindent' is on in C files, etc.
 
 130   " Also load indent files, to automatically do language-dependent indenting.
 
 131   filetype plugin indent on
 
 133   " Put these in an autocmd group, so that we can delete them easily.
 
 137   " For all text files set 'textwidth' to 78 characters.
 
 138   autocmd FileType text setlocal textwidth=78
 
 140   " When editing a file, always jump to the last known cursor position.
 
 141   " Don't do it when the position is invalid or when inside an event handler
 
 142   " (happens when dropping a file on gvim).
 
 143   " Also don't do it when the mark is in the first line, that is the default
 
 144   " position when opening a file.
 
 145   " blacklist certain filetype, you can get a file type with :echo &ft
 
 146   let blacklist = ['gitcommit']
 
 147   autocmd BufReadPost *
 
 148     \ if index(blacklist, &ft) < 0 && line("'\"") > 1 && line("'\"") <= line("$") |
 
 149     \   exe "normal! g`\"" |
 
 154   set autoindent                " always set autoindenting on
 
 155 endif " has("autocmd") }}}
 
 158 " Convenient command to see the difference between the current buffer and the
 
 159 " file it was loaded from, thus the changes you made.
 
 160 " Only define it when not defined already.
 
 161 if !exists(":DiffOrig")
 
 162   command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
 
 163                   \ | wincmd p | diffthis
 
 168 set foldmethod=marker
 
 169 set foldlevelstart=99
 
 170 " space will toggle current fold in normal mode, if not in a fold, normal
 
 172 nnoremap <silent> <Space> @=(foldlevel('.')?'za':"\<Space>")<CR>
 
 174 " save and restore folds
 
 175 autocmd BufWinLeave *.* mkview
 
 176 autocmd BufWinEnter *.* silent loadview
 
 179 function! NextIndent(exclusive, fwd, lowerlevel, skipblanks) " {{{
 
 180 " Jump to the next or previous line that has the same level or a lower
 
 181 " level of indentation than the current line.
 
 183 " exclusive (bool): true: Motion is exclusive
 
 184 " false: Motion is inclusive
 
 185 " fwd (bool): true: Go to next line
 
 186 " false: Go to previous line
 
 187 " lowerlevel (bool): true: Go to line with lower indentation level
 
 188 " false: Go to line with the same indentation level
 
 189 " skipblanks (bool): true: Skip blank lines
 
 190 " false: Don't skip blank lines
 
 192   let column = col('.')
 
 193   let lastline = line('$')
 
 194   let indent = indent(line)
 
 195   let stepvalue = a:fwd ? 1 : -1
 
 196   while (line > 0 && line <= lastline)
 
 197     let line = line + stepvalue
 
 198     if ( ! a:lowerlevel && indent(line) == indent ||
 
 199           \ a:lowerlevel && indent(line) < indent)
 
 200       if (! a:skipblanks || strlen(getline(line)) > 0)
 
 202           let line = line - stepvalue
 
 205         exe "normal " column . "|"
 
 212 " Moving back and forth between lines of same or lower indentation.
 
 213 nnoremap <silent> [l :call NextIndent(0, 0, 0, 1)<CR>
 
 214 nnoremap <silent> ]l :call NextIndent(0, 1, 0, 1)<CR>
 
 215 nnoremap <silent> [L :call NextIndent(0, 0, 1, 1)<CR>
 
 216 nnoremap <silent> ]L :call NextIndent(0, 1, 1, 1)<CR>
 
 217 vnoremap <silent> [l <Esc>:call NextIndent(0, 0, 0, 1)<CR>m'gv''
 
 218 vnoremap <silent> ]l <Esc>:call NextIndent(0, 1, 0, 1)<CR>m'gv''
 
 219 vnoremap <silent> [L <Esc>:call NextIndent(0, 0, 1, 1)<CR>m'gv''
 
 220 vnoremap <silent> ]L <Esc>:call NextIndent(0, 1, 1, 1)<CR>m'gv''
 
 221 onoremap <silent> [l :call NextIndent(0, 0, 0, 1)<CR>
 
 222 onoremap <silent> ]l :call NextIndent(0, 1, 0, 1)<CR>
 
 223 onoremap <silent> [L :call NextIndent(1, 0, 1, 1)<CR>
 
 224 onoremap <silent> ]L :call NextIndent(1, 1, 1, 1)<CR>
 
 225 " end of jump indent }}}