1 " An example for a vimrc file.
 
   3 " Maintainer:   Bram Moolenaar <Bram@vim.org>
 
   4 " Last change:  2008 Dec 17
 
   6 " To use it, copy it to
 
   7 "     for Unix and OS/2:  ~/.vimrc
 
   9 "  for MS-DOS and Win32:  $VIM\_vimrc
 
  10 "           for OpenVMS:  sys$login:.vimrc
 
  12 " When started as "evim", evim.vim will already have done these settings.
 
  13 if v:progname =~? "evim"
 
  18 " organize this file, never thought it'll get this big
 
  21 " pathogen.vim runtime path manipulation
 
  22 silent! call pathogen#infect()
 
  24 " Use Vim settings, rather than Vi settings (much better!).
 
  25 " This must be first, because it changes other options as a side effect.
 
  28 " allow backspacing over everything in insert mode
 
  29 set backspace=indent,eol,start
 
  32   set nobackup          " do not keep a backup file, use versions instead
 
  34   set backup            " keep a backup file
 
  35   set backupdir=$HOME/.vim/backupdir
 
  37 set history=50          " keep 50 lines of command line history
 
  38 set ruler               " show the cursor position all the time
 
  39 set showcmd             " display incomplete commands
 
  40 set incsearch           " do incremental searching
 
  41 set number              " show some linenumbers
 
  43 " For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
 
  44 " let &guioptions = substitute(&guioptions, "t", "", "g")
 
  46 " Don't use Ex mode, use Q for formatting
 
  49 " CTRL-U in insert mode deletes a lot.  Use CTRL-G u to first break undo,
 
  50 " so that you can undo CTRL-U after inserting a line break.
 
  51 inoremap <C-U> <C-G>u<C-U>
 
  54 nmap <F11> :set paste! paste?<CR>
 
  55 imap <F11> <C-o>:set paste!<CR>
 
  56 vmap <F11> <Esc>:set paste!<CR>gv
 
  59 " In many terminal emulators the mouse works just fine, thus enable it.
 
  61 "  "xterm mouse with middleclick paste
 
  62 "  nnoremap <MiddleMouse> i<MiddleMouse>
 
  63 "  vnoremap <MiddleMouse> s<MiddleMouse>
 
  67 "  "set ttymouse=xterm2
 
  70 " Switch syntax highlighting on, when the terminal has colors
 
  71 " Also switch on highlighting the last used search pattern.
 
  72 if &t_Co > 2 || has("gui_running")
 
  77 " Only do this part when compiled with support for autocommands.
 
  80   " Enable file type detection.
 
  81   " Use the default filetype settings, so that mail gets 'tw' set to 72,
 
  82   " 'cindent' is on in C files, etc.
 
  83   " Also load indent files, to automatically do language-dependent indenting.
 
  84   filetype plugin indent on
 
  86   " Put these in an autocmd group, so that we can delete them easily.
 
  90   " For all text files set 'textwidth' to 78 characters.
 
  91   autocmd FileType text setlocal textwidth=78
 
  93   " When editing a file, always jump to the last known cursor position.
 
  94   " Don't do it when the position is invalid or when inside an event handler
 
  95   " (happens when dropping a file on gvim).
 
  96   " Also don't do it when the mark is in the first line, that is the default
 
  97   " position when opening a file.
 
  99     \ if line("'\"") > 1 && line("'\"") <= line("$") |
 
 100     \   exe "normal! g`\"" |
 
 107   set autoindent                " always set autoindenting on
 
 109 endif " has("autocmd")
 
 111 " Convenient command to see the difference between the current buffer and the
 
 112 " file it was loaded from, thus the changes you made.
 
 113 " Only define it when not defined already.
 
 114 if !exists(":DiffOrig")
 
 115   command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
 
 116                   \ | wincmd p | diffthis
 
 119 " Ask what to do when closing unsaved documents
 
 122 " If using a dark background within the editing area and syntax highlighting
 
 123 " turn on this option as well
 
 126 " The following are commented out as they cause vim to behave a lot
 
 127 " differently from regular Vi. They are highly recommended though.
 
 128 set showcmd             " Show (partial) command in status line.
 
 129 set showmatch           " Show matching brackets.
 
 130 set ignorecase          " Do case insensitive matching
 
 131 set smartcase           " Do smart case matching
 
 132 set incsearch           " Incremental search
 
 133 set autowrite           " Automatically save before commands like :next and :make
 
 134 "set hidden             " Hide buffers when they are abandoned
 
 135 "set mouse=a            " Enable mouse usage (all modes)
 
 144 set pastetoggle=<F11>
 
 145 " split right when using :vsp
 
 148 set scrolloff=3             " keep at least 3 lines above/below
 
 149 " Press i to enter insert mode, and ii to exit.
 
 151 " Press `` to toggle insert and replace mode (no <Insert> key on Mac keyboard)
 
 154 " Jump to the next or previous line that has the same level or a lower
 
 155 " level of indentation than the current line.
 
 157 " exclusive (bool): true: Motion is exclusive
 
 158 " false: Motion is inclusive
 
 159 " fwd (bool): true: Go to next line
 
 160 " false: Go to previous line
 
 161 " lowerlevel (bool): true: Go to line with lower indentation level
 
 162 " false: Go to line with the same indentation level
 
 163 " skipblanks (bool): true: Skip blank lines
 
 164 " false: Don't skip blank lines
 
 165 function! NextIndent(exclusive, fwd, lowerlevel, skipblanks)
 
 167   let column = col('.')
 
 168   let lastline = line('$')
 
 169   let indent = indent(line)
 
 170   let stepvalue = a:fwd ? 1 : -1
 
 171   while (line > 0 && line <= lastline)
 
 172     let line = line + stepvalue
 
 173     if ( ! a:lowerlevel && indent(line) == indent ||
 
 174           \ a:lowerlevel && indent(line) < indent)
 
 175       if (! a:skipblanks || strlen(getline(line)) > 0)
 
 177           let line = line - stepvalue
 
 180         exe "normal " column . "|"
 
 187 " Moving back and forth between lines of same or lower indentation.
 
 188 nnoremap <silent> [l :call NextIndent(0, 0, 0, 1)<CR>
 
 189 nnoremap <silent> ]l :call NextIndent(0, 1, 0, 1)<CR>
 
 190 nnoremap <silent> [L :call NextIndent(0, 0, 1, 1)<CR>
 
 191 nnoremap <silent> ]L :call NextIndent(0, 1, 1, 1)<CR>
 
 192 vnoremap <silent> [l <Esc>:call NextIndent(0, 0, 0, 1)<CR>m'gv''
 
 193 vnoremap <silent> ]l <Esc>:call NextIndent(0, 1, 0, 1)<CR>m'gv''
 
 194 vnoremap <silent> [L <Esc>:call NextIndent(0, 0, 1, 1)<CR>m'gv''
 
 195 vnoremap <silent> ]L <Esc>:call NextIndent(0, 1, 1, 1)<CR>m'gv''
 
 196 onoremap <silent> [l :call NextIndent(0, 0, 0, 1)<CR>
 
 197 onoremap <silent> ]l :call NextIndent(0, 1, 0, 1)<CR>
 
 198 onoremap <silent> [L :call NextIndent(1, 0, 1, 1)<CR>
 
 199 onoremap <silent> ]L :call NextIndent(1, 1, 1, 1)<CR>