Thinking about it, the snippet I posted earlier was a bit silly as vim can open by itself multiple files way more efficiently. The only benefit from my script is that I don't have to type the --servername and --remote-silent-tab.
So let's add some usefulness ! First, when I need this script, it's often that I first grepped the files, and then decide that I want to edit them all. From this point of view, having to pass them as arguments is not that handy, so we'll add a way to pass them via STDIN.
Also, what if I want to send them to another vim server ? We'll add this ability too.
Here is the resulting script:
#!/usr/bin/env bash # set a default SERVERNAME SERVERNAME="ash0" # look for files on stdin if ! [ -t 0 ]; then FILES=`cat /dev/stdin` else exit; fi; # now let's check if we want a specific vim server if ! [ -z $1 ]; then SERVERNAME=$1 fi; # we can now open the files /usr/bin/gvim --servername $SERVERNAME --remote-silent-tab $FILES
Tada !
You can now do the followings:
grep foo | sendtovim grep foo | sendtovim grep0