Wikia

Vim Tips Wiki

Edit file found by whereis

Talk0
1,610pages on
this wiki
Revision as of 03:04, June 30, 2008 by JohnBot (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Tip 301 Printable Monobook Previous Next

created August 7, 2002 · complexity intermediate · author Little Dragon · version 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).

A more useful example: vvim profile

CommentsEdit

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` '

Advertisement | Your ad here

Around Wikia's network

Random Wiki