sponsor Vim development Vim logo Vim Book Ad

endwise.vim : Wisely add

 script karma  Rating 477/149, Downloaded by 4909  Comments, bugs, improvements  Vim wiki

created by
Tim Pope
 
script type
utility
 
description
This is a simple plugin that helps to end certain structures automatically.  In Ruby, this means adding "end" after "if", "do", "def" and several other keywords. In Vim Script, this amounts to appropriately adding "endfunction", "endif", etc.  There's also VB support (don't ask), Bourne shell, C/C++ preprocessor, Objective C, Lua, Elixir, and more.

A primary guiding principle in designing this plugin was that an erroneous insertion is never acceptable.  The behavior is only triggered once pressing enter on the end of the line.  When this happens, endwise searches for a matching end structure and only adds one if none is found.

While the goal was to make it customizable, this turned out to be a tall order.  Every language has vastly different requirements.  Nonetheless, for those bold enough to attempt it, you can follow the model of the autocmds in the plugin to set the three magic variables governing endwise's behavior.

https://github.com/tpope/vim-endwise
 
install details
Install in ~/.vim/plugin (~\vimfiles\plugin on Windows)
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
endwise.zip 1.3 2022-03-24 7.4 Tim Pope Better support for automatically combining with other <CR> maps.
Better support for manually creating combined <CR> maps.
Add support for filetype=crystal.
Add support for filetype=htmldjango.
Add support for filetype=jinja.html and filetype=htmijinja.
Add support for filetype=make.
Add support for filetype=verilog.
Add support for filetype=bash (alias for sh).
Add support for filetype=haskell (C preprocessor only).
Add support for filetype=snippets from utilsnips.
Miscellaneous improvements to various filetype support.
Fix issues with <CR> map in command-line window.
endwise.zip 1.2 2014-04-01 7.0 Tim Pope Elixer support.
MATLAB file support.
Objective C support.
Close after Ruby assignment and def modifiers.
Add support for Lua local functions.
Use then not if to trigger fi for sh.
Fix C match detection.
Fix false positives on certain file types.
Fix duplicates on <C-X><CR>.
Remove unrelated <M-o> map.
Allow chaining any <Plug>...CR mappings.
endwise.zip 1.1 2013-01-01 7.0 Tim Pope Add support for Lua, Bourne shell, and C preprocessor.
Detect delimitMate mapping and append accordingly.
Add `g:endwise_no_mappings` to allow skipping maps.
endwise.vim 1.0 2008-10-02 7.0 Tim Pope Initial upload
ip used for rating: 142.132.191.50

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github