Jayesh
Jayesh

Reputation: 53335

How to jump directly to a column number in Vim

Sometimes for debugging purposes I have to do the exciting job of wading through minified javascript code. The lines are upto 600 columns wide. The exception reporting library is kind enough to provide me the exact crash coordinates in the form of line number and column number. However I can't find a way to directly jump to the column number, even though I can jump to the line so easily.

How can I do it?

Upvotes: 326

Views: 133192

Answers (4)

sjas
sjas

Reputation: 19667

80| takes you to the 80th column - if your line has that many columns, that is, and from anywhere in the current line.

also: this is a pipe sign, not the lowercase letter 'L'

Upvotes: 13

Jon Thoms
Jon Thoms

Reputation: 10739

An alternative answer that works for me on Mac OS is to use the command that moves the cursor to the right (i.e. l). So if your cursor is on the first column, and you want to put the cursor at column 50 of your current line, use the command:

49l

Upvotes: 20

Ravikant Mane
Ravikant Mane

Reputation: 1079

You can use the cursor function. For example, to jump to column 25 of line 15, you can use :call cursor(15,25).

Upvotes: 98

A B
A B

Reputation: 8867

The | command does what you want, as in 30| will take you to column 30.

                                                        bar
|                       To screen column [count] in the current line.
                        exclusive motion.  Ceci n'est pas une pipe.

http://vimdoc.sourceforge.net/htmldoc/motion.html#bar

Upvotes: 465

Related Questions