How to use vim to write a <Tab> aligned plain text (txt) file as the vim help files?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

How to use vim to write a <Tab> aligned plain text (txt) file as the vim help files?

Hausen Schaff
vim help files are in plain text format. They'are under /vim/vim80/doc.Lots of <Tab> characters are used to align the contents.

Interestingly, I can't find a good way to write such <Tab> aligned texts by vim. Every plugin use space to align words. Some bring this issue up on these project homes, and no solution is provided.

I'm curious how the vim developers write the help documents?

Plugins
-----------------------------------------------------------
vim-easy-align: Align to Nearest Tabstop #58 https://git.io/fAdXc
tabular: https://git.io/fAdXW
 
Excerpted from vim's help
-----------------------------------------------------------
Development of Vim. *development*

This text is important for those who want to be involved in further developing
Vim.

1. Design goals |design-goals|
2. Coding style |coding-style|
3. Design decisions |design-decisions|
4. Assumptions |design-assumptions|

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to use vim to write a <Tab> aligned plain text (txt) file as the vim help files?

Tony Mechelynck
On Sat, Sep 22, 2018 at 11:48 PM Hausen Schaff <[hidden email]> wrote:

>
> vim help files are in plain text format. They'are under /vim/vim80/doc.Lots of <Tab> characters are used to align the contents.
>
> Interestingly, I can't find a good way to write such <Tab> aligned texts by vim. Every plugin use space to align words. Some bring this issue up on these project homes, and no solution is provided.
>
> I'm curious how the vim developers write the help documents?
>
> Plugins
> -----------------------------------------------------------
> vim-easy-align: Align to Nearest Tabstop #58 https://git.io/fAdXc
> tabular: https://git.io/fAdXW
>
> Excerpted from vim's help
> -----------------------------------------------------------
> Development of Vim.                                     *development*
>
> This text is important for those who want to be involved in further developing
> Vim.
>
> 1. Design goals         |design-goals|
> 2. Coding style         |coding-style|
> 3. Design decisions     |design-decisions|
> 4. Assumptions          |design-assumptions|

The following answer does not cover any third-party plugin, as I
personally don't use them for tabbing. OTOH, all or part of it may (or
may not) rely to running in 'nocompatible' mode, which nowadays is
IIUC the default except when the -C command-line switch (or -u
followed by other than DEFAULTS) is used.

Several options govern what happens when you hit the Tab key in Insert
mode in Vim. Once they are set the way you want them, aligning files
by tabbing should become a piece of cake. I'm summarizing them below
but you should check the online help about them, it is more detailed.

* 'expandtab' or 'et' is a Boolean buffer-local option, default off.
When on, hitting the Tab key produces an appropriate number of spaces.
Existing hard tabs won't be altered until or unless you |:retab|
(q.v.) but new ones won't be added unless you "force" them by hitting
Ctrl-V (in Insert mode) immediately before hitting Tab (or Ctrl-I).
(On the latter "forcing" point, see the help about |i_CTRL-V|.)
* 'tabstop' or 'ts' is a numeric buffer-local option, default 8. When
a hard tab is encountered in a text file, it will push the next
character by n columns, where 1 <= n <= &ts, in order to bring that
"next character after the tab" in a column whose number (the leftmost
column being 1) is 1 more than a multiple of &ts. For the default
value of 8, this means that the next character will be in the next
column in the list [9, 17, 25, 33, 41, …]. (Column 1 can of course not
be preceded by a tab ending in column 0.)
* 'softtabstop' or 'sts' is a numeric buffer-local option; its default
is 0 which means "soft tabs are off". When positive and 'et' above is
off, hitting the Tab key moves to the next "soft tab" of this width by
inserting the appropriate number of "hard tabs" (calculated as for
'ts' above) and, if this "soft tab stop point" does not coincide with
a "hard tab stop point", additional spaces are added as necessary.
When 'sts' is any negative number, the value of 'sw' (below) is used.
* 'shiftwidth' or 'sw' is a numeric option (default 8) which is only
used for indenting. It governs by how much autoindenting (if enabled)
and the manual indent commands (such as << >> etc.) will move the
whole line left or right when going from one indentation level to the
next. When zero the value of 'ts' above is used.
* 'smarttab' or 'sta' is a Boolean global option, default off. When it
is on, hitting the Tab key will insert tabs if used at the start of a
line, or spaces if used elsewhere.

See the online help for each of these options, and a few additional
ones, as follows:
    :h 'et'
    :h :retab
    :h i_CTRL-V
    :h 'ts'
    :h 'sts'
    :h 'sw'
    :h 'sta'
    :h ins-expandtab (and the whole 33-line section starting with it)
    :h :set
        and note that ":set option?" with question mark always
displays the value while ":set option" with nothing after the name
sets the value to TRUE when used with a Boolean option but displays
the value when used with a non-Boolean option. So when in doubt (and
maybe even when not in doubt), always use a question mark to display
the value without changinig it. (If the value of a Boolean option is
FALSE, the option name will be displayed prefixed by "no".)

The help for 'tabstop' also has a discussion of the various possible
ways to use the tabbing options described above.

Oh, and for help files in particular, see also ":h modeline"

Best regards,
Tony.

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Kit
Reply | Threaded
Open this post in threaded view
|

Re: How to use vim to write a <Tab> aligned plain text (txt) file as the vim help files?

Kit
In reply to this post by Hausen Schaff
2018-09-22 21:02 GMT+02:00, Hausen Schaff <[hidden email]>:
> Interestingly, I can't find a good way to write such <Tab> aligned texts by
> vim. Every plugin use space to align words. Some bring this issue up on
> these project homes, and no solution is provided.

:set noexpandtab
--
Kit

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to use vim to write a <Tab> aligned plain text (txt) file as the vim help files?

meine van essen
In reply to this post by Hausen Schaff
On Sat, Sep 22, 2018 at 12:02:51PM -0700, Hausen Schaff wrote:
> vim help files are in plain text format. They'are under /vim/vim80/doc.Lots of <Tab> characters are used to align the contents.
>
> Interestingly, I can't find a good way to write such <Tab> aligned texts by vim. Every plugin use space to align words. Some bring this issue up on these project homes, and no solution is provided.
>
> I'm curious how the vim developers write the help documents?

I didn't look at the documentation and help files in detail, but they
have a relatively narrow width, not too many columns width. also they
have a fixed format, linu by line.

to reproduce this you could easily use tabs or spaces to align text.
when you also use a narrow width for your document, there will be no
need for the text to rearrange itself over the full width of your screen
or window, text is formatted line by line through a sentence.

> Plugins

IMHO vim is perfect the way it is and I'm not using any plugins for this
kind of regular tasks --- that besides the fun of learning vim's
capabilities.

for the rest I mainly use vim to make text with basic markdown that I
process with pandoc to make nice pdf's, and pandoc does the clean
outlining of markedup text.

my solution would be to set the right tabwith or tabstops at the needed
position of the rightmost column in vim and/or use spaces
to make a column layout. find out how to automate with basic vim, best
is to make your document and do the formatting afterwards (vim-way:
separating writing and editing)

when you want to make such files to publish as pdf or whatever
environment, just use basic
[markdown](http://daringfireball.net/projects/markdown/) as a markup
language and use pandoc to convert it to your needed environment.
markdown has some great ways to produce a good layout.

in vim I use markdown to make nice aligned lists with

* text after the bullet goes here

text in a separate paragraph that belongs to the bullet above is
indended in vim with '>>'

//meine

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.