Vim Tips Wiki
Register
We recommend that you log in before editing. This will allow other users to leave you a message about your edit, and will let you track edits via your Watchlist. Creating an account is quick and free.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 14: Line 14:
 
Following is a ''big'' timesaver if you need to open lots of files.
 
Following is a ''big'' timesaver if you need to open lots of files.
   
Assume you have a text file containing filenames with or without paths (created by for instance 'grep -Erl "^" * > files.txt'). Following opens all these files in the same vim.
+
Assume you have a text file containing filenames with or without paths (created by for instance 'grep -Erl "^" * > files.txt'). Following opens all these files in the same vim.
   
 
Assuming that only this text file is opened:
 
Assuming that only this text file is opened:
Line 21: Line 21:
   
 
<pre>
 
<pre>
q0gf:rew<CR><DOWN-ARROW>q
+
q0gf:rew&lt;CR&gt;&lt;DOWN-ARROW&gt;q
 
</pre>
 
</pre>
   
 
This loads the file on the first line, and creates macro '0'.
 
This loads the file on the first line, and creates macro '0'.
   
Check the number of lines with <CTRL-g> and subtract one for the first line. Type this value, then:
+
Check the number of lines with &lt;CTRL-g&gt; and subtract one for the first line. Type this value, then:
   
 
<pre>
 
<pre>
Line 38: Line 38:
   
 
<pre>
 
<pre>
bash> gvim $(grep -l *.* string)
+
bash&gt; gvim $(grep -l *.* string)
 
</pre>
 
</pre>
   
Line 44: Line 44:
   
 
<pre>
 
<pre>
bash> grep -n *.* string > list
+
bash&gt; grep -n *.* string &gt; list
bash> vim -q list .. you can visit each file:line with :cnext, :cprev
+
bash&gt; vim -q list .. you can visit each file:line with :cnext, :cprev
 
</pre>
 
</pre>
   
Line 51: Line 51:
   
 
<pre>
 
<pre>
bash> find . -name *.* | xargs grep -l string | vim -
+
bash&gt; find . -name *.* | xargs grep -l string | vim -
 
</pre>
 
</pre>
   
Line 66: Line 66:
 
</pre>
 
</pre>
   
Last command may be replaced with typing :cfile <c-r>%<CR>
+
Last command may be replaced with typing :cfile &lt;c-r&gt;%&lt;cr&gt;
   
 
Now you may navigate through these files using copen, cnext, cNext, cfirst, clast.
 
Now you may navigate through these files using copen, cnext, cNext, cfirst, clast.
Please note that all contributions to the Vim Tips Wiki are considered to be released under the CC-BY-SA
Cancel Editing help (opens in new window)