Monday, May 25, 2015

VIM resource file

I have been using the VIM editor for something north of twenty years now. Even when my "primary" editor has been Visual Studio or SlickEdit, I still use VIM for quick tasks and for diffing (along with the indispensable GNU diff utility). And really, I'm far from a master with it. It occurs to me that reading back over my VIM resource file is almost like a mini personal archaeology of my programming experience. I have the simple stuff from my early days in college, a lot of the GUI movement things came from later when I started into CS more seriously, and then bits and pieces added that reflected what I was doing in my jobs. The editor wars will never really end, though the old text editors are increasingly taking a back seat to IDEs that are better at navigating through large projects or reflect the more complex work flows of modern applications. In the end a useful tool never really stops being useful.

My .vimrc:

"Basic editing behaviors
set showmode      "mode info at the bottom of the screen
set backspace=indent,eol,start "allow full backspace movement
"set autoindent    "regular auto-indent
set smartindent   "a more advanced indenting option
"set cindent       "strict rules based indenting
set columns=95    "preferred window width
set lines=40      "preferred window height
set expandtab     "use spaces instead of tabs
set ruler         "show line and column numbers
set showbreak=<=  "what to print at front of wrapped lines
set showmatch     "blip to matching brackets
set shiftwidth=2  "code indention size

"search behaviors
set nohlsearch "highlights all matches to a search
set incsearch  "search incrementally
"set smartcase  "only be case sensitive if a capital is in the search string
set ignorecase "case insensitive searching

"file behaviors
set directory=c:\windows\temp "set the swap file directory
set wildignore=*.o,*.class "ignore these files when doing filename completion

"status line stuff
"always show the status line
set laststatus=2           "always show the status line
"set statusline=%t\ %h%m%r%=%-12(0x%02.2B\ %b%)\ %c,%l/%L "broken out below
set statusline=%t          "filename (not fully qualified)
set statusline+=\ %h       "help file indicator
set statusline+=%m         "file modified indicator
set statusline+=%r         "file read-only indicator
set statusline+=%=         "shove the rest to the right (left/right separator)
set statusline+=%-12(0x%02.2B\ %b%)
                           "hex value of the character under the cursor padded
                           "  with zeros to min and max of 2 characters long [0x%02.2B]
                           "  followed by decimal value of the character [%b]. All
                           "  of this left justified and padded to min 15 characters
                           "  [%-12( ... %)].
set statusline+=\ %c,%l/%L "column cursor is in

"GUI commands
highlight Normal guibg=Black guifg=White
"set guifont=Consolas:h10:cANSI  "Set the font (***PLATFORM SPECIFIC***)
set guifont=DejaVu_Sans_Mono:h9:cANSI  "Set the font (***PLATFORM SPECIFIC***)

"Color and syntax highlighting stuff
set background=dark "MUST be before other highlighting settings
syntax on           "turns on syntax highlighting
highlight Comment   guifg=#DDA0DD "HTML Plum
highlight Constant  guifg=#FF6347 "HTML Tomato
highlight Statement guifg=#5588FF "A mid-intensity blue
highlight Type      guifg=#5588FF "A mid-intensity blue
highlight PreProc   guifg=#7CFC00 "HTML Lawn Green

"Session stuff
set sessionoptions-=options "Don't save options with the session

"Make the HOME key go to the first non-whitespace character the
" first time it is hit, and then to the first column.
fun! s:SmartHome()
  if col('.') != match(getline('.'), '\S')+1
    norm ^
  else
    :call cursor(line('.'),2)
    norm h
  endif
endfun
inoremap  :call SmartHome()
nnoremap  :call SmartHome()
vnoremap  :call SmartHome()

"Add shortcut keys to move between buffers (not to be confused with
" moving between windows, which is shortcutted below).
" Alias Alt-Up to move to the previous buffer
nmap  :bp!
" Alias Alt-Down to move to the next buffer
nmap  :bn!

"Alter split switching behavior to make me happier
set winminheight=0  "This allows open windows to display as status line only
" Alias Ctrl-Down to move down a window
map  j_
" Alias Ctrl-Up to move up one window
map  k_
" Alias Ctrl-Right to move right one window
map  l
" Alias Ctrl-Left to move left one window
map  h
" Alias Ctrl-h to 'maximize' the window
map  _

" Use specific file type highlighting for files with a given extension.
"au BufRead,BufNewFile *.bob setfiletype cpp

No comments: