Select or yank text between all types of brackets and quotes with a single key combination.
If we want to select or yank the text, lets say between double quotes for example, we have to
enter normal mode and type vi"
for selection and yi"
for yanking. If we need to perfom same
operations but on curly braces whe have to type vi{
or yi{
. This can become quite hideous if
our text is quotes/brackets-heavy. My plugin will detect bracket and quote pairs and select/yank
between them with single key combination either from insert or normal mode.
Vundle or similar
- Add
Plugin 'Szero/vim-quotebrace'
to your vimrc file. - Reload your vimrc with
:so ~/.vimrc
or restart - Run
:PluginInstall
dein (new plugin manager from the author of NeoBundle)
- Add
call dein#add('Szero/vim-quotebrace.vim')
to your vimrc file. - Reload your vimrc with
:so ~/.vimrc
or restart - Run
:call dein#install()
cd ~/.vim/bundle
git clone https://github.com/Szero/vim-quotebrace.git
Default keybindings are:
<leader>s
for selecting the text between brackets
<leader>x
for selecting the text between brackets (including the brackets)
<leader>y
for yanking the text between brackets
<leader>h
for yanking the text between brackets (including the brackets)
Leader is special key user can bind and use it in his own keybinds.
If you don't have it bound already, I recommend binding it to ,
(comma) by adding this line to
your vimrc:
let mapleader=","
Each keybind works from insert and normal mode.
If you want to change the default keybindings, there are four variables you can add you your vimrc:
let g:QuoteBraceSelect = "your keybind"
let g:QuoteBraceSelectAll = "your keybind"
let g:QuoteBraceYank = "your keybind"
let g:QuoteBraceYankAll = "your keybind"
- Add support for matching brackets/quotes pairs that span over multiple lines
- By using
searchpair()
function there is no need for inveting algorithms