308

I'm getting an error message from a python script at position 21490.

How can I go to this position in Vim?

Arslan Ali
  • 17,418
  • 8
  • 58
  • 76
Cato Johnston
  • 44,131
  • 10
  • 39
  • 42
  • 3
    For moving to the nth character in the current line, see https://stackoverflow.com/questions/4466950/go-to-n-th-symbol-in-line – naught101 Aug 26 '16 at 03:47

2 Answers2

487

:goto 21490 will take you to the 21490th byte in the buffer.

Brian Carper
  • 71,150
  • 28
  • 166
  • 168
71

vim +21490go script.py

From the command line will open the file and take you to position 21490 in the buffer.

Triggering it from the command line like this allows you to automate a script to parse the exception message and open the file to the problem position.


Excerpt from man vim:

+{command}

-c {command}

{command} will be executed after the first file has been read. {command} is interpreted as an Ex command. If the {command} contains spaces it must be enclosed in double quotes (this depends on the shell that is used).

ljs.dev
  • 4,449
  • 3
  • 47
  • 80