Home Explore Blog CI



neovim

4th chunk of `runtime/doc/usr_08.txt`
6611f01e1cb4ba3e55a0b8e464a4252a006400cb9469329c0000000100000fa2
 them away.

If you know there are windows with changes, and you want to save all these
changes, use this command: >

	:wall

This stands for "write all".  But actually, it only writes files with
changes.  Vim knows it doesn't make sense to write files that were not
changed.
   And then there is the combination of ":qall" and ":wall": the "write and
quit all" command: >

	:wqall

This writes all modified files and quits Vim.
   Finally, there is a command that quits Vim and throws away all changes: >

	:qall!

Be careful, there is no way to undo this command!


OPENING A WINDOW FOR ALL ARGUMENTS

To make Vim open a window for each file, start it with the "-o" argument: >

	vim -o one.txt two.txt three.txt

This results in:
>
	+-------------------------------+
	|file one.txt			|
	|~				|
	|one.txt========================|
	|file two.txt			|
	|~				|
	|two.txt========================|
	|file three.txt			|
	|~				|
	|three.txt======================|
	|				|
	+-------------------------------+
<
The "-O" argument is used to get vertically split windows.
   When Vim is already running, the ":all" command opens a window for each
file in the argument list.  ":vertical all" does it with vertical splits.

==============================================================================
*08.7*	Viewing differences with diff mode

There is a special way to start Nvim, which shows the differences between two
files.  Let's take a file "main.c" and insert a few characters in one line.
Write this file with the 'backup' option set, so that the backup file
"main.c~" will contain the previous version of the file.
Type this command in a shell to start Nvim in diff mode: >

	nvim -d main.c~ main.c

Vim will start, with two windows side by side.  You will only see the line
in which you added characters, and a few lines above and below it.
>
	 VV		      VV
	+-----------------------------------------+
	|+ +--123 lines: /* a|+ +--123 lines: /* a|  <- fold
	|  text		     |	text		  |
	|  text		     |	text		  |
	|  text		     |	text		  |
	|  text		     |	changed text	  |  <- changed line
	|  text		     |	text		  |
	|  text		     |	------------------|  <- deleted line
	|  text		     |	text		  |
	|  text		     |	text		  |
	|  text		     |	text		  |
	|+ +--432 lines: text|+ +--432 lines: text|  <- fold
	|  ~		     |	~		  |
	|  ~		     |	~		  |
	|main.c~==============main.c==============|
	|					  |
	+-----------------------------------------+
<
(This picture doesn't show the highlighting, use "nvim -d" for that.)

The lines that were not modified have been collapsed into one line.  This is
called a closed fold.  They are indicated in the picture with "<- fold".  Thus
the single fold line at the top stands for 123 text lines.  These lines are
equal in both files.
   The line marked with "<- changed line" is highlighted, and the inserted
text is displayed with another color.  This clearly shows what the difference
is between the two files.
   The line that was deleted is displayed with "---" in the main.c window.
See the "<- deleted line" marker in the picture.  These characters are not
really there.  They just fill up main.c, so that it displays the same number
of lines as the other window.


THE FOLD COLUMN

Each window has a column on the left with a slightly different background.  In
the picture above these are indicated with "VV".  You notice there is a plus
character there, in front of each closed fold.  Move the mouse pointer to that
plus and click the left button.  The fold will open, and you can see the text
that it contains.
   The fold column contains a minus sign for an open fold.  If you click on
this -, the fold will close.
   Obviously, this only works when you have a working mouse.  You can also use
"zo" to open a fold and "zc" to close it.


DIFFING IN VIM

Another way to start in diff mode can be done from inside Vim.  Edit the
"main.c" file, then make a split and show the differences: >

	:edit main.c
	:vertical diffsplit main.c~

The ":vertical"

Title: Managing Windows and Viewing Differences with Diff Mode
Summary
This section covers advanced window management commands such as `:wall`, `:wqall`, and `:qall!`. It also explains how to open multiple files in separate windows using `vim -o` and `vim -O`, as well as the `:all` command. The section then delves into diff mode, demonstrating how to compare files using `nvim -d` and `:vertical diffsplit` to highlight differences, utilizing folds to collapse unchanged lines for a clearer view of modifications.