My Python development environment consists of a GVim window for editing code and a gnome-terminal for running the unit tests. This works out well, but leaves some integration to be desired. In particular, jumping to a test failure point is a little cumbersome. I used to do it this way: copy the filename from the traceback, switch to vim, then type :e, paste the filename with middle-click (now I know I can use
I have written a small vimscript function to make the aforementioned use case slightly easier. Now to jump to a failure point, just triple-click the corresponding line in the traceback (that selects the whole line), switch to Vim and invoke the function, which scrapes the clipboard for a filename and line number and opens it in the active buffer.
Installation: paste the OpenFileFromClipboard function in your
~/.vimrc and bind it to a key by adding the following lines to your .vimrc:
:call OpenFileFromClipboard() imap :call OpenFileFromClipboard()
These commands bind the key F4 to our function. The first command handles normal mode, and the second handles insert mode (hence the
The function should handle following types of references from the clipboard:
John saved his work to ~john/doc.txt and left.
File "/home/gintas/devel/project/tests.py", line 123, in tests.py
/usr/include/stdio.h:333:extern int sprintf (char *__restrict __s,
I hope someone finds this useful.