Pretty new to mappings in Vim,
In Diff Mode I've got C-Up and C-Down mapped to [c
and ]c
for diffjumping. I'm wanting to map C-Right
and C-Left
to :<C-U>diffput v:count<CR>
and :<C-U>diffget v:count<CR>
respectively to speed up merging.
nnoremap <C-Left> :<C-U>diffget v:count<CR>
nnoremap <C-Right> :<C-U>diffput v:count<CR>
nnoremap <C-Up> [c
nnoremap <C-Down> ]c
This should.... put from buffer # or get from buffer #.
But I get the error "no matching buffer for v:count".
the command looks to be taking v:count
literally and running :diffget v:count
instead of :diffget 3
for example.. how do I get v:count
to resolve to a number? like dereference the variable?
I can echo "diffget v:count"
and that looks to be correct... but obviously doesn't do anything...
<expr>
:nnoremap <expr> <C-Left> ":\<C-U>diffget " .. v:count .. "\<CR>"
. Didn't test that so may not work exactly, but should point you in the right direction. Note that because it's a VimScript expression, you need to put literal text in strings. Special<..>
only work in double-quoted strings as"\<..>"
...
, that's indeed just string concatenation. Actually just.
also works, but..
is the "new" way of doing it (it solves some ambiguity in some cases with.
for other uses like decimals in numbers).