I want to be able to read man pages in Vim.
For some reason, it seems that Vim isn't able to read the output of programs through piping. E.g (man ls) | vi
doesn't seem to work, bonus points for somebody who can explain why.
To get around this, I've been using the following little script:
tempo = `mktemp` man $1 > $tempo ; vi $tempo
This script uses temporary files which I guess work fine, but I was wondering if there was a good way to read man pages in Vim without resorting to creating temporary files
Using windows. Ctrl-W w to switch between open windows, and Ctrl-W h (or j or k or l ) to navigate through open windows. Ctrl-W c to close the current window, and Ctrl-W o to close all windows except the current one. Starting vim with a -o or -O flag opens each file in its own split.
Opening a new file for editing If you're already in vim, then there's no need to exit it just to open a new file. That will open the file for editing. You can also use the tab-key for autocompletion of the path. Please note that the current file must be saved, or you've to use :e! to discard the unsaved changes.
Type w after the colon and hit Enter. This will save in Vim the changes made to the file, without exiting.
Vim includes a man page viewer, :Man
, in its runtime files.
Put this line in your vimrc:
runtime! ftplugin/man.vim
Now you can read syntax-highlighted man pages inside Vim by running :Man
. For example:
:Man 3 printf
Even better, you can just place your cursor on a word in the buffer and press <Leader>K
(\K
) to see the man page for that word.
See :h find-manpage
for complete usage and installation instructions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With