Could anyone suggest me how to open multiple files in a vim with a double click from filesystem. Currently I can open multiple files in vim using:

  1. :tabe
  2. NERDTree file navigation
  3. using gVim

But I don't like these solutions. All I want is a simple technique that when I double click a file, will open as a new tab in a vim instead of a new terminal instance of vim. The mechanism simple code-editors like sublime-text follows for example.

Thank you.

  • I don't see this working. Vim runs in the terminal and I guess you're double clickung in some file manager, right? I dont't think this "link" can be made. What I usually do is "vim foo.*" and then ":tab all" in vim. Also, typing ":tabnew bar" in vim shouldn't be much slower (actually it should be faster) than grabbing the mouse and double clicking. – fpnick Aug 30 '18 at 10:13
  • @fpnick - you are right, its fast to open when the file is in same directory using :tabe but when I have to go to completely different folder its little bit harder. – Dharma Aug 30 '18 at 10:25

Vim has a :help client-server feature built-in. For terminal Vim, this needs access to the X server (:help x11-clientserver), and you need explicitly specify a servername when launching Vim:

$ vim --servername target

Then, in a different terminal (or via a shell script that you register for "double-clicks from filesystem", e.g. via a Nautilus plugin), you can make the first Vim edit passed file(s):

$ vim --servername target --remote /path/to/file [...]
  • Thank you for your answer. But this is not what I want, I want a simple feature like opening multiple files in gedit in tabs from double click on filesystem. But I will stick to NerdTree for now. – Dharma Sep 20 '18 at 8:44
  • Well, what looks like a simple feature in other editors usually involves a similar kind of inter-process communication; it's just better hidden from you. The things I've outlined are not that complex (if you know what to do) - of course, you're free to skip the learning experience for now if you have another working alternative. – Ingo Karkat Sep 20 '18 at 8:55

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.