Dump help pages

36 views
Skip to first unread message

Julius Hamilton

unread,
Apr 13, 2021, 3:38:57 AM4/13/21
to v...@vim.org
Hey,

Is there any way to output the content of the Vim help pages to a text file, with some sort of dump or output command?

Thanks very much,
Julius Hamilton


Christian Brabandt

unread,
Apr 13, 2021, 3:52:08 AM4/13/21
to v...@vim.org

On Mo, 12 Apr 2021, Julius Hamilton wrote:

> Is there any way to output the content of the Vim help pages to a text file, with some sort of dump or output command?

The help pages are text files, you don't need to dump them, you can
:e $VIMRUNTIME/doc/options.txt
to read the options help page.

Best,
Christian
--
Das Familienleben ist eine Störung des Privatlebens.
-- Michelangelo Antonioni

Julius Hamilton

unread,
Apr 13, 2021, 8:30:46 AM4/13/21
to vim...@googlegroups.com, v...@vim.org
Thanks very much.

Sorry, I don't fully understand how to use that. That seems to be a long document about many different options. Is there listed somewhere in there the option to output a Vim help page to an external file?

For example, the Unix info reader allows outputting of an info page with the "-o" option.

Thanks very much,
Julius



--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20210413075153.GD2222154%40256bit.org.

Julius Hamilton

unread,
Apr 13, 2021, 8:35:15 AM4/13/21
to vim...@googlegroups.com, v...@vim.org
Someone showed me ":hardcopy" and ":TOhtml". ":hardcopy" for me returns "Failed to print postscript file". "TOhtml" opens a new window of HTML, but I don't know how to output it to a file. Would anyone here know how to do that?

Thanks very much,
Julius

Christian Brabandt

unread,
Apr 13, 2021, 9:32:58 AM4/13/21
to vim...@googlegroups.com, v...@vim.org

On Di, 13 Apr 2021, Julius Hamilton wrote:

> Someone showed me ":hardcopy" and ":TOhtml". ":hardcopy" for me returns "Failed
> to print postscript file". "TOhtml" opens a new window of HTML, but I don't
> know how to output it to a file. Would anyone here know how to do that?

So you want all help pages in a single text file. I am not sure if this
is useful. Use some Unix commands and append the content to a single
buffer in Vim.

