You could try the command gvim --remote-tab-silent %F
. Thunar
should substitute %F
with the paths of all selected files.
--remote-tab-silent
is a variant of --remote
. For more info about it, see :h --remote
, :h --remote-silent
and :h --remote-tab-silent
.
There are various ways to tell Thunar
to use this command when you double-click on a file.
In the settings menu of Xubuntu, there's a section called System
. Inside this section, there's an entry called MIME Type Editor
. If you click on it, you will be presented with a window where you can choose the default applications that the OS should use to open various types of files.
You can restrict the MIME Types to the ones prefixed with text/
, since they are the most relevant for gVim
. Then, you can look for a type of file you want to open with your custom command gvim --remote-tab-silent %F
.
As an example, suppose you are only interested in log files, you could improve the filtering by writing in the filter
field text/x-log
.
Click on the default application. It should be gVim, mousepad or some other editor. Then, click on Choose Application...
, and on Use a custom command:
. In the new field, you could type your gvim --remote-tab-silent %F
command. Finally, validate with Open
.
You could achieve the same result by:
- doing a right-click on a text file
- clicking on
Properties
- opening the
Open With
menu
- clicking on the
Use a custom command:
entry
- entering
gvim --remote-tab-silent %F
in the field which has just been opened
In Thunar's toolbar, you could also:
- click on
Edit
- click on
Configure custom actions...
- click on the
+
button (whose tooltip reads Add a new custom action.
)
- in the
Name:
field, give a name to the new entry you want to add in Thunar's contextual menu; example my_gvim
- in the
Command:
field, insert the command gvim --remote-tab-silent %F
- validate with
OK
After this, when you right-click on a file, or a set of selected files, the contextual menu should contain the entry my_gvim
. If you click on it, it should open the selected files in gVim, one tabpage per file.
If you don't see the my_gvim
entry, go back to the menu where you created the entry, click on the edit button (right below the +
), select the 2nd tab (its title is Appearance Conditions
), and make sure that the box Text Files
is ticked (and that the filename pattern is not too restrictive).
If you want to edit multiple MIME types, you can try the following method, but I'm not sure it will work for you.
Inside ~/.local/share/applications/
, create a file named my_gvim.desktop
(or however else you want). In this file, import the contents of another .desktop
file, and edit it so that it contains your custom command. As an example, I wrote this:
[Desktop Entry]
Version=1.0
Type=Application
Name=MyGvim
Icon=
Exec=gvim --remote-tab-silent %F
NoDisplay=
Categories=
StartupNotify=false
Terminal=false
The important line is the one prefixed by Exec=
.
Then, you need to find a mimeapps.list
file in your home directory. I used ~/.config/mimeapps.list
(you may also try ~/.local/share/applications/mimeapps.list
).
In this file, write your MIME types, using the desktop file you created earlier. For example:
text/markdown=my_gvim.desktop;
text/x-log=my_gvim.desktop;
Add one line per MIME type.
If you want to find all the MIME types relative to text files, you could have a look at the list of .xml
files inside /usr/share/mime/text/
. On my system, I found this list of MIME types:
text/cache-manifest
text/calendar
text/css
text/csv-schema
text/csv
text/enriched
text/html
text/htmlh
text/markdown
text/plain
text/rfc822-headers
text/richtext
text/rust
text/sgml
text/spreadsheet
text/tab-separated-values
text/troff
text/turtle
text/vcard
text/vnd.graphviz
text/vnd.rn-realtext
text/vnd.sun.j2me.app-descriptor
text/vnd.trolltech.linguist
text/vnd.wap.wml
text/vnd.wap.wmlscript
text/vtt
text/x-adasrc
text/x-apt-sources-list
text/x-authors
text/x-bibtex
text/x-c++hdr
text/x-c++src
text/x-changelog
text/x-chdr
text/x-cmake
text/x-cobol
text/x-copying
text/x-credits
text/x-csharp
text/x-csrc
text/x-dcl
text/x-dsl
text/x-dsrc
text/x-eiffel
text/x-emacs-lisp
text/x-erlang
text/x-fortran
text/x-genie
text/x-gettext-translation-template
text/x-gettext-translation
text/x-go
text/x-google-video-pointer
text/x-haskell
text/x-idl
text/x-imelody
text/x-install
text/x-iptables
text/x-java
text/x-ldif
text/x-lilypond
text/x-literate-haskell
text/x-log
text/x-lua
text/x-makefile
text/x-matlab
text/x-meson
text/x-microdvd
text/x-moc
text/x-modelica
text/x-mof
text/x-mpsub
text/x-mrml
text/x-ms-regedit
text/x-mup
text/x-nfo
text/x-objcsrc
text/x-ocaml
text/x-ocl
text/x-ooc
text/x-opml+xml
text/x-pascal
text/x-patch
text/x-python
text/x-qml
text/x-readme
text/x-reject
text/x-rpm-spec
text/x-scala
text/x-scheme
text/x-scons
text/x-setext
text/x-ssa
text/x-subviewer
text/x-svhdr
text/x-svsrc
text/x-tcl
text/x-tex
text/x-texinfo
text/x-troff-me
text/x-troff-mm
text/x-troff-ms
text/x-txt2tags
text/x-uil
text/x-uri
text/x-uuencode
text/x-vala
text/x-verilog
text/x-vhdl
text/x-xmi
text/x-xslfo
text/x-zim-wiki
text/xmcd
If you used this list, after editing it, you should get something looking like this:
text/cache-manifest=my_gvim.desktop;
text/calendar=my_gvim.desktop;
text/css=my_gvim.desktop;
text/csv-schema=my_gvim.desktop;
text/csv=my_gvim.desktop;
text/enriched=my_gvim.desktop;
text/html=my_gvim.desktop;
text/htmlh=my_gvim.desktop;
text/markdown=my_gvim.desktop;
text/plain=my_gvim.desktop;
text/rfc822-headers=my_gvim.desktop;
text/richtext=my_gvim.desktop;
text/rust=my_gvim.desktop;
text/sgml=my_gvim.desktop;
text/spreadsheet=my_gvim.desktop;
text/tab-separated-values=my_gvim.desktop;
text/troff=my_gvim.desktop;
text/turtle=my_gvim.desktop;
text/vcard=my_gvim.desktop;
text/vnd.graphviz=my_gvim.desktop;
text/vnd.rn-realtext=my_gvim.desktop;
text/vnd.sun.j2me.app-descriptor=my_gvim.desktop;
text/vnd.trolltech.linguist=my_gvim.desktop;
text/vnd.wap.wml=my_gvim.desktop;
text/vnd.wap.wmlscript=my_gvim.desktop;
text/vtt=my_gvim.desktop;
text/x-adasrc=my_gvim.desktop;
text/x-apt-sources-list=my_gvim.desktop;
text/x-authors=my_gvim.desktop;
text/x-bibtex=my_gvim.desktop;
text/x-c++hdr=my_gvim.desktop;
text/x-c++src=my_gvim.desktop;
text/x-changelog=my_gvim.desktop;
text/x-chdr=my_gvim.desktop;
text/x-cmake=my_gvim.desktop;
text/x-cobol=my_gvim.desktop;
text/x-copying=my_gvim.desktop;
text/x-credits=my_gvim.desktop;
text/x-csharp=my_gvim.desktop;
text/x-csrc=my_gvim.desktop;
text/x-dcl=my_gvim.desktop;
text/x-dsl=my_gvim.desktop;
text/x-dsrc=my_gvim.desktop;
text/x-eiffel=my_gvim.desktop;
text/x-emacs-lisp=my_gvim.desktop;
text/x-erlang=my_gvim.desktop;
text/x-fortran=my_gvim.desktop;
text/x-genie=my_gvim.desktop;
text/x-gettext-translation-template=my_gvim.desktop;
text/x-gettext-translation=my_gvim.desktop;
text/x-go=my_gvim.desktop;
text/x-google-video-pointer=my_gvim.desktop;
text/x-haskell=my_gvim.desktop;
text/x-idl=my_gvim.desktop;
text/x-imelody=my_gvim.desktop;
text/x-install=my_gvim.desktop;
text/x-iptables=my_gvim.desktop;
text/x-java=my_gvim.desktop;
text/x-ldif=my_gvim.desktop;
text/x-lilypond=my_gvim.desktop;
text/x-literate-haskell=my_gvim.desktop;
text/x-log=my_gvim.desktop;
text/x-lua=my_gvim.desktop;
text/x-makefile=my_gvim.desktop;
text/x-matlab=my_gvim.desktop;
text/x-meson=my_gvim.desktop;
text/x-microdvd=my_gvim.desktop;
text/x-moc=my_gvim.desktop;
text/x-modelica=my_gvim.desktop;
text/x-mof=my_gvim.desktop;
text/x-mpsub=my_gvim.desktop;
text/x-mrml=my_gvim.desktop;
text/x-ms-regedit=my_gvim.desktop;
text/x-mup=my_gvim.desktop;
text/x-nfo=my_gvim.desktop;
text/x-objcsrc=my_gvim.desktop;
text/x-ocaml=my_gvim.desktop;
text/x-ocl=my_gvim.desktop;
text/x-ooc=my_gvim.desktop;
text/x-opml+xml=my_gvim.desktop;
text/x-pascal=my_gvim.desktop;
text/x-patch=my_gvim.desktop;
text/x-python=my_gvim.desktop;
text/x-qml=my_gvim.desktop;
text/x-readme=my_gvim.desktop;
text/x-reject=my_gvim.desktop;
text/x-rpm-spec=my_gvim.desktop;
text/x-scala=my_gvim.desktop;
text/x-scheme=my_gvim.desktop;
text/x-scons=my_gvim.desktop;
text/x-setext=my_gvim.desktop;
text/x-ssa=my_gvim.desktop;
text/x-subviewer=my_gvim.desktop;
text/x-svhdr=my_gvim.desktop;
text/x-svsrc=my_gvim.desktop;
text/x-tcl=my_gvim.desktop;
text/x-tex=my_gvim.desktop;
text/x-texinfo=my_gvim.desktop;
text/x-troff-me=my_gvim.desktop;
text/x-troff-mm=my_gvim.desktop;
text/x-troff-ms=my_gvim.desktop;
text/x-txt2tags=my_gvim.desktop;
text/x-uil=my_gvim.desktop;
text/x-uri=my_gvim.desktop;
text/x-uuencode=my_gvim.desktop;
text/x-vala=my_gvim.desktop;
text/x-verilog=my_gvim.desktop;
text/x-vhdl=my_gvim.desktop;
text/x-xmi=my_gvim.desktop;
text/x-xslfo=my_gvim.desktop;
text/x-zim-wiki=my_gvim.desktop;
text/xmcd=my_gvim.desktop;