diff options
Diffstat (limited to 'vim/plugin/fixed_join.vim')
-rw-r--r-- | vim/plugin/fixed_join.vim | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/vim/plugin/fixed_join.vim b/vim/plugin/fixed_join.vim new file mode 100644 index 00000000..c002f667 --- /dev/null +++ b/vim/plugin/fixed_join.vim @@ -0,0 +1,29 @@ +" +" User-defined key mapping to keep cursor in place when joining lines in +" normal mode +" +" Author: Tom Ryder <tom@sanctum.geek.nz> +" License: Same as Vim itself +" +if has('eval') + + " Declare function + function! s:FixedJoin() + + " Save current cursor position + let l:lc = line('.') + let l:cc = col('.') + + " Build and execute join command + let l:command = '.,+' . v:count1 . 'join' + execute l:command + + " Restore cursor position + call cursor(l:lc, l:cc) + + endfunction + + " Create mapping proxy to the function just defined + noremap <Plug>FixedJoin + \ :<C-U>call <SID>FixedJoin()<CR> +endif |