aboutsummaryrefslogtreecommitdiffstats
path: root/.vim/custom-functions.vim
diff options
context:
space:
mode:
authorDavid Runge <david.runge@frqrec.com>2014-10-31 18:12:14 +0100
committerDavid Runge <david.runge@frqrec.com>2014-10-31 18:12:14 +0100
commitbb21c0b6b5a89eff0722641123982d34a2b6f395 (patch)
tree5060ede28e03963e3d1eac3f0063ff8686cc4089 /.vim/custom-functions.vim
parentd33721a35f7f61b89acaacc3e53368ae8d99d750 (diff)
downloaddotfiles-bb21c0b6b5a89eff0722641123982d34a2b6f395.tar.gz
dotfiles-bb21c0b6b5a89eff0722641123982d34a2b6f395.tar.bz2
dotfiles-bb21c0b6b5a89eff0722641123982d34a2b6f395.tar.xz
dotfiles-bb21c0b6b5a89eff0722641123982d34a2b6f395.zip
vim: Switching from yadr to VAM. Includes all modifications for vimrc, the loading of plugins and their customization.
Diffstat (limited to '.vim/custom-functions.vim')
-rw-r--r--.vim/custom-functions.vim37
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^
+