如何快速删除 Vim 中的一对圆括号、方括号或大括号? [英] How to quickly remove a pair of parentheses, brackets, or braces in Vim?
问题描述
在 Vim 中,如果我有这样的代码(在 Ruby 中):
In Vim, if I have code such as (in Ruby):
anArray << [anElement]
我的光标在第一个[
,我可以用%
键跳到]
,我可以删除所有的内容[]
对与 d%
之间,但是如果我只想删除 [
和 ]
离开两者之间的所有剩余内容.换句话说,最快的方式是:
and my cursor is on the first [
, I can hop to ]
with the %
key, and I can delete all the content between the []
pair with d%
, but what if I just want to delete the [
and ]
leaving all the remaining content between the two. In other words, what's the quickest way to get to:
anArray << anElement
推荐答案
使用 Surround 插件对于 Vim,您可以使用 ds
消除周围的分隔符.
Using the Surround plugin for Vim, you can eliminate surrounding delimiters with ds<delimeter>
.
要通过 Vundle 插件安装它,添加
To install it via Vundle plugin, add
Plugin 'tpope/vim-surround'
到你的 .vimrc
文件并运行 :PluginInstall
.
to your .vimrc
file and run :PluginInstall
.
这篇关于如何快速删除 Vim 中的一对圆括号、方括号或大括号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!