1

When coding I often get errors in a certain line of a certain file. Often the output from compiler or processor has the format filename:LINENUMBER, e.g. /home/math/foo.bar:60. Since I use vim I then often copy the path with the trailing colon and linenumber and replace the colon by a space and a '+' character, e.g.: vim /home/math/foo.bar +60 in order to open vim with this file at this line. So is there a way I can automate this? And what if filenames have colons inside their names? As I am only interested in Posix systems where colons normally not occur in filenames, I look forward to your suggestions.

2

You don't need to automate this yourself.

vim already has mechanisms to handle jumping to the appropriate source file and line. Either …

  • … write the standard error of your compiler to a temporary file and open vim with that as its quickfix file:
    vim -q errors_file
  • … invoke your compiler from within vim itself using :make, which will automatically use a temporary quickfix file.

There's more on this at :help quickfix.

| improve this answer | |
0

You can compile from inside vim by running :make and then you will be automatically moved to the line.

| improve this answer | |
  • Even if the file is not opened yet? – math Jan 6 '12 at 10:42
0

If the compiler output is in a vim buffer, you can move the cursor over the filename:linenumber and type gF. Vim will open that file with the cursor at that line. See

:help gF
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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