vi_diff.txt 56 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366
  1. *vi_diff.txt* For Vim version 9.0. Last change: 2022 Apr 03
  2. VIM REFERENCE MANUAL by Bram Moolenaar
  3. Differences between Vim and Vi *vi-differences*
  4. This file lists the differences between Vim and Vi/Ex and gives an overview of
  5. what is in Vim that is not in Vi.
  6. Vim is mostly POSIX 1003.2-1 compliant. The only command known to be missing
  7. is ":open". There are probably a lot of small differences (either because Vim
  8. is missing something or because Posix is beside the mark).
  9. 1. Simulated command |simulated-command|
  10. 2. Missing options |missing-options|
  11. 3. Limits |limits|
  12. 4. The most interesting additions |vim-additions|
  13. 5. Other vim features |other-features|
  14. 6. Supported Vi features |vi-features|
  15. 7. Command-line arguments |cmdline-arguments|
  16. 8. POSIX compliance |posix-compliance|
  17. ==============================================================================
  18. 1. Simulated command *simulated-command*
  19. This command is in Vi, but Vim only simulates it:
  20. *:o* *:op* *:open*
  21. :[range]o[pen] Works like |:visual|: end Ex mode.
  22. {Vi: start editing in open mode}
  23. :[range]o[pen] /pattern/ As above, additionally move the cursor to the
  24. column where "pattern" matches in the cursor
  25. line.
  26. Vim does not support open mode, since it's not really useful. For those
  27. situations where ":open" would start open mode Vim will leave Ex mode, which
  28. allows executing the same commands, but updates the whole screen instead of
  29. only one line.
  30. ==============================================================================
  31. 2. Missing options *missing-options*
  32. These options are in the Unix Vi, but not in Vim. If you try to set one of
  33. them you won't get an error message, but the value is not used and cannot be
  34. printed.
  35. autoprint (ap) boolean (default on) *'autoprint'* *'ap'*
  36. beautify (bf) boolean (default off) *'beautify'* *'bf'*
  37. flash (fl) boolean (default ??) *'flash'* *'fl'*
  38. graphic (gr) boolean (default off) *'graphic'* *'gr'*
  39. hardtabs (ht) number (default 8) *'hardtabs'* *'ht'*
  40. number of spaces that a <Tab> moves on the display
  41. mesg boolean (default on) *'mesg'*
  42. novice boolean (default off) *'novice'*
  43. open boolean (default on) *'open'*
  44. optimize (op) boolean (default off) *'optimize'* *'op'*
  45. redraw boolean (default off) *'redraw'*
  46. slowopen (slow) boolean (default off) *'slowopen'* *'slow'*
  47. sourceany boolean (default off) *'sourceany'*
  48. w300 number (default 23) *'w300'*
  49. w1200 number (default 23) *'w1200'*
  50. w9600 number (default 23) *'w9600'*
  51. Vi did not allow for changing the termcap entries, you would have to exit Vi,
  52. edit the termcap entry and try again. Vim has the |terminal-options|.
  53. ==============================================================================
  54. 3. Limits *limits*
  55. Vim has only a few limits for the files that can be edited {Vi: can not handle
  56. <Nul> characters and characters above 128, has limited line length, many other
  57. limits}.
  58. Maximum line length 2147483647 characters. Longer lines are split.
  59. Maximum number of lines 2147483647 lines.
  60. Maximum file size 2147483647 bytes (2 Gbyte) when a long integer is
  61. 32 bits. Much more for 64 bit longs. Also limited
  62. by available disk space for the |swap-file|.
  63. *E75*
  64. Length of a file path Unix and Win32: 1024 characters, otherwise 256
  65. characters (or as much as the system supports).
  66. Length of an expanded string option
  67. Unix and Win32: 1024 characters, otherwise 256
  68. characters
  69. Maximum display width Unix and Win32: 1024 characters, otherwise 255
  70. characters
  71. Maximum lhs of a mapping 50 characters.
  72. Number of different highlighting types: over 30000
  73. Range of a Number variable: -2147483648 to 2147483647 (might be more on 64
  74. bit systems)
  75. Maximum length of a line in a tags file: 512 bytes.
  76. Information for undo and text in registers is kept in memory, thus when making
  77. (big) changes the amount of (virtual) memory available limits the number of
  78. undo levels and the text that can be kept in registers. Other things are also
  79. kept in memory: Command-line history, error messages for Quickfix mode, etc.
  80. Memory usage limits
  81. -------------------
  82. The option 'maxmem' ('mm') is used to set the maximum memory used for one
  83. buffer (in kilobytes). 'maxmemtot' is used to set the maximum memory used for
  84. all buffers (in kilobytes). The defaults depend on the system used. For the
  85. Amiga, 'maxmemtot' is set depending on the amount of memory available.
  86. These are not hard limits, but tell Vim when to move text into a swap file.
  87. If you don't like Vim to swap to a file, set 'maxmem' and 'maxmemtot' to a
  88. very large value. The swap file will then only be used for recovery. If you
  89. don't want a swap file at all, set 'updatecount' to 0, or use the "-n"
  90. argument when starting Vim.
  91. ==============================================================================
  92. 4. The most interesting additions *vim-additions*
  93. Vi compatibility. |'compatible'|
  94. Although Vim is 99% Vi compatible, some things in Vi can be
  95. considered to be a bug, or at least need improvement. But still, Vim
  96. starts in a mode which behaves like the "real" Vi as much as possible.
  97. To make Vim behave a little bit better, try resetting the 'compatible'
  98. option:
  99. :set nocompatible
  100. Or start Vim with the "-N" argument:
  101. vim -N
  102. Vim starts with 'nocompatible' automatically if you have a .vimrc
  103. file. See |startup|.
  104. The 'cpoptions' option can be used to set Vi compatibility on/off for
  105. a number of specific items.
  106. Support for different systems.
  107. Vim can be used on:
  108. - All Unix systems (it works on all systems it was tested on, although
  109. the GUI and Perl interface may not work everywhere).
  110. - Amiga (500, 1000, 1200, 2000, 3000, 4000, ...).
  111. - MS-Windows
  112. - VMS
  113. - Macintosh
  114. - IBM OS/390
  115. Note that on some systems features need to be disabled to reduce
  116. resource usage. For some outdated systems you need to use an older
  117. Vim version.
  118. Multi level persistent undo. |undo|
  119. 'u' goes backward in time, 'CTRL-R' goes forward again. Set option
  120. 'undolevels' to the number of changes to be remembered (default 1000).
  121. Set 'undolevels' to 0 for a Vi-compatible one level undo. Set it to
  122. -1 for no undo at all.
  123. When all changes in a buffer have been undone, the buffer is not
  124. considered changed anymore. You can exit it with :q, without <!>.
  125. When undoing a few changes and then making a new change Vim will
  126. create a branch in the undo tree. This means you can go back to any
  127. state of the text, there is no risk of a change causing text to be
  128. lost forever. |undo-tree|
  129. The undo information is stored in a file when the 'undofile' option is
  130. set. This means you can exit Vim, start Vim on a previously edited
  131. file and undo changes that were made before exiting Vim.
  132. Graphical User Interface (GUI). |gui|
  133. Included support for GUI: menu's, mouse, scrollbars, etc. You can
  134. define your own menus. Better support for CTRL/SHIFT/ALT keys in
  135. combination with special keys and mouse. Supported for various
  136. platforms, such as X11 with Motif, GTK, Win32 (Windows XP and later),
  137. Amiga and Macintosh.
  138. Multiple windows and buffers. |windows.txt|
  139. Vim can split the screen into several windows, each editing a
  140. different buffer or the same buffer at a different location. Buffers
  141. can still be loaded (and changed) but not displayed in a window. This
  142. is called a hidden buffer. Many commands and options have been added
  143. for this facility.
  144. Vim can also use multiple tab pages, each with one or more windows. A
  145. line with tab labels can be used to quickly switch between these pages.
  146. |tab-page|
  147. Terminal window. |:terminal|
  148. Vim can create a window in which a terminal emulator runs. This can
  149. be used to execute an arbitrary command, a shell or a debugger.
  150. Syntax highlighting. |:syntax|
  151. Vim can highlight keywords, patterns and other things. This is
  152. defined by a number of |:syntax| commands, and can be made to
  153. highlight most languages and file types. A number of files are
  154. included for highlighting the most common languages, like C, C++,
  155. Java, Pascal, Makefiles, shell scripts, etc. The colors used for
  156. highlighting can be defined for ordinary terminals, color terminals
  157. and the GUI with the |:highlight| command. A convenient way to do
  158. this is using a |:colorscheme| command.
  159. The highlighted text can be exported as HTML. |convert-to-HTML|
  160. Other items that can be highlighted are matches with the search string
  161. |'hlsearch'|, matching parens |matchparen| and the cursor line and
  162. column |'cursorline'| |'cursorcolumn'|.
  163. Text properties |textprop.txt|
  164. Vim supports highlighting text by a plugin. Property types can be
  165. specified with |prop_type_add()| and properties can be placed with
  166. |prop_add()|.
  167. Spell checking. |spell|
  168. When the 'spell' option is set Vim will highlight spelling mistakes.
  169. About 50 languages are currently supported, selected with the
  170. 'spelllang' option. In source code only comments and strings are
  171. checked for spelling.
  172. Folding. |folding|
  173. A range of lines can be shown as one "folded" line. This allows
  174. overviewing a file and moving blocks of text around quickly.
  175. Folds can be created manually, from the syntax of the file, by indent,
  176. etc.
  177. Diff mode. |diff|
  178. Vim can show two versions of a file with the differences highlighted.
  179. Parts of the text that are equal are folded away. Commands can be
  180. used to move text from one version to the other.
  181. Plugins. |add-plugin|
  182. The functionality can be extended by dropping a plugin file in the
  183. right directory. That's an easy way to start using Vim scripts
  184. written by others. Plugins can be for all kind of files, or
  185. specifically for a filetype.
  186. Packages make this even easier. |packages|
  187. Asynchronous communication and timers. |channel| |job| |timer|
  188. Vim can exchange messages with other processes in the background.
  189. This makes it possible to have servers do work and send back the
  190. results to Vim. |channel|
  191. Vim can start a job, communicate with it and stop it. |job|
  192. Timers can fire once or repeatedly and invoke a function to do any
  193. work. |timer|
  194. Repeat a series of commands. |q|
  195. "q{c}" starts recording typed characters into named register {c}.
  196. A subsequent "q" stops recording. The register can then be executed
  197. with the "@{c}" command. This is very useful to repeat a complex
  198. action.
  199. Flexible insert mode. |ins-special-special|
  200. The arrow keys can be used in insert mode to move around in the file.
  201. This breaks the insert in two parts as far as undo and redo is
  202. concerned.
  203. CTRL-O can be used to execute a single Normal mode command. This is
  204. almost the same as hitting <Esc>, typing the command and doing |a|.
  205. Visual mode. |Visual-mode|
  206. Visual mode can be used to first highlight a piece of text and then
  207. give a command to do something with it. This is an (easy to use)
  208. alternative to first giving the operator and then moving to the end of
  209. the text to be operated upon.
  210. |v| and |V| are used to start Visual mode. |v| works on characters
  211. and |V| on lines. Move the cursor to extend the Visual area. It is
  212. shown highlighted on the screen. By typing "o" the other end of the
  213. Visual area can be moved. The Visual area can be affected by an
  214. operator:
  215. d delete
  216. c change
  217. y yank
  218. > or < insert or delete indent
  219. ! filter through external program
  220. = filter through indent
  221. : start |:| command for the Visual lines.
  222. gq format text to 'textwidth' columns
  223. J join lines
  224. ~ swap case
  225. u make lowercase
  226. U make uppercase
  227. {Vi has no Visual mode, the name "visual" is used for Normal mode, to
  228. distinguish it from Ex mode}
  229. Block operators. |visual-block|
  230. With Visual mode a rectangular block of text can be selected. Start
  231. Visual mode with CTRL-V. The block can be deleted ("d"), yanked ("y")
  232. or its case can be changed ("~", "u" and "U"). A deleted or yanked
  233. block can be put into the text with the "p" and "P" commands.
  234. Help system. |:help|
  235. Help is displayed in a window. The usual commands can be used to
  236. move around, search for a string, etc. Tags can be used to jump
  237. around in the help files, just like hypertext links. The |:help|
  238. command takes an argument to quickly jump to the info on a subject.
  239. <F1> is the quick access to the help system. The name of the help
  240. index file can be set with the 'helpfile' option.
  241. Command-line editing and history. |cmdline-editing|
  242. You can insert or delete at any place in the command-line using the
  243. cursor keys. The right/left cursor keys can be used to move
  244. forward/backward one character. The shifted right/left cursor keys
  245. can be used to move forward/backward one word. CTRL-B/CTRL-E can be
  246. used to go to the begin/end of the command-line.
  247. {Vi: can only alter the last character in the line}
  248. {Vi: when hitting <Esc> the command-line is executed. This is
  249. unexpected for most people; therefore it was changed in Vim. But when
  250. the <Esc> is part of a mapping, the command-line is executed. If you
  251. want the Vi behaviour also when typing <Esc>, use ":cmap ^V<Esc>
  252. ^V^M"}
  253. |cmdline-history|
  254. The command-lines are remembered. The up/down cursor keys can be used
  255. to recall previous command-lines. The 'history' option can be set to
  256. the number of lines that will be remembered. There is a separate
  257. history for commands and for search patterns.
  258. Command-line completion. |cmdline-completion|
  259. While entering a command-line (on the bottom line of the screen)
  260. <Tab> can be typed to complete
  261. what example ~
  262. - command :e<Tab>
  263. - tag :ta scr<Tab>
  264. - option :set sc<Tab>
  265. - option value :set hf=<Tab>
  266. - file name :e ve<Tab>
  267. - etc.
  268. If there are multiple matches, CTRL-N (next) and CTRL-P (previous)
  269. will walk through the matches. <Tab> works like CTRL-N, but wraps
  270. around to the first match.
  271. The 'wildchar' option can be set to the character for command-line
  272. completion, <Tab> is the default. CTRL-D can be typed after an
  273. (incomplete) wildcard; all matches will be listed. CTRL-A will insert
  274. all matches. CTRL-L will insert the longest common part of the
  275. matches.
  276. Insert-mode completion. |ins-completion|
  277. In Insert mode the CTRL-N and CTRL-P keys can be used to complete a
  278. word that appears elsewhere. |i_CTRL-N|
  279. With CTRL-X another mode is entered, through which completion can be
  280. done for:
  281. |i_CTRL-X_CTRL-F| file names
  282. |i_CTRL-X_CTRL-K| words from 'dictionary' files
  283. |i_CTRL-X_CTRL-T| words from 'thesaurus' files
  284. |i_CTRL-X_CTRL-I| words from included files
  285. |i_CTRL-X_CTRL-L| whole lines
  286. |i_CTRL-X_CTRL-]| words from the tags file
  287. |i_CTRL-X_CTRL-D| definitions or macros
  288. |i_CTRL-X_CTRL-O| Omni completion: clever completion
  289. specifically for a file type
  290. etc.
  291. Long line support. |'wrap'| |'linebreak'|
  292. If the 'wrap' option is off, long lines will not wrap and only part
  293. of them will be shown. When the cursor is moved to a part that is not
  294. shown, the screen will scroll horizontally. The minimum number of
  295. columns to scroll can be set with the 'sidescroll' option. The |zh|
  296. and |zl| commands can be used to scroll sideways.
  297. Alternatively, long lines are broken in between words when the
  298. 'linebreak' option is set. This allows editing a single-line
  299. paragraph conveniently (e.g. when the text is later read into a DTP
  300. program). Move the cursor up/down with the |gk| and |gj| commands.
  301. Text formatting. |formatting|
  302. The 'textwidth' option can be used to automatically limit the line
  303. length. This supplements the 'wrapmargin' option of Vi, which was not
  304. very useful. The |gq| operator can be used to format a piece of text
  305. (for example, |gqap| formats the current paragraph). Commands for
  306. text alignment: |:center|, |:left| and |:right|.
  307. Extended search patterns. |pattern|
  308. There are many extra items to match various text items. Examples:
  309. A "\n" can be used in a search pattern to match a line break.
  310. "x\{2,4}" matches "x" 2 to 4 times.
  311. "\s" matches a white space character.
  312. Directory, remote and archive browsing. |netrw|
  313. Vim can browse the file system. Simply edit a directory. Move around
  314. in the list with the usual commands and press <Enter> to go to the
  315. directory or file under the cursor.
  316. This also works for remote files over ftp, http, ssh, etc.
  317. Zip and tar archives can also be browsed. |tar| |zip|
  318. Edit-compile-edit speedup. |quickfix|
  319. The |:make| command can be used to run the compilation and jump to the
  320. first error. A file with compiler error messages is interpreted. Vim
  321. jumps to the first error.
  322. Each line in the error file is scanned for the name of a file, line
  323. number and error message. The 'errorformat' option can be set to a
  324. list of scanf-like strings to handle output from many compilers.
  325. The |:cn| command can be used to jump to the next error.
  326. |:cl| lists all the error messages. Other commands are available.
  327. The 'makeef' option has the name of the file with error messages.
  328. The 'makeprg' option contains the name of the program to be executed
  329. with the |:make| command.
  330. The 'shellpipe' option contains the string to be used to put the
  331. output of the compiler into the errorfile.
  332. Finding matches in files. |:vimgrep|
  333. Vim can search for a pattern in multiple files. This uses the
  334. advanced Vim regexp pattern, works on all systems and also works to
  335. search in compressed files.
  336. Improved indenting for programs. |'cindent'|
  337. When the 'cindent' option is on the indent of each line is
  338. automatically adjusted. C syntax is mostly recognized. The indent
  339. for various styles can be set with 'cinoptions'. The keys to trigger
  340. indenting can be set with 'cinkeys'.
  341. Comments can be automatically formatted. The 'comments' option can be
  342. set to the characters that start and end a comment. This works best
  343. for C code, but also works for e-mail (">" at start of the line) and
  344. other types of text. The |=| operator can be used to re-indent
  345. lines.
  346. For many other languages an indent plugin is present to support
  347. automatic indenting. |30.3|
  348. Searching for words in included files. |include-search|
  349. The |[i| command can be used to search for a match of the word under
  350. the cursor in the current and included files. The 'include' option
  351. can be set to a pattern that describes a command to include a file
  352. (the default is for C programs).
  353. The |[I| command lists all matches, the |[_CTRL-I| command jumps to
  354. a match.
  355. The |[d|, |[D| and |[_CTRL-D| commands do the same, but only for
  356. lines where the pattern given with the 'define' option matches.
  357. Automatic commands. |autocommand|
  358. Commands can be automatically executed when reading a file, writing a
  359. file, jumping to another buffer, etc., depending on the file name.
  360. This is useful to set options and mappings for C programs,
  361. documentation, plain text, e-mail, etc. This also makes it possible
  362. to edit compressed files.
  363. Scripts and Expressions. |expression|
  364. Commands have been added to form up a powerful script language.
  365. |:if| Conditional execution, which can be used for example
  366. to set options depending on the value of $TERM.
  367. |:while| Repeat a number of commands.
  368. |:for| Loop over a list.
  369. |:echo| Print the result of an expression.
  370. |:let| Assign a value to an internal variable, option, etc.
  371. Variable types are Number, String, List and Dictionary.
  372. |:execute| Execute a command formed by an expression.
  373. |:try| Catch exceptions.
  374. etc., etc. See |eval|.
  375. Debugging and profiling are supported. |debug-scripts| |profile|
  376. If this is not enough, an interface is provided to |Python|, |Ruby|,
  377. |Tcl|, |Lua|, |Perl| and |MzScheme|.
  378. Viminfo. |viminfo-file|
  379. The command-line history, marks and registers can be stored in a file
  380. that is read on startup. This can be used to repeat a search command
  381. or command-line command after exiting and restarting Vim. It is also
  382. possible to jump right back to where the last edit stopped with |'0|.
  383. The 'viminfo' option can be set to select which items to store in the
  384. .viminfo file. This is off by default.
  385. Printing. |printing|
  386. The |:hardcopy| command sends text to the printer. This can include
  387. syntax highlighting.
  388. Mouse support. |mouse-using|
  389. The mouse is supported in the GUI version, in an xterm for Unix, for
  390. BSDs with sysmouse, for Linux with gpm, and Win32. It can be used to
  391. position the cursor, select the visual area, paste a register, etc.
  392. Usage of key names. |<>| |key-notation|
  393. Special keys now all have a name like <Up>, <End>, etc.
  394. This name can be used in mappings, to make it easy to edit them.
  395. Editing binary files. |edit-binary|
  396. Vim can edit binary files. You can change a few characters in an
  397. executable file, without corrupting it. Vim doesn't remove NUL
  398. characters (they are represented as <NL> internally).
  399. |-b| command-line argument to start editing a binary file
  400. |'binary'| Option set by |-b|. Prevents adding an <EOL> for the
  401. last line in the file.
  402. Multi-language support. |multi-lang|
  403. Files in double-byte or multibyte encodings can be edited. There is
  404. UTF-8 support to be able to edit various languages at the same time,
  405. without switching fonts. |UTF-8|
  406. Messages and menus are available in different languages.
  407. Move cursor beyond lines.
  408. When the 'virtualedit' option is set the cursor can move all over the
  409. screen, also where there is no text. This is useful to edit tables
  410. and figures easily.
  411. ==============================================================================
  412. 5. Other vim features *other-features*
  413. A random collection of nice extra features.
  414. When Vim is started with "-s scriptfile", the characters read from
  415. "scriptfile" are treated as if you typed them. If end of file is reached
  416. before the editor exits, further characters are read from the console.
  417. The "-w" option can be used to record all typed characters in a script file.
  418. This file can then be used to redo the editing, possibly on another file or
  419. after changing some commands in the script file.
  420. The "-o" option opens a window for each argument. "-o4" opens four windows.
  421. Vi requires several termcap entries to be able to work full-screen. Vim only
  422. requires the "cm" entry (cursor motion).
  423. In command mode:
  424. When the 'showcmd' option is set, the command characters are shown in the last
  425. line of the screen. They are removed when the command is finished.
  426. If the 'ruler' option is set, the current cursor position is shown in the
  427. last line of the screen.
  428. "U" still works after having moved off the last changed line and after "u".
  429. Characters with the 8th bit set are displayed. The characters between '~' and
  430. 0xa0 are displayed as "~?", "~@", "~A", etc., unless they are included in the
  431. 'isprint' option.
  432. "][" goes to the next ending of a C function ('}' in column 1).
  433. "[]" goes to the previous ending of a C function ('}' in column 1).
  434. "]f", "[f" and "gf" start editing the file whose name is under the cursor.
  435. CTRL-W f splits the window and starts editing the file whose name is under
  436. the cursor.
  437. "*" searches forward for the identifier under the cursor, "#" backward.
  438. "K" runs the program defined by the 'keywordprg' option, with the identifier
  439. under the cursor as argument.
  440. "%" can be preceded with a count. The cursor jumps to the line that
  441. percentage down in the file. The normal "%" function to jump to the matching
  442. brace skips braces inside quotes.
  443. With the CTRL-] command, the cursor may be in the middle of the identifier.
  444. The used tags are remembered. Commands that can be used with the tag stack
  445. are CTRL-T, ":pop" and ":tag". ":tags" lists the tag stack.
  446. Vi uses 'wrapscan' when searching for a tag. When jumping to a tag Vi starts
  447. searching in line 2 of another file. It does not find a tag in line 1 of
  448. another file when 'wrapscan' is not set.
  449. The 'tags' option can be set to a list of tag file names. Thus multiple
  450. tag files can be used. For file names that start with "./", the "./" is
  451. replaced with the path of the current file. This makes it possible to use a
  452. tags file in the same directory as the file being edited.
  453. {Vi: always uses binary search in some versions}
  454. {Vi does not have the security prevention for commands in tag files}
  455. Previously used file names are remembered in the alternate file name list.
  456. CTRL-^ accepts a count, which is an index in this list.
  457. ":files" command shows the list of alternate file names.
  458. "#<N>" is replaced with the <N>th alternate file name in the list.
  459. "#<" is replaced with the current file name without extension.
  460. Search patterns have more features. The <NL> character is seen as part of the
  461. search pattern and the substitute string of ":s". Vi sees it as the end of
  462. the command.
  463. Searches can put the cursor on the end of a match and may include a character
  464. offset.
  465. Count added to "~", ":next", ":Next", "n" and "N".
  466. The command ":next!" with 'autowrite' set does not write the file. In vi the
  467. file was written, but this is considered to be a bug, because one does not
  468. expect it and the file is not written with ":rewind!".
  469. In Vi when entering a <CR> in replace mode deletes a character only when 'ai'
  470. is set (but does not show it until you hit <Esc>). Vim always deletes a
  471. character (and shows it immediately).
  472. Added :wnext command. Same as ":write" followed by ":next".
  473. The ":w!" command always writes, also when the file is write protected. In Vi
  474. you would have to do ":!chmod +w %:S" and ":set noro".
  475. When 'tildeop' has been set, "~" is an operator (must be followed by a
  476. movement command).
  477. With the "J" (join) command you can reset the 'joinspaces' option to have only
  478. one space after a period (Vi inserts two spaces).
  479. "cw" can be used to change white space formed by several characters (Vi is
  480. confusing: "cw" only changes one space, while "dw" deletes all white space).
  481. {Vi: "cw" when on a blank followed by other blanks changes only the first
  482. blank; this is probably a bug, because "dw" deletes all the blanks}
  483. "o" and "O" accept a count for repeating the insert (Vi clears a part of
  484. display).
  485. Flags after Ex commands not supported (no plans to include it).
  486. On non-UNIX systems ":cd" command shows current directory instead of going to
  487. the home directory (there isn't one). ":pwd" prints the current directory on
  488. all systems.
  489. After a ":cd" command the file names (in the argument list, opened files)
  490. still point to the same files. In Vi ":cd" is not allowed in a changed file;
  491. otherwise the meaning of file names change.
  492. ":source!" command reads Vi commands from a file.
  493. ":mkexrc" command writes current modified options and mappings to a ".exrc"
  494. file. ":mkvimrc" writes to a ".vimrc" file.
  495. No check for "tail recursion" with mappings. This allows things like
  496. ":map! foo ^]foo".
  497. When a mapping starts with number, vi loses the count typed before it (e.g.
  498. when using the mapping ":map g 4G" the command "7g" goes to line 4). This is
  499. considered a vi bug. Vim concatenates the counts (in the example it becomes
  500. "74G"), as most people would expect.
  501. The :put! command inserts the contents of a register above the current line.
  502. The "p" and "P" commands of vi cannot be repeated with "." when the putted
  503. text is less than a line. In Vim they can always be repeated.
  504. ":noremap" command can be used to enter a mapping that will not be remapped.
  505. This is useful to exchange the meaning of two keys. ":cmap", ":cunmap" and
  506. ":cnoremap" can be used for mapping in command-line editing only. ":imap",
  507. ":iunmap" and ":inoremap" can be used for mapping in insert mode only.
  508. Similar commands exist for abbreviations: ":noreabbrev", ":iabbrev"
  509. ":cabbrev", ":iunabbrev", ":cunabbrev", ":inoreabbrev", ":cnoreabbrev".
  510. In Vi the command ":map foo bar" would remove a previous mapping
  511. ":map bug foo". This is considered a bug, so it is not included in Vim.
  512. ":unmap! foo" does remove ":map! bug foo", because unmapping would be very
  513. difficult otherwise (this is vi compatible).
  514. The ':' register contains the last command-line.
  515. The '%' register contains the current file name.
  516. The '.' register contains the last inserted text.
  517. ":dis" command shows the contents of the yank registers.
  518. CTRL-O/CTRL-I can be used to jump to older/newer positions. These are the
  519. same positions as used with the '' command, but may be in another file. The
  520. ":jumps" command lists the older positions.
  521. If the 'shiftround' option is set, an indent is rounded to a multiple of
  522. 'shiftwidth' with ">" and "<" commands.
  523. The 'scrolljump' option can be set to the minimum number of lines to scroll
  524. when the cursor gets off the screen. Use this when scrolling is slow.
  525. The 'scrolloff' option can be set to the minimum number of lines to keep
  526. above and below the cursor. This gives some context to where you are
  527. editing. When set to a large number the cursor line is always in the middle
  528. of the window.
  529. Uppercase marks can be used to jump between files. The ":marks" command lists
  530. all currently set marks. The commands "']" and "`]" jump to the end of the
  531. previous operator or end of the text inserted with the put command. "'[" and
  532. "`[" do jump to the start. {Vi: no uppercase marks}
  533. The 'shelltype' option can be set to reflect the type of shell used on the
  534. Amiga.
  535. The 'highlight' option can be set for the highlight mode to be used for
  536. several commands.
  537. The CTRL-A (add) and CTRL-X (subtract) commands are new. The count to the
  538. command (default 1) is added to/subtracted from the number at or after the
  539. cursor. That number may be decimal, octal (starts with a '0') or hexadecimal
  540. (starts with '0x'). Very useful in macros.
  541. With the :set command the prefix "inv" can be used to invert boolean options.
  542. In both Vi and Vim you can create a line break with the ":substitute" command
  543. by using a CTRL-M. For Vi this means you cannot insert a real CTRL-M in the
  544. text. With Vim you can put a real CTRL-M in the text by preceding it with a
  545. CTRL-V.
  546. In Insert mode:
  547. If the 'revins' option is set, insert happens backwards. This is for typing
  548. Hebrew. When inserting normal characters the cursor will not be shifted and
  549. the text moves rightwards. Backspace, CTRL-W and CTRL-U will also work in
  550. the opposite direction. CTRL-B toggles the 'revins' option. In replace mode
  551. 'revins' has no effect. Only when enabled at compile time.
  552. The backspace key can be used just like CTRL-D to remove auto-indents.
  553. You can backspace, CTRL-U and CTRL-W over line breaks if the 'backspace' (bs)
  554. option includes "eol". You can backspace over the start of insert if the
  555. 'backspace' option includes "start".
  556. When the 'paste' option is set, a few options are reset and mapping in insert
  557. mode and abbreviation are disabled. This allows for pasting text in windowing
  558. systems without unexpected results. When the 'paste' option is reset, the old
  559. option values are restored.
  560. CTRL-T/CTRL-D always insert/delete an indent in the current line, no matter
  561. what column the cursor is in.
  562. CTRL-@ (insert previously inserted text) works always (Vi: only when typed as
  563. first character).
  564. CTRL-A works like CTRL-@ but does not leave insert mode.
  565. CTRL-R {register} can be used to insert the contents of a register.
  566. When the 'smartindent' option is set, C programs will be better auto-indented.
  567. With 'cindent' even more.
  568. CTRL-Y and CTRL-E can be used to copy a character from above/below the
  569. current cursor position.
  570. After CTRL-V you can enter a three digit decimal number. This byte value is
  571. inserted in the text as a single character. Useful for international
  572. characters that are not on your keyboard.
  573. When the 'expandtab' (et) option is set, a <Tab> is expanded to the
  574. appropriate number of spaces.
  575. The window always reflects the contents of the buffer (Vi does not do this
  576. when changing text and in some other cases).
  577. If Vim is compiled with DIGRAPHS defined, digraphs are supported. A set of
  578. normal digraphs is included. They are shown with the ":digraph" command.
  579. More can be added with ":digraph {char1}{char2} {number}". A digraph is
  580. entered with "CTRL-K {char1} {char2}" or "{char1} BS {char2}" (only when
  581. 'digraph' option is set).
  582. When repeating an insert, e.g. "10atest <Esc>" vi would only handle wrapmargin
  583. for the first insert. Vim does it for all.
  584. A count to the "i" or "a" command is used for all the text. Vi uses the count
  585. only for one line. "3iabc<NL>def<Esc>" would insert "abcabcabc<NL>def" in Vi
  586. but "abc<NL>defabc<NL>defabc<NL>def" in Vim.
  587. In Command-line mode:
  588. <Esc> terminates the command-line without executing it. In vi the command
  589. line would be executed, which is not what most people expect (hitting <Esc>
  590. should always get you back to command mode). To avoid problems with some
  591. obscure macros, an <Esc> in a macro will execute the command. If you want a
  592. typed <Esc> to execute the command like vi does you can fix this with
  593. ":cmap ^V<Esc> ^V<CR>"
  594. General:
  595. The 'ttimeout' option is like 'timeout', but only works for cursor and
  596. function keys, not for ordinary mapped characters. The 'timeoutlen' option
  597. gives the number of milliseconds that is waited for. If the 'esckeys' option
  598. is not set, cursor and function keys that start with <Esc> are not recognized
  599. in insert mode.
  600. There is an option for each terminal string. Can be used when termcap is not
  601. supported or to change individual strings.
  602. The 'fileformat' option can be set to select the <EOL>: "dos" <CR><NL>, "unix"
  603. <NL> or "mac" <CR>.
  604. When the 'fileformats' option is not empty, Vim tries to detect the type of
  605. <EOL> automatically. The 'fileformat' option is set accordingly.
  606. On systems that have no job control (older Unix systems and non-Unix systems)
  607. the CTRL-Z, ":stop" or ":suspend" command starts a new shell.
  608. If Vim is started on the Amiga without an interactive window for output, a
  609. window is opened (and :sh still works). You can give a device to use for
  610. editing with the |-d| argument, e.g. "-d con:20/20/600/150".
  611. The 'columns' and 'lines' options are used to set or get the width and height
  612. of the display.
  613. Option settings are read from the first and last few lines of the file.
  614. Option 'modelines' determines how many lines are tried (default is 5). Note
  615. that this is different from the Vi versions that can execute any Ex command
  616. in a modeline (a major security problem). |trojan-horse|
  617. If the 'insertmode' option is set (e.g. in .exrc), Vim starts in insert mode.
  618. And it comes back there, when pressing <Esc>.
  619. Undo information is kept in memory. Available memory limits the number and
  620. size of change that can be undone. This is hardly a problem on the Amiga and
  621. almost never with Unix and Win32.
  622. If the 'backup' or 'writebackup' option is set: Before a file is overwritten,
  623. a backup file (.bak) is made. If the "backup" option is set it is left
  624. behind.
  625. Vim creates a file ending in ".swp" to store parts of the file that have been
  626. changed or that do not fit in memory. This file can be used to recover from
  627. an aborted editing session with "vim -r file". Using the swap file can be
  628. switched off by setting the 'updatecount' option to 0 or starting Vim with
  629. the "-n" option. Use the 'directory' option for placing the .swp file
  630. somewhere else.
  631. Vim is able to work correctly on filesystems with 8.3 file names, also when
  632. using messydos or crossdos filesystems on the Amiga, or any 8.3 mounted
  633. filesystem under Unix. See |'shortname'|.
  634. Error messages are shown at least one second (Vi overwrites error messages).
  635. If Vim gives the |hit-enter| prompt, you can hit any key. Characters other
  636. than <CR>, <NL> and <Space> are interpreted as the (start of) a command.
  637. {Vi: only ":" commands are interpreted}
  638. The contents of the numbered and unnamed registers is remembered when
  639. changing files.
  640. The "No lines in buffer" message is a normal message instead of an error
  641. message, since that may cause a mapping to be aborted.
  642. {Vi: error messages may be overwritten with other messages before you have a
  643. chance to read them}
  644. The AUX: device of the Amiga is supported.
  645. ==============================================================================
  646. 6. Supported Vi features *vi-features*
  647. Vim supports nearly all Vi commands and mostly in the same way. That is when
  648. the 'compatible' option is set and 'cpoptions' contains all flags. What the
  649. effect is of resetting 'compatible' and removing flags from 'cpoptions' can be
  650. found at the help for the specific command.
  651. The help files used to mark features that are in Vim but not in Vi with {not
  652. in Vi}. However, since these remarks cluttered the help files we now do it
  653. the other way around: Below is listed what Vi already supported. Anything
  654. else has been added by Vim.
  655. The following Ex commands are supported by Vi: ~
  656. `:abbreviate` enter abbreviation
  657. `:append` append text
  658. `:args` print the argument list
  659. `:cd` change directory; Vi: no "cd -"
  660. `:change` replace a line or series of lines
  661. `:chdir` change directory
  662. `:copy` copy lines
  663. `:delete` delete lines
  664. `:edit` edit a file
  665. `:exit` same as `:xit`
  666. `:file` show or set the current file name; Vi: without the column number
  667. `:global` execute commands for matching lines
  668. `:insert` insert text
  669. `:join` join lines; Vi: not :join!
  670. `:k` set a mark
  671. `:list` print lines
  672. `:map` show or enter a mapping
  673. `:mark` set a mark
  674. `:move` move lines
  675. `:Next` go to previous file in the argument list {Vi: no count}
  676. `:next` go to next file in the argument list {Vi: no count}
  677. `:number` print lines with line number
  678. `:open` start open mode (not implemented in Vim)
  679. `:pop` jump to older entry in tag stack (only in some versions)
  680. `:preserve` write all text to swap file {Vi: might also exit}
  681. `:previous` same as `:Next` {Vi: only in some versions}
  682. `:print` print lines
  683. `:put` insert contents of register in the text
  684. `:quit` quit Vi
  685. `:read` read file into the text
  686. `:recover` recover a file from a swap file {Vi: recovers in another way
  687. and sends mail if there is something to recover}
  688. `:rewind` go to the first file in the argument list; no ++opt
  689. `:set` set option; but not `:set inv{option}`, `:set option&`,
  690. `:set all&`, `:set option+=value`, `:set option^=value`
  691. `:set option-=value` `:set option<`
  692. `:shell` escape to a shell
  693. `:source` read Vi or Ex commands from a file
  694. `:stop` suspend the editor or escape to a shell
  695. `:substitute` find and replace text; Vi: no '&', 'i', 's', 'r' or 'I' flag,
  696. confirm prompt only supports 'y' and 'n', no highlighting
  697. `:suspend` same as ":stop"
  698. `:t` same as ":copy"
  699. `:tag` jump to tag
  700. `:unabbreviate` remove abbreviation
  701. `:undo` undo last change {Vi: only one level}
  702. `:unmap` remove mapping
  703. `:vglobal` execute commands for not matching lines
  704. `:version` print version number and other info
  705. `:visual` same as ":edit", but turns off "Ex" mode
  706. `:wq` write to a file and quit Vi
  707. `:write` write to a file
  708. `:xit` write if buffer changed and quit Vi
  709. `:yank` yank lines into a register
  710. `:z` print some lines {not in all versions of Vi}
  711. `:!` filter lines or execute an external command
  712. `:"` comment
  713. `:#` same as ":number"
  714. `:*` execute contents of a register
  715. `:&` repeat last ":substitute"
  716. `:<` shift lines one 'shiftwidth' left
  717. `:=` print the cursor line number
  718. `:>` shift lines one 'shiftwidth' right
  719. `:@` execute contents of a register; but not `:@`; `:@@` only in
  720. some versions
  721. Common for these commands is that Vi doesn't support the ++opt argument on
  722. `:edit` and other commands that open a file.
  723. The following Normal mode commands are supported by Vi: ~
  724. note: See the beginning of |normal-index| for the meaning of WORD, N, Nmove
  725. and etc in the description text.
  726. |CTRL-B| scroll N screens Backwards
  727. |CTRL-C| interrupt current (search) command
  728. |CTRL-D| scroll Down N lines (default: half a screen); Vim scrolls
  729. 'scroll' screen lines, Vi scrolls file lines; makes a
  730. difference when lines wrap
  731. |CTRL-E| scroll N lines upwards (N lines Extra)
  732. |CTRL-F| scroll N screens Forward
  733. |CTRL-G| display current file name and position
  734. |<BS>| same as "h"
  735. |CTRL-H| same as "h"
  736. |<NL>| same as "j"
  737. |CTRL-J| same as "j"
  738. |CTRL-L| redraw screen
  739. |<CR>| cursor to the first CHAR N lines lower
  740. |CTRL-M| same as <CR>
  741. |CTRL-N| same as "j"
  742. |CTRL-P| same as "k"
  743. |CTRL-R| in some Vi versions: same as CTRL-L
  744. |CTRL-T| jump to N older Tag in tag list
  745. |CTRL-U| N lines Upwards (default: half a screen) {Vi used file lines
  746. while Vim scrolls 'scroll' screen lines; makes a difference
  747. when lines wrap}
  748. |CTRL-Y| scroll N lines downwards
  749. |CTRL-Z| suspend program (or start new shell)
  750. |CTRL-]| :ta to ident under cursor {Vi: identifier after the cursor}
  751. |CTRL-^| edit alternate file {Vi: no count}
  752. |<Space>| same as "l"
  753. |!| filter Nmove text through the {filter} command
  754. |!!| filter N lines through the {filter} command
  755. " use register {a-zA-Z0-9.%#:-"} for next delete, yank or put
  756. (uppercase to append) ({.%#:} only work with put)
  757. |$| cursor to the end of Nth next line
  758. |%| find the next (curly/square) bracket on this line and go to
  759. its match, or go to matching comment bracket, or go to
  760. matching preprocessor directive (Vi: no count supported)
  761. |&| repeat last :s
  762. |'| jump to mark (Vi: only lowercase marks)
  763. |(| cursor N sentences backward
  764. |)| cursor N sentences forward
  765. |+| same as <CR>
  766. |,| repeat latest f, t, F or T in opposite direction N times
  767. |-| cursor to the first CHAR N lines higher
  768. |.| repeat last change with count replaced with N
  769. |/| search forward for the Nth occurrence of {pattern}
  770. |0| cursor to the first char of the line
  771. |:| start entering an Ex command
  772. |;| repeat latest f, t, F or T N times
  773. |<| shift Nmove lines one 'shiftwidth' leftwards
  774. |<<| shift N lines one 'shiftwidth' leftwards
  775. |=| filter Nmove lines through "indent"
  776. |==| filter N lines through "indent"
  777. |>| shift Nmove lines one 'shiftwidth' rightwards
  778. |>>| shift N lines one 'shiftwidth' rightwards
  779. |?| search backward for the Nth previous occurrence of {pattern}
  780. |@| execute the contents of register {a-z} N times
  781. {Vi: only named registers}
  782. |@@| repeat the previous @{a-z} N times
  783. |A| append text after the end of the line N times
  784. |B| cursor N WORDS backward
  785. |C| change from the cursor position to the end of the line
  786. |D| delete the characters under the cursor until the end of the
  787. line and N-1 more lines [into register x]; synonym for "d$"
  788. |E| cursor forward to the end of WORD N
  789. |F| cursor to the Nth occurrence of {char} to the left
  790. |G| cursor to line N, default last line
  791. |H| cursor to line N from top of screen
  792. |I| insert text before the first CHAR on the line N times
  793. |J| Join N lines; default is 2
  794. |L| cursor to line N from bottom of screen
  795. |M| cursor to middle line of screen
  796. |N| repeat the latest '/' or '?' N times in opposite direction
  797. |O| begin a new line above the cursor and insert text, repeat N
  798. times {Vi: blank [count] screen lines}
  799. |P| put the text [from register x] before the cursor N times
  800. {Vi: no count}
  801. |Q| switch to "Ex" mode
  802. |R| enter replace mode: overtype existing characters, repeat the
  803. entered text N-1 times
  804. |S| delete N lines [into register x] and start insert; synonym for
  805. "cc".
  806. |T| cursor till after Nth occurrence of {char} to the left
  807. |U| undo all latest changes on one line
  808. {Vi: while not moved off of the last modified line}
  809. |W| cursor N WORDS forward
  810. |X| delete N characters before the cursor [into register x]
  811. |Y| yank N lines [into register x]; synonym for "yy"
  812. |ZZ| store current file if modified, and exit
  813. |[[| cursor N sections backward
  814. |]]| cursor N sections forward
  815. |^| cursor to the first CHAR of the line
  816. |_| cursor to the first CHAR N - 1 lines lower
  817. |`| cursor to the mark {a-zA-Z0-9}
  818. |a| append text after the cursor N times
  819. |b| cursor N words backward
  820. |c| delete Nmove text [into register x] and start insert
  821. |cc| delete N lines [into register x] and start insert
  822. |d| delete Nmove text [into register x]
  823. |dd| delete N lines [into register x]
  824. |e| cursor forward to the end of word N
  825. |f| cursor to Nth occurrence of {char} to the right
  826. |h| cursor N chars to the left
  827. |i| insert text before the cursor N times
  828. |j| cursor N lines downward
  829. |k| cursor N lines upward
  830. |l| cursor N chars to the right
  831. |m| set mark {A-Za-z} at cursor position
  832. |n| repeat the latest '/' or '?' N times
  833. |o| begin a new line below the cursor and insert text
  834. {Vi: blank [count] screen lines}
  835. |p| put the text [from register x] after the cursor N times
  836. {Vi: no count}
  837. |r| replace N chars with {char} {Vi: CTRL-V <CR> still replaces
  838. with a line break, cannot replace something with a <CR>}
  839. |s| (substitute) delete N characters [into register x] and start
  840. insert
  841. |t| cursor till before Nth occurrence of {char} to the right
  842. |u| undo changes {Vi: only one level}
  843. |w| cursor N words forward
  844. |x| delete N characters under and after the cursor [into register
  845. x]
  846. |y| yank Nmove text [into register x]
  847. |yy| yank N lines [into register x]
  848. |z<CR>| current line to the top
  849. |z-| current line to the bottom
  850. |z+| cursor on line N
  851. |z^| cursor on line N
  852. |{| cursor N paragraphs backward
  853. | cursor to column N
  854. |}| cursor N paragraphs forward
  855. |~| switch case of N characters under the cursor; Vim: depends on
  856. 'tildeop' {Vi: no count, no 'tildeop'}
  857. |<Del>| same as "x"
  858. The following commands are supported in Insert mode by Vi: ~
  859. CTRL-@ insert previously inserted text and stop insert
  860. {Vi: only when typed as first char, only up to 128 chars}
  861. CTRL-C quit insert mode, without checking for abbreviation, unless
  862. 'insertmode' set.
  863. CTRL-D delete one shiftwidth of indent in the current line
  864. {Vi: CTRL-D works only when used after autoindent}
  865. <BS> delete character before the cursor {Vi: does not delete
  866. autoindents, does not cross lines, does not delete past start
  867. position of insert}
  868. CTRL-H same as <BS>
  869. <Tab> insert a <Tab> character
  870. CTRL-I same as <Tab>
  871. <NL> same as <CR>
  872. CTRL-J same as <CR>
  873. <CR> begin new line
  874. CTRL-M same as <CR>
  875. CTRL-T insert one shiftwidth of indent in current line {Vi: only when
  876. in indent}
  877. CTRL-V {char} insert next non-digit literally {Vi: no decimal byte entry}
  878. CTRL-W delete word before the cursor
  879. CTRL-Z when 'insertmode' set: suspend Vi
  880. <Esc> end insert mode (unless 'insertmode' set)
  881. CTRL-[ same as <Esc>
  882. 0 CTRL-D delete all indent in the current line
  883. ^ CTRL-D delete all indent in the current line, restore it in the next
  884. line
  885. <Del> delete character under the cursor
  886. The following options are supported by Vi: ~
  887. 'autoindent' 'ai' take indent for new line from previous line
  888. {Vi does this slightly differently: After the
  889. indent is deleted when typing <Esc> or <CR>, the
  890. cursor position when moving up or down is after
  891. the deleted indent; Vi puts the cursor somewhere
  892. in the deleted indent}.
  893. 'autowrite' 'aw' automatically write file if changed
  894. 'directory' 'dir' list of directory names for the swap file
  895. {Vi: directory to put temp file in, defaults to
  896. "/tmp"}
  897. 'edcompatible' 'ed' toggle flags of ":substitute" command
  898. 'errorbells' 'eb' ring the bell for error messages
  899. 'ignorecase' 'ic' ignore case in search patterns
  900. 'lines' number of lines in the display
  901. 'lisp' automatic indenting for Lisp {Vi: Does it a little
  902. bit differently}
  903. 'list' show <Tab> and <EOL>
  904. 'magic' changes special characters in search patterns
  905. 'modeline' 'ml' recognize 'modelines' at start or end of file
  906. {called modelines in some Vi versions}
  907. 'number' 'nu' print the line number in front of each line
  908. 'paragraphs' 'para' nroff macros that separate paragraphs
  909. 'prompt' 'prompt' enable prompt in Ex mode
  910. 'readonly' 'ro' disallow writing the buffer {Vim sets 'readonly'
  911. when editing a file with `:view`}
  912. 'remap' allow mappings to work recursively
  913. 'report' threshold for reporting nr. of lines changed
  914. 'scroll' 'scr' lines to scroll with CTRL-U and CTRL-D
  915. 'sections' 'sect' nroff macros that separate sections
  916. 'shell' 'sh' name of shell to use for external commands
  917. 'shiftwidth' 'sw' number of spaces to use for (auto)indent step
  918. 'showmatch' 'sm' briefly jump to matching bracket if insert one
  919. 'showmode' 'smd' message on status line to show current mode
  920. 'tabstop' 'ts' number of spaces that <Tab> in file uses
  921. 'taglength' 'tl' number of significant characters for a tag
  922. 'tags' 'tag' list of file names used by the tag command
  923. {Vi: default is "tags /usr/lib/tags"}
  924. 'tagstack' 'tgst' push tags onto the tag stack {not in all versions
  925. of Vi}
  926. 'term' name of the terminal
  927. 'terse' shorten some messages
  928. 'timeout' 'to' time out on mappings and key codes
  929. 'timeoutlen' 'tm' time for 'timeout' {only in some Vi versions}
  930. 'ttytype' 'tty' alias for 'term'
  931. 'verbose' 'vbs' give informative messages {only in some Vi
  932. versions as a boolean option}
  933. 'warn' warn for shell command when buffer was changed
  934. 'window' 'wi' nr of lines to scroll for CTRL-F and CTRL-B
  935. {Vi also uses the option to specify the number of
  936. displayed lines}
  937. 'wrapmargin' 'wm' chars from the right where wrapping starts
  938. {Vi: works differently and less usefully}
  939. 'wrapscan' 'ws' searches wrap around the end of the file
  940. 'writeany' 'wa' write to file with no need for "!" override
  941. Also see |missing-options|.
  942. ==============================================================================
  943. 7. Command-line arguments *cmdline-arguments*
  944. Different versions of Vi have different command-line arguments. This can be
  945. confusing. To help you, this section gives an overview of the differences.
  946. Five variants of Vi will be considered here:
  947. Elvis Elvis version 2.1b
  948. Nvi Nvi version 1.79
  949. Posix Posix 1003.2
  950. Vi Vi version 3.7 (for Sun 4.1.x)
  951. Vile Vile version 7.4 (incomplete)
  952. Vim Vim version 5.2
  953. Only Vim is able to accept options in between and after the file names.
  954. +{command} Elvis, Nvi, Posix, Vi, Vim: Same as "-c {command}".
  955. - Nvi, Posix, Vi: Run Ex in batch mode.
  956. Vim: Read file from stdin (use -s for batch mode).
  957. -- Vim: End of options, only file names are following.
  958. --cmd {command} Vim: execute {command} before sourcing vimrc files.
  959. --echo-wid Vim: GTK+ echoes the Window ID on stdout
  960. --help Vim: show help message and exit.
  961. --literal Vim: take file names literally, don't expand wildcards.
  962. --nofork Vim: same as |-f|
  963. --noplugin[s] Vim: Skip loading plugins.
  964. --remote Vim: edit the files in another Vim server
  965. --remote-expr {expr} Vim: evaluate {expr} in another Vim server
  966. --remote-send {keys} Vim: send {keys} to a Vim server and exit
  967. --remote-silent {file} Vim: edit the files in another Vim server if possible
  968. --remote-wait Vim: edit the files in another Vim server and wait for it
  969. --remote-wait-silent Vim: like --remote-wait, no complaints if not possible
  970. --role {role} Vim: GTK+ 2: set role of main window
  971. --serverlist Vim: Output a list of Vim servers and exit
  972. --servername {name} Vim: Specify Vim server name
  973. --socketid {id} Vim: GTK window socket to run Vim in
  974. --windowid {id} Vim: Win32 window ID to run Vim in
  975. --version Vim: show version message and exit.
  976. -? Vile: print usage summary and exit.
  977. -a Elvis: Load all specified file names into a window (use -o for
  978. Vim).
  979. -A Vim: Start in Arabic mode (when compiled with Arabic).
  980. -b {blksize} Elvis: Use {blksize} blocksize for the session file.
  981. -b Vim: set 'binary' mode.
  982. -C Vim: Compatible mode.
  983. -c {command} Elvis, Nvi, Posix, Vim: run {command} as an Ex command after
  984. loading the edit buffer.
  985. Vim: allow up to 10 "-c" arguments
  986. -d {device} Vim: Use {device} for I/O (Amiga only). {only when compiled
  987. without the |+diff| feature}
  988. -d Vim: start with 'diff' set. |vimdiff|
  989. -dev {device} Vim: Use {device} for I/O (Amiga only).
  990. -D Vim: debug mode.
  991. -e Elvis, Nvi, Vim: Start in Ex mode, as if the executable is
  992. called "ex".
  993. -E Vim: Start in improved Ex mode |gQ|, like "exim".
  994. -f Vim: Run GUI in foreground (Amiga: don't open new window).
  995. -f {session} Elvis: Use {session} as the session file.
  996. -F Vim: Start in Farsi mode (when compiled with Farsi).
  997. Nvi: Fast start, don't read the entire file when editing
  998. starts.
  999. -G {gui} Elvis: Use the {gui} as user interface.
  1000. -g Vim: Start GUI.
  1001. -g N Vile: start editing at line N
  1002. -h Vim: Give help message.
  1003. Vile: edit the help file
  1004. -H Vim: start Hebrew mode (when compiled with it).
  1005. -i Elvis: Start each window in Insert mode.
  1006. -i {viminfo} Vim: Use {viminfo} for viminfo file.
  1007. -L Vim: Same as "-r" {only in some versions of Vi: "List
  1008. recoverable edit sessions"}.
  1009. -l Nvi, Vi, Vim: Set 'lisp' and 'showmatch' options.
  1010. -m Vim: Modifications not allowed to be written, resets 'write'
  1011. option.
  1012. -M Vim: Modifications not allowed, resets 'modifiable' and the
  1013. 'write' option.
  1014. -N Vim: No-compatible mode.
  1015. -n Vim: No swap file used.
  1016. -nb[args] Vim: open a NetBeans interface connection
  1017. -O[N] Vim: Like -o, but use vertically split windows.
  1018. -o[N] Vim: Open [N] windows, or one for each file.
  1019. -p[N] Vim: Open [N] tab pages, or one for each file.
  1020. -P {parent-title} Win32 Vim: open Vim inside a parent application window
  1021. -q {name} Vim: Use {name} for quickfix error file.
  1022. -q{name} Vim: Idem.
  1023. -R Elvis, Nvi, Posix, Vile, Vim: Set the 'readonly' option.
  1024. -r Elvis, Nvi, Posix, Vi, Vim: Recovery mode.
  1025. -S Nvi: Set 'secure' option.
  1026. -S {script} Vim: source script after starting up.
  1027. -s Nvi, Posix, Vim: Same as "-" (silent mode), when in Ex mode.
  1028. Elvis: Sets the 'safer' option.
  1029. -s {scriptin} Vim: Read from script file {scriptin}; only when not in Ex
  1030. mode.
  1031. -s {pattern} Vile: search for {pattern}
  1032. -t {tag} Elvis, Nvi, Posix, Vi, Vim: Edit the file containing {tag}.
  1033. -t{tag} Vim: Idem.
  1034. -T {term} Vim: Set terminal name to {term}.
  1035. -u {vimrc} Vim: Read initializations from {vimrc} file.
  1036. -U {gvimrc} Vim: Read GUI initializations from {gvimrc} file.
  1037. -v Nvi, Posix, Vi, Vim: Begin in Normal mode (visual mode, in Vi
  1038. terms).
  1039. Vile: View mode, no changes possible.
  1040. -V Elvis, Vim: Verbose mode.
  1041. -V{nr} Vim: Verbose mode with specified level.
  1042. -w {size} Elvis, Posix, Nvi, Vi, Vim: Set value of 'window' to {size}.
  1043. -w{size} Nvi, Vi: Same as "-w {size}".
  1044. -w {name} Vim: Write to script file {name} (must start with non-digit).
  1045. -W {name} Vim: Append to script file {name}.
  1046. -x Vi, Vim: Ask for encryption key. See |encryption|.
  1047. -X Vim: Don't connect to the X server.
  1048. -y Vim: Start in easy mode, like |evim|.
  1049. -Z Vim: restricted mode
  1050. @{cmdfile} Vile: use {cmdfile} as startup file.
  1051. ==============================================================================
  1052. 8. POSIX compliance *posix* *posix-compliance*
  1053. In 2005 the POSIX test suite was run to check the compatibility of Vim. Most
  1054. of the test was executed properly. There are the few things where Vim
  1055. is not POSIX compliant, even when run in Vi compatibility mode.
  1056. *$VIM_POSIX*
  1057. Set the $VIM_POSIX environment variable to have 'cpoptions' include the POSIX
  1058. flags when Vim starts up. This makes Vim run as POSIX as it can. That's
  1059. a bit different from being Vi compatible.
  1060. You can find the Posix specification for Vi here:
  1061. https://pubs.opengroup.org/onlinepubs/9699919799/utilities/vi.html
  1062. And the related Ex specification:
  1063. https://pubs.opengroup.org/onlinepubs/9699919799/utilities/ex.html
  1064. This is where Vim does not behave as POSIX specifies and why:
  1065. *posix-screen-size*
  1066. The $COLUMNS and $LINES environment variables are ignored by Vim if
  1067. the size can be obtained from the terminal in a more reliable way.
  1068. Add the '|' flag to 'cpoptions' to have $COLUMNS and $LINES overrule
  1069. sizes obtained in another way.
  1070. The "{" and "}" commands don't stop at a "{" in the original Vi, but
  1071. POSIX specifies it does. Add the '{' flag to 'cpoptions' if you want
  1072. it the POSIX way.
  1073. The "D", "o" and "O" commands accept a count. Also when repeated.
  1074. Add the '#' flag to 'cpoptions' if you want to ignore the count.
  1075. The ":cd" command fails if the current buffer is modified when the '.'
  1076. flag is present in 'cpoptions'.
  1077. There is no ATTENTION message, the "A" flag is added to 'shortmess'.
  1078. These are remarks about running the POSIX test suite:
  1079. - vi test 33 sometimes fails for unknown reasons
  1080. - vi test 250 fails; behavior will be changed in a new revision
  1081. http://www.opengroup.org/austin/mailarchives/ag-review/msg01710.html
  1082. (link no longer works, perhaps it's now:
  1083. https://www.opengroup.org/sophocles/show_mail.tpl?CALLER=show_archive.tpl&source=L&listname=austin-review-l&id=1711)
  1084. - vi test 310 fails; exit code non-zero when any error occurred?
  1085. - ex test 24 fails because test is wrong. Changed between SUSv2 and SUSv3.
  1086. - ex tests 47, 48, 49, 72, 73 fail because .exrc file isn't read in silent
  1087. mode and $EXINIT isn't used.
  1088. - ex tests 76, 78 fail because echo is used instead of printf. (fixed)
  1089. Also: problem with \s not changed to space.
  1090. - ex test 355 fails because 'window' isn't used for "30z".
  1091. - ex test 368 fails because shell command isn't echoed in silent mode.
  1092. - ex test 394 fails because "=" command output isn't visible in silent mode.
  1093. - ex test 411 fails because test file is wrong, contains stray ':'.
  1094. - ex test 475 and 476 fail because reprint output isn't visible in silent mode.
  1095. - ex test 480 and 481 fail because the tags file has spaces instead of a tab.
  1096. - ex test 502 fails because .exrc isn't read in silent mode.
  1097. - ex test 509 fails because .exrc isn't read in silent mode. and exit code is
  1098. 1 instead of 2.
  1099. - ex test 534 fails because .exrc isn't read in silent mode.
  1100. vim:tw=78:ts=8:noet:ft=help:norl: