.vimrc

vi and vim are two out of many text editors on Unix, this is my .vimrc. I put this here mostly so I can easily grab it.

syntax on
set hlsearch
set ignorecase
set visualbell
set bg=dark
highlight LineNr term=bold cterm=NONE ctermfg=DarkGrey ctermbg=NONE gui=NONE guifg=DarkGrey guibg=NONE

set wildmenu
set wildignore=*.o,*.r,*.so,*.sl,*.tar,*.tgz "we want to ignore those
"set wildmode=list:longest,full
set scrolloff=3   " always show n lines above and below cursor
set nostartofline " dont move to the start of line when scrolling/moving up and down
set laststatus=2  "we like a status bar
set ttyfast "supposedly treat our tty as if its 'fast'
set pastetoggle=<F5>
set updatetime=2000 " crash recovery fun (in ms)


highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd BufWinLeave * call clearmatches()

"match ExtraWhitespace /\s\+$\| \+\ze\t/

set nocompatible
"set smarttab
"set smartindent
"set copyindent
set noautoindent
"set tabstop=4
set shiftwidth=4
set incsearch   " actively search while typing

map <space> /

"map <silent> <unique> <F2> :NERDTree<CR>
"map <silent> <S-Tab> :NERDTreeToggle<CR>
"map <s-tab> :NERDTreeToggle<CR>

set statusline=%t%(\ %R%M%H%)%(\ [%<%{expand(\"%:p:h\")}]%)%(\ %a%)%=%(%<[%{&ff}\|%{&enc}\|%Y]%)\ %=%(<%l\,%c%V>%)\ %P
set titlestring=%t%(\ %R%M%H%)


hi StatusLine cterm=bold       ctermbg=lightblue ctermfg=black guibg=white guifg=blue
hi StatusLineNC cterm=bold     ctermbg=lightblue ctermfg=black  guibg=white guifg=blue


function StripTrailingWhitespace()
  if !&binary && &filetype != 'diff'
    normal mz
    normal Hmy
    %s/\s\+$//e
    normal 'yz<CR>
    normal `z
  endif
endfunction

nnoremap <Leader>x :<C-U>call StripTrailingWhitespace()<CR>

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.