Home Explore Blog CI



neovim

1st chunk of `runtime/doc/editing.txt`
8382f4920830a18031c8dea227e3787760f53f75ba9b56350000000100000fa0
*editing.txt*   Nvim


		  VIM REFERENCE MANUAL    by Bram Moolenaar


Editing files						*edit-files*

                                      Type |gO| to see the table of contents.

==============================================================================
1. Introduction						*edit-intro*

Editing a file with Vim means:

1. reading the file into a buffer
2. changing the buffer with editor commands
3. writing the buffer into a file

							*current-file*
As long as you don't write the buffer, the original file remains unchanged.
If you start editing a file (read a file into the buffer), the file name is
remembered as the "current file name".  This is also known as the name of the
current buffer.  It can be used with "%" on the command line |:_%|.

							*alternate-file*
If there already was a current file name, then that one becomes the alternate
file name.  It can be used with "#" on the command line |:_#| and you can use
the |CTRL-^| command to toggle between the current and the alternate file.
However, the alternate file name is not changed when |:keepalt| is used.
An alternate file name is remembered for each window.

							*:keepalt* *:keepa*
:keepalt {cmd}		Execute {cmd} while keeping the current alternate file
			name.  Note that commands invoked indirectly (e.g.,
			with a function) may still set the alternate file
			name.

All file names are remembered in the buffer list.  When you enter a file name,
for editing (e.g., with ":e filename") or writing (e.g., with ":w filename"),
the file name is added to the list.  You can use the buffer list to remember
which files you edited and to quickly switch from one file to another (e.g.,
to copy text) with the |CTRL-^| command.  First type the number of the file
and then hit CTRL-^.


CTRL-G		or				*CTRL-G* *:f* *:fi* *:file*
:f[ile]			Prints the current file name (as typed, unless ":cd"
			was used), the cursor position (unless the 'ruler'
			option is set), and the file status (readonly,
			modified, read errors, new file).  See the 'shortmess'
			option about how to make this message shorter.

:f[ile]!		like |:file|, but don't truncate the name even when
			'shortmess' indicates this.

{count}CTRL-G		Like CTRL-G, but prints the current file name with
			full path.  If the count is higher than 1 the current
			buffer number is also given.

					*g_CTRL-G* *word-count* *byte-count*
g CTRL-G		Prints the current position of the cursor in five
			ways: Column, Line, Word, Character and Byte.  If the
			number of Characters and Bytes is the same then the
			Character position is omitted.

			If there are characters in the line that take more
			than one position on the screen (<Tab> or special
			character), or characters using more than one byte per
			column (characters above 0x7F when 'encoding' is
			utf-8), both the byte column and the screen column are
			shown, separated by a dash.

			Also see the 'ruler' option and the |wordcount()|
			function.

							*v_g_CTRL-G*
{Visual}g CTRL-G	Similar to "g CTRL-G", but Word, Character, Line, and
			Byte counts for the visually selected region are
			displayed.
			In Blockwise mode, Column count is also shown.  (For
			{Visual} see |Visual-mode|.)

							*:file_f*
:f[ile][!] {name}	Sets the current file name to {name}.  The optional !
			avoids truncating the message, as with |:file|.
			If the buffer did have a name, that name becomes the
			|alternate-file| name.  An unlisted buffer is created
			to hold the old name.
							*:0file*
:0f[ile][!]		Remove the name of the current buffer.  The optional !
			avoids truncating the message, as with |:file|.

:buffers
:files
:ls			List all the currently known file names.  See
			|windows.txt| |:files| |:buffers| |:ls|.

Vim will remember the full path name of a file name that you enter.  In most
cases when the file name is displayed only the name you typed is shown, but
the full path name is being used if you used the ":cd" command |:cd|.

							*home-replace*
If the environment

Title: Introduction to Editing Files in Vim
Summary
This section introduces the basics of editing files in Vim, including reading a file into a buffer, making changes, and writing the buffer back to the file. It defines the 'current file name' and 'alternate file name', explaining how they are used and managed. The section also covers commands for displaying file information (like CTRL-G and :file), listing buffers (:buffers), and manipulating file names.