diff --git a/CHANGELOG.md b/CHANGELOG.md index df59418..d10882f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ All notable changes to this project will be documented in this file. - Tips: [Saner command-line history](README.md#saner-command-line-history) - Usage: [Editing remote files](README.md#editing-remote-files) - Usage: [Restore cursor position when opening file](#restore-cursor-position-when-opening-file) +- Usage: [MatchIt](README.md#matchit) - Debugging: [Verbosity](README.md#verbosity) - Debugging: [Debugging Vim scripts](README.md#debugging-vim-scripts) - Debugging: [Debugging syntax files](README.md#debugging-syntax-files) diff --git a/README.md b/README.md index 6c94d6b..365c452 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ added every day. Things about to be added can be found here: - [Editing remote files](#editing-remote-files) - [Managing plugins](#managing-plugins) - [Block insert](#block-insert) +- [MatchIt](#matchit) #### [Tips](#tips-1) @@ -829,6 +830,53 @@ but quickly becomes second nature. If you want to get real fancy, have a look at [multiple-cursors](https://github.com/terryma/vim-multiple-cursors). +#### MatchIt + +Since Vim is written in C, a lot of features assume C-like syntax. By default, +if your cursor is on `{` or `#endif`, you can use `%` to jump to the +corresponding `}` or `#ifdef` respectively. + +Vim comes bundled with a plugin called matchit.vim which is not enabled by +default. It makes `%` also cycle through HTML tags, if/else/endif constructs in +VimL etc. and introduces a few new commands. + +To always load the plugin, put this in your vimrc: + +```viml +if !exists('g:loaded_matchit') + runtime macros/matchit.vim +endif +``` + +Since the documentation of matchit is pretty extensive, I suggest also doing the +following once: + +```viml +:!mkdir -p ~/.vim/doc +:!cp $VIMRUNTIME/macros/matchit.txt ~/.vim/doc +:helptags ~/.vim/doc +``` + +The plugin is ready to use now. See `:h matchit-intro` for the supported +commands and `:h matchit-languages` for the supported languages. + +That said, it's easy to define your own matching pairs: + +```viml +autocmd FileType python let b:match_words = '\:\:\' +``` + +Afterwards you can cycle through these 3 statements in any Python file by using +`%` (forward) or `g%` (backward). + +Related help: + +``` +:h matchit-install +:h matchit +:h b:match_words +``` + ## Tips #### Saner behavior of n and N