Vim Configuration

(Chip) Some of my students have asked about my Vim configuration, so here it is, with some documentation (but not enough, I’m sure). To see more about any command – use vim’s internal help (:help foo).


Note that in a vim config file, a quote (“) begins a comment. So some of this file is commented out.

To use this config – you will need to either include this in your .vimrc, or elsewhere depending on your vim skills.

set nocompatible        " enable some vim-specific stuff without worrying about vi compatibility

" numerics
set backspace=2         " so i can backspace over newlines, indentation, etc.

set nostartofline       " preserve column on page movements
"set nobackup           " don't store my crap in /tmp
"set nowritebackup      " and don't write it either.. (??)
"set nowrap             " so lines don't wrap
set hidden              " allow hidden buffers. supposedly a 'must have'

set magic               " enable extended regexp support

set showmode            " show current mode
set showcmd             " show current uncompleted command

set autoindent          " for programming indentation
"set tabstop=2
set softtabstop=2       " I like using just 2 spaces for indentation (and tabbing)
set shiftwidth=2        " Shifting is a kind of indentation
"set showmatch          " Causes the matching brace to be highlighted 
"set ignorecase         " search case-insensitive
set smartcase           " search case-insensitive if only lower-case letters are typed 
set hlsearch            " highlight matching search words
set incsearch           " jump to things that match as searches are typed
syntax on               " turn on syntax highlighting
set expandtab           " don't save tabs in files - expand them to spaces instead
set background=dark     " I use a dark terminal, so this makes the colors more dark-friendly
set ruler               " Shows the row and column information of the cursor
"set modeline
set wildmode=longest,list " Make tab completion work like bash - which is what I'm used to
"set mouse=n
"let g:Tb_TabWrap = 1
let g:Tb_MaxSize = 0   
map <C-J> <C-W>j<C-W>_  " Use Ctrl-J to move down one buffer and maximize it.
map <C-K> <C-W>k<C-W>_  " Use Ctrl-K to move up one buffer and maximize it.

" These options are based on the file explorer plugin, which I do not generally use
map <Leader>wf :FirstExplorerWindow<cr>
map <Leader>wb :BottomExplorerWindow<cr>
map <Leader>wt :WMToggle<cr>
set wmh=0

set guicursor+=a:blinkon0  "Do not blink the cursor using guis such as MacVim

" Mappings with function keys I do not use anymore since my Mac keyboard does funny things with function keys.
" quickly remove the search highlights
"map <F4> :nohl<CR>
" quickly close the current buffer
"map <F5> :bd<CR>
"map <F5> :se syntax=macelog<cr>:%!~/mace/tools/<cr>

" Change the syntax of the current buffer to the macelog syntax, and indent the buffer using the logindenter tool Mace provides.
map <Leader>ml :se syntax=macelog<cr>:%!~/mace/tools/<cr>

" allow for quick saves
map <F10> :w<CR>
imap <F10> <ESC>:w<CR>a

" If the file ends with .mlog or .out-*, treat it as a mace log (set syntax style)
au BufNewFile,BufRead *.out-* set syntax=macelog
au BufNewFile,BufRead *.mlog set syntax=macelog

" If the file is a .mh file, treat it as a Mace header file.
au BufNewFile,BufRead *.mh set syntax=mh

" If the file is a C, C++, or Java file, use syntax folding (braces cause the file to collapse -- se :help fold-commands for opening and closing folds
au BufNewFile,BufRead *.{c,h,cc,cpp,C,H,java} set foldmethod=syntax

" If the file is perl, I'd like to use indentation of 4 characters, not 2.
au BufNewFile,BufRead *.{pl,pm} set softtabstop=4 shiftwidth=4

" If the file is a Mace file (.m, .mac, .mace, .vmac, .mi), then set some options - syntax, indentation, etc.)
au BufNewFile,BufRead *.{m} set ft=mac sm autoindent expandtab
au BufNewFile,BufRead *.{m} set syntax=mace
au BufNewFile,BufRead *.{m} set foldmethod=syntax

au BufNewFile,BufRead *.{mac} set ft=mac sm autoindent expandtab
au BufNewFile,BufRead *.{mac} set syntax=mace
au BufNewFile,BufRead *.{mac} set foldmethod=syntax

au BufNewFile,BufRead *.{vmac} set ft=mac sm autoindent expandtab
au BufNewFile,BufRead *.{vmac} set syntax=mace
au BufNewFile,BufRead *.{vmac} set foldmethod=syntax

au BufNewFile,BufRead *.{mi} set ft=mac sm autoindent expandtab
au BufNewFile,BufRead *.{mi} set syntax=mace
au BufNewFile,BufRead *.{mi} set foldmethod=syntax

" For LaTeX files, fold them based on markers, and use a 72 column width for wrapping.
au BufNewFile,BufRead *.{tex} set spell foldmethod=marker textwidth=72

" For mutt email compositions, turn on spell checking and set a 72 column wrapping width.
au BufNewFile,BufRead mutt-* set spell textwidth=72

" For HTML files, use the closetags vimscript.
au Filetype html,xml,xsl source ~/.vim/scripts/closetags.vim

" :cn is to move to the next compilation error, :cp moves to the prior one.  I use \= and \- because they are shorter
map <Leader>= :cn<cr>
map <Leader>- :cp<cr>

" \l then does what :cl does, which is to list all errors.
map <Leader>l :cl<cr>

set laststatus=2      " Always have a status line
"if version >= 700
"  au InsertEnter * hi StatusLine term=reverse ctermbg=5 gui=undercurl guisp=Magenta
"  au InsertLeave * hi StatusLine term=reverse ctermfg=0 ctermbg=2 gui=bold,reverse

" Settings recommended by vim-latex
" REQUIRED. This makes vim invoke Latex-Suite when you open a tex file.
filetype plugin on

" IMPORTANT: win32 users will need to have 'shellslash' set so that latex
" can be called correctly.
set shellslash

" IMPORTANT: grep will sometimes skip displaying the file name if you
" search in a singe file. This will confuse Latex-Suite. Set your grep
" program to always generate a file-name.
set grepprg=grep\ -nH\ $*

" OPTIONAL: This enables automatic indentation as you type.
filetype indent on

" OPTIONAL: Starting with Vim 7, the filetype of empty .tex files defaults to
" 'plaintex' instead of 'tex', which results in vim-latex not being loaded.
" The following changes the default filetype back to 'tex':
let g:tex_flavor='latex'


Note that this is not all of my configuration. I additionally have a number of plugins, scripts, and syntax files I’ve installed. For example, I have installed these plugins:

  • latex-suite
  • bufexplorer
  • CommentToggle
  • filebrowser
  • imaps
  • MultipleSearch
  • Shell
  • SuperTabs
  • SyntaxFolds
  • winfileexplorer
  • winmanager
  • wintaxexplorer

I have bolded the ones I use most. Most of them I found on the website, a long time ago. I’m sure you can find them too with the help of your favorite search engine or the Vim website.

Syntax Files

I have these syntax files added:


I have the closetags script installed, though I’m not sure how much I use it.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>