From bc347234ae4e8d15a5fc4a3f9f3e1e6a22aa85e8 Mon Sep 17 00:00:00 2001 From: Tony Duckles Date: Fri, 4 Jan 2013 20:51:54 -0600 Subject: [PATCH] .vimrc: Custom statusline, lots of new helper mappings * Custom statusline which includes &fenc, &ff, etc. * A bunch of neat misc helper leader-based mappings, inspired by https://github.com/carlhuda/janus. * Don't jump to last position in gitcommit file. * Use real tabs (not spaces) for Makefiles --- .vimrc | 65 +++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 46 insertions(+), 19 deletions(-) diff --git a/.vimrc b/.vimrc index e11afd7..ebe4219 100644 --- a/.vimrc +++ b/.vimrc @@ -114,6 +114,9 @@ set laststatus=2 " always show the status line set ignorecase " ignore case when searching set smartcase " case-sensitive if search contains an uppercase character set visualbell " shut the heck up +set statusline=%n\ %<%f\ %h%m%r%y\ \ %{strlen(&fenc)?&fenc:&enc},%{&ff} +set statusline+=%= +set statusline+=\(%b\ 0x%B)\ \ \ %-16.(%c,%l/%L%)\ %P " ---------------------------------------------------------------------------- " Text Formatting @@ -168,7 +171,7 @@ vnoremap / /\v nnoremap Q gqap vnoremap Q gq -" sane movement with wrap turned on +" movement based on display lines not physical lines (sane movement with wrap turned on) nnoremap j gj nnoremap k gk vnoremap j gj @@ -198,12 +201,45 @@ nnoremap l nmap ev :edit $MYVIMRC nmap sv :source $MYVIMRC +" upper/lower word +nmap u mQviwU`Q +nmap l mQviwu`Q + +" upper/lower first char of word +nmap U mQgewvU`Q +nmap L mQgewvu`Q + +" cd to the directory containing the file in the buffer +nmap cd :lcd %:h + +" edit file in same directoy as current file (http://vimcasts.org/e/14) +" 'ew' = edit file in same directory as current file; 'es'/'ev','et' = open in split/vert-split/tab +nmap ew :e =expand('%:h').'/' +nmap es :sp =expand('%:h').'/' +nmap ev :vsp =expand('%:h').'/' +nmap et :tabe =expand('%:h').'/' + +" set text wrapping toggles +nmap tw :set invwrap:set wrap? + +" find merge conflict markers +nmap fc /\v^[<=>]{7}( .*\|$) + +" toggle hlsearch with hs +nmap hs :set hlsearch! hlsearch? + +" strip all trailing whitespace in file +function! StripWhitespace () + exec ':%s/ \+$//gc' +endfunction +map s :call StripWhitespace () + " ---------------------------------------------------------------------------- " Auto Commands " ---------------------------------------------------------------------------- -" jump to last position of buffer when opening -au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | +" jump to last position of buffer when opening (but not for commit messages) +au BufReadPost * if &filetype !~ '^git\c' && line("'\"") > 0 && line("'\"") <= line("$") | \ exe "normal g'\"" | endif " ---------------------------------------------------------------------------- @@ -219,31 +255,22 @@ if system('uname') =~ 'Darwin' endif " --------------------------------------------------------------------------- -" sh config +" File Types " --------------------------------------------------------------------------- +" sh config au Filetype sh,bash set ts=4 sts=4 sw=4 expandtab let g:is_bash = 1 - -" --------------------------------------------------------------------------- -" Strip all trailing whitespace in file -" --------------------------------------------------------------------------- - -function! StripWhitespace () - exec ':%s/ \+$//gc' -endfunction -map s :call StripWhitespace () - -" --------------------------------------------------------------------------- -" File Types -" --------------------------------------------------------------------------- - +" git commit message au Filetype gitcommit set tw=68 spell +" html variants au Filetype html,xml,xsl,rhtml source $HOME/.vim/scripts/closetag.vim " don't use cindent for javascript au FileType javascript setlocal nocindent -" Use Octopress syntax-highlighting for *.markdown files +" use Octopress syntax-highlighting for *.markdown files au BufNewFile,BufRead *.markdown set filetype=octopress +" in Makefiles, use real tabs not tabs expanded to spaces +au FileType make setlocal noexpandtab " -------------------------------------------------------------------------- " ManPageView -- 2.45.2