editing.txt 69 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707
  1. *editing.txt* Nvim
  2. VIM REFERENCE MANUAL by Bram Moolenaar
  3. Editing files *edit-files*
  4. Type |gO| to see the table of contents.
  5. ==============================================================================
  6. 1. Introduction *edit-intro*
  7. Editing a file with Vim means:
  8. 1. reading the file into a buffer
  9. 2. changing the buffer with editor commands
  10. 3. writing the buffer into a file
  11. *current-file*
  12. As long as you don't write the buffer, the original file remains unchanged.
  13. If you start editing a file (read a file into the buffer), the file name is
  14. remembered as the "current file name". This is also known as the name of the
  15. current buffer. It can be used with "%" on the command line |:_%|.
  16. *alternate-file*
  17. If there already was a current file name, then that one becomes the alternate
  18. file name. It can be used with "#" on the command line |:_#| and you can use
  19. the |CTRL-^| command to toggle between the current and the alternate file.
  20. However, the alternate file name is not changed when |:keepalt| is used.
  21. An alternate file name is remembered for each window.
  22. *:keepalt* *:keepa*
  23. :keepalt {cmd} Execute {cmd} while keeping the current alternate file
  24. name. Note that commands invoked indirectly (e.g.,
  25. with a function) may still set the alternate file
  26. name.
  27. All file names are remembered in the buffer list. When you enter a file name,
  28. for editing (e.g., with ":e filename") or writing (e.g., with ":w filename"),
  29. the file name is added to the list. You can use the buffer list to remember
  30. which files you edited and to quickly switch from one file to another (e.g.,
  31. to copy text) with the |CTRL-^| command. First type the number of the file
  32. and then hit CTRL-^.
  33. CTRL-G or *CTRL-G* *:f* *:fi* *:file*
  34. :f[ile] Prints the current file name (as typed, unless ":cd"
  35. was used), the cursor position (unless the 'ruler'
  36. option is set), and the file status (readonly,
  37. modified, read errors, new file). See the 'shortmess'
  38. option about how to make this message shorter.
  39. :f[ile]! like |:file|, but don't truncate the name even when
  40. 'shortmess' indicates this.
  41. {count}CTRL-G Like CTRL-G, but prints the current file name with
  42. full path. If the count is higher than 1 the current
  43. buffer number is also given.
  44. *g_CTRL-G* *word-count* *byte-count*
  45. g CTRL-G Prints the current position of the cursor in five
  46. ways: Column, Line, Word, Character and Byte. If the
  47. number of Characters and Bytes is the same then the
  48. Character position is omitted.
  49. If there are characters in the line that take more
  50. than one position on the screen (<Tab> or special
  51. character), or characters using more than one byte per
  52. column (characters above 0x7F when 'encoding' is
  53. utf-8), both the byte column and the screen column are
  54. shown, separated by a dash.
  55. Also see the 'ruler' option and the |wordcount()|
  56. function.
  57. *v_g_CTRL-G*
  58. {Visual}g CTRL-G Similar to "g CTRL-G", but Word, Character, Line, and
  59. Byte counts for the visually selected region are
  60. displayed.
  61. In Blockwise mode, Column count is also shown. (For
  62. {Visual} see |Visual-mode|.)
  63. *:file_f*
  64. :f[ile][!] {name} Sets the current file name to {name}. The optional !
  65. avoids truncating the message, as with |:file|.
  66. If the buffer did have a name, that name becomes the
  67. |alternate-file| name. An unlisted buffer is created
  68. to hold the old name.
  69. *:0file*
  70. :0f[ile][!] Remove the name of the current buffer. The optional !
  71. avoids truncating the message, as with |:file|.
  72. :buffers
  73. :files
  74. :ls List all the currently known file names. See
  75. |windows.txt| |:files| |:buffers| |:ls|.
  76. Vim will remember the full path name of a file name that you enter. In most
  77. cases when the file name is displayed only the name you typed is shown, but
  78. the full path name is being used if you used the ":cd" command |:cd|.
  79. *home-replace*
  80. If the environment variable $HOME is set, and the file name starts with that
  81. string, it is often displayed with HOME replaced with "~". This was done to
  82. keep file names short. When reading or writing files the full name is still
  83. used, the "~" is only used when displaying file names. When replacing the
  84. file name would result in just "~", "~/" is used instead (to avoid confusion
  85. between options set to $HOME with 'backupext' set to "~").
  86. When writing the buffer, the default is to use the current file name. Thus
  87. when you give the "ZZ" or ":wq" command, the original file will be
  88. overwritten. If you do not want this, the buffer can be written into another
  89. file by giving a file name argument to the ":write" command. For example: >
  90. vim testfile
  91. [change the buffer with editor commands]
  92. :w newfile
  93. :q
  94. This will create a file "newfile", that is a modified copy of "testfile".
  95. The file "testfile" will remain unchanged. Anyway, if the 'backup' option is
  96. set, Vim renames or copies the original file before it will be overwritten.
  97. You can use this file if you discover that you need the original file. See
  98. also the 'patchmode' option. The name of the backup file is normally the same
  99. as the original file with 'backupext' appended. The default "~" is a bit
  100. strange to avoid accidentally overwriting existing files. If you prefer ".bak"
  101. change the 'backupext' option. The backup file can be placed in another
  102. directory by setting 'backupdir'.
  103. When you started editing without giving a file name, "No File" is displayed in
  104. messages. If the ":write" command is used with a file name argument, the file
  105. name for the current file is set to that file name. This only happens when
  106. the 'F' flag is included in 'cpoptions' (by default it is included) |cpo-F|.
  107. This is useful when entering text in an empty buffer and then writing it to a
  108. file. If 'cpoptions' contains the 'f' flag (by default it is NOT included)
  109. |cpo-f| the file name is set for the ":read file" command. This is useful
  110. when starting Vim without an argument and then doing ":read file" to start
  111. editing a file.
  112. When the file name was set and 'filetype' is empty the filetype detection
  113. autocommands will be triggered.
  114. *not-edited*
  115. Because the file name was set without really starting to edit that file, you
  116. are protected from overwriting that file. This is done by setting the
  117. "notedited" flag. You can see if this flag is set with the CTRL-G or ":file"
  118. command. It will include "[Not edited]" when the "notedited" flag is set.
  119. When writing the buffer to the current file name (with ":w!"), the "notedited"
  120. flag is reset.
  121. *abandon*
  122. Vim remembers whether you have changed the buffer. You are protected from
  123. losing the changes you made. If you try to quit without writing, or want to
  124. start editing another file, Vim will refuse this. In order to overrule this
  125. protection, add a '!' to the command. The changes will then be lost. For
  126. example: ":q" will not work if the buffer was changed, but ":q!" will. To see
  127. whether the buffer was changed use the "CTRL-G" command. The message includes
  128. the string "[Modified]" if the buffer has been changed, or "+" if the 'm' flag
  129. is in 'shortmess'.
  130. If you want to automatically save the changes without asking, switch on the
  131. 'autowriteall' option. 'autowrite' is the associated Vi-compatible option
  132. that does not work for all commands.
  133. If you want to keep the changed buffer without saving it, switch on the
  134. 'hidden' option. See |hidden-buffer|. Some commands work like this even when
  135. 'hidden' is not set, check the help for the command.
  136. ==============================================================================
  137. 2. Editing a file *edit-a-file*
  138. *:e* *:edit* *reload*
  139. :e[dit][!] [++opt] [+cmd]
  140. Edit the current file. This is useful to re-edit the
  141. current file, when it has been changed outside of Vim.
  142. *:edit!* *discard*
  143. If [!] is given, unsaved changes in the current buffer
  144. are discarded. Without [!] the command fails if there
  145. are unsaved changes, unless 'autowriteall' is set and
  146. the file can be written.
  147. Also see |++opt| and |+cmd|.
  148. *:edit_f*
  149. :e[dit][!] [++opt] [+cmd] {file}
  150. Edit {file}.
  151. *:edit!_f*
  152. If [!] is given, unsaved changes in the current buffer
  153. are discarded. Without [!] the command fails if there
  154. are unsaved changes, unless 'hidden' is set or
  155. 'autowriteall' is set and the file can be written.
  156. Also see |++opt| and |+cmd|.
  157. *:edit_#* *:e#*
  158. :e[dit] [++opt] [+cmd] #[count]
  159. Edit the [count]th buffer (as shown by |:files|).
  160. This command does the same as [count] CTRL-^. But ":e
  161. #" doesn't work if the alternate buffer doesn't have a
  162. file name, while CTRL-^ still works then.
  163. Also see |++opt| and |+cmd|.
  164. *:ene* *:enew*
  165. :ene[w] Edit a new, unnamed buffer. This fails when changes
  166. have been made to the current buffer, unless 'hidden'
  167. is set or 'autowriteall' is set and the file can be
  168. written.
  169. If 'fileformats' is not empty, the first format given
  170. will be used for the new buffer. If 'fileformats' is
  171. empty, the 'fileformat' of the current buffer is used.
  172. *:ene!* *:enew!*
  173. :ene[w]! Edit a new, unnamed buffer. Discard any changes to
  174. the current buffer.
  175. Set 'fileformat' like |:enew|.
  176. *:fin* *:find*
  177. :fin[d][!] [++opt] [+cmd] {file}
  178. Find {file} in 'path' and then |:edit| it.
  179. :{count}fin[d][!] [++opt] [+cmd] {file}
  180. Just like ":find", but use the {count} match in
  181. 'path'. Thus ":2find file" will find the second
  182. "file" found in 'path'. When there are fewer matches
  183. for the file in 'path' than asked for, you get an
  184. error message.
  185. *:ex*
  186. :ex [++opt] [+cmd] [file]
  187. Same as |:edit|.
  188. *:vi* *:visual*
  189. :vi[sual][!] [++opt] [+cmd] [file]
  190. When used in Ex mode: Leave |Ex-mode|, go back to
  191. Normal mode. Otherwise same as |:edit|.
  192. *:vie* *:view*
  193. :vie[w][!] [++opt] [+cmd] file
  194. When used in Ex mode: Leave |Ex-mode|, go back to
  195. Normal mode. Otherwise same as |:edit|, but set
  196. 'readonly' option for this buffer.
  197. *CTRL-^* *CTRL-6*
  198. CTRL-^ Edit the alternate file. Mostly the alternate file is
  199. the previously edited file. This is a quick way to
  200. toggle between two files. It is equivalent to ":e #",
  201. except that it also works when there is no file name.
  202. If the 'autowrite' or 'autowriteall' option is on and
  203. the buffer was changed, write it.
  204. Mostly the ^ character is positioned on the 6 key,
  205. pressing CTRL and 6 then gets you what we call CTRL-^.
  206. But on some non-US keyboards CTRL-^ is produced in
  207. another way.
  208. {count}CTRL-^ Edit [count]th file in the buffer list (equivalent to
  209. ":e #[count]"). This is a quick way to switch between
  210. files.
  211. See |CTRL-^| above for further details.
  212. *gf* *E446* *E447*
  213. [count]gf Edit the file whose name is under or after the cursor.
  214. Mnemonic: "goto file".
  215. Uses the 'isfname' option to find out which characters
  216. are supposed to be in a file name. Trailing
  217. punctuation characters ".,:;!" are ignored. Escaped
  218. spaces "\ " are reduced to a single space.
  219. Uses the 'path' option as a list of directory names to
  220. look for the file. See the 'path' option for details
  221. about relative directories and wildcards.
  222. Uses the 'suffixesadd' option to check for file names
  223. with a suffix added.
  224. If the file can't be found, 'includeexpr' is used to
  225. modify the name and another attempt is done.
  226. If a [count] is given, the count'th file that is found
  227. in the 'path' is edited.
  228. This command fails if Vim refuses to |abandon| the
  229. current file.
  230. If you want to edit the file in a new window use
  231. |CTRL-W_CTRL-F|.
  232. If you do want to edit a new file, use: >
  233. :e <cfile>
  234. < To make gf always work like that: >
  235. :map gf :e <cfile><CR>
  236. < If the name is a hypertext link, that looks like
  237. "type://machine/path", you need the |netrw| plugin.
  238. For Unix the '~' character is expanded, like in
  239. "~user/file". Environment variables are expanded too
  240. |expand-env|.
  241. *v_gf*
  242. {Visual}[count]gf Same as "gf", but the highlighted text is used as the
  243. name of the file to edit. 'isfname' is ignored.
  244. Leading blanks are skipped, otherwise all blanks and
  245. special characters are included in the file name.
  246. (For {Visual} see |Visual-mode|.)
  247. *gF*
  248. [count]gF Same as "gf", except if a number follows the file
  249. name, then the cursor is positioned on that line in
  250. the file.
  251. The file name and the number must be separated by a
  252. non-filename (see 'isfname') and non-numeric
  253. character. " line " is also recognized, like it is
  254. used in the output of `:verbose command UserCmd`
  255. White space between the filename, the separator and
  256. the number are ignored.
  257. Examples:
  258. eval.c:10 ~
  259. eval.c @ 20 ~
  260. eval.c (30) ~
  261. eval.c 40 ~
  262. *v_gF*
  263. {Visual}[count]gF Same as "v_gf".
  264. These commands are used to start editing a single file. This means that the
  265. file is read into the buffer and the current file name is set. The file that
  266. is opened depends on the current directory, see |:cd|.
  267. See |read-messages| for an explanation of the message that is given after the
  268. file has been read.
  269. You can use the ":e!" command if you messed up the buffer and want to start
  270. all over again. The ":e" command is only useful if you have changed the
  271. current file name.
  272. *:filename* *{file}*
  273. Besides the things mentioned here, more special items for where a filename is
  274. expected are mentioned at |cmdline-special|.
  275. Note for systems other than Unix: When using a command that accepts a single
  276. file name (like ":edit file") spaces in the file name are allowed, but
  277. trailing spaces are ignored. This is useful on systems that regularly embed
  278. spaces in file names (like MS-Windows). Example: The command ":e Long File
  279. Name " will edit the file "Long File Name". When using a command that accepts
  280. more than one file name (like ":next file1 file2") embedded spaces must be
  281. escaped with a backslash.
  282. *wildcard* *wildcards*
  283. Wildcards in {file} are expanded, but as with file completion, 'wildignore'
  284. and 'suffixes' apply. Which wildcards are supported depends on the system.
  285. These are the common ones:
  286. `?` matches one character
  287. `*` matches anything, including nothing
  288. `**` matches anything, including nothing, recurses into directories
  289. [abc] match 'a', 'b' or 'c'
  290. To avoid the special meaning of the wildcards prepend a backslash. However,
  291. on MS-Windows the backslash is a path separator and "path\[abc]" is still seen
  292. as a wildcard when "[" is in the 'isfname' option. A simple way to avoid this
  293. is to use "path\[[]abc]", this matches the file "path\[abc]".
  294. *starstar-wildcard*
  295. Expanding "**" is possible on Unix, Win32, macOS and a few other systems (but
  296. it may depend on your 'shell' setting on Unix and macOS. It's known to work
  297. correctly for zsh; for bash this requires at least bash version >= 4.X).
  298. This allows searching a directory tree. This goes up to 100 directories deep.
  299. Note there are some commands where this works slightly differently, see
  300. |file-searching|.
  301. Example: >
  302. :n **/*.txt
  303. Finds files:
  304. aaa.txt ~
  305. subdir/bbb.txt ~
  306. a/b/c/d/ccc.txt ~
  307. When non-wildcard characters are used right before or after "**" these are
  308. only matched in the top directory. They are not used for directories further
  309. down in the tree. For example: >
  310. :n /usr/inc**/types.h
  311. Finds files:
  312. /usr/include/types.h ~
  313. /usr/include/sys/types.h ~
  314. /usr/inc/old/types.h ~
  315. Note that the path with "/sys" is included because it does not need to match
  316. "/inc". Thus it's like matching "/usr/inc*/*/*...", not
  317. "/usr/inc*/inc*/inc*".
  318. *backtick-expansion* *`-expansion*
  319. On Unix and a few other systems you can also use backticks for the file name
  320. argument, for example: >
  321. :next `find . -name ver\\*.c -print`
  322. :view `ls -t *.patch \| head -n1`
  323. Vim will run the command in backticks using the 'shell' and use the standard
  324. output as argument for the given Vim command (error messages from the shell
  325. command will be discarded).
  326. To see what shell command Vim is running, set the 'verbose' option to 4. When
  327. the shell command returns a non-zero exit code, an error message will be
  328. displayed and the Vim command will be aborted. To avoid this make the shell
  329. always return zero like so: >
  330. :next `find . -name ver\\*.c -print \|\| true`
  331. The backslashes before the star are required to prevent the shell from
  332. expanding "ver*.c" prior to execution of the find program. The backslash
  333. before the shell pipe symbol "|" prevents Vim from parsing it as command
  334. termination.
  335. This also works for most other systems, with the restriction that the
  336. backticks must be around the whole item. It is not possible to have text
  337. directly before the first or just after the last backtick.
  338. *`=*
  339. You can have the backticks expanded as a Vim expression, instead of as an
  340. external command, by putting an equal sign right after the first backtick,
  341. e.g.: >
  342. :e `=tempname()`
  343. The expression can contain just about anything, thus this can also be used to
  344. avoid the special meaning of '"', "|", '%' and '#'. However, 'wildignore'
  345. does apply like to other wildcards.
  346. Environment variables in the expression are expanded when evaluating the
  347. expression, thus this works: >
  348. :e `=$HOME .. '/.vimrc'`
  349. This uses $HOME inside a string and it will be used literally, most likely not
  350. what you intended: >
  351. :e `='$HOME' .. '/.vimrc'`
  352. If the expression returns a string then names are to be separated with line
  353. breaks. When the result is a |List| then each item is used as a name. Line
  354. breaks also separate names.
  355. Note that such expressions are only supported in places where a filename is
  356. expected as an argument to an Ex-command.
  357. *++opt* *[++opt]*
  358. The [++opt] argument can be used to set some options for one command, and to
  359. specify the behavior for bad characters. The form is: >
  360. ++{optname}
  361. Or: >
  362. ++{optname}={value}
  363. Where {optname} is one of: *++ff* *++enc* *++bin* *++nobin* *++edit*
  364. ff or fileformat overrides 'fileformat'
  365. enc or encoding overrides 'fileencoding'
  366. bin or binary sets 'binary'
  367. nobin or nobinary resets 'binary'
  368. bad specifies behavior for bad characters
  369. edit for |:read|: keeps options as if editing a file
  370. p for |:write|: creates the file's parent directory
  371. {value} cannot contain whitespace. It can be any valid value for the options.
  372. Examples: >
  373. :e ++ff=unix
  374. This edits the same file again with 'fileformat' set to "unix". >
  375. :w ++enc=latin1 newfile
  376. This writes the current buffer to "newfile" in latin1 format.
  377. The message given when writing a file will show "[converted]" when
  378. 'fileencoding' or the value specified with ++enc differs from 'encoding'.
  379. There may be several ++opt arguments, separated by whitespace. They must all
  380. appear before any |+cmd| argument.
  381. *++p*
  382. The "++p" flag creates the parent directory of the file if it does not exist.
  383. For example if you edit "foo/bar/file.txt", the ":write ++p" command creates
  384. "foo/bar/" if necessary before writing the file. >
  385. :edit foo/bar/file.txt
  386. :write ++p
  387. If you want :write (without "++p") to always create missing parent
  388. directories, add this autocmd to your config: >
  389. " Auto-create parent directories (except for URIs "://").
  390. au BufWritePre,FileWritePre * if @% !~# '\(://\)' | call mkdir(expand('<afile>:p:h'), 'p') | endif
  391. <
  392. *++bad*
  393. The argument of "++bad=" specifies what happens with characters that can't be
  394. converted and illegal bytes. It can be one of three things:
  395. ++bad=X A single-byte character that replaces each bad character.
  396. ++bad=keep Keep bad characters without conversion. Note that this may
  397. result in illegal bytes in your text!
  398. ++bad=drop Remove the bad characters.
  399. The default is like "++bad=?": Replace each bad character with a question
  400. mark. In some places an inverted question mark is used (0xBF).
  401. Note that not all commands use the ++bad argument, even though they do not
  402. give an error when you add it. E.g. |:write|.
  403. Note that when reading, the 'fileformat' and 'fileencoding' options will be
  404. set to the used format. When writing this doesn't happen, thus a next write
  405. will use the old value of the option. Same for the 'binary' option.
  406. *+cmd* *[+cmd]*
  407. The [+cmd] argument can be used to position the cursor in the newly opened
  408. file, or execute any other command:
  409. + Start at the last line.
  410. +{num} Start at line {num}.
  411. +/{pat} Start at first line containing {pat}.
  412. +{command} Execute {command} after opening the new file.
  413. {command} is any Ex command.
  414. To include a white space in the {pat} or {command}, precede it with a
  415. backslash. Double the number of backslashes. >
  416. :edit +/The\ book file
  417. :edit +/dir\ dirname\\ file
  418. :edit +set\ dir=c:\\\\temp file
  419. Note that in the last example the number of backslashes is halved twice: Once
  420. for the "+cmd" argument and once for the ":set" command.
  421. *file-formats*
  422. The 'fileformat' option sets the <EOL> style for a file:
  423. 'fileformat' characters name ~
  424. "dos" <CR><NL> or <NL> DOS format *DOS-format*
  425. "unix" <NL> Unix format *Unix-format*
  426. "mac" <CR> Mac format *Mac-format*
  427. When reading a file, the mentioned characters are interpreted as the <EOL>.
  428. In DOS format (default for Windows), <CR><NL> and <NL> are both interpreted as
  429. the <EOL>. Note that when writing the file in DOS format, <CR> characters will
  430. be added for each single <NL>. Also see |file-read|.
  431. When writing a file, the mentioned characters are used for <EOL>. For DOS
  432. format <CR><NL> is used. Also see |DOS-format-write|.
  433. You can read a file in DOS format and write it in Unix format. This will
  434. replace all <CR><NL> pairs by <NL> (assuming 'fileformats' includes "dos"): >
  435. :e file
  436. :set fileformat=unix
  437. :w
  438. If you read a file in Unix format and write with DOS format, all <NL>
  439. characters will be replaced with <CR><NL> (assuming 'fileformats' includes
  440. "unix"): >
  441. :e file
  442. :set fileformat=dos
  443. :w
  444. If you start editing a new file and the 'fileformats' option is not empty
  445. (which is the default), Vim will try to detect whether the lines in the file
  446. are separated by the specified formats. When set to "unix,dos", Vim will
  447. check for lines with a single <NL> (as used on Unix) or by a <CR><NL> pair
  448. (MS-Windows). Only when ALL lines end in <CR><NL>, 'fileformat' is
  449. set to "dos", otherwise it is set to "unix". When 'fileformats' includes
  450. "mac", and no <NL> characters are found in the file, 'fileformat' is set to
  451. "mac".
  452. If the 'fileformat' option is set to "dos" on non-MS-Windows systems the
  453. message "[dos]" is shown to remind you that something unusual is happening. On
  454. MS-Windows systems you get the message "[unix]" if 'fileformat' is set to
  455. "unix". On all systems you get the message "[mac]" if 'fileformat' is set to
  456. "mac".
  457. If the 'fileformats' option is empty and DOS format is used, but while reading
  458. a file some lines did not end in <CR><NL>, "[CR missing]" will be included in
  459. the file message.
  460. If the 'fileformats' option is empty and Mac format is used, but while reading
  461. a file a <NL> was found, "[NL missing]" will be included in the file message.
  462. If the new file does not exist, the 'fileformat' of the current buffer is used
  463. when 'fileformats' is empty. Otherwise the first format from 'fileformats' is
  464. used for the new file.
  465. Before editing binary, executable or Vim script files you should set the
  466. 'binary' option. A simple way to do this is by starting Vim with the "-b"
  467. option. This will avoid the use of 'fileformat'. Without this you risk that
  468. single <NL> characters are unexpectedly replaced with <CR><NL>.
  469. END OF LINE AND END OF FILE *eol-and-eof*
  470. Vim has several options to control the file format:
  471. 'fileformat' the <EOL> style: Unix, DOS, Mac
  472. 'endofline' whether the last line ends with a <EOL>
  473. 'endoffile' whether the file ends with a CTRL-Z
  474. 'fixendofline' whether to fix eol and eof
  475. The first three values are normally detected automatically when reading the
  476. file and are used when writing the text to a file. While editing the buffer
  477. it looks like every line has a line ending and the CTRL-Z isn't there (an
  478. exception is when 'binary' is set, it works differently then).
  479. The 'fixendofline' option can be used to choose what to write. You can also
  480. change the option values to write the file differently than how it was read.
  481. Here are some examples how to use them.
  482. If you want files in Unix format (every line NL terminated): >
  483. setl ff=unix fixeol
  484. You should probably do this on any Unix-like system. Also modern MS-Windows
  485. systems tend to work well with this. It is recommended to always use this
  486. format for Vim scripts.
  487. If you want to use an old MS-DOS file in a modern environment, fixing line
  488. endings and dropping CTRL-Z, but keeping the <CR><NL> style <EOL>: >
  489. setl ff=dos fixeol
  490. This is useful for many MS-Windows programs, they regularly expect the
  491. <CR><NL> line endings.
  492. If you want to drop the final <EOL> and add a final CTRL-Z (e.g. for an old
  493. system like CP/M): >
  494. setl ff=dos nofixeol noeol eof
  495. If you want to preserve the fileformat exactly as-is, including any final
  496. <EOL> and final CTRL-Z: >
  497. setl nofixeol
  498. ==============================================================================
  499. 3. The argument list *argument-list* *arglist*
  500. If you give more than one file name when starting Vim, this list is remembered
  501. as the argument list. You can jump to each file in this list.
  502. Do not confuse this with the buffer list, which you can see with the
  503. |:buffers| command. The argument list was already present in Vi, the buffer
  504. list is new in Vim. Every file name in the argument list will also be present
  505. in the buffer list (unless it was deleted with |:bdel| or |:bwipe|). But it's
  506. common that names in the buffer list are not in the argument list.
  507. This subject is introduced in section |07.2| of the user manual.
  508. There is one global argument list, which is used for all windows by default.
  509. It is possible to create a new argument list local to a window, see
  510. |:arglocal|.
  511. You can use the argument list with the following commands, and with the
  512. expression functions |argc()| and |argv()|. These all work on the argument
  513. list of the current window.
  514. *:ar* *:arg* *:args*
  515. :ar[gs] Print the argument list, with the current file in
  516. square brackets.
  517. :ar[gs] [++opt] [+cmd] {arglist} *:args_f*
  518. Define {arglist} as the new argument list and edit
  519. the first one. This fails when changes have been made
  520. and Vim does not want to |abandon| the current buffer.
  521. Also see |++opt| and |+cmd|.
  522. :ar[gs]! [++opt] [+cmd] {arglist} *:args_f!*
  523. Define {arglist} as the new argument list and edit
  524. the first one. Discard any changes to the current
  525. buffer.
  526. Also see |++opt| and |+cmd|.
  527. :[count]arge[dit][!] [++opt] [+cmd] {name} .. *:arge* *:argedit*
  528. Add {name}s to the argument list and edit it.
  529. There is no check for duplicates, it is possible to
  530. add a file to the argument list twice |:argded|.
  531. This is like using |:argadd| and then |:edit| (with
  532. the small exception that |:edit| does not change the
  533. argument list, so the argument list pointer isn't
  534. changed).
  535. Spaces in filenames have to be escaped with "\".
  536. [count] is used like with |:argadd|.
  537. If the current file cannot be |abandon|ed {name}s will
  538. still be added to the argument list, but won't be
  539. edited. No check for duplicates is done.
  540. Also see |++opt| and |+cmd|.
  541. :[count]arga[dd] {name} .. *:arga* *:argadd* *E479*
  542. :[count]arga[dd] *E1156*
  543. Add the {name}s to the argument list. When {name} is
  544. omitted add the current buffer name to the argument
  545. list.
  546. If [count] is omitted, the {name}s are added just
  547. after the current entry in the argument list.
  548. Otherwise they are added after the [count]'th file.
  549. If the argument list is "a b c", and "b" is the
  550. current argument, then these commands result in:
  551. command new argument list ~
  552. :argadd x a [b] x c
  553. :0argadd x x a [b] c
  554. :1argadd x a x [b] c
  555. :$argadd x a [b] c x
  556. And after the last one:
  557. :+2argadd y a [b] c x y
  558. There is no check for duplicates, it is possible to
  559. add a file to the argument list twice. You can use
  560. |:argdedupe| to fix it afterwards: >
  561. :argadd *.txt | argdedupe
  562. < The currently edited file is not changed.
  563. Note: you can also use this method: >
  564. :args ## x
  565. < This will add the "x" item and sort the new list.
  566. :argded[upe] *:argded* *:argdedupe*
  567. Remove duplicate filenames from the argument list.
  568. If your current file is a duplicate, your current file
  569. will change to the original file index.
  570. :argd[elete] {pattern} .. *:argd* *:argdelete* *E480* *E610*
  571. Delete files from the argument list that match the
  572. {pattern}s. {pattern} is used like a file pattern,
  573. see |file-pattern|. "%" can be used to delete the
  574. current entry.
  575. This command keeps the currently edited file, also
  576. when it's deleted from the argument list.
  577. Example: >
  578. :argdel *.obj
  579. :[range]argd[elete] Delete the [range] files from the argument list.
  580. Example: >
  581. :10,$argdel
  582. < Deletes arguments 10 and further, keeping 1-9. >
  583. :$argd
  584. < Deletes just the last one. >
  585. :argd
  586. :.argd
  587. < Deletes the current argument. >
  588. :%argd
  589. < Removes all the files from the arglist.
  590. When the last number in the range is too high, up to
  591. the last argument is deleted.
  592. *:argu* *:argument*
  593. :[count]argu[ment] [count] [++opt] [+cmd]
  594. Edit file [count] in the argument list. When [count]
  595. is omitted the current entry is used. This fails
  596. when changes have been made and Vim does not want to
  597. |abandon| the current buffer.
  598. Also see |++opt| and |+cmd|.
  599. :[count]argu[ment]! [count] [++opt] [+cmd]
  600. Edit file [count] in the argument list, discard any
  601. changes to the current buffer. When [count] is
  602. omitted the current entry is used.
  603. Also see |++opt| and |+cmd|.
  604. :[count]n[ext] [++opt] [+cmd] *:n* *:ne* *:next* *]a* *E165* *E163*
  605. Edit [count] next file. This fails when changes have
  606. been made and Vim does not want to |abandon| the
  607. current buffer. Also see |++opt| and |+cmd|.
  608. :[count]n[ext]! [++opt] [+cmd]
  609. Edit [count] next file, discard any changes to the
  610. buffer. Also see |++opt| and |+cmd|.
  611. :n[ext] [++opt] [+cmd] {arglist} *:next_f*
  612. Same as |:args_f|.
  613. :n[ext]! [++opt] [+cmd] {arglist}
  614. Same as |:args_f!|.
  615. :[count]N[ext] [count] [++opt] [+cmd] *:Next* *:N* *E164*
  616. Edit [count] previous file in argument list. This
  617. fails when changes have been made and Vim does not
  618. want to |abandon| the current buffer.
  619. Also see |++opt| and |+cmd|.
  620. :[count]N[ext]! [count] [++opt] [+cmd]
  621. Edit [count] previous file in argument list. Discard
  622. any changes to the buffer. Also see |++opt| and
  623. |+cmd|.
  624. :[count]prev[ious] [count] [++opt] [+cmd] *:prev* *:previous* *[a*
  625. Same as :Next. Also see |++opt| and |+cmd|.
  626. *:rew* *:rewind* *[A*
  627. :rew[ind] [++opt] [+cmd]
  628. Start editing the first file in the argument list.
  629. This fails when changes have been made and Vim does
  630. not want to |abandon| the current buffer.
  631. Also see |++opt| and |+cmd|.
  632. :rew[ind]! [++opt] [+cmd]
  633. Start editing the first file in the argument list.
  634. Discard any changes to the buffer. Also see |++opt|
  635. and |+cmd|.
  636. *:fir* *:first*
  637. :fir[st][!] [++opt] [+cmd]
  638. Other name for ":rewind".
  639. *:la* *:last* *]A*
  640. :la[st] [++opt] [+cmd]
  641. Start editing the last file in the argument list.
  642. This fails when changes have been made and Vim does
  643. not want to |abandon| the current buffer.
  644. Also see |++opt| and |+cmd|.
  645. :la[st]! [++opt] [+cmd]
  646. Start editing the last file in the argument list.
  647. Discard any changes to the buffer. Also see |++opt|
  648. and |+cmd|.
  649. *:wn* *:wnext*
  650. :[count]wn[ext] [++opt]
  651. Write current file and start editing the [count]
  652. next file. Also see |++opt| and |+cmd|.
  653. :[count]wn[ext] [++opt] {file}
  654. Write current file to {file} and start editing the
  655. [count] next file, unless {file} already exists and
  656. the 'writeany' option is off. Also see |++opt| and
  657. |+cmd|.
  658. :[count]wn[ext]! [++opt] {file}
  659. Write current file to {file} and start editing the
  660. [count] next file. Also see |++opt| and |+cmd|.
  661. :[count]wN[ext][!] [++opt] [file] *:wN* *:wNext*
  662. :[count]wp[revious][!] [++opt] [file] *:wp* *:wprevious*
  663. Same as :wnext, but go to previous file instead of
  664. next.
  665. The [count] in the commands above defaults to one. For some commands it is
  666. possible to use two counts. The last one (rightmost one) is used.
  667. If no [+cmd] argument is present, the cursor is positioned at the last known
  668. cursor position for the file. If 'startofline' is set, the cursor will be
  669. positioned at the first non-blank in the line, otherwise the last know column
  670. is used. If there is no last known cursor position the cursor will be in the
  671. first line (the last line in Ex mode).
  672. *{arglist}*
  673. The wildcards in the argument list are expanded and the file names are sorted.
  674. Thus you can use the command `vim *.c` to edit all the C files. From within
  675. Vim the command `:n *.c` does the same.
  676. White space is used to separate file names. Put a backslash before a space or
  677. tab to include it in a file name. E.g., to edit the single file "foo bar": >
  678. :next foo\ bar
  679. On Unix and a few other systems you can also use backticks, for example: >
  680. :next `find . -name \\*.c -print`
  681. The backslashes before the star are required to prevent "*.c" to be expanded
  682. by the shell before executing the find program.
  683. *arglist-position*
  684. When there is an argument list you can see which file you are editing in the
  685. title of the window (if there is one and 'title' is on) and with the file
  686. message you get with the "CTRL-G" command. You will see something like
  687. (4 of 11)
  688. If you are not really editing the file at the current position in the argument
  689. list it will be
  690. ((4) of 11)
  691. This means that you are position 4 in the argument list, but not editing the
  692. fourth file in the argument list. This happens when you do ":e file".
  693. LOCAL ARGUMENT LIST
  694. *:arglocal*
  695. :argl[ocal] Make a local copy of the global argument list.
  696. Doesn't start editing another file.
  697. :argl[ocal][!] [++opt] [+cmd] {arglist}
  698. Define a new argument list, which is local to the
  699. current window. Works like |:args_f| otherwise.
  700. *:argglobal*
  701. :argg[lobal] Use the global argument list for the current window.
  702. Doesn't start editing another file.
  703. :argg[lobal][!] [++opt] [+cmd] {arglist}
  704. Use the global argument list for the current window.
  705. Define a new global argument list like |:args_f|.
  706. All windows using the global argument list will see
  707. this new list.
  708. There can be several argument lists. They can be shared between windows.
  709. When they are shared, changing the argument list in one window will also
  710. change it in the other window.
  711. When a window is split the new window inherits the argument list from the
  712. current window. The two windows then share this list, until one of them uses
  713. |:arglocal| or |:argglobal| to use another argument list.
  714. USING THE ARGUMENT LIST
  715. *:argdo*
  716. :[range]argdo[!] {cmd} Execute {cmd} for each file in the argument list or,
  717. if [range] is specified, only for arguments in that
  718. range. It works like doing this: >
  719. :rewind
  720. :{cmd}
  721. :next
  722. :{cmd}
  723. etc.
  724. < When the current file can't be |abandon|ed and the [!]
  725. is not present, the command fails.
  726. When an error is detected on one file, further files
  727. in the argument list will not be visited.
  728. The last file in the argument list (or where an error
  729. occurred) becomes the current file.
  730. {cmd} can contain '|' to concatenate several commands.
  731. {cmd} must not change the argument list.
  732. Note: While this command is executing, the Syntax
  733. autocommand event is disabled by adding it to
  734. 'eventignore'. This considerably speeds up editing
  735. each file.
  736. Also see |:windo|, |:tabdo|, |:bufdo|, |:cdo|, |:ldo|,
  737. |:cfdo| and |:lfdo|.
  738. Example: >
  739. :args *.c
  740. :argdo set ff=unix | update
  741. This sets the 'fileformat' option to "unix" and writes the file if it is now
  742. changed. This is done for all `*.c` files.
  743. Example: >
  744. :args *.[ch]
  745. :argdo %s/\<my_foo\>/My_Foo/ge | update
  746. This changes the word "my_foo" to "My_Foo" in all "*.c" and "*.h" files. The "e"
  747. flag is used for the ":substitute" command to avoid an error for files where
  748. "my_foo" isn't used. ":update" writes the file only if changes were made.
  749. ==============================================================================
  750. 4. Writing *writing* *save-file*
  751. Note: When the 'write' option is off, you are not able to write any file.
  752. *:w* *:write*
  753. *E502* *E503* *E504* *E505*
  754. *E512* *E514* *E667* *E949*
  755. :w[rite] [++opt] Write the whole buffer to the current file. This is
  756. the normal way to save changes to a file. Fails when
  757. 'readonly' is set or when there is another reason why
  758. the file can't be written, such as when the parent
  759. directory doesn't exist (use |++p| to avoid that).
  760. For ++opt see |++opt|, but only ++p, ++bin, ++nobin,
  761. ++ff and ++enc are effective.
  762. :w[rite]! [++opt] Like ":write", but forcefully write when 'readonly' is
  763. set or there is another reason why writing was
  764. refused.
  765. Note: This may change the permission and ownership of
  766. the file and break (symbolic) links. Add the 'W' flag
  767. to 'cpoptions' to avoid this.
  768. :[range]w[rite][!] [++opt]
  769. Write the specified lines to the current file. This
  770. is unusual, because the file will not contain all
  771. lines in the buffer.
  772. *:w_f* *:write_f*
  773. :[range]w[rite] [++opt] {file}
  774. Write the specified lines to {file}, unless it
  775. already exists and the 'writeany' option is off.
  776. *:w!*
  777. :[range]w[rite]! [++opt] {file}
  778. Write the specified lines to {file}. Overwrite an
  779. existing file.
  780. *:w_a* *:write_a* *E494*
  781. :[range]w[rite][!] [++opt] >>
  782. Append the specified lines to the current file.
  783. :[range]w[rite][!] [++opt] >> {file}
  784. Append the specified lines to {file}. '!' forces the
  785. write even if file does not exist.
  786. *:w_c* *:write_c*
  787. :[range]w[rite] [++opt] !{cmd}
  788. Execute {cmd} with [range] lines as standard input
  789. (note the space in front of the '!'). {cmd} is
  790. executed like with ":!{cmd}", any '!' is replaced with
  791. the previous command |:!|.
  792. The default [range] for the ":w" command is the whole buffer (1,$). If you
  793. write the whole buffer, it is no longer considered changed. When you
  794. write it to a different file with ":w somefile" it depends on the "+" flag in
  795. 'cpoptions'. When included, the write command will reset the 'modified' flag,
  796. even though the buffer itself may still be different from its file.
  797. If a file name is given with ":w" it becomes the alternate file. This can be
  798. used, for example, when the write fails and you want to try again later with
  799. ":w #". This can be switched off by removing the 'A' flag from the
  800. 'cpoptions' option.
  801. Note that the 'fsync' option matters here. If it's set it may make writes
  802. slower (but safer).
  803. *:sav* *:saveas*
  804. :sav[eas][!] [++opt] {file}
  805. Save the current buffer under the name {file} and set
  806. the filename of the current buffer to {file}. The
  807. previous name is used for the alternate file name.
  808. The [!] is needed to overwrite an existing file.
  809. When 'filetype' is empty filetype detection is done
  810. with the new name, before the file is written.
  811. When the write was successful 'readonly' is reset.
  812. *:up* *:update*
  813. :[range]up[date][!] [++opt] [>>] [file]
  814. Like ":write", but only write when the buffer has been
  815. modified.
  816. WRITING WITH MULTIPLE BUFFERS *buffer-write*
  817. *:wa* *:wall*
  818. :wa[ll] Write all changed buffers. Buffers without a file
  819. name cause an error message. Buffers which are
  820. readonly are not written.
  821. :wa[ll]! Write all changed buffers, even the ones that are
  822. readonly. Buffers without a file name are not
  823. written and cause an error message.
  824. Vim will warn you if you try to overwrite a file that has been changed
  825. elsewhere (unless "!" was used). See |timestamp|.
  826. *backup* *E207* *E506* *E507* *E508* *E509* *E510*
  827. If you write to an existing file (but do not append) while the 'backup',
  828. 'writebackup' or 'patchmode' option is on, a backup of the original file is
  829. made. The file is either copied or renamed (see 'backupcopy'). After the
  830. file has been successfully written and when the 'writebackup' option is on and
  831. the 'backup' option is off, the backup file is deleted. When the 'patchmode'
  832. option is on the backup file may be renamed.
  833. *backup-table*
  834. 'backup' 'writebackup' action ~
  835. off off no backup made
  836. off on backup current file, deleted afterwards (default)
  837. on off delete old backup, backup current file
  838. on on delete old backup, backup current file
  839. When the 'backupskip' pattern matches with the name of the file which is
  840. written, no backup file is made. The values of 'backup' and 'writebackup' are
  841. ignored then.
  842. When the 'backup' option is on, an old backup file (with the same name as the
  843. new backup file) will be deleted. If 'backup' is not set, but 'writebackup'
  844. is set, an existing backup file will not be deleted. The backup file that is
  845. made while the file is being written will have a different name.
  846. On some filesystems it's possible that in a crash you lose both the backup and
  847. the newly written file (it might be there but contain bogus data). In that
  848. case try recovery, because the swap file is synced to disk and might still be
  849. there. |:recover|
  850. The directories given with the 'backupdir' option are used to put the backup
  851. file in. (default: same directory as the written file).
  852. Whether the backup is a new file, which is a copy of the original file, or the
  853. original file renamed depends on the 'backupcopy' option. See there for an
  854. explanation of when the copy is made and when the file is renamed.
  855. If the creation of a backup file fails, the write is not done. If you want
  856. to write anyway add a '!' to the command.
  857. *file-watcher*
  858. When you notice issues with programs, that act upon when a buffer is written
  859. (like inotify, entr or fswatch) or when external applications execute Vim to
  860. edit the file (like git) and those programs do not seem to notice that the
  861. original file has been changed, you may want to consider switching the
  862. 'backupcopy' option value to "yes". This makes sure, Vim writes to the same
  863. file, that those watcher programs expect, without creating a new file (which
  864. prevents them from detecting that the file has changed). See also |crontab|
  865. *write-permissions*
  866. When writing a new file the permissions are read-write. For unix the mask is
  867. 0o666 with additionally umask applied. When writing a file that was read Vim
  868. will preserve the permissions, but clear the s-bit.
  869. *write-readonly*
  870. When the 'cpoptions' option contains 'W', Vim will refuse to overwrite a
  871. readonly file. When 'W' is not present, ":w!" will overwrite a readonly file,
  872. if the system allows it (the directory must be writable).
  873. *write-fail*
  874. If the writing of the new file fails, you have to be careful not to lose
  875. your changes AND the original file. If there is no backup file and writing
  876. the new file failed, you have already lost the original file! DON'T EXIT VIM
  877. UNTIL YOU WRITE OUT THE FILE! If a backup was made, it is put back in place
  878. of the original file (if possible). If you exit Vim, and lose the changes
  879. you made, the original file will mostly still be there. If putting back the
  880. original file fails, there will be an error message telling you that you
  881. lost the original file.
  882. *DOS-format-write*
  883. If the 'fileformat' is "dos", <CR><NL> is used for <EOL>. This is default
  884. for Windows. On other systems the message "[dos]" is shown to
  885. remind you that an unusual <EOL> was used.
  886. *Unix-format-write*
  887. If the 'fileformat' is "unix", <NL> is used for <EOL>. On Windows
  888. the message "[unix]" is shown.
  889. *Mac-format-write*
  890. If the 'fileformat' is "mac", <CR> is used for <EOL>. The
  891. message "[mac]" is shown.
  892. See also |file-formats| and the 'fileformat' and 'fileformats' options.
  893. *ACL*
  894. ACL stands for Access Control List. It is an advanced way to control access
  895. rights for a file. It is used on new MS-Windows and Unix systems, but only
  896. when the filesystem supports it.
  897. Vim attempts to preserve the ACL info when writing a file. The backup file
  898. will get the ACL info of the original file.
  899. The ACL info is also used to check if a file is read-only (when opening the
  900. file).
  901. *xattr* *E1506* *E1508* *E1509*
  902. xattr stands for Extended Attributes. It is an advanced way to save metadata
  903. alongside the file in the filesystem. It depends on the actual filesystem
  904. being used and Vim supports it only on a Linux system.
  905. Vim attempts to preserve the extended attribute info when writing a file.
  906. The backup file will get the extended attribute of the original file.
  907. *read-only-share*
  908. When MS-Windows shares a drive on the network it can be marked as read-only.
  909. This means that even if the file read-only attribute is absent, and the ACL
  910. settings on NT network shared drives allow writing to the file, you can still
  911. not write to the file. Vim on Win32 platforms will detect read-only network
  912. drives and will mark the file as read-only. You will not be able to override
  913. it with |:write|.
  914. *write-device*
  915. When the file name is actually a device name, Vim will not make a backup (that
  916. would be impossible). You need to use "!", since the device already exists.
  917. Example for Unix: >
  918. :w! /dev/lpt0
  919. and MS-Windows: >
  920. :w! lpt0
  921. For Unix a device is detected when the name doesn't refer to a normal file or
  922. a directory. A fifo or named pipe also looks like a device to Vim.
  923. For MS-Windows the device is detected by its name:
  924. CON
  925. CLOCK$
  926. NUL
  927. PRN
  928. COMn n=1,2,3... etc
  929. LPTn n=1,2,3... etc
  930. The names can be in upper- or lowercase.
  931. ==============================================================================
  932. 5. Writing and quitting *write-quit*
  933. *:q* *:quit*
  934. :q[uit] Quit the current window. Quit Vim if this is the last
  935. |edit-window|. This fails when changes have been made
  936. and Vim refuses to |abandon| the current buffer, and
  937. when the last file in the argument list has not been
  938. edited.
  939. If there are other tab pages and quitting the last
  940. window in the current tab page the current tab page is
  941. closed |tab-page|.
  942. Triggers the |QuitPre| autocommand event.
  943. See |CTRL-W_q| for quitting another window.
  944. :conf[irm] q[uit] Quit, but give prompt when changes have been made, or
  945. the last file in the argument list has not been
  946. edited. See |:confirm| and 'confirm'.
  947. :q[uit]! Quit without writing, also when the current buffer has
  948. changes. The buffer is unloaded, also when it has
  949. 'hidden' set.
  950. If this is the last window and there is a modified
  951. hidden buffer, the current buffer is abandoned and the
  952. first changed hidden buffer becomes the current
  953. buffer.
  954. Use ":qall!" to exit always.
  955. :cq[uit] Quit always, without writing, and return an error
  956. code. See |:cq|.
  957. *:wq*
  958. :wq [++opt] Write the current file and close the window. If this
  959. was the last |edit-window| Vim quits.
  960. Writing fails when the file is read-only or the buffer
  961. does not have a name. Quitting fails when the last
  962. file in the argument list has not been edited.
  963. :wq! [++opt] Write the current file and close the window. If this
  964. was the last |edit-window| Vim quits. Writing fails
  965. when the current buffer does not have a name.
  966. :wq [++opt] {file} Write to {file} and close the window. If this was the
  967. last |edit-window| Vim quits. Quitting fails when the
  968. last file in the argument list has not been edited.
  969. :wq! [++opt] {file} Write to {file} and close the current window. Quit
  970. Vim if this was the last |edit-window|.
  971. :[range]wq[!] [++opt] [file]
  972. Same as above, but only write the lines in [range].
  973. *:x* *:xit*
  974. :[range]x[it][!] [++opt] [file]
  975. Like ":wq", but write only when changes have been
  976. made.
  977. When 'hidden' is set and there are more windows, the
  978. current buffer becomes hidden, after writing the file.
  979. *:exi* *:exit*
  980. :[range]exi[t][!] [++opt] [file]
  981. Same as :xit.
  982. *ZZ*
  983. ZZ Write current file, if modified, and close the current
  984. window (same as ":x").
  985. If there are several windows for the current file,
  986. only the current window is closed.
  987. *ZQ*
  988. ZQ Quit without checking for changes (same as ":q!").
  989. MULTIPLE WINDOWS AND BUFFERS *window-exit*
  990. *:qa* *:qall*
  991. :qa[ll] Exit Vim, unless there are some buffers which have been
  992. changed. (Use ":bmod" to go to the next modified buffer).
  993. When 'autowriteall' is set all changed buffers will be
  994. written, like |:wqall|.
  995. :conf[irm] qa[ll]
  996. Exit Vim. Bring up a prompt when some buffers have been
  997. changed. See |:confirm|.
  998. :qa[ll]! Exit Vim. Any changes to buffers are lost.
  999. Also see |:cquit|, it does the same but exits with a non-zero
  1000. value.
  1001. *:quita* *:quitall*
  1002. :quita[ll][!] Same as ":qall".
  1003. :wqa[ll] [++opt] *:wqa* *:wqall* *:xa* *:xall*
  1004. :xa[ll] Write all changed buffers and exit Vim. If there are buffers
  1005. without a file name, which are readonly or which cannot be
  1006. written for another reason, Vim will not quit.
  1007. :conf[irm] wqa[ll] [++opt]
  1008. :conf[irm] xa[ll]
  1009. Write all changed buffers and exit Vim. Bring up a prompt
  1010. when some buffers are readonly or cannot be written for
  1011. another reason. See |:confirm|.
  1012. :wqa[ll]! [++opt]
  1013. :xa[ll]! Write all changed buffers, even the ones that are readonly,
  1014. and exit Vim. If there are buffers without a file name or
  1015. which cannot be written for another reason, Vim will not quit.
  1016. ==============================================================================
  1017. 6. Dialogs *edit-dialogs*
  1018. *:confirm* *:conf*
  1019. :conf[irm] {command} Execute {command}, and use a dialog when an
  1020. operation has to be confirmed. Can be used on the
  1021. |:edit|, |:q|, |:qa| and |:w| commands (the latter to
  1022. override a read-only setting), and any commands that
  1023. can fail because of unsaved changes, such as |:only|,
  1024. |:buffer|, |:bdelete|, etc.
  1025. Examples: >
  1026. :confirm w foo
  1027. < Will ask for confirmation when "foo" already exists. >
  1028. :confirm q
  1029. < Will ask for confirmation when there are changes. >
  1030. :confirm qa
  1031. < If any modified, unsaved buffers exist, you will be prompted to save
  1032. or abandon each one. There are also choices to "save all" or "abandon
  1033. all".
  1034. If you want to always use ":confirm", set the 'confirm' option.
  1035. *:browse* *:bro* *E338* *E614* *E615* *E616*
  1036. :bro[wse] {command} Open a file selection dialog for an argument to
  1037. {command}. At present this works for |:e|, |:w|,
  1038. |:wall|, |:wq|, |:wqall|, |:x|, |:xall|, |:exit|,
  1039. |:view|, |:sview|, |:r|, |:saveas|, |:sp|, |:mkexrc|,
  1040. |:mkvimrc|, |:mksession|, |:mkview|, |:split|,
  1041. |:vsplit|, |:tabe|, |:tabnew|, |:cfile|, |:cgetfile|,
  1042. |:caddfile|, |:lfile|, |:lgetfile|, |:laddfile|,
  1043. |:diffsplit|, |:diffpatch|, |:pedit|, |:redir|,
  1044. |:source|, |:update|, |:visual|, |:vsplit|,
  1045. and |:qall| if 'confirm' is set.
  1046. Note: only in Win32 GUI; in console `:browse edit`
  1047. works if the FileExplorer autocommand group exists.
  1048. When ":browse" is not possible you get an error
  1049. message. If {command} doesn't support browsing, the
  1050. {command} is executed without a dialog.
  1051. ":browse set" works like |:options|.
  1052. See also |:oldfiles| for ":browse oldfiles".
  1053. The syntax is best shown via some examples: >
  1054. :browse e $vim/foo
  1055. < Open the browser in the $vim/foo directory, and edit the
  1056. file chosen. >
  1057. :browse e
  1058. < Open the browser in the directory specified with 'browsedir',
  1059. and edit the file chosen. >
  1060. :browse w
  1061. < Open the browser in the directory of the current buffer,
  1062. with the current buffer filename as default, and save the
  1063. buffer under the filename chosen. >
  1064. :browse w C:/bar
  1065. < Open the browser in the C:/bar directory, with the current
  1066. buffer filename as default, and save the buffer under the
  1067. filename chosen.
  1068. Also see the 'browsedir' option.
  1069. For versions of Vim where browsing is not supported, the command is executed
  1070. unmodified.
  1071. *browsefilter*
  1072. For MS-Windows you can modify the filters that are used in the browse
  1073. dialog. By setting the g:browsefilter or b:browsefilter variables, you can
  1074. change the filters globally or locally to the buffer. The variable is set to
  1075. a string in the format "{filter label}\t{pattern};{pattern}\n" where "{filter
  1076. label}" is the text that appears in the "Files of Type" comboBox, and {pattern}
  1077. is the pattern which filters the filenames. Several patterns can be given,
  1078. separated by ';'.
  1079. For example, to have only Vim files in the dialog, you could use the following
  1080. command: >
  1081. let g:browsefilter = "Vim scripts\t*.vim\nVim Startup Files\t*vimrc\n"
  1082. You can override the filter setting on a per-buffer basis by setting the
  1083. b:browsefilter variable. You would most likely set b:browsefilter in a
  1084. filetype plugin, so that the browse dialog would contain entries related to
  1085. the type of file you are currently editing. Disadvantage: This makes it
  1086. difficult to start editing a file of a different type. To overcome this, you
  1087. may want to add "All Files (*.*)\t*\n" as the final filter on Windows or "All
  1088. Files (*)\t*\n" on other platforms, so that the user can still access any
  1089. desired file.
  1090. To avoid setting browsefilter when Vim does not actually support it, you can
  1091. use has("browsefilter"): >
  1092. if has("browsefilter")
  1093. let g:browsefilter = "whatever"
  1094. endif
  1095. ==============================================================================
  1096. 7. The current directory *current-directory*
  1097. You can use |:cd|, |:tcd| and |:lcd| to change to another directory, so you
  1098. will not have to type that directory name in front of the file names. It also
  1099. makes a difference for executing external commands, e.g. ":!ls" or ":te ls".
  1100. There are three current-directory "scopes": global, tab and window. The
  1101. window-local working directory takes precedence over the tab-local
  1102. working directory, which in turn takes precedence over the global
  1103. working directory. If a local working directory (tab or window) does not
  1104. exist, the next-higher scope in the hierarchy applies.
  1105. *:cd* *E747* *E472*
  1106. :cd[!] On non-Unix systems when 'cdhome' is off: Print the
  1107. current directory name.
  1108. Otherwise: Change the current directory to the home
  1109. directory. Clear any window-local directory.
  1110. Use |:pwd| to print the current directory on all
  1111. systems.
  1112. :cd[!] {path} Change the current directory to {path}.
  1113. If {path} is relative, it is searched for in the
  1114. directories listed in |'cdpath'|.
  1115. Clear any window-local directory.
  1116. Does not change the meaning of an already opened file,
  1117. because its full path name is remembered. Files from
  1118. the |arglist| may change though!
  1119. On MS-Windows this also changes the active drive.
  1120. To change to the directory of the current file: >
  1121. :cd %:h
  1122. <
  1123. *:cd-* *E186*
  1124. :cd[!] - Change to the previous current directory (before the
  1125. previous ":cd {path}" command).
  1126. *:chd* *:chdir*
  1127. :chd[ir][!] [path] Same as |:cd|.
  1128. *:tc* *:tcd*
  1129. :tc[d][!] {path} Like |:cd|, but only set the directory for the current
  1130. tab. The current window will also use this directory.
  1131. The current directory is not changed for windows in
  1132. other tabs and for windows in the current tab that
  1133. have their own window-local directory.
  1134. *:tcd-*
  1135. :tc[d][!] - Change to the previous current directory (before the
  1136. previous ":tcd {path}" command).
  1137. *:tch* *:tchdir*
  1138. :tch[dir][!] Same as |:tcd|.
  1139. *:lc* *:lcd*
  1140. :lc[d][!] {path} Like |:cd|, but only set the current directory for the
  1141. current window. The current directory for other
  1142. windows or tabs is not changed.
  1143. *:lch* *:lchdir*
  1144. :lch[dir][!] Same as |:lcd|.
  1145. *:lcd-*
  1146. :lc[d][!] - Change to the previous current directory (before the
  1147. previous ":lcd {path}" command).
  1148. *:pw* *:pwd* *E187*
  1149. :pw[d] Print the current directory name.
  1150. Also see |getcwd()|.
  1151. *:pwd-verbose*
  1152. When 'verbose' is non-zero, |:pwd| will also display
  1153. what scope the current directory was set. Example: >
  1154. " Set by :cd
  1155. :verbose pwd
  1156. [global] /path/to/current
  1157. " Set by :lcd
  1158. :verbose pwd
  1159. [window] /path/to/current
  1160. " Set by :tcd
  1161. :verbose pwd
  1162. [tabpage] /path/to/current
  1163. So long as no |:lcd| or |:tcd| command has been used, all windows share the
  1164. same current directory. Using a command to jump to another window doesn't
  1165. change anything for the current directory.
  1166. When |:lcd| has been used for a window, the specified directory becomes the
  1167. current directory for that window. Windows where the |:lcd| command has not
  1168. been used stick to the global or tab-local directory. When jumping to another
  1169. window the current directory is changed to the last specified local current
  1170. directory. If none was specified, the global or tab-local directory is used.
  1171. When creating a new window it inherits the local directory of the current window.
  1172. When changing tabs the same behaviour applies. If the current tab has no
  1173. local working directory the global working directory is used.
  1174. When a |:cd| command is used, the current window and tab will lose their local
  1175. current directories and will use the global current directory from now on.
  1176. When a |:tcd| command is used, only the current window will lose its local
  1177. working directory.
  1178. After using |:cd| the full path name will be used for reading and writing
  1179. files. On some networked file systems this may cause problems. The result of
  1180. using the full path name is that the file names currently in use will remain
  1181. referring to the same file. Example: If you have a file a:test and a
  1182. directory a:vim the commands ":e test" ":cd vim" ":w" will overwrite the file
  1183. a:test and not write a:vim/test. But if you do ":w test" the file a:vim/test
  1184. will be written, because you gave a new file name and did not refer to a
  1185. filename before the ":cd".
  1186. ==============================================================================
  1187. 8. Editing binary files *edit-binary*
  1188. Although Vim was made to edit text files, it is possible to edit binary
  1189. files. The |-b| Vim argument (b for binary) makes Vim do file I/O in binary
  1190. mode, and sets some options for editing binary files ('binary' on, 'textwidth'
  1191. to 0, 'modeline' off, 'expandtab' off). Setting the 'binary' option has the
  1192. same effect. Don't forget to do this before reading the file.
  1193. There are a few things to remember when editing binary files:
  1194. - When editing executable files the number of bytes must not change.
  1195. Use only the "R" or "r" command to change text. Do not delete characters
  1196. with "x" or by backspacing.
  1197. - Set the 'textwidth' option to 0. Otherwise lines will unexpectedly be
  1198. split in two.
  1199. - When there are not many <EOL>s, the lines will become very long. If you
  1200. want to edit a line that does not fit on the screen reset the 'wrap' option.
  1201. Horizontal scrolling is used then. If a line becomes too long (see |limits|)
  1202. you cannot edit that line. The line will be split when reading the file.
  1203. It is also possible that you get an "out of memory" error when reading the
  1204. file.
  1205. - Make sure the 'binary' option is set BEFORE loading the
  1206. file. Otherwise both <CR><NL> and <NL> are considered to end a line
  1207. and when the file is written the <NL> will be replaced with <CR><NL>.
  1208. - <Nul> characters are shown on the screen as ^@. You can enter them with
  1209. "CTRL-V CTRL-@" or "CTRL-V 000".
  1210. - To insert a <NL> character in the file split a line. When writing the
  1211. buffer to a file a <NL> will be written for the <EOL>.
  1212. - Vim normally appends an <EOL> at the end of the file if there is none.
  1213. Setting the 'binary' option prevents this. If you want to add the final
  1214. <EOL>, set the 'endofline' option. You can also read the value of this
  1215. option to see if there was an <EOL> for the last line (you cannot see this
  1216. in the text).
  1217. ==============================================================================
  1218. 9. Encryption *encryption*
  1219. *:X* *E817* *E818* *E819* *E820*
  1220. Support for editing encrypted files has been removed.
  1221. https://github.com/neovim/neovim/issues/694
  1222. https://github.com/neovim/neovim/issues/701
  1223. ==============================================================================
  1224. 10. Timestamps *timestamp* *timestamps*
  1225. Vim remembers the modification timestamp, mode and size of a file when you
  1226. begin editing it. This is used to avoid that you have two different versions
  1227. of the same file (without you knowing this).
  1228. After a shell command is run (|:!cmd| |suspend| |:read!| |K|) timestamps,
  1229. file modes and file sizes are compared for all buffers in a window. Vim will
  1230. run any associated |FileChangedShell| autocommands or display a warning for
  1231. any files that have changed. In the GUI this happens when Vim regains input
  1232. focus.
  1233. *E321* *E462*
  1234. If you want to automatically reload a file when it has been changed outside of
  1235. Vim, set the 'autoread' option. This doesn't work at the moment you write the
  1236. file though, only when the file wasn't changed inside of Vim.
  1237. *ignore-timestamp*
  1238. If you do not want to be asked or automatically reload the file, you can use
  1239. this: >
  1240. set buftype=nofile
  1241. Or, when starting gvim from a shell: >
  1242. gvim file.log -c "set buftype=nofile"
  1243. Note that if a FileChangedShell autocommand is defined you will not get a
  1244. warning message or prompt. The autocommand is expected to handle this.
  1245. There is no warning for a directory (e.g., with |netrw-browse|). But you do
  1246. get warned if you started editing a new file and it was created as a directory
  1247. later.
  1248. When Vim notices the timestamp of a file has changed, and the file is being
  1249. edited in a buffer but has not changed, Vim checks if the contents of the file
  1250. is equal. This is done by reading the file again (into a hidden buffer, which
  1251. is immediately deleted again) and comparing the text. If the text is equal,
  1252. you will get no warning.
  1253. If you don't get warned often enough you can use the following command.
  1254. *:checkt* *:checktime*
  1255. :checkt[ime] Check if any buffers were changed outside of Vim.
  1256. This checks and warns you if you would end up with two
  1257. versions of a file.
  1258. If this is called from an autocommand, a ":global"
  1259. command or is not typed the actual check is postponed
  1260. until a moment the side effects (reloading the file)
  1261. would be harmless.
  1262. Each loaded buffer is checked for its associated file
  1263. being changed. If the file was changed Vim will take
  1264. action. If there are no changes in the buffer and
  1265. 'autoread' is set, the buffer is reloaded. Otherwise,
  1266. you are offered the choice of reloading the file. If
  1267. the file was deleted you get an error message.
  1268. If the file previously didn't exist you get a warning
  1269. if it exists now.
  1270. Once a file has been checked the timestamp is reset,
  1271. you will not be warned again.
  1272. Syntax highlighting, marks, diff status,
  1273. 'fileencoding', 'fileformat' and 'binary' options
  1274. are not changed. See |v:fcs_choice| to reload these
  1275. too (for example, if a code formatting tools has
  1276. changed the file).
  1277. :[N]checkt[ime] {filename}
  1278. :[N]checkt[ime] [N]
  1279. Check the timestamp of a specific buffer. The buffer
  1280. may be specified by name, number or with a pattern.
  1281. *E813* *E814*
  1282. Vim will reload the buffer if you chose to. If a window is visible that
  1283. contains this buffer, the reloading will happen in the context of this window.
  1284. Otherwise a special window is used, so that most autocommands will work. You
  1285. can't close this window. A few other restrictions apply. Best is to make
  1286. sure nothing happens outside of the current buffer. E.g., setting
  1287. window-local options may end up in the wrong window. Splitting the window,
  1288. doing something there and closing it should be OK (if there are no side
  1289. effects from other autocommands). Closing unrelated windows and buffers will
  1290. get you into trouble.
  1291. Before writing a file, the timestamp is checked (unless "!" was used).
  1292. If it has changed, Vim will ask if you really want to overwrite the file:
  1293. WARNING: The file has been changed since reading it!!!
  1294. Do you really want to write to it (y/n)?
  1295. If you hit 'y' Vim will continue writing the file. If you hit 'n' the write is
  1296. aborted. If you used ":wq" or "ZZ" Vim will not exit, you will get another
  1297. chance to write the file.
  1298. The message would normally mean that somebody has written to the file after
  1299. the edit session started. This could be another person, in which case you
  1300. probably want to check if your changes to the file and the changes from the
  1301. other person should be merged. Write the file under another name and check for
  1302. differences (the "diff" program can be used for this).
  1303. It is also possible that you modified the file yourself, from another edit
  1304. session or with another command (e.g., a filter command). Then you will know
  1305. which version of the file you want to keep.
  1306. The accuracy of the time check depends on the filesystem. On Unix it is
  1307. usually sub-second. With old file systems and on MS-Windows it is normally one
  1308. second. Use `has('nanotime')` to check if sub-second time stamp checks are
  1309. available.
  1310. There is one situation where you get the message while there is nothing wrong:
  1311. On a Win32 system on the day daylight saving time starts. There is something
  1312. in the Win32 libraries that confuses Vim about the hour time difference. The
  1313. problem goes away the next day.
  1314. ==============================================================================
  1315. 11. File Searching *file-searching*
  1316. The file searching is currently used for the 'path', 'cdpath' and 'tags'
  1317. options, for |finddir()| and |findfile()|. Other commands use |wildcards|
  1318. which is slightly different.
  1319. There are three different types of searching:
  1320. 1) Downward search: *starstar*
  1321. Downward search uses the wildcards "*", "**" and possibly others
  1322. supported by your operating system. "*" and "**" are handled inside Vim,
  1323. so they work on all operating systems. Note that "**" only acts as a
  1324. special wildcard when it is at the start of a name.
  1325. The usage of "*" is quite simple: It matches 0 or more characters. In a
  1326. search pattern this would be ".*". Note that the "." is not used for file
  1327. searching.
  1328. "**" is more sophisticated:
  1329. - It ONLY matches directories.
  1330. - It matches up to 30 directories deep by default, so you can use it to
  1331. search an entire directory tree
  1332. - The maximum number of levels matched can be given by appending a number
  1333. to "**".
  1334. Thus '/usr/**2' can match: >
  1335. /usr
  1336. /usr/include
  1337. /usr/include/sys
  1338. /usr/include/g++
  1339. /usr/lib
  1340. /usr/lib/X11
  1341. ....
  1342. < It does NOT match '/usr/include/g++/std' as this would be three
  1343. levels.
  1344. The allowed number range is 0 ("**0" is removed) to 100
  1345. If the given number is smaller than 0 it defaults to 30, if it's
  1346. bigger than 100 then 100 is used. The system also has a limit on the
  1347. path length, usually 256 or 1024 bytes.
  1348. - "**" can only be at the end of the path or be followed by a path
  1349. separator or by a number and a path separator.
  1350. You can combine "*" and "**" in any order: >
  1351. /usr/**/sys/*
  1352. /usr/*tory/sys/**
  1353. /usr/**2/sys/*
  1354. 2) Upward search:
  1355. Here you can give a directory and then search the directory tree upward for
  1356. a file. You could give stop-directories to limit the upward search. The
  1357. stop-directories are appended to the path (for the 'path' option) or to
  1358. the filename (for the 'tags' option) with a ';'. If you want several
  1359. stop-directories separate them with ';'. If you want no stop-directory
  1360. ("search upward till the root directory") just use ';'. >
  1361. /usr/include/sys;/usr
  1362. < will search in: >
  1363. /usr/include/sys
  1364. /usr/include
  1365. /usr
  1366. <
  1367. If you use a relative path the upward search is started in Vim's current
  1368. directory or in the directory of the current file (if the relative path
  1369. starts with './' and 'd' is not included in 'cpoptions').
  1370. If Vim's current path is /u/user_x/work/release and you do >
  1371. :set path=include;/u/user_x
  1372. < and then search for a file with |gf| the file is searched in: >
  1373. /u/user_x/work/release/include
  1374. /u/user_x/work/include
  1375. /u/user_x/include
  1376. < Note: If your 'path' setting includes a non-existing directory, Vim will
  1377. skip the non-existing directory, and also does not search in the parent of
  1378. the non-existing directory if upwards searching is used.
  1379. 3) Combined up/downward search:
  1380. If Vim's current path is /u/user_x/work/release and you do >
  1381. set path=**;/u/user_x
  1382. < and then search for a file with |gf| the file is searched in: >
  1383. /u/user_x/work/release/**
  1384. /u/user_x/work/**
  1385. /u/user_x/**
  1386. <
  1387. BE CAREFUL! This might consume a lot of time, as the search of
  1388. '/u/user_x/**' includes '/u/user_x/work/**' and
  1389. '/u/user_x/work/release/**'. So '/u/user_x/work/release/**' is searched
  1390. three times and '/u/user_x/work/**' is searched twice.
  1391. In the above example you might want to set path to: >
  1392. :set path=**,/u/user_x/**
  1393. < This searches: >
  1394. /u/user_x/work/release/**
  1395. /u/user_x/**
  1396. < This searches the same directories, but in a different order.
  1397. Note that completion for ":find", ":sfind", and ":tabfind" commands do not
  1398. currently work with 'path' items that contain a URL or use the double star
  1399. with depth limiter (/usr/**2) or upward search (;) notations.
  1400. ==============================================================================
  1401. 12. Trusted Files *trust*
  1402. Nvim executes arbitrary code found on the filesystem if 'exrc' is enabled. To
  1403. prevent executing malicious code, only "trusted files" are executed. You can
  1404. mark a file as trusted or untrusted using the |:trust| command or the
  1405. |vim.secure.read()| function.
  1406. *:trust* *E5570*
  1407. :trust [++deny] [++remove] [file]
  1408. Manage trusted files. Without ++ options, :trust marks
  1409. the current buffer as trusted, keyed on a hash of its
  1410. contents. The trust list is stored on disk, Nvim will
  1411. re-use it after restarting.
  1412. [++deny] marks [file] (or current buffer if no [file]) as
  1413. untrusted: it will never be executed, 'exrc' will
  1414. ignore it.
  1415. [++remove] removes [file] (or current buffer if no
  1416. [file]) from the trust list. When the file is
  1417. discovered by 'exrc' or |vim.secure.read()|, the user
  1418. will be asked whether to trust or deny the file.
  1419. vim:tw=78:ts=8:noet:ft=help:norl: