views:

41

answers:

5

For example suppose I do a certain man or maybe a grep.

I want to see the results using gvim without the normal procedure of saving them first and opening the saved file [because I don't need the results once I view them]

I tried two ways, both the methods fail:

a)

man gcc | gvim
//opens a blank gvim window

b)

man gcc > gvim
//saves the result in a new file named "gvim"

Is there a way to do it?


Below is a copy paste of the first few lines of what I get using man gcc | gvim - or :r! man gcc :

(N^HNA^HAM^HME^HE is what the NAME looks like in gvim. I guess ^H is some non-displayable character, because it is not being displayed here on SO)

GCC(1)
GNU
GCC(1)

NNAAMMEE gcc - GNU project C and C++ compiler

SSYYNNOOPPSSIISS gcc [--cc|--SS|--EE] [--ssttdd==_s_t_a_n_d_a_r_d]

+1  A: 

Try:

man gcc | gvim -

Here

  • man gcc writes its output to the stdout and
  • gvim - reads its input from its stdin and
  • the pile connects the stdout of man gcc to stdin of gvim
codaddict
yes, it does display the `man gcc` in `gvim`, but the text is filled with a lot of `^H` characters.
Lazer
btw, what does `-` sign after `gvim` do? can't find it in `man gvim`.
Lazer
- stands for stdin
codaddict
okay, what are these `^H` things?
Lazer
These are terminal char.
codaddict
+1  A: 

You can try from within gvim:

:r! man gcc

Some more info here

ccheneson
same as what happens with `man gcc | gvim -`, the text is filled with a lot of `^H` characters.
Lazer
+1  A: 

those are control characters. Here's one way to "get rid" of it

man gcc|col -b| gvim -
ghostdog74
thanks! this works!
Lazer
+1  A: 

See this answer that I have given to a similar question on prior occasion on SO, in that case do

man gcc | col -b | gvim -R -

Which takes the manual page for 'gcc', pipes it to 'col' with a switch '-p', then pipe it into 'gvim' opening the file as read-only using the dash '-' as taking in input from the previous pipe.

tommieb75
A: 

If you have your PAGER & EDITOR variables set up correctly:

export PAGER=less
export EDITOR=gvim

Then you can simply hit 'v' while viewing the man page in less.

pra
where do I look for these variables?
Lazer
Environment variables are typically set in your shell's initialization file. For bash, that's .profile or .bashrc.
pra