sponsor Vim development Vim logo Vim Book Ad

ovim : open files in running gvim from a terminal

 script karma  Rating 5/4, Downloaded by 336    Comments, bugs, improvements  Vim wiki

created by
Pavol Juhas
 
script type
utility
 
description
ovim is a zsh script that makes it convenient to open files
or execute "ex" commands in gvim from a Unix terminal.

Examples:

Open all c files and jump to the first "main" string:
    ovim *.c +/main

Open all cpp files that contain the "sstream" string:
    grep -l sstream *.cpp | xargs ovim
or
    ovim -c vimgrep sstream *.cpp

Open the README.txt file in a new window:
    ovim -c split README.txt

Make gvim jump to a tag with respect to the "tags" file
in the shell directory (try this in /usr/share/vim/vim72/doc):
    ovim -c tag /grail

Change to the current shell directory in gvim:
    ovim -c cd .

Open all txt files in the gvim server MYGVIM.  The server name is
capitalized thus "-s mygvim" is the same as "-s MYGVIM":
    ovim -s mygvim *.txt

Make gvim a bit animated:
    ovim -c "winpos "{1..400}" 1|"

Feautures:

* speed "gvim --remote f1 f2 f3 ... f50" could cause about 10 second screen
updates in some older gvim versions.  With ovim gvim sources a temporary
script file and avoids such slow downs.

* intelligent server selection.  ovim attempts to reuse
the last server used, if it is not running, it will select the last live
gvim server or finally would start new gvim process.  The server
selection can be forced with a "-s MYSERVER" option.  Note that this
server choice is permanent, i.e., subsequent calls of ovim would try
to use the same server.

* "ex" commands are executed in the current shell directory
"ovim -c split filename" works even if terminal and the gvim server are
in different directories.  The gvim directory is changed to the terminal
directory just before the ex commands execution and then restored back.
This is done in such way that "ovim -c cd somewhere" works as expected.
 
install details
Copy the script file to $HOME/bin/ or to some other directory
in the PATH and make it executable using "chmod +x ovim".  
Make sure the zsh shell is installed, it is usually available
as a "zsh" package in recent Linux distributions.
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
ovim 161 2010-08-10 7.0 Pavol Juhas Initial upload
ip used for rating: 54.87.70.14

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
SourceForge.net Logo