Balance parentheses, curly-braces, and square-brackets
This repository requires the [Vim][link__vim_home] text editor to be installed the source code is available on GitHub -- vim/vim, and most GNU Linux package managers are able to install Vim directly, eg...
- Arch based Operating Systems
sudo packman -Syy
sudo packman -S vim- Debian derived Distributions
sudo apt-get update
sudo apt-get install vimPerhaps as easy as one, 2.0,...
Clone this project...
mkdir -vp ~/git/hub/vim-utilities
cd ~/git/hub/vim-utilities
git clone [email protected]:vim-utilities/balanced-braces.gitIf not using a plugin manager, then this plugin may be installed via make install command...
cd ~/git/hub/vim-utilities/balanced-braces
make installIf not using a plugin manager, then this plugin may be uninstalled via uninstall Make target...
cd ~/git/hub/vim-utilities/balanced-braces
make uninstall... Which will remove symbolic links and update the Vim help tags file.
To update in the future use make upgrade command...
cd ~/git/hub/vim-utilities/balanced-braces
make upgradeAfter installation, plugin documentation may be accessed via Vim's :help command, eg...
help balanced-braces.txtWhile in Insert mode open/close curly-braces, parentheses, and square-brackets will have the following behavior:
-
{Open curly-brace; automatically insert a closing curly-brace, and move the cursor left by one column -
}Close curly-brace; optionally move the cursor right by one column, if currently on a closing curly-brace, or insert closing curly-brace -
(Open parenthesis; automatically insert a closing parenthesis, and move the cursor left by one column -
)Close parenthesis; optionally move the cursor right by one column, if currently on a closing parenthesis, or insert closing parenthesis -
[Open square-bracket; automatically insert a closing square-bracket, and move the cursor left by one column -
]Close square-bracket; optionally move the cursor right by one column, if currently on a closing square-bracket, or insert closing square-bracket
Existing defaults may be modified or extended by assigning g:balanced_braces variable within the ~/.vimrc file for a given account. Example of defaults...
let g:balanced_braces = {
\ 'exclude': [],
\ 'all': {
\ 'parentheses': { 'open': '(', 'close': ')' },
\ 'curly-brace': { 'open': '{', 'close': '}' },
\ 'square-bracket': { 'open': '[', 'close': ']' },
\ },
\ }Exclude example...
let g:balanced_braces = {
\ 'exclude': [ 'help', 'markdown' ],
\ }Example of adding angle-bracket support...
let g:balanced_braces = {
\ 'all': {
\ 'angle-bracket': { 'open': '<', 'close': '>' },
\ },
\ }Filetype customization example
let g:balanced_braces = {
\ 'html': {
\ 'angle-bracket': { 'open': '<', 'close': '>' },
\ },
\ }Remove all entry example...
let g:balanced_braces = {
\ 'all': {
\ 'square-bracket': false,
\ },
\ }Alternatively one may instead assign a JSON file path to the g:balanced_braces variable to customize configurations, eg...
{
"exclude": [],
"all": {
"parentheses": {
"open": "(",
"close": ")"
},
"curly-brace": {
"open": "{",
"close": "}"
},
"square-bracket": {
"open": "[",
"close": "]"
}
},
"html": {
"angle-bracket": {
"open": "<",
"close": ">"
}
}
}Configuration via JSON file path example...
let g:balanced_braces = '~/.vim/configs/balanced-braces.json'This repository may not be feature complete and/or fully functional, Pull Requests that add features or fix bugs are certainly welcomed.
Options for contributing to balanced-braces and vim-utilities
Start making a Fork of this repository to an account that you have write permissions for.
- Add remote for fork URL. The URL syntax is
[email protected]:<NAME>/<REPO>.git...
cd ~/git/hub/vim-utilities/balanced-braces
git remote add fork [email protected]:<NAME>/balanced-braces.git- Commit your changes and push to your fork, eg. to fix an issue...
cd ~/git/hub/vim-utilities/balanced-braces
git commit -F- <<'EOF'
:bug: Fixes #42 Issue
**Edits**
- `<SCRIPT-NAME>` script, fixes some bug reported in issue
EOF
git push fork mainNote, the
-uoption may be used to setforkas the default remote, eg.git push -u fork mainhowever, this will also default theforkremote for pulling from too! Meaning that pulling updates fromoriginmust be done explicitly, eg.git pull origin main
- Then on GitHub submit a Pull Request through the Web-UI, the URL syntax is
https://github.com/<NAME>/<REPO>/pull/new/<BRANCH>
Note; to decrease the chances of your Pull Request needing modifications before being accepted, please check the dot-github repository for detailed contributing guidelines.
Thanks for even considering it!
Via Liberapay you may on a repeating basis.
Regardless of if you're able to financially support projects such as balanced-braces that vim-utilities maintains, please consider sharing projects that are useful with others, because one of the goals of maintaining Open Source repositories is to provide value to the community.
-
Vi -- StackExchange -- How can I merge two dictionaries in Vim?
-
Vim -- Redit -- How do I make Vim automatically complete parentheses and quotes for me?
-
StackOverflow -- how to make a vimscript function with optional arguments
Balance parentheses, curly-braces, and square-brackets
Copyright (C) 2021 S0AndS0
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, version 3 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For further details review full length version of AGPL-3.0 License.