Tip #485: Open a new window and read in the man page for the word under the cursor
tip karma |
Rating 15/8, Viewed by 1087
|
created: |
|
June 13, 2003 22:25 |
|
complexity: |
|
intermediate |
author: |
|
munk |
|
as of Vim: |
|
6.0 |
This short function opens a new window and reads in the Unix man page for the word under the cursor. To use it add the following to your ~/.vimrc file:
fun! ReadMan()
" Assign current word under cursor to a script variable:
let s:man_word = expand('<cword>')
" Open a new window:
:exe ":wincmd n"
" Read in the manpage for man_word (col -b is for formatting):
:exe ":r!man " . s:man_word . " | col -b"
" Goto first line...
:exe ":goto"
" and delete it:
:exe ":delete"
endfun
" Map the K key to the ReadMan function:
map K :call ReadMan()<CR>
cf:
:help windows
:help wincmd
etc
The col command may differ on your version of Unix, see col(1) for details.
<<Console-like fonts for Windows GVim |
Search for word under cursor, but don't move. >>
Additional Notes
|