sponsor Vim development Vim logo Vim Book Ad

indent-motion : Vim motions to the start and end of the current indentation-delimited block

 script karma  Rating 6/3, Downloaded by 167    Comments, bugs, improvements  Vim wiki

created by
Taylor Hedberg
script type
indent-motion is a Vim plugin which maps `<Leader>[` and `<Leader>]` in normal, visual, and operator-pending modes to move to the beginning and end (respectively) of your current indentation-delimited block (`<Leader>` refers to your current user-defined "mapleader", which is `\` by default).

For example (using JavaScript):

    function foo(a, b, c) {
        var x = 1;
        var y = 2;
        if (x == y) {
            alert("This will never happen!");

In the above snippet, if the cursor is positioned on the `var x = 1;` line, then `<Leader>]` will move the cursor to the next-to-last line (closing brace of the conditional block) and `<Leader>[` will move it back to the original location. If the cursor is positioned on the `alert` call, then `<Leader>]` will move down 1 line to `++y;`.

If one of the mappings is executed on an empty line (containing no characters, not even whitespace), then the assumed indentation will be that of the next non-empty line, where "next" is in the direction of the requested motion.

Currently, the mappings are not configurable, but this can easily be changed upon request.
install details
Clone my Github repo (see https://github.com/tmhedberg/indent-motion) if you use Pathogen and Git to manage your plugins, or just download the file and drop it into your ~/.vim/plugin directory.

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
indent-motion.vim 1.0.1 2011-09-03 7.0 Taylor Hedberg Initial upload
ip used for rating:

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.
SourceForge.net Logo