diff options
Diffstat (limited to '.vim/custom-functions.vim')
-rw-r--r-- | .vim/custom-functions.vim | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/.vim/custom-functions.vim b/.vim/custom-functions.vim new file mode 100644 index 0000000..ecf92bd --- /dev/null +++ b/.vim/custom-functions.vim @@ -0,0 +1,37 @@ +" ================ strip trailing whitespaces ================ +" via: http://rails-bestpractices.com/posts/60-remove-trailing-whitespace +" Strip trailing whitespace +function! <SID>StripTrailingWhitespaces() + " Preparation: save last search, and cursor position. + let _s=@/ + let l = line(".") + let c = col(".") + " Do the business: + %s/\s\+$//e + " Clean up: restore previous search history, and cursor position + let @/=_s + call cursor(l, c) +endfunction +command! StripTrailingWhitespaces call <SID>StripTrailingWhitespaces() +nmap ,w :StripTrailingWhitespaces<CR> +" ================ text wrapping ================ +" http://vimcasts.org/episodes/soft-wrapping-text/ +function! SetupWrapping() + set wrap linebreak nolist + set showbreak=… +endfunction + +" TODO: this should happen automatically for certain file types (e.g. markdown) +command! -nargs=* Wrap :call SetupWrapping()<CR> + +vmap <D-j> gj +vmap <D-k> gk +vmap <D-$> g$ +vmap <D-^> g^ +vmap <D-0> g^ +nmap <D-j> gj +nmap <D-k> gk +nmap <D-$> g$ +nmap <D-^> g^ +nmap <D-0> g^ + |