Thursday, April 29, 2010

vim: my ~/.vimrc file

set number
set incsearch
set shiftwidth=4
set tabstop=4
set autoindent
set smartindent
set paste
set expandtab
set showcmd
 
" set search highlighting on
set hls
 
set scrolloff=2
 
" Quit without fuss on :Q
:command -nargs=0 Quit :qa!

" Write without fuss on :W
:command -nargs=0 Write :w 
 
 
" fix the vim+backspace problem in cygwin - might NOT be needed on native linux shells!
set backspace=indent,eol,start
 
" set syntax highlighting on (for all possible file types)
syntax on
 
" always show current cursor position (row, column) at bottom right
set ruler
 
" choose colors that look good on a dark background, if possible
" set background=dark

" set more suitable colors for the line numbers
highlight LineNr gui=NONE guifg=black    guibg=grey 
highlight LineNr cterm=NONE ctermfg=darkgrey  ctermbg=grey


" This highlights the background in a subtle red for text that goes over the 80 column limit
" http://stackoverflow.com/questions/235439/vim-80-column-layout-concerns
" press F3 to toggle 80 column overlength highlighting
let ColHL='off'
highlight OverLength ctermbg=darkred ctermfg=white guibg=#592929
" match OverLength /\%81v.\+/

function! Toggle80ColumnHighlight()
    if g:ColHL == 'on'
        match OverLength //
        let g:ColHL='off'
    elseif g:ColHL == 'off'
        match OverLength /\%81v.\+/
        let g:ColHL='on'
    endif
endfunction

nnoremap  :call Toggle80ColumnHighlight()

" mark text after column 80 ( >= vim7.3 )
" set colorcolumn=80


" function to show color scheme in use
" source: http://stackoverflow.com/questions/2419624/how-to-tell-which-colorscheme-a-vim-session-currently-uses
function! ShowColorSchemeName()
    try
        echo g:colors_name
    catch /^Vim:E121/
        echo "default
    endtry
endfunction

" set a better search highlight colors
" http://stackoverflow.com/questions/7103173/vim-how-to-change-the-highlight-color-for-search-hits-and-quickfix-selection
highlight Search cterm=NONE ctermfg=white ctermbg=darkblue
highlight Search gui=NONE   guifg=white  guibg=darkblue
" set better incremental search highlight colors
highlight IncSearch cterm=NONE ctermfg=darkgreen ctermbg=grey
highlight IncSearch gui=NONE   guifg=darkgreen  guibg=grey

No comments: