I want to do something like map
df
to these all these commands
yt) //yank till the ")" character
yt}
yt]
Example:
111)
222}
333]
Starting from the beginning of any of these lines, running df
should copy any of the lines into the clip board register.
I want to do this since its less work than having to look what the closing character is :)
I tried to do something like this but it doesn't seem to work....
map df ys) <bar> ys} <bar> ys] <CR>
$y0
would do what you ask in the given sample in an agnostic way:
$
moves the cursor to the last character of the line, whatever it is,y0
yanks the text from the current character (exclusive) to the first character (inclusive).If what you want is more generic than your example, something like "goes from here to the next closing bracket", then creating a custom motion seems more canonical than messing with the operator d
and the motion f
.
It should look like this:
xnoremap gb <Cmd>call search('.\ze[)}\]]')<CR>
onoremap gb <Cmd>normal vgb<CR>
which can be used with any operator, not just y
:
dgb
ygb
etc.
The snippet above is the blueprint for custom motions:
Now, the hard part is finding available keys.
See :help omap-info
, :help :map-cmd
, :help :call
, :help search()
.