Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Move to the next row which has non-white space character in the same column in VIM?

Tags:

vim

As source code is usually indented, it will help navigate source code quickly if I can move to the next/previous row which has non-empty white character in the same column. Using below code snippet as example and the cursor in on the last }, is there a way to navigate the cursor to i which starts if?

if (condition) {
    //  some code
}
like image 238
Thomson Avatar asked Jan 02 '14 12:01

Thomson


3 Answers

I've now implemented this motion in my JumpToVerticalOccurrence plugin; by default mapped to ]| / [|. There are other, related mappings like a ]V{char} mapping that works just like f, but vertically.

So if you don't mind installing a plugin (plus dependencies), this is more robust and functional (it supports [count] as well).

like image 161
Ingo Karkat Avatar answered Nov 01 '22 10:11

Ingo Karkat


Not exactly what you're asking for, but if you start at } and hit %, the cursor moves to the matching {.

like image 1
ales_t Avatar answered Nov 01 '22 08:11

ales_t


If your code has a defined indentation system, jeetsukumaran/vim-indentwise works well for relative, absolute, or block-scope movements across indented blocks.

like image 1
Harry Avatar answered Nov 01 '22 09:11

Harry