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
 
  36 " For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
 
  37 " let &guioptions = substitute(&guioptions, "t", "", "g")
 
  39 " Don't use Ex mode, use Q for formatting
 
  42 " CTRL-U in insert mode deletes a lot.  Use CTRL-G u to first break undo,
 
  43 " so that you can undo CTRL-U after inserting a line break.
 
  44 inoremap <C-U> <C-G>u<C-U>
 
  47 nmap <F11> :set paste! paste?<CR>
 
  48 imap <F11> <C-o>:set paste!<CR>
 
  49 vmap <F11> <Esc>:set paste!<CR>gv
 
  52 " In many terminal emulators the mouse works just fine, thus enable it.
 
  54 "  "xterm mouse with middleclick paste
 
  55 "  nnoremap <MiddleMouse> i<MiddleMouse>
 
  56 "  vnoremap <MiddleMouse> s<MiddleMouse>
 
  60 "  "set ttymouse=xterm2
 
  63 " Switch syntax highlighting on, when the terminal has colors
 
  64 " Also switch on highlighting the last used search pattern.
 
  65 if &t_Co > 2 || has("gui_running")
 
  70 " Only do this part when compiled with support for autocommands.
 
  73   " Enable file type detection.
 
  74   " Use the default filetype settings, so that mail gets 'tw' set to 72,
 
  75   " 'cindent' is on in C files, etc.
 
  76   " Also load indent files, to automatically do language-dependent indenting.
 
  77   filetype plugin indent on
 
  79   " Put these in an autocmd group, so that we can delete them easily.
 
  83   " For all text files set 'textwidth' to 78 characters.
 
  84   autocmd FileType text setlocal textwidth=78
 
  86   " When editing a file, always jump to the last known cursor position.
 
  87   " Don't do it when the position is invalid or when inside an event handler
 
  88   " (happens when dropping a file on gvim).
 
  89   " Also don't do it when the mark is in the first line, that is the default
 
  90   " position when opening a file.
 
  91   " blacklist certain filetype, you can get a file type with :echo &ft
 
  92   let blacklist = ['gitcommit']
 
  94     \ if index(blacklist, &ft) < 0 && line("'\"") > 1 && line("'\"") <= line("$") |
 
  95     \   exe "normal! g`\"" |
 
 102   set autoindent                " always set autoindenting on
 
 104 endif " has("autocmd")
 
 106 " Convenient command to see the difference between the current buffer and the
 
 107 " file it was loaded from, thus the changes you made.
 
 108 " Only define it when not defined already.
 
 109 if !exists(":DiffOrig")
 
 110   command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
 
 111                   \ | wincmd p | diffthis
 
 114 " Ask what to do when closing unsaved documents
 
 117 " If using a dark background within the editing area and syntax highlighting
 
 118 " turn on this option as well
 
 121 " The following are commented out as they cause vim to behave a lot
 
 122 " differently from regular Vi. They are highly recommended though.
 
 123 set showcmd             " Show (partial) command in status line.
 
 124 set showmatch           " Show matching brackets.
 
 125 set ignorecase          " Do case insensitive matching
 
 126 set smartcase           " Do smart case matching
 
 127 set incsearch           " Incremental search
 
 128 set autowrite           " Automatically save before commands like :next and :make
 
 129 "set hidden             " Hide buffers when they are abandoned
 
 130 "set mouse=a            " Enable mouse usage (all modes)
 
 138 " show these chars for tabs and trailing spaces
 
 139 set list listchars=tab:»·,trail:·
 
 141 set pastetoggle=<F11>
 
 142 " split right when using :vsp
 
 145 set scrolloff=3             " keep at least 3 lines above/below
 
 146 " Press i to enter insert mode, and ii to exit.
 
 148 " Press `` to toggle insert and replace mode (no <Insert> key on Mac keyboard)
 
 151 " fold between {{{ }}}
 
 152 set foldmethod=marker
 
 153 set foldlevelstart=99
 
 154 " space will toggle current fold in normal mode, if not in a fold, normal
 
 156 nnoremap <silent> <Space> @=(foldlevel('.')?'za':"\<Space>")<CR>
 
 158 " save and restore folds
 
 159 autocmd BufWinLeave *.* mkview
 
 160 autocmd BufWinEnter *.* silent loadview
 
 162 " Jump to the next or previous line that has the same level or a lower
 
 163 " level of indentation than the current line.
 
 165 " exclusive (bool): true: Motion is exclusive
 
 166 " false: Motion is inclusive
 
 167 " fwd (bool): true: Go to next line
 
 168 " false: Go to previous line
 
 169 " lowerlevel (bool): true: Go to line with lower indentation level
 
 170 " false: Go to line with the same indentation level
 
 171 " skipblanks (bool): true: Skip blank lines
 
 172 " false: Don't skip blank lines
 
 173 function! NextIndent(exclusive, fwd, lowerlevel, skipblanks)
 
 175   let column = col('.')
 
 176   let lastline = line('$')
 
 177   let indent = indent(line)
 
 178   let stepvalue = a:fwd ? 1 : -1
 
 179   while (line > 0 && line <= lastline)
 
 180     let line = line + stepvalue
 
 181     if ( ! a:lowerlevel && indent(line) == indent ||
 
 182           \ a:lowerlevel && indent(line) < indent)
 
 183       if (! a:skipblanks || strlen(getline(line)) > 0)
 
 185           let line = line - stepvalue
 
 188         exe "normal " column . "|"
 
 195 " Moving back and forth between lines of same or lower indentation.
 
 196 nnoremap <silent> [l :call NextIndent(0, 0, 0, 1)<CR>
 
 197 nnoremap <silent> ]l :call NextIndent(0, 1, 0, 1)<CR>
 
 198 nnoremap <silent> [L :call NextIndent(0, 0, 1, 1)<CR>
 
 199 nnoremap <silent> ]L :call NextIndent(0, 1, 1, 1)<CR>
 
 200 vnoremap <silent> [l <Esc>:call NextIndent(0, 0, 0, 1)<CR>m'gv''
 
 201 vnoremap <silent> ]l <Esc>:call NextIndent(0, 1, 0, 1)<CR>m'gv''
 
 202 vnoremap <silent> [L <Esc>:call NextIndent(0, 0, 1, 1)<CR>m'gv''
 
 203 vnoremap <silent> ]L <Esc>:call NextIndent(0, 1, 1, 1)<CR>m'gv''
 
 204 onoremap <silent> [l :call NextIndent(0, 0, 0, 1)<CR>
 
 205 onoremap <silent> ]l :call NextIndent(0, 1, 0, 1)<CR>
 
 206 onoremap <silent> [L :call NextIndent(1, 0, 1, 1)<CR>
 
 207 onoremap <silent> ]L :call NextIndent(1, 1, 1, 1)<CR>