328

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?

3
  • It sounds like this a tool that needs to be invented. "Deminify my js, and while you're at it jump to the spot identified by this column number." Commented Feb 18, 2016 at 20:34
  • 3
    @dnellis74 That tool exists. It's called "sourcemaps" ;) Commented May 31, 2016 at 8:21
  • // , @Burgi, can haz 3 word summary & link? Commented Sep 24, 2016 at 20:17

4 Answers 4

469

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

Sign up to request clarification or add additional context in comments.

6 Comments

Be aware, for general usage, that this is screen column, not real column. This means that <Tab> characters will get different results. If these characters will be there, you will instead want |30lh or |29l or 029l or something like that.
You can also pass a number before various motion commands, e.g. 50h will move 50 characters left.
:set nowrap may also help reduce confusion between screen lines and file lines.
@DavidPope: note that in this case "screen columns" means that it's still relative to the start of the line. g0 achieves "start of current screen line".
The vim documentation is hilarious: "Ceci n'est pas une pipe" :-)
|
100

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

2 Comments

This does give an answer to the question and it's convenient having the Ex command alternative for scripting. Note that if the line number is zero, the cursor will stay in the current line.
This is especially nice for opening Vim from other tools, as this call can be done on the command-line: "+call cursor($LINE,$COLUMN)"
20

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

1 Comment

I use this all the time, but the good ol :21 (enter) 049l felt like a lot of work to get to a specific location, so that's why I came upon this question lol
14

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'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.