How to view some data in gvim without saving it first?
-
18-09-2019 - |
Question
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]
Solution
those are control characters. Here's one way to "get rid" of it
man gcc|col -b| gvim -
OTHER TIPS
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.
Try:
man gcc | gvim -
Here
man gcc
writes its output to the stdout andgvim -
reads its input from its stdin and- the pile connects the stdout of man gcc to stdin of gvim
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.