gpt4 book ai didi

vim - 为什么 ci"和 ci(, ci{.... 行为不同?

转载 作者:行者123 更新时间:2023-12-03 11:42:49 29 4
gpt4 key购买 nike

我们都知道ci" ci' ci( ci[ ... 做。在日常编辑中非常方便。我发现了一些奇怪的东西,并查看了帮助,没有找出原因。

说,我有一个文件:

foo "target"
foo 'target'
foo (target)
foo {target}
foo [target]
foo <target>

如果我的光标在 开始每一行,(在' f'),然后我输入ci", ci', ci(...
cix仅适用于引号(单引号或双引号),不适用于括号。为什么他们的行为不同?

( dix , vix 相同)

用 --noplugin,vim 7.3 测试

谢谢你。

更新

感谢@romainl 的回答。我仍然对“vim中的配对处理”有疑问

检查这个例子:
foo "targ\"eti\" some\"thing else "

如果我有上面这样的一行,我输入 ci" ,无论光标在开头还是引号之间,都可以完美运行,看来vim确实有“对”的想法?

这也许是你所说的配对?
foo "target x some"thing else "
foo (target x some(thing else )

我有以上两行,如果(光标在 x )我输入 ci"ci( ,第二行没有发生任何事情,但第一行更改为:
foo "I"thing else " (I is cursor)

最佳答案

使用%

" nnoremap cb cib
nnoremap cb %cib
" nnoremap vb vib
nnoremap vb %vib
nnoremap yb %yib
nnoremap db %dab
加强 % :
https://github.com/andymass/vim-matchup#tocbar-dopjfd b可以匹配 ( [ { ,
想用 '匹配 '" ?

nnoremap c' :call DoubleAsSingleC()<CR>
func! DoubleAsSingleC()
" When [!] is added, error messages will also be skipped,
" and commands and mappings will not be aborted
" when an error is detected. |v:errmsg| is still set.
let v:errmsg = ""
silent! :s#\"\([^"]*\)\"#'\1'#g
if (v:errmsg == "")
echo "双变单"
endif

exec "normal ci'"
endfunc
类似的: d' y' v'

关于vim - 为什么 ci"和 ci(, ci{.... 行为不同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14650788/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com