From 534f8ccabd777d419fc88aed28c7dc10a6637392 Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Thu, 15 Sep 2022 20:54:46 +0000 Subject: fieldmarshal: some minor changes. --- plugin/insert.vim | 7 +++++-- plugin/move.vim | 9 +++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) (limited to 'plugin') diff --git a/plugin/insert.vim b/plugin/insert.vim index 3caca81..dea819a 100644 --- a/plugin/insert.vim +++ b/plugin/insert.vim @@ -57,6 +57,9 @@ if g:field_marshal_insert_include_bindings " noremap Zi (insert-before-motion) noremap Za (append-after-motion) + + vnoremap Zi "\'<" . (visualmode() == "V" ? "0" : "") . "i" + vnoremap Za "\'>" . (visualmode() == "V" ? "$" : "") . "a" endif noremap (insert-after-comment) call insert_comment_count(v:count1)1c(insert-comment-obj-nog) @@ -171,8 +174,8 @@ function! s:insert_before_recorded() abort " Something of a hack. If the motion starts with i or a, it is probably a " text object. " - " I think there's probably a better way to handle this, butth - if s:recorded =~ '^[ia]' + " I think there's probably a better way to handle this, but + if s:recorded =~ '^[ia]' || s:recorded =~ 'g[nN]' || s:recorded =~ '[_]' " Without Rahm's patched Neovim, custom text objects will not work. This is " because while the redo buffer is saved and restored when calling a user " function, repeat_cmdline is not, and thus the g@ command clobbers the diff --git a/plugin/move.vim b/plugin/move.vim index 88680cd..aa89f40 100644 --- a/plugin/move.vim +++ b/plugin/move.vim @@ -50,9 +50,14 @@ function! s:inner_next(operator, ai, open, close) abort if v:operator =~ "[cd]" " Cheese a 0-width by inserting a space to then immediately delete for d and c operators. exec "normal! i \v" - else - " Other operations, just reset the position to what it was before. + elseif v:operator =~ "[y]" + " Yank operation, don't do anything. call setpos('.', opos) + else + let [a, l, c, b] = getpos(".") + call setpos("'<", [a, l, c, b]) + call setpos("'>", [a, l, c-1, b]) + normal! gv endif return endif -- cgit