简体   繁体   English

diffget 的 Vim 映射 | diffput 不适用于 v:count

[英]Vim mapping for diffget | diffput not working with v:count

Pretty new to mappings in Vim, Vim 中的映射很新,

In Diff Mode I've got C-Up and C-Down mapped to [c and ]c for diffjumping.在 Diff 模式下,我将C-UpC-Down映射到[c]c以进行 diffjumping。 I'm wanting to map C-Right and C-Left to :<CU>diffput v:count<CR> and :<CU>diffget v:count<CR> respectively to speed up merging.我想要 map C-RightC-Left:<CU>diffput v:count<CR>:<CU>diffget v:count<CR>分别加速合并。

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".但是我收到错误“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?该命令看起来是从字面上理解 v:count 并运行:diffget v:count而不是:diffget 3例如..我如何让 v:count 解析为一个数字? like dereference the variable?喜欢取消引用变量?

I can echo "diffget v:count" and that looks to be correct... but obviously doesn't do anything...我可以echo "diffget v:count" ,这看起来是正确的……但显然什么也没做……

Found the answer in vi.SE在 vi.SE 中找到答案

<expr> <C-Left> ":\<CU>diffget ".. v:count.. "\<CR>"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM