On 13/10/11 10:12, Gergely Buday wrote:
Hi,

the percent sign makes vi jump to the corresponding closing
parenthesis, should I point to the opening one.

How can I program a similar functionality for other classes of
syntactical elements? In Standard ML, there is a let - in - end
construct that can span several pages so it would be useful to jump
from one let to the corresponding end. Of course a let-in-end triple
can be found in another.

Is there a way to program this in vi?

- Gergely


1. Enable the matchit plugin, see :help matchit-install
1.1 Create the directory $VIM/vimfiles/plugin if it doesn't exist, and place in it a one-line file containing just

        runtime macros/matchit.vim

You can name it matchit.vim

   1.2 On Unix/Linux, you can enable the matchit help via a softlink:

        :shell
        mkdir -pv $VIM/vimfiles/doc
        cd $VIM/vimfiles/doc
        ln -sv ../../vim73/macros/matchit.txt
        exit
        :helptags $VIM/vimfiles/doc

On Windows, you may have to copy the matchit.txt file from $VIMRUNTIME/macros to $VIM/vimfiles/doc/. The :helptags command (as above) is still necessary so that the help entries in the file will be made part of Vim's help system.

2. If the ftplugin for StandardML doesn't already set the b:match_words variable, you can set it in an after-plugin, named (for instance) $VIM/vimfiles/after/ftplugin/standardml.vim (if "standardml" is the 'filetype' value for those files). For details, see :help matchit-newlang (after installing the matchit help as above).

3. In order not to lose the "standard" function of the % key for files which have no specific syntax pairings, I recommend adding the following in your vimrc:

        augroup vimrclocal
                au FileType c,cpp,css,javascript
                        \ let b:match_words = &matchpairs
        augroup END

This will also avoid %-jumping from ( or ) in a comment to ) or ( in the code or vice-versa (likewise for []{}).


Best regards,
Tony.
--
"In any world menu, Canada must be considered the vichyssoise of
nations -- it's cold, half-French, and difficult to stir."
                -- Stuart Keate

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to