Vim Tips Wiki
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 11: Line 11:
 
|category2=
 
|category2=
 
}}
 
}}
Press <code>[I</code> to display all lines that contain the keyword under the cursor. Lines from the current file, and from included files, are listed. Another command (see the [[#References|references below]]) allows you to jump to one of the displayed occurrences.
+
Press <tt>[I</tt> to display all lines that contain the keyword under the cursor. Lines from the current file, and from included files, are listed. Another command (see the [[#References|references below]]) allows you to jump to one of the displayed occurrences.
   
Here are two functions to simplify the process. With the mappings shown (and the default backspace Leader key) you can press <code>\j</code> to list occurrences of the keyword under the cursor. You are then prompted to enter the number of an item, in order to jump to that occurrence. Alternatively, press <code>\p</code> for a prompt allowing you to enter the keyword.
+
Here are two functions to simplify the process. With the mappings shown (and the default backspace Leader key) you can press <tt>\j</tt> to list occurrences of the keyword under the cursor. You are then prompted to enter the number of an item, in order to jump to that occurrence. Alternatively, press <tt>\p</tt> for a prompt allowing you to enter the keyword.
   
 
<pre>
 
<pre>
Line 49: Line 49:
 
</pre>
 
</pre>
   
Paste the code above into a file, save the file, then enter the command <code>:so %</code> (source current file). Then put the cursor on a word in any file and press <code>\j</code> to list occurrences, and jump to the selected occurrence.
+
Paste the code above into a file, save the file, then enter the command <tt>:so %</tt> (source current file). Then put the cursor on a word in any file and press <tt>\j</tt> to list occurrences, and jump to the selected occurrence.
   
 
==References==
 
==References==
Line 59: Line 59:
   
 
==Comments==
 
==Comments==
If you would prefer to modify <code>[I</code> to prompt for a number to jump to the following map does so:
+
If you would prefer to modify <tt>[I</tt> to prompt for a number to jump to the following map does so:
   
 
<code>nnoremap [I [I:let nr = input("Which one: ")<Bar>if nr != ""<Bar>exe "silent! normal " . nr ."[\t"<Bar>endif<CR></code>
 
<code>nnoremap [I [I:let nr = input("Which one: ")<Bar>if nr != ""<Bar>exe "silent! normal " . nr ."[\t"<Bar>endif<CR></code>
   
and again for <code>]I</code>
+
and again for <tt>]I</tt>
   
 
<code>nnoremap ]I ]I:let nr = input("Which one: ")<Bar>if nr != ""<Bar>exe "silent! normal " . nr ."]\t"<Bar>endif<CR></code>
 
<code>nnoremap ]I ]I:let nr = input("Which one: ")<Bar>if nr != ""<Bar>exe "silent! normal " . nr ."]\t"<Bar>endif<CR></code>
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)