Home > SyntaxMotion.vim

SyntaxMotion.vim

SyntaxMotion.vim is a project mainly written in Vim Script, it's free.

Cursor motion & visual selection by syntax highlighting group

This is a mirror of http://www.vim.org/scripts/script.php?script_id=2965

This plugin provides cursor motion by syntax highlighting groups in normal and visual mode:

  • type (actually ) to move the cursor forward to the end of the syntax group where cursor is located.

  • type (actually ) to move the cursor forward to the beginning of the syntax group where cursor is located.

For example, when inside a string, pressing moves to the end of the string. When inside a comment, pressing moves to the beginning of the comment. You can extrapolate this behavior to any kind of syntax group.

Repeating the motion multiple times will move to the next syntax highlighting group (forward or backward). A repeat count number can also be given before typing or . For example, typing 3 moves the cursor to the left by 3 syntax elements.

Strictly speaking, motion actually moves to the start or end of the text which has the same "color" (rather than same "syntax group") as the color of the text where cursor is originally located. So if your color scheme defines the same colors for multiple syntax groups, motion may actually span multiple consecutive syntax groups if they have the same colors. Motion is based on syntax highlighting colors rather than syntax highlighting groups to make behavior more intuitive (what you see is what you get) since users see colors on the screen but may not be aware of different syntax highlight groups.

Plugin also provides a way to select the text visually around the position of the cursor with the same syntax group as where cursor is located:

  • type va to visually select the text with the same syntax as where cursor is located, and move the cursor to the end of the selected text.

  • type va to visually select the text with the same syntax as where cursor is located, and move the cursor to the beginning of the selected text.

Syntax highlighting must be enabled for the plugin to work.

License: The VIM LICENSE applies to SyntaxMotion.vim (see ":help copyright" except use "SyntaxMotion.vim" instead of "Vim").

ToDo:

  • write a proper help page
  • provide mapping in operator pending mode
Previous:Doxia-APT