Indentation problem

26 views
Skip to first unread message

Guido Milanese

unread,
Sep 21, 2014, 10:30:28 AM9/21/14
to vim...@googlegroups.com
Please excuse me for asking this very trivial question, which I'm afraid has already been discussed, but I got confused browsing manuals, wiki and group.

I have a file of notes about books I have studied and I would like to obtain this structure (PN = real page numbers):

PN[TAB]my notes

If the "my notes" field spans over more than one line, I would like the continuation lines to be indented aligned at the TAB position, such as:

32 Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea.

I tried to play with all the options (tw, ai, ts) but to no success.
I am using TAB and keeping my comments/notes as ONE line, even if displayed as continuation, because in this way I can easily parse the files to extract information, having an unambiguous and simple pattern to deal with. So in this example the NewLine should be placed only after the final words (/ex ea/).

Many thanks for your kind help!
guido m. (Italy)

Tim Chase

unread,
Sep 21, 2014, 2:14:38 PM9/21/14
to vim...@googlegroups.com, guido.m...@gmail.com
On 2014-09-21 07:30, Guido Milanese wrote:
> Please excuse me for asking this very trivial question, which I'm
> afraid has already been discussed, but I got confused browsing
> manuals, wiki and group.

No problem -- it's non-trivial, so it's certainly a good/worthwhile
question for the list.

> I have a file of notes about books I have studied and I would like
> to obtain this structure (PN = real page numbers):
>
> PN[TAB]my notes
>
> If the "my notes" field spans over more than one line, I would like
> the continuation lines to be indented aligned at the TAB position,

It sounds like you're looking for the 'showbreak' option. While it's
not perfect and doesn't work so well for more than one tab-stop worth
of indentation, you can do something like

:let &showbreak=repeat(' ', &ts)

which will display (rather than insert) extra &tabstop number of
spaces at the front of wrapped lines. It will break if you have more
than one tab, or if the page-number exceeds the width of a tab.

-tim





Tim Chase

unread,
Sep 21, 2014, 2:22:31 PM9/21/14
to vim...@googlegroups.com, guido.m...@gmail.com
On 2014-09-21 07:30, Guido Milanese wrote:
> If the "my notes" field spans over more than one line, I would like
> the continuation lines to be indented aligned at the TAB position,

Also, it sounds like there's a 'breakindent' option that was added in
7.4.338

https://retracile.net/blog/2014/07/18/18.00

to handle additional nested indentations. (Thanks to Christian
Brabandt for shepherding this patch into the official code-base!)

-tim



Boyko Bantchev

unread,
Sep 21, 2014, 5:48:50 PM9/21/14
to vim...@googlegroups.com
> If the "my notes" field spans over more than one line, I would like the continuation
> lines to be indented aligned at the TAB position ..................
> ................
> I am using TAB and keeping my comments/notes as ONE line ..........

Perhaps you would like to format your file so that it takes the shape
you want for editing, and format it back to the form "one note -- one
line" upon leaving vim. While editing, the internal formatting can
be preserved by setting formatoptions, e.g.: set fo=a2
(along with proper value of tw). Or, you may prefer to not have
autoformatting, but do formatting yourself when you wish to: gqap.
In this case set fo=2 will do.
You might also need to check the formatexpr and formatprg options.

Christian Brabandt

unread,
Sep 22, 2014, 2:17:34 PM9/22/14
to vim...@googlegroups.com
Hi Tim!
Let's give credit to where it is due. That feature has been originally
developed by Václav Šmilauer, I was just one of many supporters to fix
bugs, making sure it still applies cleanly and wrote a simple test.

Best,
Christian
--
Reply all
Reply to author
Forward
0 new messages