Monday, July 5, 2021

Re: Pre-fold output of :r! command

On So, 04 Jul 2021, Julius Hamilton wrote:

> I would like to print the output of a shell command - a webpage dump - into a
> Vim buffer, and have those lines immediately folded, rather than a second step
> of selecting and folding them.
>
> The command would look something like:
>
> :r! w3m -dump url.com FOLD
>
> How would this be possible?

Perhaps like this:

:exe ":r! w3m -dump url" |'[,']fold

Unfortunately the `|` is seen as an argument to the :r! command, that's
why we have to wrap it in an `:exe "..." call and can separate the next
ex command using |, which in this case is the :fold command for the
region given by the markers '[,'], which describes the region of the
previously inserted text.

You can probably wrap this into a custom command like this:

:com -nargs=1 Dump :exe ":r! -dump <args>"|'[,']fold

(untested) and then use

:Dump <url>


>
> I would like to navigate my folds in an easier way than navigating to the blue
> line that appears, and unfolding them.

The little blue line is hard-coded I believe. But you can disable it
using :set foldcolumn=0

> Is it possible to get some kind of table
> of contents sidebar where you can select a fold and open or close it? In my
> current configuration, I don't see an indicator that a fold is on a certain
> line, if that fold is currently unfolded.

Not sure I understand what you want here.

Best,
Christian
--
Ein Idealist ist ein Mann, der aus der Tatsache, daß die Rose besser
riecht als der Kohl, darauf schließt, eine Suppe aus Rosen müsse auch
besser schmecken.
-- Ernest Hemingway

--
--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20210705115544.GC283422%40256bit.org.

No comments:

Post a Comment