Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a way to read man pages in Vim without using temporary files

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

like image 619
MYV Avatar asked May 24 '13 17:05

MYV


People also ask

How do I view multiple files in Vim?

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.

How do I open a new file in Vim editor without exit from that?

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.

Which Vim command will save the current file without exiting?

Type w after the colon and hit Enter. This will save in Vim the changes made to the file, without exiting.


1 Answers

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.

like image 100
glts Avatar answered Sep 17 '22 15:09

glts