:r! cat $VIMRUNTIME/doc/*.txt

Note there is also:
https://nathangrigg.com/vimhelp/
https://www.vi-improved.org/vimusermanual.pdf

Not sure how current those versions are.

Best,
Christian
--
Wie man sein Kind nicht nennen sollte:
I. K. Russ

Ottavio Caruso

unread,
Apr 13, 2021, 11:20:17 AM4/13/21
to vim...@googlegroups.com
On Tue, 13 Apr 2021 at 08:51, Christian Brabandt <cbl...@256bit.org> wrote:
>
>
> On Mo, 12 Apr 2021, Julius Hamilton wrote:
>
> > Is there any way to output the content of the Vim help pages to a text file, with some sort of dump or output command?
>
> The help pages are text files, you don't need to dump them, you can
> :e $VIMRUNTIME/doc/options.txt
> to read the options help page.
>

I wonder if you all could be so kind and forgive my hijack attempt and
ask you if this is also possible with good ol' fashioned vi/nvi?

I would like to dump the output of :viu and :exu to to a file. I've
looked into these directories but I couldn't find anything:

$ find /usr/pkg/share/vi/
/usr/pkg/share/vi/
/usr/pkg/share/vi/tcl
/usr/pkg/share/vi/tcl/mailprocs.tcl
/usr/pkg/share/vi/tcl/gnats.tcl
/usr/pkg/share/vi/tcl/errors.tcl
/usr/pkg/share/vi/tcl/wc.tcl
/usr/pkg/share/vi/perl
/usr/pkg/share/vi/perl/tk.pl
/usr/pkg/share/vi/perl/wc.pl
/usr/pkg/share/vi/perl/make.pl
/usr/pkg/share/vi/perl/forall.pl
/usr/pkg/share/vi/catalog
/usr/pkg/share/vi/catalog/english
/usr/pkg/share/vi/catalog/dutch
/usr/pkg/share/vi/catalog/swedish
/usr/pkg/share/vi/catalog/ru_SU.KOI8-R
/usr/pkg/share/vi/catalog/spanish
/usr/pkg/share/vi/catalog/german
/usr/pkg/share/vi/catalog/french
/usr/pkg/share/vi/recover


--
Ottavio Caruso

Christian Brabandt

unread,
Apr 13, 2021, 11:29:07 AM4/13/21
to vim...@googlegroups.com

On Di, 13 Apr 2021, 'Ottavio Caruso' via vim_use wrote:

> I wonder if you all could be so kind and forgive my hijack attempt and
> ask you if this is also possible with good ol' fashioned vi/nvi?
>
> I would like to dump the output of :viu and :exu to to a file. I've
> looked into these directories but I couldn't find anything:

nvi? That looks hard-coded in the source

~/code/nvi % git grep --no-index 'search forward for cursor word'
Binary file build.unix/.libs/libvi.a matches
Binary file build.unix/.libs/libvi.so.0.0.0 matches
Binary file build.unix/.libs/v_cmd.o matches
Binary file build.unix/v_cmd.o matches
vi/v_cmd.c: "^A search forward for cursor word"},

May be one can redirect the output. Not sure.

Best,
Christian
--
Wenn man sagt, daß man einer Sache grundsätzlich zustimmt, so
bedeutet es, daß man nicht die geringste Absicht hat, sie in der
Praxis durchzuführen.
-- Otto von Bismarck

Bram Moolenaar

unread,
Apr 13, 2021, 11:50:49 AM4/13/21
to vim...@googlegroups.com, Christian Brabandt, v...@vim.org

Christian wrote:

> On Di, 13 Apr 2021, Julius Hamilton wrote:
>
> > Someone showed me ":hardcopy" and ":TOhtml". ":hardcopy" for me returns "Failed
> > to print postscript file". "TOhtml" opens a new window of HTML, but I don't
> > know how to output it to a file. Would anyone here know how to do that?
>
> So you want all help pages in a single text file. I am not sure if this
> is useful. Use some Unix commands and append the content to a single
> buffer in Vim.
>
> :r! cat $VIMRUNTIME/doc/*.txt
>
> Note there is also:
> https://nathangrigg.com/vimhelp/
> https://www.vi-improved.org/vimusermanual.pdf
>
> Not sure how current those versions are.

Ask a dump question, get a dump answer! :-)

--
I AM THANKFUL...
...for a lawn that needs mowing, windows that need cleaning
and gutters that need fixing because it means I have a home.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Julius Hamilton

unread,
Apr 13, 2021, 3:34:01 PM4/13/21
to vim...@googlegroups.com, v...@vim.org
Thanks very much. Yes, that'll do the trick. Not all pages, but just any individual one I happen to be reading, so I can edit and take notes on it.

Thanks very much, really appreciate it.

Julius


--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+u...@googlegroups.com.

meine

unread,
Apr 14, 2021, 3:09:32 AM4/14/21
to vim...@googlegroups.com, v...@vim.org
Maybe one of these pages is of your help:

https://vimhelp.org/

https://vim-jp.org/vimdoc-en/

and here is one help in one file, in different formats:

https://archive.org/details/vimdoc/page/n5/mode/2up

//meine

Efraim Yawitz

unread,
Apr 14, 2021, 5:04:33 AM4/14/21
to vim_use
On Wed, 14 Apr 2021 at 10:09, meine <tria...@gmx.com> wrote:
Maybe one of these pages is of your help:

https://vimhelp.org/

https://vim-jp.org/vimdoc-en/

and here is one help in one file, in different formats:

https://archive.org/details/vimdoc/page/n5/mode/2up

//meine



Maybe this is slightly OT, but this post reminded me that the vim help is the most comprehensive and clear documentation I have seen for any program I use!  Thanks again, Bram!

Charles Campbell

unread,
Apr 14, 2021, 1:21:35 PM4/14/21
to vim...@googlegroups.com
Julius Hamilton wrote:
> Thanks very much. Yes, that'll do the trick. Not all pages, but just
> any individual one I happen to be reading, so I can edit and take
> notes on it.
>
> Thanks very much, really appreciate it.
>
> Julius
>
I was surprised no one mentioned what seemed to me to be the most
obvious -- just

    :w filename

Chip Campbell

Julius Hamilton

unread,
Apr 16, 2021, 12:42:38 PM4/16/21
to vim...@googlegroups.com
Thank you very much, I'll use that.
                                                                                  I'm currently reading the Vim docs by editing them inside Vim, it's a good way for me to process them better.
                                                                                  However, to speed things up, I was wondering if anyone could tip me off about a few functionalities. 

At the beginning of a paragraph which has been separated mid-sentence onto separate lines, how might I automate the process of calling CTRL-J until all the separated lines in the paragraph have been combined into one line? Will Vim be able to call CTRL-J until a condition is met, for example, that the single line being built ends in a sentence (a period), or until the next line is a blank newline?

Then, how might I automate the process of entering N newlines between every sentence? I.e., automating pressing ), i, enter a few times, then escape, for multiple sentences? I could create a shortcut to execute these commands and call it myself, or it could also repeat until the conditions above. How would I do either?

Also, how do I go back to where the cursor previously was, in case I accidentally move it?

 Thanks very much,
 Julius

Stan Brown

unread,
Apr 16, 2021, 1:27:14 PM4/16/21
to vim...@googlegroups.com
On 2021-04-16 09:42, Julius Hamilton wrote:

> At the beginning of a paragraph which has been separated mid-sentence
> onto separate lines, how might I automate the process of calling CTRL-J
> until all the separated lines in the paragraph have been combined into
> one line? Will Vim be able to call CTRL-J until a condition is met, for
> example, that the single line being built ends in a sentence (a period),
> or until the next line is a blank newline?

The short answer is go to the top of the paragraph and press Shift+V,
then to the bottom and press Shift+J (not Ctrl+J). You can automate this
further by writing a function that would figure out the top and bottom
of the paragraph via whatever logic you build in. See :help :function.

> Then, how might I automate the process of entering N newlines between
> every sentence? I.e., automating pressing ), i, enter a few times, then
> escape, for multiple sentences? I could create a shortcut to execute
> these commands and call it myself, or it could also repeat until the
> conditions above. How would I do either?

Example, for N = 4:
:imap <F9> <CR><CR><CR><CR><Esc>
Type the actual < and > characters as shown. To use this, at the end of
typing your paragraph do not press Esc but press F9 (or whatever key you
mapped).

If you sometimes want to insert N blank lines in already-written text,
add this:
:map <F9> A<F9>
The previous map was active in insert mode; this one is active in normal
mode. It moves to the end of the current line ("A") in insert mode and
then appends the insert-mode version of F9.

Once you've verified that these work as you wish, you can put them in
your $VIM/_vimrc file so that they will be executed whenever you start Vim.

> Also, how do I go back to where the cursor previously was, in case I
> accidentally move it?

`` or ''
(One goes back to the _line_) where you were; the other goes back to the
exact position within the line.)

--
Stan Brown
Tehachapi, CA, USA
https://BrownMath.com
https://OakRoadSystems.com

Julius Hamilton

unread,
Apr 17, 2021, 9:30:47 AM4/17/21
to vim...@googlegroups.com
Thanks very much, really appreciate it.

Would you mind providing a simple outline of a function which would terminate on some basic condition, such as, the next line is a blank newline? I will read those docs.

I use Vim in Termux, an Android terminal emulator app. I don't know if I have buttons such as F9. I will investigate it. However, is there a way to check what non-F keys are free to be mapped to something? Thanks very much.

Best regards,
Julius



--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+u...@googlegroups.com.

Julius Hamilton

unread,
Apr 17, 2021, 9:44:05 AM4/17/21
to vim...@googlegroups.com
I have a question related to editing documents inside Vim. If anyone might have any tips, I'd really appreciate hearing them.

I'd like to edit PDFs which contain mathematical symbols, not to publish the papers myself, as I could with Latex, but just as a form of note-taking.

I'm curious, could Vim open a PDF as raw textual data? Or is the source text of a PDF sealed off, and inaccessible?

And if it could, could it support mathematical formula? Not as a markup language, but as a kind of textual object you could actually stick the cursor into and manipulate a bit, such as extracting the top of a quotient and putting it somewhere else, or an expression to the right of an integral symbol, for example.

Or, is there any tool that could do this? Perhaps Emacs?

Thanks very much,
Julius


Tony Mechelynck

unread,
Apr 17, 2021, 10:17:34 AM4/17/21
to vim_use
On Sat, Apr 17, 2021 at 3:43 PM Julius Hamilton <julk...@gmail.com> wrote:
>
> I have a question related to editing documents inside Vim. If anyone might have any tips, I'd really appreciate hearing them.
>
> I'd like to edit PDFs which contain mathematical symbols, not to publish the papers myself, as I could with Latex, but just as a form of note-taking.
>
> I'm curious, could Vim open a PDF as raw textual data? Or is the source text of a PDF sealed off, and inaccessible?
>
> And if it could, could it support mathematical formula? Not as a markup language, but as a kind of textual object you could actually stick the cursor into and manipulate a bit, such as extracting the top of a quotient and putting it somewhere else, or an expression to the right of an integral symbol, for example.
>
> Or, is there any tool that could do this? Perhaps Emacs?
>
> Thanks very much,
> Julius

IIUC PDF files are like books, not meant to be edited (which is one
reason while enterprises use them: to avoid text counterfeiting).
Again IIUC, it is possible to edit them by using the appropriate Adobe
tool, which is not for free, but even with this tool you may need to
know the edit password set by the file's creator.

OTOH, for simple mathematical formulæ (in ordinary text) you may want
to install Dr. Chip Campbell's math menu & keymap
http://www.drchip.org/astronaut/vim/#MATH ; and for complex formulæ
you may want to use one of the flavours of the Teχ language — maybe
XəTeχ which is Unicode-aware and can write PDF but IIUC not read it.
In HTML, I think you could also avail yourself of the MathML language
(which can be embedded in HTML), provided that the target browser(s)
can decipher that.

Best regards,
Tony.

Stan Brown

unread,
Apr 17, 2021, 11:23:46 AM4/17/21
to vim...@googlegroups.com

On 2021-04-17 06:30, Julius Hamilton wrote:
> Would you mind providing a simple outline of a function which would
> terminate on some basic condition, such as, the next line is a blank
> newline? I will read those docs.

The first step is for you to clarify your criteria. Then :help
:function, :help if, and so on, to turn your intentions into code. Or
you may not need code as such in your function. :help / tells you how to
do searches based on all sorts of criteria, and any Vim command can be
included in a function.

> I use Vim in Termux, an Android terminal emulator app. I don't know if I
> have buttons such as F9. I will investigate it. However, is there a way
> to check what non-F keys are free to be mapped to something? Thanks very
> much.

:help :map

I would suggest you not set a goal of reading all the help documents; I
believe even experienced Vim users could find that overwhelming. (I know
I would.) A much more reasonable goal is to read appropriate _portions_
that answer your questions. And when you're reading something for which
you have immediate use, you're much more likely to retain what you read.

There is also Google, of course. Just a day or two ago I couldn't think
what term to query via :help, so I googled my query and got an answer
immediately.

BPJ

unread,
Apr 20, 2021, 3:13:19 AM4/20/21
to vim_use
Den fre 16 apr. 2021 19:27Stan Brown <the_sta...@fastmail.fm> skrev:
On 2021-04-16 09:42, Julius Hamilton wrote:

> At the beginning of a paragraph which has been separated mid-sentence
> onto separate lines, how might I automate the process of calling CTRL-J
> until all the separated lines in the paragraph have been combined into
> one line? Will Vim be able to call CTRL-J until a condition is met, for
> example, that the single line being built ends in a sentence (a period),
> or until the next line is a blank newline?

I have the following in my .vimrc :

" Command to join lines in all paragraphs in a range/the whole buffer (Jp == join paras)
:com! -range=% Jp <line>,<line>g/^\s*\S/ .,/^\s*$/-join

" Explanation:
"  :g/^\s*\S/ " Go to the first in each sequence of non-blank lines
          " Actually every non-blank line but the result is the same here!
"  .,/^\s*$/- " "Select" all lines from the current to the one before the next blank line
"  join  " Join the "selected" lines

" Mapping to join lines in all paras in the buffer
:nnor Jp Go<esc>ggVG:Jp<cr>

" Explanation:
"  G " Go to the last line in the buffer
"  o<esc> " Add a blank line below the last so we are sure there is one!
"  gg " Go to the first line in the buffer
"  V  " Visually select the (first) line
"  G  " Extend the selection to the last line in the buffer
"  :Jp<cr> " Execute the command defined above

" Mapping to execute the :Jp command over the current visual selection
:vnor Jp :Jp<cr>

HTH

/bpj

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+u...@googlegroups.com.

BPJ

unread,
Apr 20, 2021, 3:29:32 AM4/20/21
to bpj, vim_use
I wrote:

I have the following in my .vimrc :

" Command to join lines in all paragraphs in a range/the whole buffer (Jp == join paras)
:com! -range=% Jp <line>,<line>g/^\s*\S/ .,/^\s*$/-join

" Explanation:
"  :g/^\s*\S/ " Go to the first in each sequence of non-blank lines
          " Actually every non-blank line but the result is the same here!
"  .,/^\s*$/- " "Select" all lines from the current to the one before the next blank line

This should have been:

"  .,/^\s*$/-1

I accidentally removed the digit 1 (not sure it matters though!)

Julius Hamilton

unread,
Apr 20, 2021, 11:46:13 AM4/20/21
to vim...@googlegroups.com
Thanks.

This is pretty complicated, but probably what I had in mind.

So, some basic clarification -

You defined a new command called Jp. You specify a line range, and it starts at every non blank line and joins all following non blank lines.

That's quite good. Thanks very much.

What about the second command I had in mind? I could really use a way to select a paragraph and insert N newlines between every Word (Vim "W") (and also sentence, on a separate occasion), with a single command, say in visual mode.

With your command, I can imagine it could be modified to start at every Word and just append newlines. Do you think you could write an example of this? And, how to use it on highlighted text in visual mode, instead of specifying a line range?

Thanks very much,
Julius 





BPJ

unread,
Apr 21, 2021, 5:28:21 AM4/21/21
to vim_use
Den tis 20 apr. 2021 17:46Julius Hamilton <julk...@gmail.com> skrev:
Thanks.

This is pretty complicated, but probably what I had in mind.

So, some basic clarification -

You defined a new command called Jp. You specify a line range, and it starts at every non blank line and joins all following non blank lines.

That's quite good. Thanks very much.

What about the second command I had in mind? I could really use a way to select a paragraph and insert N newlines between every Word (Vim "W") (and also sentence, on a separate occasion), with a single command, say in visual mode.

With your command, I can imagine it could be modified to start at every Word and just append newlines. Do you think you could write an example of this?

I came up with the following. It basically is a pair of typing-saving canned s/// command which replaces all consecutive horizontal whitespace with a given number of linebreaks throughout the buffer, in a range or in the current visual selection, in the second version restricted to horizontal whitespace after sentence-final punctuation.

" Command :Wl [{N}] (*W*ord *l*ine)
"   Replace consecutive horizontal whitespace in buffer/range/selection
"   with N line breaks (Default: the number in variable g:Wl_line_breaks)

let g:Wl_line_breaks=1

:com! -range=% -nargs=? Wl exe printf('<line1>,<line2>s/\s\+/%s/g',repeat('\r', (<q-args> ? <q-args> : g:Wl_line_breaks)))

" Explanation:
"   -range=%
"     The command operates over the whole buffer or over a given range, which
"     may be visual.
"   -nargs=?
"     The command takes an optional argument.
"   exe printf(...)
"     Constructs a string containing the actual command, then executes this
"     string as a command.
"   (<q-args> ? <q-args> : g:Wl_line_breaks)
"     Compute N: use the argument if there was one (and it was non-zero)
"     or else use the number which is the value of the global variable
"     g:Wl_line_breaks, which must be defined.
"     It is up to you to make sure that the argument and the variable value
"     are positive integers!
"   repeat('\r', N)
"     Construct a string which will be interpolated as N linebreaks.
"     The string doesn't actually contain linebreaks, but they will "become"
"     line breaks when the command is executed.
"   s/\s\+/%s/g
"     Here %s will be replaced with N linebreaks,
"     so if N is 1 it's s/\s+/\r/g
"     and if N is 4 it's s/\s+/\r\r\r\r/g
"     so basically replace all consecutive horizontal whitespace
"     with the desired number of linebreaks.

" Command :Sl [{N}] (*S*entence *l*ine)
"   Replace consecutive horizontal whitespace *after a ./?/!*
"   in buffer/range/selection with N line breaks (Default: the number in variable g:Sl_line_breaks)

let g:Sl_line_breaks=1

:com! -range=% -nargs=? Sl exe printf('<line1>,<line2>s/[.?!]\zs\s\+/%s/g',repeat('\r', (<q-args> ? <q-args> : g:Sl_line_breaks)))

" Explanation:
"   This is basically the same as above, but requires that the horizontal
"   whitespace is preceded with a "." or "?" or "!", and it has its own
"   variable for the default value of N.

" Mappings to execute :Wl/:Sl (without argument) over buffer/selection
nor Wl :Wl<cr>
nor Sl :Sl<cr>


And, how to use it on highlighted text in visual mode, instead of specifying a line range?

The commands above and the command from yesterday work on an existing or previous visual selection too. If you have a visual selection and press : the commandline is prefixed with '<,'> which is a range equal to the lines holding the visual selection. You can also insert that range manually to restrict a previously used command to the latest visual selection.

The mappings above work either on the whole buffer or the visual selection, so just make a visual selection and type Wl and it just happens in the visual selection.

In yesterday's installment the

vnor Jp :Jp<cr>

means that you can make a visual selection and just type Jp and have the :Jp command applied to the selection. Just make sure that the selection ends with a blank line. The

nnor Jp ...

line from yesterday does the same over the whole buffer in normal mode, with the difference that it first inserts a blank line at the bottom of the buffer to make sure there is one.



Thanks very much,
Julius 

It's nothing. I have been using yesterday's command/mappings for ages, and I will certainly use those from today too.

/bpj

Reply all
Reply to author
Forward
0 new messages