When g++ or gdb are reporting some error (e.g. compilation error) in some file the output is like:
a.c:3: error: ‘pintf’ was not declared in this scope
then I usually do “vi a.c” and I go to the line 3 (:3).
Using this script you can do:
vi.py a.c:3 and will go to the line 3.
Or vi.py a.c:3:5 and will go the line 3, column 5.
Or vi.py a.c:3: and will also go to the line 3 (so you can copy-paste g++ output).
The script also accepts some other variations, see the first big comment in the script sourcecode.
It’s useful in my case, I thought to share in case that it’s also useful for somebody else.
By the way, you can rename the script to vi and save in some directory that has preference to the standard vi, or create an alias, etc. I’m always using the script, since it just does something when it’s needed.
As said in the script: it could be improved a lot, but it’s not needed for my needs. If somebody has some suggestion just say it here or by mail, it’s inside the script.
Leave a Reply