Saturday, September 18, 2010

My fantastic .vimrc file.

I get a lot of "wow what editor is that?!" around my desk at work these days. I'm going to be brief about this: its vim 7.

Here it basically is (I removed some references to custom python modules which I won't places here.)

""" Indentation settings                  
""" Since I use python, I prefer using spaces
"""     Yes this makes the code bigger    
"""     However, if you use: set list     
"""     You can visually identify where a \t or "^I" came in
set tabstop=4       "Tabs at 4 spaces     
set shiftwidth=4    "Not sure             
set autoindent      "Auto indent helps    
set expandtab       "Expand tabs to spaces

""" Visual settings
"""     These settings are the "WOW" factor
"""     syn on is just syntax
"""     cursorline gives you a horizonal line
"""     cursorcolumn gives you a vertical line
"""     Together they give you a crosshair,
"""         which means you cant miss your cursor
"""         even if your screen is 30" big
syn on              " syntax
set cursorline      " Horizontal bar
set cursorcolumn    " Vertical bar
set nu              " Line numbers
set ruler           " Position

""" Search and semi-word completion settings
"""     Searching in code can be really easy with the right settings
set ignorecase      "Case insensitive search
set infercase       "This is for autocompletion (ctrl-p or ctrl-n)
set incsearch       "Emacs like incremental search, search as you type
set hlsearch        "Highlight the search pattern
" I like a green search
highlight Search ctermfg=Black ctermbg=Green cterm=NONE

""" General and misc
set autoread        "Automaticall check if the file was modified
set history=100     "Cmd history (:,:)
set novisualbell    "NO BELL, I use putty/screen combo, visual bell HURTS ME
set bs=0            "Backspace set to 0, This means I wont erase what I didn't write

""" Tabs key bindings
""" New tab with ctrl+y (I use ctags, ctrl+t is reserved for that)
"""     Normal mode ONLY
nmap :tabnew                    
""" New tab with ctrl+y (I use ctags, ctrl+t is reserved for that)
"""     Insert mode (Escapes out and types in tabnew)
imap :tabnew
""" Normal mode only, YOU dont want this in insert mode
""" You'll never use capital X or Z again
nmap X :tabnext
nmap Z :tabprev                       

""" Basic vim Fix/Canonical functions     
function! GetFixCanonicalToReadable()     
python << EOF
import vim
import sys                                
print sys.argv                            
print len(vim.current.buffer)             
for each in vim.current.line.split( "^A" ):
    each = each.strip()
    if not each:
    print each.split("=")

comm! -nargs=? -bang PP call GetFixCanonicalToReadable()