sponsor Vim development Vim logo Vim Book Ad

intermediate Tip #301: Edit files in path, or related.

 tip karma   Rating 5/2, Viewed by 901 

created:   August 7, 2002 0:09      complexity:   intermediate
author:   Little Dragon      as of Vim:   5.7

You can write a little shell function that will let you easily edit any file that is in the path, or which's location can be retrieved with the whereis tool. This is something similar to what I have in /etc/profile:

function vvim() { vim `whereis $1|cut -d: -f2` }
function ggvim() { gvim `whereis $1|cut -d: -f2` }

Then just type, for example, "vvim ls", and you'll start vim with /bin/ls and /usr/share/man/ls.1.gz loaded :)
(it's not very useful to edit /bin/ls, but you get the ideea ;)

 rate this tip  Life Changing Helpful Unfulfilling 

<<Making a tags file for IDL (Interactive Data Language) | Use gvim in kmail >>

Additional Notes

[email protected], August 7, 2002 3:34
A more useful example: vvim profile
[email protected], August 8, 2002 19:12

I liked the idea, great for editing scripts, but it didn't work for the shells
I use. Here's how I got it to work for the 2 shells I use:

For 'bash':
vvim () { command vim `whereis "$@" | cut -d: -f2` ; }

For 'tcsh' in .tcshrc:
alias vvim 'vim `whereis \!* | cut -d: -f2` '
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 [email protected] after searching the archive. Help Bram help Uganda.
Sponsored by Web Concept Group Inc. SourceForge Logo