Home Explore Blog CI



neovim

7th chunk of `runtime/doc/repeat.txt`
2ff13f3b2246eef7c070352a3aff5d75382fbaf03624fde60000000100000fad

detection, because it's common to start with a line that defines a mapping
that ends in a <CR>, which will confuse the automaton.

							*line-continuation*
Long lines in a ":source"d Ex command script file can be split by inserting
a line continuation symbol "\" (backslash) at the start of the next line.
There can be white space before the backslash, which is ignored.

Example: the lines >
	:set comments=sr:/*,mb:*,el:*/,
		     \://,
		     \b:#,
		     \:%,
		     \n:>,
		     \fb:-
are interpreted as if they were given in one line: >
	:set comments=sr:/*,mb:*,el:*/,://,b:#,:%,n:>,fb:-

All leading whitespace characters in the line before a backslash are ignored.
Note however that trailing whitespace in the line before it cannot be
inserted freely; it depends on the position where a command is split up
whether additional whitespace is allowed or not.

When a space is required it's best to put it right after the backslash.  A
space at the end of a line is hard to see and may be accidentally deleted. >
	:syn match Comment
		\ "very long regexp"
		\ keepend

There is a problem with the ":append" and ":insert" commands: >
   :1append
   \asdf
   .
The backslash is seen as a line-continuation symbol, thus this results in the
command: >
   :1appendasdf
   .
To avoid this, add the 'C' flag to the 'cpoptions' option: >
   :set cpo+=C
   :1append
   \asdf
   .
   :set cpo-=C

Note that when the commands are inside a function, you need to add the 'C'
flag when defining the function, it is not relevant when executing it. >
   :set cpo+=C
   :function Foo()
   :1append
   \asdf
   .
   :endfunction
   :set cpo-=C
<
					*line-continuation-comment*
To add a comment in between the lines start with `'"\ '`.  Notice the space
after the backslash.  Example: >
	let array = [
		"\ first entry comment
		\ 'first',
		"\ second entry comment
		\ 'second',
		\ ]

Rationale:
	Most programs work with a trailing backslash to indicate line
	continuation.  Using this in Vim would cause incompatibility with Vi.
	For example for this Vi mapping: >
		:map xx  asdf\
<	Therefore the unusual leading backslash is used.

	Starting a comment in a continuation line results in all following
	continuation lines to be part of the comment.  Since it was like this
	for a long time, when making it possible to add a comment halfway a
	sequence of continuation lines, it was not possible to use \", since
	that was a valid continuation line.  Using `'"\ '` comes closest, even
	though it may look a bit weird.  Requiring the space after the
	backslash is to make it very unlikely this is a normal comment line.

==============================================================================
Using Vim packages					*packages*

A Vim "package" is a directory that contains |plugin|s.  Compared to normal
plugins, a package can...
- be downloaded as an archive and unpacked in its own directory, so the files
  are not mixed with files of other plugins.
- be a git, mercurial, etc. repository, thus easy to update.
- contain multiple plugins that depend on each other.
- contain plugins that are automatically loaded on startup ("start" packages,
  located in "pack/*/start/*") and ones that are only loaded when needed with
  |:packadd| ("opt" packages, located in "pack/*/opt/*").

							*runtime-search-path*
Nvim searches for |:runtime| files in:
	1. all paths in 'runtimepath'
	2. all "pack/*/start/*" dirs

Note that the "pack/*/start/*" paths are not explicitly included in
'runtimepath', so they will not be reported by ":set rtp" or "echo &rtp".
Scripts can use |nvim_list_runtime_paths()| to list all used directories, and
|nvim_get_runtime_file()| to query for specific files or sub-folders within
the runtime path. Example: >
	" List all runtime dirs and packages with Lua paths.
	:echo nvim_get_runtime_file("lua/", v:true)

Using a package and loading automatically ~

Let's assume your Nvim files are in "~/.local/share/nvim/site" and you want to
add a package from a zip archive "/tmp/foopack.zip":

Title: Line Continuation Examples, Packages Introduction
Summary
This section provides examples of line continuation, particularly with the `:append` and `:insert` commands, highlighting the use of the 'C' flag in 'cpoptions' to avoid issues. It also explains how to add comments within continued lines using `'\ '`. The section concludes by introducing Vim packages, emphasizing their advantages for plugin management, including easy updating, dependency handling, and automatic loading options, and describing the use of nvim_list_runtime_paths() and nvim_get_runtime_file().