]> ruderich.org/simon Gitweb - config/dotfiles.git/blobdiff - vimrc
vimrc: Add support to undo Ctrl-U in insert mode.
[config/dotfiles.git] / vimrc
diff --git a/vimrc b/vimrc
index c39fa3c3b720e427d2fa7e8de76207d46174d019..9e98ef675bca1522958bea887413e1e8de949165 100644 (file)
--- a/vimrc
+++ b/vimrc
@@ -26,7 +26,7 @@ endif
 set nocompatible
 
 " Load my scripts from ~/.vim (my scripts) and ~/.vim/runtime (checkout of Vim
-" runtime files).
+" runtime files) if available.
 set runtimepath-=~/.vim
 set runtimepath^=~/.vim,~/.vim/runtime
 
@@ -328,6 +328,11 @@ endif
 " vimgor (bot) in #vim on Freenode (2010-03-30 05:58 CEST).
 noremap <silent> <C-L> :nohlsearch<CR><C-L>
 
+" Ctrl-U in insert mode deletes a lot, break undo sequence before deleting the
+" line so the change can be undone. Thanks to the vimrc_example.vim file in
+" Vim's source.
+inoremap <C-U> <C-G>u<C-U>
+
 
 " ABBREVIATIONS
 
@@ -450,7 +455,7 @@ if has('autocmd')
             autocmd InsertLeave * set nopaste
         endif
 
-" Save changes when running :mak[e] before 'makeprg' is called.
+" Write file when running :mak[e] before 'makeprg' is called.
         autocmd QuickFixCmdPre * write
 
 " AFTER/FTPLUGIN AUTO COMMANDS
@@ -493,7 +498,7 @@ if has('autocmd')
 endif
 
 
-" CUSTOM FUNCTIONS
+" CUSTOM FUNCTIONS AND COMMANDS
 
 if has('eval')
 " New text-objects ii and ai to work on text with the same indentation. Thanks
@@ -538,4 +543,21 @@ if has('eval')
         endif
     endfunction
 
+" Convenient command to see the difference between the current buffer and the
+" file it was loaded from, thus the changes you made. Thanks to the
+" vimrc_example.vim file in Vim's source. Modified to use the same filetype
+" for the diffed file than the filetype for the original file.
+    if !exists(":DiffOrig")
+        command DiffOrig
+            \ let s:diff_orig_filetype = &filetype
+            \ | vertical new
+            \ | let &filetype = s:diff_orig_filetype
+            \ | unlet s:diff_orig_filetype
+            \ | set buftype=nofile
+            \ | read ++edit #
+            \ | 0d_
+            \ | diffthis
+            \ | wincmd p
+            \ | diffthis
+    endif
 endif