在 Vim 中更改引号
在 Vim 中,这是一个快速的 3 字符命令,用于更改当前带引号的字符串(例如 ci")内的内容,但是有没有一种简单的方法可以更改当前光标周围的引号类型?
有时我需要从 " blah”到“”“blah””或“blah”到“blah”(在Python源代码中),我理想地希望使用默认的键绑定快速完成此操作。
In Vim, it's a quick 3-character command to change what's inside the current quoted string (e.g., ci"), but is there a simple way to change what type of quotes are currently surrounding the cursor?
Sometimes I need to go from "blah" to """blah""" or "blah" to 'blah' (in Python source code) and I'd ideally like to do it quickly using default key bindings.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试使用 surround.vim 插件。我发现它是任何 vim 安装的重要补充。
Try the surround.vim plugin. I find it an essential addition to any vim installation.
Surround.vim 很棒,但我认为它不能直接处理您的三引号需求。
我沿着这些思路做事的方法(当环绕声不合适时)是使用
%
进行更改,然后双击反引号返回到起点。例如,如果光标位于单引号字符串中的某个位置,请执行f'%
,进行更改,然后双反引号和.
。Surround.vim is great, but I don't think it'll handle your triple-quoted needs directly.
The way I've done stuff along these lines (when surround wasn't appropriate) was to use
%
, make the change, then double-backtick to go back to the starting point. E.g. if the cursor is somewhere in a single-quoted string, dof'%
, make the change, then double-backtick and.
.