Home Explore Blog CI



neovim

13th chunk of `runtime/doc/change.txt`
167a815544be3f5d74b8ac2321945839b389a4691f98a4390000000100000fa0
 item becomes a line, except that they can contain line
breaks themselves.

The |submatch()| function can be used to obtain matched text.  The whole
matched text can be accessed with "submatch(0)".  The text matched with the
first pair of () with "submatch(1)".  Likewise for further sub-matches in ().

Be careful: The separation character must not appear in the expression!
Consider using a character like "@" or ":".  There is no problem if the result
of the expression contains the separation character.

Examples: >
	:s@\n@\="\r" .. expand("$HOME") .. "\r"@
This replaces an end-of-line with a new line containing the value of $HOME. >

	s/E/\="\<Char-0x20ac>"/g
This replaces each 'E' character with a euro sign.  Read more in |<Char->|.


4.3 Changing tabs					*change-tabs*
							*:ret* *:retab* *:retab!*
:[range]ret[ab][!] [new_tabstop]
			Replace all sequences of white-space containing a
			<Tab> with new strings of white-space using the new
			tabstop value given.  If you do not specify a new
			tabstop size or it is zero, Vim uses the current value
			of 'tabstop'.
			The current value of 'tabstop' is always used to
			compute the width of existing tabs.
			With !, Vim also replaces strings of only normal
			spaces with tabs where appropriate.
			With 'expandtab' on, Vim replaces all tabs with the
			appropriate number of spaces.
			This command sets 'tabstop' to the new value given,
			and if performed on the whole file, which is default,
			should not make any visible change.
			Careful: This command modifies any <Tab> characters
			inside of strings in a C program.  Use "\t" to avoid
			this (that's a good habit anyway).
			`:retab!` may also change a sequence of spaces by
			<Tab> characters, which can mess up a printf().
			A list of tab widths separated by commas may be used
			in place of a single tabstop.  Each value in the list
			represents the width of one tabstop, except the final
			value which applies to all following tabstops.

							*retab-example*
Example for using autocommands and ":retab" to edit a file which is stored
with tabstops at 8 but edited with tabstops set at 4.  Warning: white space
inside of strings can change!  Also see 'softtabstop' option. >

  :auto BufReadPost	*.xx	retab! 4
  :auto BufWritePre	*.xx	retab! 8
  :auto BufWritePost	*.xx	retab! 4
  :auto BufNewFile	*.xx	set ts=4

==============================================================================
5. Copying and moving text				*copy-move*

							*quote*
"{register}		Use {register} for next delete, yank or put.  Use
			an uppercase character to append with delete and yank.
			Registers ".", "%", "#" and ":" only work with put.

							*:reg* *:registers*
:reg[isters]		Display the type and contents of all numbered and
			named registers.  If a register is written to for
			|:redir| it will not be listed.
			Type can be one of:
			"c"	for |characterwise| text
			"l"	for |linewise| text
			"b"	for |blockwise-visual| text


:reg[isters] {arg}	Display the contents of the numbered and named
			registers that are mentioned in {arg}.  For example: >
				:reg 1a
<			to display registers '1' and 'a'.  Spaces are allowed
			in {arg}.

							*:di* *:dis* *:display*
:di[splay] [arg]	Same as :registers.

							*y* *yank*
["x]y{motion}		Yank {motion} text [into register x].  When no
			characters are to be yanked (e.g., "y0" in column 1),
			this is an error when 'cpoptions' includes the 'E'
			flag.

							*yy*
["x]yy			Yank [count] lines [into register x] |linewise|.

							*Y*
["x]Y			yank [count] lines [into register x] (synonym for
			yy, |linewise|).
							*Y-default*
			Mapped to "y$" by default. |default-mappings|

							*zy*
["x]zy{motion}		Yank {motion} text [into register x].  Only differs
			from `y` when selecting a block of text, see |v_zy|.

							*v_y*
{Visual}["x]y		Yank the highlighted text [into register x] (for
			{Visual} see |Visual-mode|).

							*v_Y*
{Visual}["x]Y		Yank the highlighted lines [into register x] (for
	

Title: Vim: Substitute Expressions, Changing Tabs, and Copying/Moving Text (Yanking and Registers)
Summary
This section describes how to use the |submatch()| function to extract matched text from substitute commands. It warns about avoiding the separation character in expressions. It explains the `:retab` command for changing tabs to a new tabstop value, including options for handling spaces and considering the 'expandtab' setting, also cautions on side-effects with C programs. Then it moves on to cover copying and moving text in Vim using registers. It discusses how to use registers for delete, yank, and put operations, including appending to registers. It details the `:registers` command for displaying register contents and the `y` (yank) command for copying text into registers.