When I want to run vim in a new terminal, I prefer vim inside gnome-terminal rather than gvim. Thats easily enough accomplished with
gnome-terminal --execute vim "$@"
However, sometimes you want to block until vim is done.
One example of this is pentadactl's editor (invoked with ctrl-i)
older versions of gnome-terminal had --disable-factory
, that would
block until the command executed returned. Newer versions have dropped that
functionality, so we have to come up with another way.
Usage of this program is simple enough:
xvim [block] [vim-arguments]
This will invoke vim in a gnome-terminal with the provided arguments.
If the first argument is 'block' then it will not return until vim exits.
Otherwise it will return immediately.
The implementation is generic enough to support running any command
inside a terminal and waiting for the return, but as implemented now
only vim
is run.
To use in pentadactl, put this program in your path, and put the following in ~/.pentadactlrc:
set editor='xvim block -f +<line> +"sil! call cursor(0, <column>)" <file>'
To add this to the dialog of things (like firefox) that look for an application to open, do the following, which is modelled after /usr/share/applications/vim.desktop:
$ cat > ~/.local/share/applications/xvim.desktop <<EOF
[Desktop Entry]
Name=xvim
GenericName=Text Editor
GenericName[de]=Texteditor
Comment=Edit text files
TryExec=xvim
Exec=xvim %F
Type=Application
Keywords=Text;editor;
Icon=gvim
Categories=Utility;TextEditor;
MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++;application/octet-stream;
EOF