deleft.vim : Delete a wrapping if-clause, try-catch block, etc. and shift left.
| script karma
Downloaded by 119
Comments, bugs, improvements
script versions (upload new version)
|This plugin allows you to delete wrapping if-clauses, try-catch blocks, and similar constructs. For example:
Executing the :Deleft command or using the provided "dh" mapping on the container div results in just:
So, the mapping/command deletes the opening and closing HTML tag and shifts the code to the left (hence the name "deleft", from "delete left").
Note that "dh" is a built-in mapping, but it's a synonym to "x", so I'm okay with overwriting it. Set "g:deleft_mapping" to "" (or whatever else you like) to avoid this.
The plugin attempts to use the extended match definitions from "matchit". In ruby, for instance, the "matchit.vim" (built-in) plugin lets you jump between any related `if`/`elsif`/`else`/`end` lines:
Delefting the if-clause will also remove all other else-like lines, anything that the matchit plugin jumps to, as long as it's at the same level of indent, leaving you with just this:
Please read the built-in documentation for settings and additional informaiton.
|The easiest way to install the plugin is with a plugin manager:
- vim-plug: https://github.com/junegunn/vim-plug
- Vundle: https://github.com/VundleVim/Vundle.vim
If you use one, just follow the instructions in its documentation.
You can install the plugin yourself using Vim's "packages" functionality by cloning the project (or adding it as a submodule) under `~/.vim/pack/<any-name>/start/`. For example:
git clone https://github.com/AndrewRadev/deleft.vim ~/.vim/pack/_/start/deleft
This should automatically load the plugin for you on Vim start. Alternatively, you can add it to `~/.vim/pack/<any-name>/opt/` instead and load it in your .vimrc manually with:
If you'd rather not use git, you can download the files from the "releases" tab and unzip them in the relevant directory: https://github.com/AndrewRadev/deleft.vim/releases.
Click on the package to download.
ip used for rating: 126.96.36.199