💾 Archived View for gmi.noulin.net › vim › version5.gmi captured on 2024-08-31 at 17:32:47. Gemini links have been rewritten to link to archived content
View Raw
More Information
⬅️ Previous capture (2024-02-05)
-=-=-=-=-=-=-
- version5.txt* For Vim version 9.1. Last change: 2022 Nov 09
VIM REFERENCE MANUAL by Bram Moolenaar
Welcome to Vim Version 5.0!
This document lists the differences between Vim 4.x and Vim 5.0.
Although 5.0 is mentioned here, this is also for version 5.1, 5.2, etc.
See |vi_diff.txt| for an overview of differences between Vi and Vim 5.0.
See |version4.txt| for differences between Vim 3.0 and Vim 4.0.
INCOMPATIBLE: |incompatible-5|
Default value for 'compatible' changed |cp-default|
Text formatting command "Q" changed |Q-command-changed|
Command-line arguments changed |cmdline-changed|
Autocommands are kept |autocmds-kept|
Use of 'hidden' changed |hidden-changed|
Text object commands changed |text-objects-changed|
X-Windows Resources removed |x-resources|
Use of $VIM |$VIM-use|
Use of $HOME for MS-DOS and Win32 |$HOME-use|
Tags file format changed |tags-file-changed|
Options changed |options-changed|
CTRL-B in Insert mode gone |i_CTRL-B-gone|
NEW FEATURES: |new-5|
Syntax highlighting |new-highlighting|
Built-in script language |new-script|
Perl and Python support |new-perl-python|
Win32 GUI version |added-win32-GUI|
VMS version |added-VMS|
BeOS version |added-BeOS|
Macintosh GUI version |added-Mac|
More Vi compatible |more-compatible|
Read input from stdin |read-stdin|
Regular expression patterns |added-regexp|
Overloaded tags |tag-overloaded|
New commands |new-commands|
New options |added-options|
New command-line arguments |added-cmdline-args|
Various additions |added-various|
IMPROVEMENTS |improvements-5|
COMPILE TIME CHANGES |compile-changes-5|
BUG FIXES |bug-fixes-5|
VERSION 5.1 |version-5.1|
Changed |changed-5.1|
Added |added-5.1|
Fixed |fixed-5.1|
VERSION 5.2 |version-5.2|
Long lines editable |long-lines|
File browser added |file-browser-5.2|
Dialogs added |dialogs-added|
Popup menu added |popup-menu-added|
Select mode added |new-Select-mode|
Session files added |new-session-files|
User defined functions and commands |new-user-defined|
New interfaces |interfaces-5.2|
New ports |ports-5.2|
Multi-byte support |new-multi-byte|
New functions |new-functions-5.2|
New options |new-options-5.2|
New Ex commands |new-ex-commands-5.2|
Changed |changed-5.2|
Added |added-5.2|
Fixed |fixed-5.2|
VERSION 5.3 |version-5.3|
Changed |changed-5.3|
Added |added-5.3|
Fixed |fixed-5.3|
VERSION 5.4 |version-5.4|
Runtime directory introduced |new-runtime-dir|
Filetype introduced |new-filetype-5.4|
Vim script line continuation |new-line-continuation|
Improved session files |improved-sessions|
Autocommands improved |improved-autocmds-5.4|
Encryption |new-encryption|
GTK GUI port |new-GTK-GUI|
Menu changes |menu-changes-5.4|
Viminfo improved |improved-viminfo|
Various new commands |new-commands-5.4|
Various new options |new-options-5.4|
Vim scripts |new-script-5.4|
Avoid hit-enter prompt |avoid-hit-enter|
Improved quickfix |improved-quickfix|
Regular expressions |regexp-changes-5.4|
Changed |changed-5.4|
Added |added-5.4|
Fixed |fixed-5.4|
VERSION 5.5 |version-5.5|
Changed |changed-5.5|
Added |added-5.5|
Fixed |fixed-5.5|
VERSION 5.6 |version-5.6|
Changed |changed-5.6|
Added |added-5.6|
Fixed |fixed-5.6|
VERSION 5.7 |version-5.7|
Changed |changed-5.7|
Added |added-5.7|
Fixed |fixed-5.7|
VERSION 5.8 |version-5.8|
Changed |changed-5.8|
Added |added-5.8|
Fixed |fixed-5.8|
==============================================================================
INCOMPATIBLE *incompatible-5*
Default value for 'compatible' changed *cp-default*
--------------------------------------
Vim version 5.0 tries to be more Vi compatible. This helps people who use Vim
as a drop-in replacement for Vi, but causes some things to be incompatible
with version 4.x.
In version 4.x the default value for the 'compatible' option was off. Now the
default is on. The first thing you will notice is that the "u" command undoes
itself. Other side effects will be that mappings may work differently or not
work at all.
Since a lot of people switching from Vim 4.x to 5.0 will find this annoying,
the 'compatible' option is switched off if Vim finds a vimrc file. This is a
bit of magic to make sure that 90% of the Vim users will not be bitten by
this change.
What does this mean?
- If you prefer to run in 'compatible' mode and don't have a vimrc file, you
don't have to do anything.
- If you prefer to run in 'nocompatible' mode and do have a vimrc file, you
don't have to do anything.
- If you prefer to run in 'compatible' mode and do have a vimrc file, you
should put this line first in your vimrc file: >
:set compatible
- If you prefer to run in 'nocompatible' mode and don't have a vimrc file,
you can do one of the following:
- Create an empty vimrc file (e.g.: "~/.vimrc" for Unix).
- Put this command in your .exrc file or $EXINIT: >
:set nocompatible
< - Start Vim with the "-N" argument.
If you are new to Vi and Vim, using 'nocompatible' is strongly recommended,
because Vi has a lot of unexpected side effects, which are avoided by this
setting. See 'compatible'.
If you like some things from 'compatible' and some not, you can tune the
compatibility with 'cpoptions'.
When you invoke Vim as "ex" or "gex", Vim always starts in compatible mode.
Text formatting command "Q" changed *Q-command-changed*
-----------------------------------
The "Q" command formerly formatted lines to the width the 'textwidth' option
specifies. The command for this is now "gq" (see |gq| for more info). The
reason for this change is that "Q" is the standard Vi command to enter "Ex"
mode, and Vim now does in fact have an "Ex" mode (see |Q| for more info).
If you still want to use "Q" for formatting, use this mapping: >
:noremap Q gq
And if you also want to use the functionality of "Q": >
:noremap gQ Q
Command-line arguments changed *cmdline-changed*
------------------------------
Command-line file-arguments and option-arguments can now be mixed. You can
give options after the file names. Example: >
vim main.c -g
This is not possible when editing a file that starts with a '-'. Use the "--"
argument then |---|: >
vim -g -- -main.c
"-v" now means to start Ex in Vi mode, use "-R" for read-only mode.
old: "vim -v file" |-v|
new: "vim -R file" |-R|
"-e" now means to start Vi in Ex mode, use "-q" for quickfix.
old: "vim -e errorfile" |-e|
new: "vim -q errorfile" |-q|
"-s" in Ex mode now means to run in silent (batch) mode. |-s-ex|
"-x" reserved for crypt, use "-f" to avoid starting a new CLI (Amiga).
old: "vim -x file" |-x|
new: "vim -f file" |-f|
Vim allows up to ten "+cmd" and "-c cmd" arguments. Previously Vim executed
only the last one.
"-n" now overrides any setting for 'updatecount' in a vimrc file, but not in
a gvimrc file.
Autocommands are kept *autocmds-kept*
---------------------
Before version 5.0, autocommands with the same event, file name pattern, and
command could appear only once. This was fine for simple autocommands (like
setting option values), but for more complicated autocommands, where the same
command might appear twice, this restriction caused problems. Therefore
Vim stores all autocommands and keeps them in the order that they are defined.
The most obvious side effect of this change is that when you source a vimrc
file twice, the autocommands in it will be defined twice. To avoid this, do
one of these:
- Remove any autocommands that might already be defined before defining
them. Example: >
:au! * *.ext
:au BufEnter *.ext ...
- Put the autocommands inside an ":if" command. Example: >
if !exists("did_ext_autocmds")
let did_ext_autocmds = 1
autocmd BufEnter *.ext ...
endif
- Put your autocommands in a different autocommand group so you can remove
them before defining them |:augroup|: >
augroup uncompress
au!
au BufReadPost *.gz ...
augroup END
Use of 'hidden' changed *hidden-changed*
-----------------------
In version 4.x, only some commands used the 'hidden' option. Now all commands
uses it whenever a buffer disappears from a window.
Previously you could do ":buf xxx" in a changed buffer and that buffer would
then become hidden. Now you must set the 'hidden' option for this to work.
The new behavior is simpler: whether Vim hides buffers no longer depends on
the specific command that you use.
- with 'hidden' not set, you never get hidden buffers. Exceptions are the
":hide" and ":close!" commands and, in rare cases, where you would otherwise
lose changes to the buffer.
- With 'hidden' set, you almost never unload a buffer. Exceptions are the
":bunload" or ":bdel" commands.
":buffer" now supports a "!": abandon changes in current buffer. So do
":bnext", ":brewind", etc.
Text object commands changed *text-objects-changed*
----------------------------
Text object commands have new names. This allows more text objects and makes
characters available for other Visual mode commands. Since no more single
characters were available, text objects names now require two characters.
The first one is always 'i' or 'a'.
OLD NEW ~
a aw a word |v_aw|
A aW a WORD |v_aW|
s as a sentence |v_as|
p ap a paragraph |v_ap|
S ab a () block |v_ab|
P aB a {} block |v_aB|
There is another set of text objects that starts with "i", for "inner". These
select the same objects, but exclude white space.
X-Windows Resources removed *x-resources*
--------------------------
Vim no longer supports the following X resources:
- boldColor
- italicColor
- underlineColor
- cursorColor
Vim now uses highlight groups to set colors. This avoids the confusion of
using a bold Font, which would imply a certain color. See |:highlight| and
|gui-resources|.
Use of $VIM *$VIM-use*
-----------
Vim now uses the VIM environment variable to find all Vim system files. This
includes the global vimrc, gvimrc, and menu.vim files and all on-line help
and syntax files. See |$VIM|. Starting with version 5.4, |$VIMRUNTIME| can
also be used.
For Unix, Vim sets a default value for $VIM when doing "make install".
When $VIM is not set, its default value is the directory from 'helpfile',
excluding "/doc/help.txt".
Use of $HOME for MS-DOS and Win32 *$HOME-use*
---------------------------------
The MS-DOS and Win32 versions of Vim now first check $HOME when searching for
a vimrc or exrc file and for reading/storing the viminfo file. Previously Vim
used $VIM for these systems, but this causes trouble on a system with several
users. Now Vim uses $VIM only when $HOME is not set or the file is not found
in $HOME. See |_vimrc|.
Tags file format changed *tags-file-changed*
------------------------
Only tabs are allowed to separate fields in a tags file. This allows for
spaces in a file name and is still Vi compatible. In previous versions of
Vim, any white space was allowed to separate the fields. If you have a file
which doesn't use a single tab between fields, edit the tags file and execute
this command: >
:%s/\(\S*\)\s\+\(\S*\)\s\+\(.*\)/\1\t\2\t\3/
Options changed *options-changed*
---------------
The default value of 'errorfile' has changed from "errors.vim" to "errors.err".
The reason is that only Vim scripts should have the ".vim" extensions.
The ":make" command no longer uses the 'errorfile' option. This prevents the
output of the ":make" command from overwriting a manually saved error file.
":make" uses the 'makeef' option instead. This also allows for generating a
unique name, to prevent concurrently running ":make" commands from overwriting
each other's files.
With 'insertmode' set, a few more things change:
- <Esc> in Normal mode goes to Insert mode.
- <Esc> in Insert mode doesn't leave Insert mode.
- When doing ":set im", go to Insert mode immediately.
Vim considers a buffer to be changed when the 'fileformat' (formerly the
'textmode' option) is different from the buffer's initial format.
CTRL-B in Insert mode gone *i_CTRL-B-gone*
--------------------------
When Vim was compiled with the |+rightleft| feature, you could use CTRL-B to
toggle the 'revins' option. Unfortunately, some people hit the 'B' key
accidentally when trying to type CTRL-V or CTRL-N and then didn't know how to
undo this. Since toggling the 'revins' option can easily be done with the
mapping below, this use of the CTRL-B key is disabled. You can still use the
CTRL-_ key for this |i_CTRL-_|. >
:imap <C-B> <C-O>:set revins!<CR>
==============================================================================
NEW FEATURES *new-5*
Syntax highlighting *new-highlighting*
-------------------
Vim now has a very flexible way to highlighting just about any type of file.
See |syntax|. Summary: >
:syntax on
Colors and attributes can be set for the syntax highlighting, and also for
other highlighted items with the ':' flag in the 'highlight' option. All
highlighted items are assigned a highlight group which specifies their
highlighting. See |:highlight|. The default colors have been improved.
You can use the "Normal" group to set the default fore/background colors for a
color terminal. For the GUI, you can use this group to specify the font, too.
The "2html.vim" script can be used to convert any file that has syntax
highlighting to HTML. The colors will be exactly the same as how you see them
in Vim. With a HTML viewer you can also print the file with colors.
Built-in script language *new-script*
------------------------
A few extra commands and an expression evaluator enable you to write simple
but powerful scripts. Commands include ":if" and ":while". Expressions can
manipulate numbers and strings. You can use the '=' register to insert
directly the result of an expression. See |expression|.
Perl and Python support *new-perl-python*
-----------------------
Vim can call Perl commands with ":perldo", ":perl", etc. See |perl|.
Patches made by Sven Verdoolaege and Matt Gerassimoff.
Vim can call Python commands with ":python" and ":pyfile". See |python|.
Both of these are only available when enabled at compile time.
Win32 GUI version *added-win32-GUI*
-----------------
The GUI has been ported to MS-Windows 95 and NT. All the features of the X11
GUI are available to Windows users now. |gui-w32|
This also fixes problems with running the Win32 console version under Windows
95, where console support has always been bad.
There is also a version that supports OLE automation interface. |if_ole.txt|
Vim can be integrated with Microsoft Developer Studio using the VisVim DLL.
It is possible to produce a DLL version of gvim with Borland C++ (Aaron).
VMS version *added-VMS*
-----------
Vim can now also be used on VMS systems. Port done by Henk Elbers.
This has not been tested much, but it should work.
Sorry, no documentation!
BeOS version *added-BeOS*
------------
Vim can be used on BeOS systems (including the BeBox). (Olaf Seibert)
See |os_beos.txt|.
Macintosh GUI version *added-Mac*
---------------------
Vim can now be used on the Macintosh. (Dany St-Amant)
It has not been tested much yet, be careful!
See |os_mac.txt|.
More Vi compatible *more-compatible*
------------------
There is now a real Ex mode. Started with the "Q" command, or by calling the
executable "ex" or "gex". |Ex-mode|
Always allow multi-level undo, also in Vi compatible mode. When the 'u' flag
in 'cpoptions' is included, CTRL-R is used for repeating the undo or redo
(like "." in Nvi).
Read input from stdin *read-stdin*
---------------------
When using the "-" command-line argument, Vim reads its text input from stdin.
This can be used for putting Vim at the end of a pipe: >
grep "^a.*" *.c | vim -
See |--|.
Regular expression patterns *added-regexp*
---------------------------
Added specifying a range for the number of matches of an atom: "\{a,b}". |/\{|
Added the "shortest match" regexp "\{-}" (Webb).
Added "\s", matches a white character. Can replace "[ \t]". |/\s|
Added "\S", matches a non-white character. Can replace "[^ \t]". |/\S|
Overloaded tags *tag-overloaded*
---------------
When using a language like C++, there can be several tags for the same
tagname. Commands have been added to be able to jump to any of these
overloaded tags:
|:tselect| List matching tags, and jump to one of them.
|:stselect| Idem, and split window.
|g_CTRL-]| Do ":tselect" with the word under the cursor.
After ":ta {tagname}" with multiple matches:
|:tnext| Go to next matching tag.
|:tprevious| Go to previous matching tag.
|:trewind| Go to first matching tag.
|:tlast| Go to last matching tag.
The ":tag" command now also accepts wildcards. When doing command-line
completion on tags, case-insensitive matching is also available (at the end).
New commands *new-commands*
------------
|:amenu| Define menus for all modes, inserting a CTRL-O for Insert
mode, ESC for Visual and CTRL-C for Cmdline mode. "amenu" is
used for the default menus and the Syntax menu.
|:augroup| Set group to be used for following autocommands. Allows the
grouping of autocommands to enable deletion of a specific
group.
|:crewind| Go to first error.
|:clast| Go to last error.
|:doautoall| Execute autocommands for all loaded buffers.
|:echo| Echo its argument, which is an expression. Can be used to
display messages which include variables.
|:execute| Execute its argument, which is an expression. Can be used to
built up an Ex command with anything.
|:hide| Works like ":close".
|:if| Conditional execution, for built-in script language.
|:intro| Show introductory message. This is always executed when Vim
is started without file arguments.
|:let| Assign a value to an internal variable.
|:omap| Map only in operator-pending mode. Makes it possible to map
text-object commands.
|:redir| Redirect output of messages to a file.
|:update| Write when buffer has changed.
|:while| While-loop for built-in script language.
Visual mode:
|v_O| "O" in Visual block mode, moves the cursor to the other corner
horizontally.
|v_D| "D" in Visual block mode deletes till end of line.
Insert mode:
|i_CTRL-]| Triggers abbreviation, without inserting any character.
New options *added-options*
-----------
'background' Used for selecting highlight color defaults. Also used in
"syntax.vim" for selecting the syntax colors. Often set
automatically, depending on the terminal used.
'complete' Specifies how Insert mode completion works.
'eventignore' Makes it possible to ignore autocommands temporarily.
'fileformat' Current file format. Replaces 'textmode'.
'fileformats' Possible file formats. Replaces 'textauto'.
New is that this also supports Macintosh format: A single <CR>
separates lines.
The default for 'fileformats' for MS-DOS, Win32 and OS/2 is
"dos,unix", also when 'compatible' set. Unix type files
didn't work anyway when 'fileformats' was empty.
'guicursor' Set the cursor shape and blinking in various modes.
Default is to adjust the cursor for Insert and Replace mode,
and when an operator is pending. Blinking is default on.
'fkmap' Farsi key mapping.
'hlsearch' Highlight all matches with the last used search pattern.
'hkmapp' Phonetic Hebrew mapping. (Ilya Dogolazky)
'iconstring' Define the name of the icon, when not empty. (Version 5.2: the
string is used literally, a newline can be used to make two
lines.)
'lazyredraw' Don't redraw the screen while executing macros, registers or
other not typed commands.
'makeef' Errorfile to be used for ":make". "##" is replaced with a
unique number. Avoids that two Vim sessions overwrite each
others errorfile. The Unix default is "/tmp/vim##.err"; for
Amiga "t:vim##.Err, for others "vim##.err".
'matchtime' 1/10s of a second to show a matching paren, when 'showmatch'
is set. Like Nvi.
'mousehide' Hide mouse pointer in GUI when typing text.
'nrformats' Defines what bases Vim will consider for numbers when using
the CTRL-A and CTRL-X commands. Default: "hex,octal".
'shellxquote' Add extra quotes around the whole shell command, including
redirection.
'softtabstop' Make typing behave like tabstop is set at this value, without
changing the value of 'tabstop'. Makes it more easy to keep
'ts' at 8, while still getting four spaces for a <Tab>.
'titlestring' String for the window title, when not empty. (Version 5.2:
this string is used literally, a newline can be used to make
two lines.)
'verbose' Level of verbosity. Makes it possible to show which .vimrc,
.exrc, .viminfo files etc. are used for initializing. Also
to show autocommands that are being executed. Can also be set
by using the "-V" command-line argument.
New command-line arguments *added-cmdline-args*
--------------------------
|-U| Set the gvimrc file to be used. Like "-u" for the vimrc.
|-V| Set the 'verbose' option. E.g. "vim -V10".
|-N| Start in non-compatible mode.
|-C| Start in compatible mode.
|-Z| Start in restricted mode, disallow shell commands. Can also
be done by calling the executable "rvim".
|-h| Show usage information and exit.
Various additions *added-various*
-----------------
Added support for SNiFF+ connection (submitted by Toni Leherbauer). Vim can
be used as an editor for SNiFF. No documentation available...
For producing a bug report, the bugreport.vim script has been included.
Can be used with ":so $VIMRUNTIME/bugreport.vim", which creates the file
"bugreport.txt" in the current directory. |bugs|
Added range to ":normal" command. Now you can repeat the same command for
each line in the range. |:normal-range|
Included support for the Farsi language (Shiran). Only when enabled at
compile time. See |farsi|.
==============================================================================
IMPROVEMENTS *improvements-5*
Performance:
- When 'showcmd' was set, mappings would execute much more slowly because the
output would be flushed very often. Helps a lot when executing the "life"
macros with 'showcmd' set.
- Included patches for binary searching in tags file (David O'Neill).
Can be disabled by resetting the 'tagbsearch' option.
- Don't update the ruler when repeating insert (slowed it down a lot).
- For Unix, file name expansion is now done internally instead of starting a
shell for it.
- Expand environment variables with expand_env(), instead of calling the
shell. Makes ":so $VIMRUNTIME/syntax/syntax.vim" a LOT faster.
- Reduced output for cursor positioning: Use CR-LF for moving to first few
columns in next few lines; Don't output CR twice when using termios.
- Optimized cursor positioning. Use CR, BS and NL when it's shorter than
absolute cursor positioning.
- Disable redrawing while repeating insert "1000ii<Esc>".
- Made "d$" or "D" for long lines a lot faster (delete all characters at once,
instead of one by one).
- Access option table by first letter, instead of searching from start.
- Made setting special highlighting attributes a lot faster by using
highlight_attr[], instead of searching in the 'highlight' string.
- Don't show the mode when redrawing is disabled.
- When setting an option, only redraw the screen when required.
- Improved performance of Ex commands by using a lookup table for the first
character.
Options:
'cinoptions' Added 'g' flag, for C++ scope declarations.
'cpoptions' Added 'E' flag: Disallow yanking, deleting, etc. empty text
area. Default is to allow empty yanks. When 'E' is included,
"y$" in an empty line now is handled as an error (Vi
compatible).
Added 'j' flag: Only add two spaces for a join after a '.',
not after a '?' or '!'.
Added 'A' flag: don't give ATTENTION message.
Added 'L' flag: When not included, and 'list' is set,
'textwidth' formatting works like 'list' is not set.
Added 'W' flag: Let ":w!" behave like Vi: don't overwrite
readonly files, or a file owned by someone else.
'highlight' Added '@' flag, for '@' characters after the last line on the
screen, and '