Skip to content

Instantly share code, notes, and snippets.

@PaulusTM
Created April 12, 2011 20:11
Show Gist options
  • Save PaulusTM/916281 to your computer and use it in GitHub Desktop.
Save PaulusTM/916281 to your computer and use it in GitHub Desktop.
" -----------------------------------------------------------------------------
" VIM Configuration for Janus (https://github.com/carlhuda/janus.git)
" Lars Smit larssmit@me.com
" -----------------------------------------------------------------------------
" -----------------------------------------------------------------------------
" Basics
" -----------------------------------------------------------------------------
set encoding=utf8
set noswapfile
" -----------------------------------------------------------------------------
" Gui settings
" -----------------------------------------------------------------------------
set background=dark
colorscheme solarized
set guifont=Menlo:h12
set showtabline=2
set cursorline
" -----------------------------------------------------------------------------
" Set VIM window settings
" -----------------------------------------------------------------------------
if has("gui_running")
set guioptions-=T "Remove toolbar
set transparency=0
set guioptions=aAce
endif
" -----------------------------------------------------------------------------
" NERDTree configuration
" -----------------------------------------------------------------------------
let NERDChristmasTree = 1
let NERDTreeHighlightCursorline = 1
let NERDTreeShowBookmarks = 1
let NERDTreeStatusline = 1
let NERDTreeSortOrder = ['\/$', '*', '\.swp$', '\.bak$', '\~$']
let NERDTreeWinSize = 45
let NERDTreeChDirMode= 2
" -----------------------------------------------------------------------------
" Status line customization
" -----------------------------------------------------------------------------
set statusline=%<%t\ %h%w%m%r%y%=C:%v\ L:%l/%L\ (%p%%)
" -----------------------------------------------------------------------------
" Set ruler
" -----------------------------------------------------------------------------
set ruler
set rulerformat=%=%h%m%r%w\ %(%c%V%),%l/%L\ %P
" -----------------------------------------------------------------------------
" Map tab navigation to <SHIFT> + <CTRL><TAB>
" -----------------------------------------------------------------------------
map <C-S-Tab> :tabprevious<CR>
nmap <C-S-Tab> :tabprevious<CR>
imap <C-S-Tab> <Esc>:tabprevious<CR>
map <C-Tab> :tabnext<CR>
nmap <C-Tab> :tabnext<CR>
imap <C-Tab> <Esc>:tabnext<CR>
" -----------------------------------------------------------------------------
" No sound on errors
" -----------------------------------------------------------------------------
set noerrorbells
set novisualbell
" -----------------------------------------------------------------------------
" Replace the given lines using a dictionary
" replacing all occurences of each key in the dictionary with its value
" http://stackoverflow.com/questions/765894/can-i-substitute-multiple-items-in-a-single-regular-expression-in-vim-or-perl/766
" Running :Replace {'quick':'slow', 'lazy':'energetic'} will change the following text:
" The quick brown fox ran quickly next to the lazy brook.
"into:
" The slow brown fox ran slowly next to the energetic brook.
" -----------------------------------------------------------------------------
function! Replace(dict) range
execute a:firstline . ',' . a:lastline . 's/\C\<\%(' . join(keys(a:dict),'\|'). '\)\>/\='.string(a:dict).'[submatch(0)]/ge'
endfunction
command! -range=% -nargs=1 Replace :<line1>,<line2>call Replace(<args>)
" -----------------------------------------------------------------------------
" Vim sessions configuration
" https://github.com/xolox/vim-session
" -----------------------------------------------------------------------------
let g:session_autoload = 1
let g:session_autosave = 1
" -----------------------------------------------------------------------------
" When .gvimrc.local is edited, reload it
" -----------------------------------------------------------------------------
autocmd! bufwritepost vimrc source ~/.vim/.gvimrc.local
" -----------------------------------------------------------------------------
" Show syntax highlighting groups for word under cursor
" -----------------------------------------------------------------------------
nmap <C-S-P> :call <SID>SynStack()<CR>
function! <SID>SynStack()
if !exists("*synstack")
return
endif
echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
endfunc
" -----------------------------------------------------------------------------
" Toggle full screen
" -----------------------------------------------------------------------------
if has("gui_macvim")
macmenu Window.Toggle\ Full\ Screen\ Mode key=<D-CR>
endif
" -----------------------------------------------------------------------------
" Peepopen
" -----------------------------------------------------------------------------
if has("gui_macvim")
macmenu &File.New\ Tab key=<nop>
map <D-t> <Plug>PeepOpen
end
" -----------------------------------------------------------------------------
" Tabularize
" -----------------------------------------------------------------------------
if exists(":Tabularize")
nmap <Leader>t :Tabularize /
vmap <Leader>t :Tabularize /
endif
" -----------------------------------------------------------------------------
" Solarized
" -----------------------------------------------------------------------------
function! ToggleBackground()
if (g:solarized_style=="dark")
let g:solarized_style="light"
colorscheme solarized
else
let g:solarized_style="dark"
colorscheme solarized
endif
endfunction
command! Togbg call ToggleBackground()
nnoremap <F2> :call ToggleBackground()<CR>
inoremap <F2> <ESC>:call ToggleBackground()<CR>
vnoremap <F2> <ESC>:call ToggleBackground()<CR>
" -----------------------------------------------------------------------------
" Printing layout
" -----------------------------------------------------------------------------
set printoptions=number:y,left:5pc,syntax:y
set printfont=Menlo:h8
set printencoding=utf-8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment