Home Explore Blog CI



neovim

25th chunk of `runtime/doc/change.txt`
dccc24adc1a3b272f5517d3a60b7b9e8db96673b76f594880000000100000be5

'formatoptions') gives the correct start of the line automatically.  The same
happens with formatting and auto-wrapping.  Opening a line after a line
starting with "/*" or "*" and containing "*/", will cause no comment leader to
be inserted, and the indent of the new line is taken from the line containing
the start of the comment.
E.g.: >
    /*
     * Your typical comment.
     */
    The indent on this line is the same as the start of the above
    comment.

All of this should be really cool, especially in conjunction with the new
:autocmd command to prepare different settings for different types of file.

Some examples:
  for C code (only format comments): >
	:set fo=croq
< for Mail/news	(format all, don't start comment with "o" command): >
	:set fo=tcrq
<

Automatic formatting				*auto-format* *autoformat*

When the 'a' flag is present in 'formatoptions' text is formatted
automatically when inserting text or deleting text.  This works nicely for
editing text paragraphs.  A few hints on how to use this:

- You need to properly define paragraphs.  The simplest is paragraphs that are
  separated by a blank line.  When there is no separating blank line, consider
  using the 'w' flag and adding a space at the end of each line in the
  paragraphs except the last one.

- You can set the 'formatoptions' based on the type of file |filetype| or
  specifically for one file with a |modeline|.

- Set 'formatoptions' to "aw2tq" to make text with indents like this:

	    bla bla foobar bla 
	bla foobar bla foobar bla
	    bla bla foobar bla 
	bla foobar bla bla foobar

- Add the 'c' flag to only auto-format comments.  Useful in source code.

- Set 'textwidth' to the desired width.  If it is zero then 79 is used, or the
  width of the screen if this is smaller.

And a few warnings:

- When part of the text is not properly separated in paragraphs, making
  changes in this text will cause it to be formatted anyway.  Consider doing >

	:set fo-=a

- When using the 'w' flag (trailing space means paragraph continues) and
  deleting the last line of a paragraph with |dd|, the paragraph will be
  joined with the next one.

- Changed text is saved for undo.  Formatting is also a change.  Thus each
  format action saves text for undo.  This may consume quite a lot of memory.

- Formatting a long paragraph and/or with complicated indenting may be slow.

==============================================================================
7. Sorting text						*sorting*

Vim has a sorting function and a sorting command.  The sorting function can be
found here: |sort()|, |uniq()|.

							*:sor* *:sort*
:[range]sor[t][!] [b][f][i][l][n][o][r][u][x] [/{pattern}/]
			Sort lines in [range].  When no range is given all
			lines are sorted.

			With [!] the order is reversed.

			With [i] case is ignored.

			With [l] sort uses the current collation locale.
			Implementation details: strcoll() is used to compare
			strings. See |:language| to check or set the collation
			locale. Example: >
				:language collate en_US.UTF-8
	

Title: Automatic Formatting Usage and Sorting Text
Summary
This section provides hints and warnings for using automatic formatting ('a' flag in 'formatoptions'). It covers defining paragraphs, setting 'formatoptions' based on file type or modeline, using indentations, and formatting only comments. It warns about potential issues with paragraph separation, the 'w' flag, undo memory consumption, and performance with long paragraphs. Additionally, the section introduces Vim's sorting capabilities, mentioning the `sort()` and `uniq()` functions. It details the `:sort` command, including options for reversing order, ignoring case, using collation locale, and sorting with patterns.