aboutsummaryrefslogtreecommitdiff
path: root/plugin/command.vim
diff options
context:
space:
mode:
authorJosh Rahm <rahm@google.com>2022-08-22 13:44:02 -0600
committerJosh Rahm <rahm@google.com>2022-08-22 13:44:02 -0600
commit17703b92b44e5afd12e4bca418f61cadb50ac91d (patch)
tree9d2dbde900e0ba52dd2ad55f4847f63a386c190a /plugin/command.vim
parentb6617fa378fb16b19fc669d39cb875711368307d (diff)
downloadfieldmarshal.vim-17703b92b44e5afd12e4bca418f61cadb50ac91d.tar.gz
fieldmarshal.vim-17703b92b44e5afd12e4bca418f61cadb50ac91d.tar.bz2
fieldmarshal.vim-17703b92b44e5afd12e4bca418f61cadb50ac91d.zip
Add command motion and make some changes to substitute.
Diffstat (limited to 'plugin/command.vim')
-rw-r--r--plugin/command.vim14
1 files changed, 14 insertions, 0 deletions
diff --git a/plugin/command.vim b/plugin/command.vim
new file mode 100644
index 0000000..51633b5
--- /dev/null
+++ b/plugin/command.vim
@@ -0,0 +1,14 @@
+" g: is a command to run a vim command around a text object.
+"
+" For example, to do a substitution inside the current block, one can do:
+"
+" g:iBs/foo/bar/g<cr>
+
+noremap <silent> g: :set operatorfunc=<SID>do_command_around<cr>g@
+
+function! s:do_command_around(str) abort
+ let [_, lnum0, _, _] = getpos("'[")
+ let [_, lnum1, _, _] = getpos("']")
+
+ call feedkeys(printf(":%d,%d ", lnum0, lnum1))
+endfunction