vi_diff.txt 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. *vi_diff.txt* Nvim
  2. VIM REFERENCE MANUAL by Bram Moolenaar
  3. Differences between Vim and Vi *vi-differences*
  4. Type |gO| to see the table of contents.
  5. ==============================================================================
  6. 1. Limits *limits*
  7. Vim has only a few limits for the files that can be edited {Vi: can not handle
  8. <Nul> characters and characters above 128, has limited line length, many other
  9. limits}.
  10. Maximum line length 2147483647 characters
  11. Maximum number of lines 2147483647 lines
  12. Maximum file size 2147483647 bytes (2 Gbyte) when a long integer is
  13. 32 bits. Much more for 64 bit longs. Also limited
  14. by available disk space for the |swap-file|.
  15. *E75*
  16. Length of a file path Unix and Win32: 1024 characters, otherwise 256
  17. characters (or as much as the system supports).
  18. Length of an expanded string option
  19. Unix and Win32: 1024 characters, otherwise 256
  20. characters
  21. Maximum display width Unix and Win32: 1024 characters, otherwise 255
  22. characters
  23. Maximum lhs of a mapping 50 characters.
  24. Number of different highlighting types: over 30000
  25. Range of a Number variable: -2147483648 to 2147483647 (might be more on 64
  26. bit systems)
  27. Maximum length of a line in a tags file: 512 bytes.
  28. Information for undo and text in registers is kept in memory, thus when making
  29. (big) changes the amount of (virtual) memory available limits the number of
  30. undo levels and the text that can be kept in registers. Other things are also
  31. kept in memory: Command-line history, error messages for Quickfix mode, etc.
  32. ==============================================================================
  33. 2. The most interesting additions *vim-additions*
  34. Support for different systems.
  35. Vim can be used on:
  36. - Modern Unix systems (*BSD, Linux, etc.)
  37. - Windows (XP SP 2 or greater)
  38. - OS X
  39. Multi level persistent undo. |undo|
  40. 'u' goes backward in time, 'CTRL-R' goes forward again. Set option
  41. 'undolevels' to the number of changes to be remembered (default 1000).
  42. Set 'undolevels' to 0 for a Vi-compatible one level undo. Set it to
  43. -1 for no undo at all.
  44. When all changes in a buffer have been undone, the buffer is not
  45. considered changed anymore. You can exit it with :q, without <!>.
  46. When undoing a few changes and then making a new change Vim will
  47. create a branch in the undo tree. This means you can go back to any
  48. state of the text, there is no risk of a change causing text to be
  49. lost forever. |undo-tree|
  50. The undo information is stored in a file when the 'undofile' option is
  51. set. This means you can exit Vim, start Vim on a previously edited
  52. file and undo changes that were made before exiting Vim.
  53. Graphical User Interface (GUI). |gui|
  54. Included support for GUI: menu's, mouse, scrollbars, etc. You can
  55. define your own menus. Better support for CTRL/SHIFT/ALT keys in
  56. combination with special keys and mouse. Supported for various
  57. platforms such as Win32.
  58. Multiple windows and buffers. |windows.txt|
  59. Vim can split the screen into several windows, each editing a
  60. different buffer or the same buffer at a different location. Buffers
  61. can still be loaded (and changed) but not displayed in a window. This
  62. is called a hidden buffer. Many commands and options have been added
  63. for this facility.
  64. Vim can also use multiple tab pages, each with one or more windows. A
  65. line with tab labels can be used to quickly switch between these pages.
  66. |tab-page|
  67. Syntax highlighting. |:syntax|
  68. Vim can highlight keywords, patterns and other things. This is
  69. defined by a number of |:syntax| commands, and can be made to
  70. highlight most languages and file types. A number of files are
  71. included for highlighting the most common languages, like C, C++,
  72. Java, Pascal, Makefiles, shell scripts, etc. The colors used for
  73. highlighting can be defined for ordinary terminals, color terminals
  74. and the GUI with the |:highlight| command. A convenient way to do
  75. this is using a |:colorscheme| command.
  76. The highlighted text can be exported as HTML. |convert-to-HTML|
  77. Other items that can be highlighted are matches with the search string
  78. |'hlsearch'|, matching parens |matchparen| and the cursor line and
  79. column |'cursorline'| |'cursorcolumn'|.
  80. Spell checking. |spell|
  81. When the 'spell' option is set Vim will highlight spelling mistakes.
  82. About 50 languages are currently supported, selected with the
  83. 'spelllang' option. In source code only comments and strings are
  84. checked for spelling.
  85. Folding. |folding|
  86. A range of lines can be shown as one "folded" line. This allows
  87. overviewing a file and moving blocks of text around quickly.
  88. Folds can be created manually, from the syntax of the file, by indent,
  89. etc.
  90. Diff mode. |diff-mode|
  91. Vim can show two versions of a file with the differences highlighted.
  92. Parts of the text that are equal are folded away. Commands can be
  93. used to move text from one version to the other.
  94. Plugins. |add-plugin|
  95. The functionality can be extended by dropping a plugin file in the
  96. right directory. That's an easy way to start using Vim scripts
  97. written by others. Plugins can be for all kind of files, or
  98. specifically for a filetype.
  99. Packages make this even easier. |packages|
  100. Asynchronous communication and timers. |job-control| |timer|
  101. Vim can exchange messages with other processes in the background.
  102. Vim can start a job, communicate with it and stop it. |job-control|
  103. Timers can fire once or repeatedly and invoke a function to do any
  104. work. |timer|
  105. Repeat a series of commands. |q|
  106. "q{c}" starts recording typed characters into named register {c}.
  107. A subsequent "q" stops recording. The register can then be executed
  108. with the "@{c}" command. This is very useful to repeat a complex
  109. action.
  110. Flexible insert mode. |ins-special-special|
  111. The arrow keys can be used in insert mode to move around in the file.
  112. This breaks the insert in two parts as far as undo and redo is
  113. concerned.
  114. CTRL-O can be used to execute a single Normal mode command. This is
  115. almost the same as hitting <Esc>, typing the command and doing |a|.
  116. Visual mode. |Visual-mode|
  117. Visual mode can be used to first highlight a piece of text and then
  118. give a command to do something with it. This is an (easy to use)
  119. alternative to first giving the operator and then moving to the end of
  120. the text to be operated upon.
  121. |v| and |V| are used to start Visual mode. |v| works on characters
  122. and |V| on lines. Move the cursor to extend the Visual area. It is
  123. shown highlighted on the screen. By typing "o" the other end of the
  124. Visual area can be moved. The Visual area can be affected by an
  125. operator:
  126. d delete
  127. c change
  128. y yank
  129. > or < insert or delete indent
  130. ! filter through external program
  131. = filter through indent
  132. : start |:| command for the Visual lines.
  133. gq format text to 'textwidth' columns
  134. J join lines
  135. ~ swap case
  136. u make lowercase
  137. U make uppercase
  138. Block operators. |visual-block|
  139. With Visual mode a rectangular block of text can be selected. Start
  140. Visual mode with CTRL-V. The block can be deleted ("d"), yanked ("y")
  141. or its case can be changed ("~", "u" and "U"). A deleted or yanked
  142. block can be put into the text with the "p" and "P" commands.
  143. Help system. |:help|
  144. Help is displayed in a window. The usual commands can be used to
  145. move around, search for a string, etc. Tags can be used to jump
  146. around in the help files, just like hypertext links. The |:help|
  147. command takes an argument to quickly jump to the info on a subject.
  148. <F1> is the quick access to the help system. The name of the help
  149. index file can be set with the 'helpfile' option.
  150. Command-line editing and history. |cmdline-editing|
  151. You can insert or delete at any place in the command-line using the
  152. cursor keys. The right/left cursor keys can be used to move
  153. forward/backward one character. The shifted right/left cursor keys
  154. can be used to move forward/backward one word. CTRL-B/CTRL-E can be
  155. used to go to the begin/end of the command-line.
  156. {Vi: can only alter the last character in the line}
  157. {Vi: when hitting <Esc> the command-line is executed. This is
  158. unexpected for most people; therefore it was changed in Vim. But when
  159. the <Esc> is part of a mapping, the command-line is executed. If you
  160. want the Vi behaviour also when typing <Esc>, use ":cmap ^V<Esc>
  161. ^V^M"}
  162. |cmdline-history|
  163. The command-lines are remembered. The up/down cursor keys can be used
  164. to recall previous command-lines. The 'history' option can be set to
  165. the number of lines that will be remembered. There is a separate
  166. history for commands and for search patterns.
  167. Command-line completion. |cmdline-completion|
  168. While entering a command-line (on the bottom line of the screen)
  169. <Tab> can be typed to complete
  170. what example ~
  171. - command :e<Tab>
  172. - tag :ta scr<Tab>
  173. - option :set sc<Tab>
  174. - option value :set hf=<Tab>
  175. - file name :e ve<Tab>
  176. - etc.
  177. If there are multiple matches, CTRL-N (next) and CTRL-P (previous)
  178. will walk through the matches. <Tab> works like CTRL-N, but wraps
  179. around to the first match.
  180. The 'wildchar' option can be set to the character for command-line
  181. completion, <Tab> is the default. CTRL-D can be typed after an
  182. (incomplete) wildcard; all matches will be listed. CTRL-A will insert
  183. all matches. CTRL-L will insert the longest common part of the
  184. matches.
  185. Insert-mode completion. |ins-completion|
  186. In Insert mode the CTRL-N and CTRL-P keys can be used to complete a
  187. word that appears elsewhere. |i_CTRL-N|
  188. With CTRL-X another mode is entered, through which completion can be
  189. done for:
  190. |i_CTRL-X_CTRL-F| file names
  191. |i_CTRL-X_CTRL-K| words from 'dictionary' files
  192. |i_CTRL-X_CTRL-T| words from 'thesaurus' files
  193. |i_CTRL-X_CTRL-I| words from included files
  194. |i_CTRL-X_CTRL-L| whole lines
  195. |i_CTRL-X_CTRL-]| words from the tags file
  196. |i_CTRL-X_CTRL-D| definitions or macros
  197. |i_CTRL-X_CTRL-O| Omni completion: clever completion
  198. specifically for a file type
  199. etc.
  200. Long line support. |'wrap'| |'linebreak'|
  201. If the 'wrap' option is off, long lines will not wrap and only part
  202. of them will be shown. When the cursor is moved to a part that is not
  203. shown, the screen will scroll horizontally. The minimum number of
  204. columns to scroll can be set with the 'sidescroll' option. The |zh|
  205. and |zl| commands can be used to scroll sideways.
  206. Alternatively, long lines are broken in between words when the
  207. 'linebreak' option is set. This allows editing a single-line
  208. paragraph conveniently (e.g. when the text is later read into a DTP
  209. program). Move the cursor up/down with the |gk| and |gj| commands.
  210. Text formatting. |formatting|
  211. The 'textwidth' option can be used to automatically limit the line
  212. length. This supplements the 'wrapmargin' option of Vi, which was not
  213. very useful. The |gq| operator can be used to format a piece of text
  214. (for example, |gqap| formats the current paragraph). Commands for
  215. text alignment: |:center|, |:left| and |:right|.
  216. Extended search patterns. |pattern|
  217. There are many extra items to match various text items. Examples:
  218. A "\n" can be used in a search pattern to match a line break.
  219. "x\{2,4}" matches "x" 2 to 4 times.
  220. "\s" matches a white space character.
  221. Directory, remote and archive browsing. |netrw|
  222. Vim can browse the file system. Simply edit a directory. Move around
  223. in the list with the usual commands and press <Enter> to go to the
  224. directory or file under the cursor.
  225. This also works for remote files over ftp, http, ssh, etc.
  226. Zip and tar archives can also be browsed. |tar| |zip|
  227. Edit-compile-edit speedup. |quickfix|
  228. The |:make| command can be used to run the compilation and jump to the
  229. first error. A file with compiler error messages is interpreted. Vim
  230. jumps to the first error.
  231. Each line in the error file is scanned for the name of a file, line
  232. number and error message. The 'errorformat' option can be set to a
  233. list of scanf-like strings to handle output from many compilers.
  234. The |:cn| command can be used to jump to the next error.
  235. |:cl| lists all the error messages. Other commands are available.
  236. The 'makeef' option has the name of the file with error messages.
  237. The 'makeprg' option contains the name of the program to be executed
  238. with the |:make| command.
  239. The 'shellpipe' option contains the string to be used to put the
  240. output of the compiler into the errorfile.
  241. Finding matches in files. |:vimgrep|
  242. Vim can search for a pattern in multiple files. This uses the
  243. advanced Vim regexp pattern, works on all systems and also works to
  244. search in compressed files.
  245. Improved indenting for programs. |'cindent'|
  246. When the 'cindent' option is on the indent of each line is
  247. automatically adjusted. C syntax is mostly recognized. The indent
  248. for various styles can be set with 'cinoptions'. The keys to trigger
  249. indenting can be set with 'cinkeys'.
  250. Comments can be automatically formatted. The 'comments' option can be
  251. set to the characters that start and end a comment. This works best
  252. for C code, but also works for e-mail (">" at start of the line) and
  253. other types of text. The |=| operator can be used to re-indent
  254. lines.
  255. For many other languages an indent plugin is present to support
  256. automatic indenting. |30.3|
  257. Searching for words in included files. |include-search|
  258. The |[i| command can be used to search for a match of the word under
  259. the cursor in the current and included files. The 'include' option
  260. can be set to a pattern that describes a command to include a file
  261. (the default is for C programs).
  262. The |[I| command lists all matches, the |[_CTRL-I| command jumps to
  263. a match.
  264. The |[d|, |[D| and |[_CTRL-D| commands do the same, but only for
  265. lines where the pattern given with the 'define' option matches.
  266. Automatic commands. |autocommand|
  267. Commands can be automatically executed when reading a file, writing a
  268. file, jumping to another buffer, etc., depending on the file name.
  269. This is useful to set options and mappings for C programs,
  270. documentation, plain text, e-mail, etc. This also makes it possible
  271. to edit compressed files.
  272. Scripts and Expressions. |expression|
  273. Commands have been added to form up a powerful script language.
  274. |:if| Conditional execution, which can be used for example
  275. to set options depending on the value of $TERM.
  276. |:while| Repeat a number of commands.
  277. |:for| Loop over a list.
  278. |:echo| Print the result of an expression.
  279. |:let| Assign a value to an internal variable, option, etc.
  280. Variable types are Number, String, List and Dictionary.
  281. |:execute| Execute a command formed by an expression.
  282. |:try| Catch exceptions.
  283. etc., etc. See |eval|.
  284. Debugging and profiling are supported. |debug-scripts| |profile|
  285. If this is not enough, an interface is provided to |Python|.
  286. Viminfo.
  287. The command-line history, marks and registers can be stored in a file
  288. that is read on startup. This can be used to repeat a search command
  289. or command-line command after exiting and restarting Vim. It is also
  290. possible to jump right back to where the last edit stopped with |'0|.
  291. The 'viminfo' option can be set to select which items to store in the
  292. .viminfo file. This is off by default.
  293. Printing. |printing|
  294. The |:hardcopy| command sends text to the printer. This can include
  295. syntax highlighting.
  296. Mouse support. |mouse-using|
  297. The mouse is supported in the GUI version, in an xterm for Unix, for
  298. BSDs with sysmouse, for Linux with gpm, and for Win32. It can be used
  299. to position the cursor, select the visual area, paste a register, etc.
  300. Usage of key names. |<>| |key-notation|
  301. Special keys now all have a name like <Up>, <End>, etc.
  302. This name can be used in mappings, to make it easy to edit them.
  303. Editing binary files. |edit-binary|
  304. Vim can edit binary files. You can change a few characters in an
  305. executable file, without corrupting it. Vim doesn't remove NUL
  306. characters (they are represented as <NL> internally).
  307. |-b| command-line argument to start editing a binary file
  308. |'binary'| Option set by |-b|. Prevents adding an <EOL> for the
  309. last line in the file.
  310. Multi-language support. |multi-lang|
  311. Files in double-byte or multibyte encodings can be edited. There is
  312. UTF-8 support to be able to edit various languages at the same time,
  313. without switching fonts. |UTF-8|
  314. Messages and menus are available in different languages.
  315. Move cursor beyond lines.
  316. When the 'virtualedit' option is set the cursor can move all over the
  317. screen, also where there is no text. This is useful to edit tables
  318. and figures easily.
  319. vim:tw=78:ts=8:noet:ft=help:norl: