Vim Tips Wiki
(merge in tip from 200904 by Walf)
(Change <tt> to <code>, perhaps also minor tweak.)
 
Line 4: Line 4:
 
|previous=264
 
|previous=264
 
|next=266
 
|next=266
|created=June 22, 2002
+
|created=2002
 
|complexity=basic
 
|complexity=basic
 
|author=Mikolaj Machowski
 
|author=Mikolaj Machowski
Line 20: Line 20:
 
</pre>
 
</pre>
   
Now name it, for example, <tt>vih</tt> and from the command line:
+
Now name it, for example, <code>vih</code> and from the command line:
 
<pre>
 
<pre>
 
$ vih makeprg
 
$ vih makeprg
Line 34: Line 34:
   
 
==From 200904 tip (now removed)==
 
==From 200904 tip (now removed)==
Sometimes you may want to start Vim to look at a specific help page. I have these two functions in my <tt>~/.bashrc</tt> for this purpose.
+
Sometimes you may want to start Vim to look at a specific help page. I have these two functions in my <code>~/.bashrc</code> for this purpose.
   
 
To open the help page for a given word from the command line:
 
To open the help page for a given word from the command line:
Line 51: Line 51:
 
}
 
}
 
</pre>
 
</pre>
Now you can invoke the function with your search and Vim opens the desired help page. With the <tt>;vimhelpgrep</tt> function it opens an additional quickfix window and goes to the first hit.
+
Now you can invoke the function with your search and Vim opens the desired help page. With the <code>;vimhelpgrep</code> function it opens an additional quickfix window and goes to the first hit.
   
 
{{todo}}
 
{{todo}}
*The two commands above include <tt>"au! VimEnter *"</tt> which removes all VimEnter autocommands.
+
*The two commands above include <code>"au! VimEnter *"</code> which removes all VimEnter autocommands.
 
*That is probably to remove the effect of something in the author's vimrc, but is not required in general.
 
*That is probably to remove the effect of something in the author's vimrc, but is not required in general.
 
*Think about whether to remove it, or perhaps replace with something like:
 
*Think about whether to remove it, or perhaps replace with something like:
:<tt>view -u '$VIMRUNTIME/vimrc_example.vim' -c "help $1" -c only</tt>
+
:<code>view -u '$VIMRUNTIME/vimrc_example.vim' -c "help $1" -c only</code>
   
 
==See also==
 
==See also==
Line 64: Line 64:
 
*[[VimTip823|823 Add your note files to Vim help]]
 
*[[VimTip823|823 Add your note files to Vim help]]
   
These tips relate to using <tt>vim -c</tt>:
+
These tips relate to using <code>vim -c</code>:
 
*[[VimTip36|36 Using Gnu-info help in vim]]
 
*[[VimTip36|36 Using Gnu-info help in vim]]
 
*[[VimTip167|167 Using vim as a man-page viewer under Unix]]
 
*[[VimTip167|167 Using vim as a man-page viewer under Unix]]

Latest revision as of 05:21, 13 July 2012

Tip 265 Printable Monobook Previous Next

created 2002 · complexity basic · author Mikolaj Machowski · version 6.0


You can get fast access to read Vim's help by writing a small script. This can be particularly helpful if you have written your own documentation using Vim's help file type.

Suggestion 1[]

#!/bin/bash
vim -c "help $1" -c only

Now name it, for example, vih and from the command line:

$ vih makeprg

Suggestion 2[]

Make an alias or shortcut to the command:

gvim -c ":h MyKeyWord" -c :only

This will open gvim, jump to your help text in help mode and close all the rest. You only see your help text, just what you wanted to read.

From 200904 tip (now removed)[]

Sometimes you may want to start Vim to look at a specific help page. I have these two functions in my ~/.bashrc for this purpose.

To open the help page for a given word from the command line:

vimhelp()
{
  view -c "help $1" -c on -c "au! VimEnter *"
}

and the same with helpgrep (you need the command Vim, not view because of the quickfix window)

vimhelpgrep()
{
  vim -c "helpgrep $1" -c on -c copen -c "au! VimEnter *"
}

Now you can invoke the function with your search and Vim opens the desired help page. With the ;vimhelpgrep function it opens an additional quickfix window and goes to the first hit.

 TO DO 

  • The two commands above include "au! VimEnter *" which removes all VimEnter autocommands.
  • That is probably to remove the effect of something in the author's vimrc, but is not required in general.
  • Think about whether to remove it, or perhaps replace with something like:
view -u '$VIMRUNTIME/vimrc_example.vim' -c "help $1" -c only

See also[]

These tips attempt to deal with making your own help text:

These tips relate to using vim -c:

Comments[]