Wikia

Vim Tips Wiki

Changes: Using Gnu-info help in vim

Edit

Back to page

(Show how to escape the word before passing it on to the shell.)
(Change <tt> to <code>, perhaps also minor tweak.)
 
Line 4: Line 4:
 
|previous=35
 
|previous=35
 
|next=37
 
|next=37
|created=March 7, 2001
+
|created=2001
 
|complexity=basic
 
|complexity=basic
 
|author=vimer
 
|author=vimer
Line 18: Line 18:
 
Now press F1 while the cursor is hold by a keyword such as printf will bring you to Gnu-info help page.
 
Now press F1 while the cursor is hold by a keyword such as printf will bring you to Gnu-info help page.
   
The word should be escaped before passing it on to the shell. Using Vim 7.2 or later, this is simple:
+
The word should be escaped before passing it on to the shell. Using Vim 7.2 or later, this is simple:
   
 
:nnoremap <F1> :exe ":!info ".shellescape(expand('<cword>'), 1)
 
:nnoremap <F1> :exe ":!info ".shellescape(expand('<cword>'), 1)
Line 43: Line 43:
 
----
 
----
   
Another choice is simply to change the {{help|prefix=no|'keywordprg'}} option to <tt>info</tt>. Then K will invoke info instead of man.
+
Another choice is simply to change the {{help|prefix=no|'keywordprg'}} option to <code>info</code>. Then K will invoke info instead of man.
   
 
-- [[User:JamesVega|JamesVega]] 17:39, February 9, 2010 (UTC)
 
-- [[User:JamesVega|JamesVega]] 17:39, February 9, 2010 (UTC)

Latest revision as of 05:08, July 13, 2012

Tip 36 Printable Monobook Previous Next

created 2001 · complexity basic · author vimer · version 5.7


K in normal bring you the man page about the keyword under current cursor.

:nnoremap <F1> :exe ":!info ".expand("<cword>")

Now press F1 while the cursor is hold by a keyword such as printf will bring you to Gnu-info help page.

The word should be escaped before passing it on to the shell. Using Vim 7.2 or later, this is simple:

:nnoremap <F1> :exe ":!info ".shellescape(expand('<cword>'), 1)

ReferencesEdit

See alsoEdit

CommentsEdit

Far better to use Info browsing within Vim.

Then e.g. :nnoremap <F1> :exe ":Info ".expand("<cword>")<CR>

Also, set your shell to alias info to use vim: (bash)

function viminfo () { vim -c "Info $1" -c "bdelete 1"; }
alias info=viminfo

Another choice is simply to change the 'keywordprg' option to info. Then K will invoke info instead of man.

-- JamesVega 17:39, February 9, 2010 (UTC)

Around Wikia's network

Random Wiki