Vim Tips Wiki
No edit summary
 
(Adjust previous/next navigation)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
{{review}}
 
{{review}}
  +
{{TipImported
{{Tip
 
 
|id=301
 
|id=301
  +
|previous=299
|title=Edit files in path, or related.
 
  +
|next=302
|created=August 7, 2002 0:09
+
|created=August 7, 2002
 
|complexity=intermediate
 
|complexity=intermediate
 
|author=Little Dragon
 
|author=Little Dragon
 
|version=5.7
 
|version=5.7
 
|rating=5/2
 
|rating=5/2
  +
|category1=
|text=
 
  +
|category2=
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:
 
 
}}
 
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:
  +
<pre>
 
function vvim() { vim `whereis $1|cut -d: -f2` }
 
function ggvim() { gvim `whereis $1|cut -d: -f2` }
  +
</pre>
   
 
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).
   
 
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 ;)
 
}}
 
 
== Comments ==
 
 
A more useful example: vvim profile
 
A more useful example: vvim profile
   
 
==Comments==
littledragon--AT--altern.org
 
 
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:
, August 7, 2002 3:34
 
----
 
 
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 "$--AT--" | cut -d: -f2` ; }
 
   
For 'tcsh' in .tcshrc:
+
For 'bash':
  +
<pre>
alias vvim 'vim `whereis \!* | cut -d: -f2` '
 
 
vvim () { command vim `whereis "$@" | cut -d: -f2` ; }
  +
</pre>
   
  +
For 'tcsh' in .tcshrc:
  +
<pre>
 
alias vvim 'vim `whereis \!* | cut -d: -f2` '
  +
</pre>
   
weisbier--AT--aol.com
 
, August 8, 2002 19:12
 
 
----
 
----
<!-- parsed by vimtips.py in 0.500443 seconds-->
 

Latest revision as of 03:04, 30 June 2008

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

Comments[]

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