I have a love affair with Vim. It’s the programmers text editor: with just a few key-strokes you can do just about anything. This is what programmers live for! We share a collective belief that the answer to all of the world’s problems, lay just a few key-strokes away. Vim–ever so slightly–confirms our mutual delusion. Without moving your hands away from the keyboard, you can edit, paste, search, replace, undo, redo, automate, and this and more, and so much more.
Vim is especially popular among the Unix\Linux crowd where Vi(m) originated. However, there’s no need for windows power-users to lag behind. gVim (graphical vim) is a great port of Vim for windows. In this article I will go over my _vimrc (windows version of .vimrc) and my basic setup.
I based my vimrc file on Yan Pritzker’s, and I recommend you check his setup up (especially if you’re running on a mac).
- The first thing you want to check is to ensure that your $HOME directory is set to C:/Users/[username]. If it’s not, then some of the features in this setup may not work properly.
- Next you’ll want to create the folder $HOME/vimfiles/, $HOME/vimfiles/backups, $HOME/vimfiles/ftplugin, $HOME/vimfiles/views
- Finally, you’ll want to create a “_vimrc” in the $HOME directory
_vimrc Contents with Detailed Comments” Begin with ensuring that we are running in vim mode not vi
set nocompatible” Set the color scheme of choice.
” In vim ‘:colorscheme [tab]‘ to see more options
” Start in documents folder [WINDOWS specific]
” (this is not as useful if you start vim from cmd line since
” in that case you may want the pwd to be the dir where you
” loaded vim from; however, since most of us start gVim from
” the start menu then starting off in yoru documents folder
” is a good choice)
” The following two lines turn on highlight for search (1st
” line) and allow you to use to turn off highlight
” for that search. The highlight will return on your next
“Line numbers are good–turn them on
“Allow backspace in insert mode
“Store lots of :cmdline history
“Show incomplete cmds down the bottom
“Show current mode down the bottom
“Reload files changed outside vim
“Modeline option enabled for custom vim settings per file
” This makes vim act like all other editors, buffers can
” exist in the background without being in a window.
“turn on syntax highlighting
” ================ Turn Off Swap Files ==============
” ================ Persistent Undo ==================
” Keep undo history across sessions, by storing in file.
” ================ Indentation ======================
filetype plugin on
filetype indent on
set list listchars=tab:\ \ ,trail:·
“Don’t wrap lines
“Wrap lines at convenient points
” ================ Folds ============================
set foldmethod=indent “fold based on indent
set foldnestmax=3 “deepest fold is 3 levels
set nofoldenable “dont fold by default
” The following lines save the view of the file including
” the folds and automatically saves and opens them. The
” next time that you open up the same file it will
” remember where you closed and open all the folds!
autocmd BufWinLeave *.* mkview!
autocmd BufWinEnter *.* silent loadview
” ================ Completion =======================
set wildmenu “enable ctrl-n and ctrl-p to scroll thru matches
set wildignore=*.o,*.obj,*~ “stuff to ignore when tab completing
” ================ Scrolling ========================
“Start scrolling when we’re 8 lines away from margins