From 111dd43954006b254c27a43f6e3b6af57a4c49d8 Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Fri, 16 Sep 2022 20:04:30 +0000 Subject: insert.vim: add more text objects Z] - move to the end of the next text object Z[ - move to the start of the next text object Zd - delete in the recorded text object Zc - change in the recorded text object Zn - repeat Z] --- plugin/insert.vim | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) (limited to 'plugin/insert.vim') diff --git a/plugin/insert.vim b/plugin/insert.vim index 722c0b5..0029827 100644 --- a/plugin/insert.vim +++ b/plugin/insert.vim @@ -63,13 +63,31 @@ if g:field_marshal_insert_include_bindings noremap Z[ (to-object-start) noremap Z] (to-object-end) + noremap Zn (to-object-pos-post) + + " Zx commands, run x on the last recorded action. The equivalelent of xZr + noremap Zd "d" . getrecorded() + noremap Zc "c" . getrecorded() + noremap Zg~ "g~" . getrecorded() + noremap Zv "v" . getrecorded() + + " The last recorded object. + onoremap Zr getrecorded() + " Zgi -- start another insert using the same parameters from the last Z[ia] noremap Zgi c(insert-about-obj) vnoremap Zi "\'<" . (visualmode() == "V" ? "0" : "") . "i" vnoremap Za "\'>" . (visualmode() == "V" ? "$" : "") . "a" + + vnoremap Z[ "\'<" . (visualmode() == "V" ? "0" : "") . "i" + vnoremap Z] "\'<" . (visualmode() == "V" ? "0" : "") . "i" + + vnoremap Zo "\'>o" + vnoremap ZO "\'(insert-after-comment) call insert_comment_count(v:count1)1c(insert-comment-obj-nog) noremap (insert-after-comment-g)> call insert_comment_count(v:count1)1c(insert-comment-obj-g) @@ -188,19 +206,12 @@ let s:instype = '' " Not many people use the 'z' register, right? let s:reg_to_clobber = 'z' -" if exists('&urf') -" " Neovim has Rahm's multibyte register extension patch. Pick an arbitrary -" " unicode character which is probably not used very often to clobber. -" let s:reg_to_clobber = '∫' -" endif - function! s:start_recording() exec "normal! q" . s:reg_to_clobber endfunction let s:operate_keys='' function! s:prepare_operation(instype, operate_keys) - echom "operate_keys: " . a:operate_keys " Unfortunately macros kinda break this feature. While I think I might be able " to patch together a fix to make them work, I figure that I'll see if there's " any real need to implement it. @@ -214,8 +225,6 @@ function! s:prepare_operation(instype, operate_keys) let s:operate_keys = a:operate_keys endfunction -noremap (ñóþ) - " Save the motion postions, for use with g@. function s:save_object(t) abort let s:object = { @@ -231,7 +240,6 @@ function! s:to_object_start() abort let pos = s:instype == '[' ? s:object.start : s:object.end - echom printf("Jump To [%s] (%s) (%s)", string(pos), s:recorded, v:operator) call setpos('.', pos) endfunction @@ -290,10 +298,10 @@ function! s:recordop(...) abort normal! q " Save the recorded amount let s:recorded=getreg(s:reg_to_clobber) - " A limitation of normal! is that it can't start with a space, so use a NOP - " instead. + " A limitation of normal! is that it can't start with a space, so prefix with + " a 1 to get around this if s:recorded =~ '^\s' - let s:recorded = "\(ñóþ)" . s:recorded + let s:recorded = "1" . s:recorded endif " Restore the register call setreg(s:reg_to_clobber, s:savereg[0], s:savereg[1]) @@ -304,3 +312,6 @@ function! s:recordop(...) abort call feedkeys(s:operate_keys) endfunction +function! s:getrecorded() + return s:recorded +endfunction -- cgit