Fandom

Vim Tips Wiki

Edit file found by whereis

1,624pages on
this wiki
Add New Page
Talk0 Share

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

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

Also on Fandom

Random Wiki