vim.man 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  1. VIM(1) General Commands Manual VIM(1)
  2. NAME
  3. vim - Vi IMproved, a programmer's text editor
  4. SYNOPSIS
  5. vim [options] [file ..]
  6. vim [options] -
  7. vim [options] -t tag
  8. vim [options] -q [errorfile]
  9. ex
  10. view
  11. gvim gview evim eview
  12. rvim rview rgvim rgview
  13. DESCRIPTION
  14. Vim is a text editor that is upwards compatible to Vi. It can be used
  15. to edit all kinds of plain text. It is especially useful for editing
  16. programs.
  17. There are a lot of enhancements above Vi: multi level undo, multi win‐
  18. dows and buffers, syntax highlighting, command line editing, filename
  19. completion, on-line help, visual selection, etc.. See ":help
  20. vi_diff.txt" for a summary of the differences between Vim and Vi.
  21. While running Vim a lot of help can be obtained from the on-line help
  22. system, with the ":help" command. See the ON-LINE HELP section below.
  23. Most often Vim is started to edit a single file with the command
  24. vim file
  25. More generally Vim is started with:
  26. vim [options] [filelist]
  27. If the filelist is missing, the editor will start with an empty buffer.
  28. Otherwise exactly one out of the following four may be used to choose
  29. one or more files to be edited.
  30. file .. A list of filenames. The first one will be the current
  31. file and read into the buffer. The cursor will be posi‐
  32. tioned on the first line of the buffer. You can get to the
  33. other files with the ":next" command. To edit a file that
  34. starts with a dash, precede the filelist with "--".
  35. - The file to edit is read from stdin. Commands are read
  36. from stderr, which should be a tty.
  37. -t {tag} The file to edit and the initial cursor position depends on
  38. a "tag", a sort of goto label. {tag} is looked up in the
  39. tags file, the associated file becomes the current file and
  40. the associated command is executed. Mostly this is used
  41. for C programs, in which case {tag} could be a function
  42. name. The effect is that the file containing that function
  43. becomes the current file and the cursor is positioned on
  44. the start of the function. See ":help tag-commands".
  45. -q [errorfile]
  46. Start in quickFix mode. The file [errorfile] is read and
  47. the first error is displayed. If [errorfile] is omitted,
  48. the filename is obtained from the 'errorfile' option (de‐
  49. faults to "AztecC.Err" for the Amiga, "errors.err" on other
  50. systems). Further errors can be jumped to with the ":cn"
  51. command. See ":help quickfix".
  52. Vim behaves differently, depending on the name of the command (the exe‐
  53. cutable may still be the same file).
  54. vim The "normal" way, everything is default.
  55. ex Start in Ex mode. Go to Normal mode with the ":vi" command.
  56. Can also be done with the "-e" argument.
  57. view Start in read-only mode. You will be protected from writing
  58. the files. Can also be done with the "-R" argument.
  59. gvim gview
  60. The GUI version. Starts a new window. Can also be done with
  61. the "-g" argument.
  62. evim eview
  63. The GUI version in easy mode. Starts a new window. Can also
  64. be done with the "-y" argument.
  65. rvim rview rgvim rgview
  66. Like the above, but with restrictions. It will not be possi‐
  67. ble to start shell commands, or suspend Vim. Can also be
  68. done with the "-Z" argument.
  69. OPTIONS
  70. The options may be given in any order, before or after filenames. Op‐
  71. tions without an argument can be combined after a single dash.
  72. +[num] For the first file the cursor will be positioned on line
  73. "num". If "num" is missing, the cursor will be positioned
  74. on the last line.
  75. +/{pat} For the first file the cursor will be positioned in the
  76. line with the first occurrence of {pat}. See ":help
  77. search-pattern" for the available search patterns.
  78. +{command}
  79. -c {command}
  80. {command} will be executed after the first file has been
  81. read. {command} is interpreted as an Ex command. If the
  82. {command} contains spaces it must be enclosed in double
  83. quotes (this depends on the shell that is used). Example:
  84. vim "+set si" main.c
  85. Note: You can use up to 10 "+" or "-c" commands.
  86. -S {file} {file} will be sourced after the first file has been read.
  87. This is equivalent to -c "source {file}". {file} cannot
  88. start with '-'. If {file} is omitted "Session.vim" is used
  89. (only works when -S is the last argument).
  90. --cmd {command}
  91. Like using "-c", but the command is executed just before
  92. processing any vimrc file. You can use up to 10 of these
  93. commands, independently from "-c" commands.
  94. -A If Vim has been compiled with ARABIC support for editing
  95. right-to-left oriented files and Arabic keyboard mapping,
  96. this option starts Vim in Arabic mode, i.e. 'arabic' is
  97. set. Otherwise an error message is given and Vim aborts.
  98. -b Binary mode. A few options will be set that makes it pos‐
  99. sible to edit a binary or executable file.
  100. -C Compatible. Set the 'compatible' option. This will make
  101. Vim behave mostly like Vi, even though a .vimrc file ex‐
  102. ists.
  103. -d Start in diff mode. There should between two to eight file
  104. name arguments. Vim will open all the files and show dif‐
  105. ferences between them. Works like vimdiff(1).
  106. -d {device} Open {device} for use as a terminal. Only on the Amiga.
  107. Example: "-d con:20/30/600/150".
  108. -D Debugging. Go to debugging mode when executing the first
  109. command from a script.
  110. -e Start Vim in Ex mode, just like the executable was called
  111. "ex".
  112. -E Start Vim in improved Ex mode, just like the executable was
  113. called "exim".
  114. -f Foreground. For the GUI version, Vim will not fork and de‐
  115. tach from the shell it was started in. On the Amiga, Vim
  116. is not restarted to open a new window. This option should
  117. be used when Vim is executed by a program that will wait
  118. for the edit session to finish (e.g. mail). On the Amiga
  119. the ":sh" and ":!" commands will not work.
  120. --nofork Foreground. For the GUI version, Vim will not fork and de‐
  121. tach from the shell it was started in.
  122. -F If Vim has been compiled with FKMAP support for editing
  123. right-to-left oriented files and Farsi keyboard mapping,
  124. this option starts Vim in Farsi mode, i.e. 'fkmap' and
  125. 'rightleft' are set. Otherwise an error message is given
  126. and Vim aborts.
  127. -g If Vim has been compiled with GUI support, this option en‐
  128. ables the GUI. If no GUI support was compiled in, an error
  129. message is given and Vim aborts.
  130. -h Give a bit of help about the command line arguments and op‐
  131. tions. After this Vim exits.
  132. -H If Vim has been compiled with RIGHTLEFT support for editing
  133. right-to-left oriented files and Hebrew keyboard mapping,
  134. this option starts Vim in Hebrew mode, i.e. 'hkmap' and
  135. 'rightleft' are set. Otherwise an error message is given
  136. and Vim aborts.
  137. -i {viminfo}
  138. Specifies the filename to use when reading or writing the
  139. viminfo file, instead of the default "~/.viminfo". This
  140. can also be used to skip the use of the .viminfo file, by
  141. giving the name "NONE".
  142. -L Same as -r.
  143. -l Lisp mode. Sets the 'lisp' and 'showmatch' options on.
  144. -m Modifying files is disabled. Resets the 'write' option.
  145. You can still modify the buffer, but writing a file is not
  146. possible.
  147. -M Modifications not allowed. The 'modifiable' and 'write'
  148. options will be unset, so that changes are not allowed and
  149. files can not be written. Note that these options can be
  150. set to enable making modifications.
  151. -N No-compatible mode. Resets the 'compatible' option. This
  152. will make Vim behave a bit better, but less Vi compatible,
  153. even though a .vimrc file does not exist.
  154. -n No swap file will be used. Recovery after a crash will be
  155. impossible. Handy if you want to edit a file on a very
  156. slow medium (e.g. floppy). Can also be done with ":set
  157. uc=0". Can be undone with ":set uc=200".
  158. -nb Become an editor server for NetBeans. See the docs for de‐
  159. tails.
  160. -o[N] Open N windows stacked. When N is omitted, open one window
  161. for each file.
  162. -O[N] Open N windows side by side. When N is omitted, open one
  163. window for each file.
  164. -p[N] Open N tab pages. When N is omitted, open one tab page for
  165. each file.
  166. -R Read-only mode. The 'readonly' option will be set. You
  167. can still edit the buffer, but will be prevented from acci‐
  168. dentally overwriting a file. If you do want to overwrite a
  169. file, add an exclamation mark to the Ex command, as in
  170. ":w!". The -R option also implies the -n option (see
  171. above). The 'readonly' option can be reset with ":set
  172. noro". See ":help 'readonly'".
  173. -r List swap files, with information about using them for re‐
  174. covery.
  175. -r {file} Recovery mode. The swap file is used to recover a crashed
  176. editing session. The swap file is a file with the same
  177. filename as the text file with ".swp" appended. See ":help
  178. recovery".
  179. -s Silent mode. Only when started as "Ex" or when the "-e"
  180. option was given before the "-s" option.
  181. -s {scriptin}
  182. The script file {scriptin} is read. The characters in the
  183. file are interpreted as if you had typed them. The same
  184. can be done with the command ":source! {scriptin}". If the
  185. end of the file is reached before the editor exits, further
  186. characters are read from the keyboard.
  187. -T {terminal}
  188. Tells Vim the name of the terminal you are using. Only re‐
  189. quired when the automatic way doesn't work. Should be a
  190. terminal known to Vim (builtin) or defined in the termcap
  191. or terminfo file.
  192. -u {vimrc} Use the commands in the file {vimrc} for initializations.
  193. All the other initializations are skipped. Use this to
  194. edit a special kind of files. It can also be used to skip
  195. all initializations by giving the name "NONE". See ":help
  196. initialization" within vim for more details.
  197. -U {gvimrc} Use the commands in the file {gvimrc} for GUI initializa‐
  198. tions. All the other GUI initializations are skipped. It
  199. can also be used to skip all GUI initializations by giving
  200. the name "NONE". See ":help gui-init" within vim for more
  201. details.
  202. -V[N] Verbose. Give messages about which files are sourced and
  203. for reading and writing a viminfo file. The optional num‐
  204. ber N is the value for 'verbose'. Default is 10.
  205. -v Start Vim in Vi mode, just like the executable was called
  206. "vi". This only has effect when the executable is called
  207. "ex".
  208. -w {scriptout}
  209. All the characters that you type are recorded in the file
  210. {scriptout}, until you exit Vim. This is useful if you
  211. want to create a script file to be used with "vim -s" or
  212. ":source!". If the {scriptout} file exists, characters are
  213. appended.
  214. -W {scriptout}
  215. Like -w, but an existing file is overwritten.
  216. -x Use encryption when writing files. Will prompt for a crypt
  217. key.
  218. -X Don't connect to the X server. Shortens startup time in a
  219. terminal, but the window title and clipboard will not be
  220. used.
  221. -y Start Vim in easy mode, just like the executable was called
  222. "evim" or "eview". Makes Vim behave like a click-and-type
  223. editor.
  224. -Z Restricted mode. Works like the executable starts with
  225. "r".
  226. -- Denotes the end of the options. Arguments after this will
  227. be handled as a file name. This can be used to edit a
  228. filename that starts with a '-'.
  229. --clean Do not use any personal configuration (vimrc, plugins,
  230. etc.). Useful to see if a problem reproduces with a clean
  231. Vim setup.
  232. --echo-wid GTK GUI only: Echo the Window ID on stdout.
  233. --help Give a help message and exit, just like "-h".
  234. --literal Take file name arguments literally, do not expand wild‐
  235. cards. This has no effect on Unix where the shell expands
  236. wildcards.
  237. --noplugin Skip loading plugins. Implied by -u NONE.
  238. --remote Connect to a Vim server and make it edit the files given in
  239. the rest of the arguments. If no server is found a warning
  240. is given and the files are edited in the current Vim.
  241. --remote-expr {expr}
  242. Connect to a Vim server, evaluate {expr} in it and print
  243. the result on stdout.
  244. --remote-send {keys}
  245. Connect to a Vim server and send {keys} to it.
  246. --remote-silent
  247. As --remote, but without the warning when no server is
  248. found.
  249. --remote-wait
  250. As --remote, but Vim does not exit until the files have
  251. been edited.
  252. --remote-wait-silent
  253. As --remote-wait, but without the warning when no server is
  254. found.
  255. --serverlist
  256. List the names of all Vim servers that can be found.
  257. --servername {name}
  258. Use {name} as the server name. Used for the current Vim,
  259. unless used with a --remote argument, then it's the name of
  260. the server to connect to.
  261. --socketid {id}
  262. GTK GUI only: Use the GtkPlug mechanism to run gvim in an‐
  263. other window.
  264. --startuptime {file}
  265. During startup write timing messages to the file {fname}.
  266. --version Print version information and exit.
  267. ON-LINE HELP
  268. Type ":help" in Vim to get started. Type ":help subject" to get help
  269. on a specific subject. For example: ":help ZZ" to get help for the
  270. "ZZ" command. Use <Tab> and CTRL-D to complete subjects (":help cmd‐
  271. line-completion"). Tags are present to jump from one place to another
  272. (sort of hypertext links, see ":help"). All documentation files can be
  273. viewed in this way, for example ":help syntax.txt".
  274. FILES
  275. /usr/local/lib/vim/doc/*.txt
  276. The Vim documentation files. Use ":help doc-file-list"
  277. to get the complete list.
  278. /usr/local/lib/vim/doc/tags
  279. The tags file used for finding information in the docu‐
  280. mentation files.
  281. /usr/local/lib/vim/syntax/syntax.vim
  282. System wide syntax initializations.
  283. /usr/local/lib/vim/syntax/*.vim
  284. Syntax files for various languages.
  285. /usr/local/lib/vim/vimrc
  286. System wide Vim initializations.
  287. ~/.vimrc Your personal Vim initializations.
  288. /usr/local/lib/vim/gvimrc
  289. System wide gvim initializations.
  290. ~/.gvimrc Your personal gvim initializations.
  291. /usr/local/lib/vim/optwin.vim
  292. Script used for the ":options" command, a nice way to
  293. view and set options.
  294. /usr/local/lib/vim/menu.vim
  295. System wide menu initializations for gvim.
  296. /usr/local/lib/vim/bugreport.vim
  297. Script to generate a bug report. See ":help bugs".
  298. /usr/local/lib/vim/filetype.vim
  299. Script to detect the type of a file by its name. See
  300. ":help 'filetype'".
  301. /usr/local/lib/vim/scripts.vim
  302. Script to detect the type of a file by its contents.
  303. See ":help 'filetype'".
  304. /usr/local/lib/vim/print/*.ps
  305. Files used for PostScript printing.
  306. For recent info read the VIM home page:
  307. <URL:http://www.vim.org/>
  308. SEE ALSO
  309. vimtutor(1)
  310. AUTHOR
  311. Most of Vim was made by Bram Moolenaar, with a lot of help from others.
  312. See ":help credits" in Vim.
  313. Vim is based on Stevie, worked on by: Tim Thompson, Tony Andrews and
  314. G.R. (Fred) Walter. Although hardly any of the original code remains.
  315. BUGS
  316. Probably. See ":help todo" for a list of known problems.
  317. Note that a number of things that may be regarded as bugs by some, are
  318. in fact caused by a too-faithful reproduction of Vi's behaviour. And
  319. if you think other things are bugs "because Vi does it differently",
  320. you should take a closer look at the vi_diff.txt file (or type :help
  321. vi_diff.txt when in Vim). Also have a look at the 'compatible' and
  322. 'cpoptions' options.
  323. 2021 Jun 13 VIM(1)