12

I can parse out the paths to the files of a Python traceback, and I can then send those on to Vim using -p on the command line, so that they are opened one file per tab. So I end up with a command like, for example

vim -p main.py module.py another.py

That opens each file in a new tab, but I would like them opened in a new tab, at the correct line number. So I have tried variations like

vim -p main.py +10 module.py +20 another.py +30

But I cannot seem to get Vim to respect the line numbers I send in on command line - it always just takes the last line number and applies it to first tab. So the example left me in main.py at line 30. Trying variations like

vim -p main.py+10 module.py+20 another.py+30
vim -p main.py\ +10 "module.py +20" another.py@30

all just ended up with bad filenames.

Answers at the level of Python, or Bash command line, or within Vim script, or Vim-Python would all be welcome. Or, indeed, entirely different approaches

(The tracebacks could come from anywhere, and are not necessarily controllable by me. The one that started me off today was just a set of lines in a log from a server.)

3

1 Answer 1

2

Try vim plugin: file_line:

vim -p new main.py:10 module.py:20 another.py:30

Known Issue: the first filename should not have a lineno. (I'm trying to figure out WHY...)

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.