aboutsummaryrefslogtreecommitdiff
path: root/vim/plugin
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2017-11-04 02:27:42 +1300
committerTom Ryder <tom@sanctum.geek.nz>2017-11-04 02:28:16 +1300
commitb0a15bf0e7aae09b8a875a3803632e878be595bd (patch)
tree5088d5c15fba8ed4812344972e7ecf32e764fee8 /vim/plugin
parentUse <Plug> prefix, make space strip configurable (diff)
downloaddotfiles-b0a15bf0e7aae09b8a875a3803632e878be595bd.tar.gz
dotfiles-b0a15bf0e7aae09b8a875a3803632e878be595bd.zip
Spin stable join config out into new plugin
Again using the <Plug> mapping abstraction and not defining the mapping for the user.
Diffstat (limited to 'vim/plugin')
-rw-r--r--vim/plugin/fixed_join.vim26
1 files changed, 26 insertions, 0 deletions
diff --git a/vim/plugin/fixed_join.vim b/vim/plugin/fixed_join.vim
new file mode 100644
index 00000000..ef1b03ef
--- /dev/null
+++ b/vim/plugin/fixed_join.vim
@@ -0,0 +1,26 @@
+" User-defined key mapping to keep cursor in place when joining lines in
+" normal mode
+" Suggesting mapping: normal J
+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
+ " Suggesting mapping: normal J
+ noremap <Plug>FixedJoin
+ \ :<C-U>call <SID>FixedJoin()<CR>
+endif