This is a very basic implementation of auto-pairing of brackets and quotations for vim/neovim. A small tutorial video can be seen here.
- Copy and paste the following line in your vim plug config:
Plug 'AbeerVaishnav13/vim-pairs-basic'
- Download the files in
.zip
format and unzip the contents. - Copy the
plugin/autopair.vim
file in your vim/neovim config directory. - Copy and paste this line in your
.vimrc
orinit.vim
:
source /path/to/vim/config/directory/autopair.vim
The following characters are supported for pair completion using vim-pairs-basic plugin:
(
, {
, [
, <
, '
, "
, and `
- Insert in pair
input: []
output: [|]
input: ""
output: "|"
- Insert with
;
or,
input: (;
output: (|);
input: ";
output: "|";
input: (,
output: (|),
input: ",
output: "|",
- Multi line brackets (the corresponding pair is displayed after pressing
<Enter>
key)
input: {<Enter>
output: {
|
}
- Multi line brackets and quotations with
;
or,
input: {;<Enter>
output: {
|
};
input: [,<Enter>
output: [
|
],
input: `;<Enter>
output: `
|
`;
input: ```<Enter>
output: ```
|
\```
- Example for quotations -
rs'"
has the following effect:
input text: 'Hello'
output text: "Hello"
- Example for brackets -
rs({
has the following effect:
input text: (2 + 3)
output text: {2 + 3}
- Example for quotation and bracket mixed -
rs'<
has the following effect:
input text: 'html'
output text: <html>
- Visually select the text you want to surround with any of the supported pairs.
- Press
as<pair-char>
for surrounding the selected text with them.
- Input text
- Visual selection
- Pressing the
as{
key-combination for surrounding selected text with{.}
- Place the cursor within the pair that you want to delete
- Use the
ds<pair-char>
command to delete the surrounding bracket/quote pairs.
- After typing the
ds{
command, with the cursor inside{.}
:
input text: {Hello World}, you're using vim-pairs-basic.
output text: Hello World, you're using vim-pairs-basic.