From 244dbe3a77bf548f73d8781da7327f30e818b08a Mon Sep 17 00:00:00 2001 From: ZyX Date: Sat, 25 Apr 2015 18:47:31 +0300 Subject: viminfo: First version of ShaDa file dumping What works: 1. ShaDa file dumping: header, registers, jump list, history, search patterns, substitute strings, variables. 2. ShaDa file reading: registers, global marks, variables. Most was not tested. TODO: 1. Merging. 2. Reading history, local marks, jump and buffer lists. 3. Documentation update. 4. Converting some data from &encoding. 5. Safer variant of dumping viminfo (dump to temporary file then rename). 6. Removing old viminfo code (currently masked with `#if 0` in a ShaDa file for reference). --- runtime/doc/options.txt | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 897137ff42..085f6f21a8 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -6770,10 +6770,14 @@ A jump table for the options with a short description can be found at |Q_op|. e.g., for Unix: "r/tmp". Case is ignored. Maximum length of each 'r' argument is 50 characters. *viminfo-s* - s Maximum size of an item in Kbyte. If zero then registers are - not saved. Currently only applies to registers. The default - "s10" will exclude registers with more than 10 Kbyte of text. - Also see the '<' item above: line count limit. + s Maximum size of an item contents in KiB. If zero then nothing + is saved. Unlike Vim this applies to all items, except for + the buffer list and header. Full item size is off by three + unsigned integers: with `s10` maximum item size may be 1 byte + (type: 7-bit integer) + 9 bytes (timestamp: up to 64-bit + integer) + 3 bytes (item size: up to 16-bit integer because + 2^8 < 10240 < 2^16) + 10240 bytes (requested maximum item + contents size) = 10253 bytes. Example: > :set viminfo='50,<1000,s100,:0,n~/vim/viminfo @@ -6782,7 +6786,8 @@ A jump table for the options with a short description can be found at |Q_op|. edited. <1000 Contents of registers (up to 1000 lines each) will be remembered. - s100 Registers with more than 100 Kbyte text are skipped. + s100 Items with contents occupying more then 100 KiB are + skipped. :0 Command-line history will not be saved. n~/vim/viminfo The name of the file to use is "~/vim/viminfo". no / Since '/' is not specified, the default will be used, -- cgit From b7ebd16af099defc76264d3e525c83d799ad875c Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 5 Jul 2015 14:08:50 +0300 Subject: documentation: Update documentation --- runtime/doc/autocmd.txt | 8 +-- runtime/doc/cmdline.txt | 2 +- runtime/doc/eval.txt | 14 ++-- runtime/doc/index.txt | 6 +- runtime/doc/mbyte.txt | 2 +- runtime/doc/motion.txt | 10 +-- runtime/doc/options.txt | 69 +++++++++--------- runtime/doc/quickref.txt | 12 ++-- runtime/doc/starting.txt | 177 +++++++++++++++++++++++------------------------ runtime/doc/usr_21.txt | 38 +++++----- runtime/doc/usr_45.txt | 2 +- runtime/doc/usr_toc.txt | 2 +- runtime/doc/various.txt | 2 +- runtime/doc/vim_diff.txt | 11 ++- runtime/doc/windows.txt | 2 +- 15 files changed, 183 insertions(+), 174 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/autocmd.txt b/runtime/doc/autocmd.txt index af9676272f..f63c319c2f 100644 --- a/runtime/doc/autocmd.txt +++ b/runtime/doc/autocmd.txt @@ -265,8 +265,8 @@ Name triggered by ~ |TermResponse| after the terminal response to |t_RV| is received |QuitPre| when using `:quit`, before deciding whether to quit -|VimLeavePre| before exiting Vim, before writing the viminfo file -|VimLeave| before exiting Vim, after writing the viminfo file +|VimLeavePre| before exiting Vim, before writing the shada file +|VimLeave| before exiting Vim, after writing the shada file Various |FileChangedShell| Vim notices that a file changed since editing started @@ -912,14 +912,14 @@ VimEnter After doing all the startup stuff, including the buffers in them. *VimLeave* VimLeave Before exiting Vim, just after writing the - .viminfo file. Executed only once, like + .shada file. Executed only once, like VimLeavePre. To detect an abnormal exit use |v:dying|. When v:dying is 2 or more this event is not triggered. *VimLeavePre* VimLeavePre Before exiting Vim, just before writing the - .viminfo file. This is executed only once, + .shada file. This is executed only once, if there is a match with the name of what happens to be the current buffer when exiting. Mostly useful with a "*" pattern. > diff --git a/runtime/doc/cmdline.txt b/runtime/doc/cmdline.txt index b208bba9a8..627a7000ec 100644 --- a/runtime/doc/cmdline.txt +++ b/runtime/doc/cmdline.txt @@ -729,7 +729,7 @@ function expand() |expand()|. # 0) is replaced with old *:_#<* *c_#<* file name n. See |:oldfiles| or |v:oldfiles| to get the number. *E809* - {only when compiled with the |+eval| and |+viminfo| features} + {only when compiled with the |+eval| and |+shada| features} Note that these, except "# set charconvert=CharConvert() fun CharConvert() @@ -2165,7 +2165,7 @@ A jump table for the options with a short description can be found at |Q_op|. feature} Sets the character encoding used inside Vim. It applies to text in the buffers, registers, Strings in expressions, text stored in the - viminfo file, etc. It sets the kind of characters which Vim can work + shada file, etc. It sets the kind of characters which Vim can work with. See |encoding-names| for the possible values. 'encoding' cannot be changed after startup, because (1) it causes @@ -2197,7 +2197,7 @@ A jump table for the options with a short description can be found at |Q_op|. When "unicode", "ucs-2" or "ucs-4" is used, Vim internally uses utf-8. You don't notice this while editing, but it does matter for the - |viminfo-file|. And Vim expects the terminal to use utf-8 too. Thus + |shada-file|. And Vim expects the terminal to use utf-8 too. Thus setting 'encoding' to one of these values instead of utf-8 only has effect for encoding used for files when 'fileencoding' is empty. @@ -3409,7 +3409,7 @@ A jump table for the options with a short description can be found at |Q_op|. line below a closed fold. A match in a previous line which is not drawn may not continue in a newly drawn line. You can specify whether the highlight status is restored on startup - with the 'h' flag in 'viminfo' |viminfo-h|. + with the 'h' flag in 'viminfo' |shada-h|. *'history'* *'hi'* 'history' 'hi' number (Vim default: 10000, Vi default: 0) @@ -3795,7 +3795,8 @@ A jump table for the options with a short description can be found at |Q_op|. option. Careful: If you change this option, it might break expanding environment variables. E.g., when '/' is included and Vim tries to - expand "$HOME/.viminfo". Maybe you should change 'iskeyword' instead. + expand "$HOME/.nvim/shada/main.shada". Maybe you should change + 'iskeyword' instead. *'iskeyword'* *'isk'* 'iskeyword' 'isk' string (Vim default for @@ -6622,7 +6623,7 @@ A jump table for the options with a short description can be found at |Q_op|. global When bigger than zero, Vim will give messages about what it is doing. Currently, these messages are given: - >= 1 When the viminfo file is read or written. + >= 1 When the shada file is read or written. >= 2 When a file is ":source"'ed. >= 5 Every searched tags file and include file. >= 8 Files for which a group of autocommands is executed. @@ -6688,10 +6689,10 @@ A jump table for the options with a short description can be found at |Q_op|. others: '!,100,<50,s10,h Vi default: "") global - {not available when compiled without the |+viminfo| + {not available when compiled without the |+shada| feature} - When non-empty, the viminfo file is read upon startup and written - when exiting Vim (see |viminfo-file|). The string should be a comma + When non-empty, the shada file is read upon startup and written + when exiting Vim (see |shada-file|). The string should be a comma separated list of parameters, each consisting of a single character identifying the particular parameter, followed by a number or string which specifies the value of that parameter. If a particular @@ -6699,69 +6700,69 @@ A jump table for the options with a short description can be found at |Q_op|. parameter. The following is a list of the identifying characters and the effect of their value. CHAR VALUE ~ - *viminfo-!* + *shada-!* ! When included, save and restore global variables that start with an uppercase letter, and don't contain a lowercase letter. Thus "KEEPTHIS and "K_L_M" are stored, but "KeepThis" and "_K_L_M" are not. Nested List and Dict items may not be read back correctly, you end up with an empty item. - *viminfo-quote* + *shada-quote* " Maximum number of lines saved for each register. Old name of the '<' item, with the disadvantage that you need to put a backslash before the ", otherwise it will be recognized as the start of a comment! - *viminfo-%* + *shada-%* % When included, save and restore the buffer list. If Vim is started with a file name argument, the buffer list is not restored. If Vim is started without a file name argument, the - buffer list is restored from the viminfo file. Buffers + buffer list is restored from the shada file. Buffers without a file name and buffers for help files are not written - to the viminfo file. + to the shada file. When followed by a number, the number specifies the maximum number of buffers that are stored. Without a number all buffers are stored. - *viminfo-'* + *shada-'* ' Maximum number of previously edited files for which the marks are remembered. This parameter must always be included when 'viminfo' is non-empty. Including this item also means that the |jumplist| and the - |changelist| are stored in the viminfo file. - *viminfo-/* + |changelist| are stored in the shada file. + *shada-/* / Maximum number of items in the search pattern history to be saved. If non-zero, then the previous search and substitute patterns are also saved. When not included, the value of 'history' is used. - *viminfo-:* + *shada-:* : Maximum number of items in the command-line history to be saved. When not included, the value of 'history' is used. - *viminfo-<* + *shada-<* < Maximum number of lines saved for each register. If zero then registers are not saved. When not included, all lines are saved. '"' is the old name for this item. Also see the 's' item below: limit specified in Kbyte. - *viminfo-@* + *shada-@* @ Maximum number of items in the input-line history to be saved. When not included, the value of 'history' is used. - *viminfo-c* - c When included, convert the text in the viminfo file from the - 'encoding' used when writing the file to the current - 'encoding'. See |viminfo-encoding|. - *viminfo-f* + *shada-c* + c Dumb option, kept for compatibility reasons. Has no actual + effect. Current encoding state is described in + |shada-encoding|. + *shada-f* f Whether file marks need to be stored. If zero, file marks ('0 to '9, 'A to 'Z) are not stored. When not present or when non-zero, they are all stored. '0 is used for the current cursor position (when exiting or when doing ":wviminfo"). - *viminfo-h* - h Disable the effect of 'hlsearch' when loading the viminfo + *shada-h* + h Disable the effect of 'hlsearch' when loading the shada file. When not included, it depends on whether ":nohlsearch" has been used since the last search command. - *viminfo-n* - n Name of the viminfo file. The name must immediately follow + *shada-n* + n Name of the shada file. The name must immediately follow the 'n'. Must be the last one! If the "-i" argument was given when starting Vim, that file name overrides the one given here with 'viminfo'. Environment variables are expanded when opening the file, not when setting the option. - *viminfo-r* + *shada-r* r Removable media. The argument is a string (up to the next ','). This parameter can be given several times. Each specifies the start of a path for which no marks will be @@ -6769,7 +6770,7 @@ A jump table for the options with a short description can be found at |Q_op|. could use "ra:,rb:". You can also use it for temp files, e.g., for Unix: "r/tmp". Case is ignored. Maximum length of each 'r' argument is 50 characters. - *viminfo-s* + *shada-s* s Maximum size of an item contents in KiB. If zero then nothing is saved. Unlike Vim this applies to all items, except for the buffer list and header. Full item size is off by three @@ -6780,7 +6781,7 @@ A jump table for the options with a short description can be found at |Q_op|. contents size) = 10253 bytes. Example: > - :set viminfo='50,<1000,s100,:0,n~/vim/viminfo + :set viminfo='50,<1000,s100,:0,n~/nvim/shada < '50 Marks will be remembered for the last 50 files you edited. @@ -6789,7 +6790,7 @@ A jump table for the options with a short description can be found at |Q_op|. s100 Items with contents occupying more then 100 KiB are skipped. :0 Command-line history will not be saved. - n~/vim/viminfo The name of the file to use is "~/vim/viminfo". + n~/nvim/shada The name of the file to use is "~/nvim/shada". no / Since '/' is not specified, the default will be used, that is, save all of the search history, and also the previous search and substitute patterns. diff --git a/runtime/doc/quickref.txt b/runtime/doc/quickref.txt index c42d98ba90..503ab07079 100644 --- a/runtime/doc/quickref.txt +++ b/runtime/doc/quickref.txt @@ -911,7 +911,7 @@ Short explanation of each option: *option-list* 'verbosefile' 'vfile' file to write messages in 'viewdir' 'vdir' directory where to store files with :mkview 'viewoptions' 'vop' specifies what to save for :mkview -'viminfo' 'vi' use .viminfo file upon startup and exiting +'viminfo' 'vi' use .shada file upon startup and exiting 'virtualedit' 've' when to use virtual editing 'visualbell' 'vb' use visual bell instead of beeping 'warn' warn for shell command when buffer was changed @@ -1131,7 +1131,7 @@ Context-sensitive completion on the command-line: |-w| -w {scriptout} write typed chars to file {scriptout} (append) |-W| -W {scriptout} write typed chars to file {scriptout} (overwrite) |-u| -u {vimrc} read inits from {vimrc} instead of other inits -|-i| -i {viminfo} read info from {viminfo} instead of other files +|-i| -i {shada} read info from {shada} instead of other files |---| -- end of options, other arguments are file names |--help| --help show list of arguments and exit |--version| --version show version info and exit @@ -1215,12 +1215,12 @@ Context-sensitive completion on the command-line: ------------------------------------------------------------------------------ *Q_ac* Automatic Commands -|viminfo-file| read registers, marks, history at startup, save when exiting. +|shada-file| read registers, marks, history at startup, save when exiting. -|:rviminfo| :rv[iminfo] [file] read info from viminfo file [file] +|:rviminfo| :rv[iminfo] [file] read info from ShaDa file [file] |:rviminfo| :rv[iminfo]! [file] idem, overwrite existing info -|:wviminfo| :wv[iminfo] [file] add info to viminfo file [file] -|:wviminfo| :wv[iminfo]! [file] write info to viminfo file [file] +|:wviminfo| :wv[iminfo] [file] add info to ShaDa file [file] +|:wviminfo| :wv[iminfo]! [file] write info to ShaDa file [file] |modeline| Automatic option setting when editing a file diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt index aa37913779..83351c1002 100644 --- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -12,7 +12,7 @@ Starting Vim *starting* 4. Suspending |suspend| 5. Saving settings |save-settings| 6. Views and Sessions |views-sessions| -7. The viminfo file |viminfo-file| +7. The ShaDa file |shada-file| ============================================================================== 1. Vim arguments *vim-arguments* @@ -128,7 +128,7 @@ argument. "pat" in the first file being edited (see |pattern| for the available search patterns). The search starts at the cursor position, which can be the first line or the cursor position - last used from |viminfo|. To force a search from the first + last used from |shada|. To force a search from the first line use "+1 +/pat". +{command} *-+c* *-c* @@ -251,7 +251,7 @@ argument. *-V* *verbose* -V[N] Verbose. Sets the 'verbose' option to [N] (default: 10). Messages will be given for each file that is ":source"d and - for reading or writing a viminfo file. Can be used to find + for reading or writing a ShaDa file. Can be used to find out what is happening upon startup and exit. Example: > vim -V8 foobar @@ -322,10 +322,10 @@ argument. same effect as "NONE", but loading plugins is not skipped. *-i* --i {viminfo} The file "viminfo" is used instead of the default viminfo - file. If the name "NONE" is used (all uppercase), no viminfo +-i {shada} The file {shada} is used instead of the default ShaDa + file. If the name "NONE" is used (all uppercase), no ShaDa file is read or written, even if 'viminfo' is set or when - ":rv" or ":wv" are used. See also |viminfo-file|. + ":rv" or ":wv" are used. See also |shada-file|. *-s* -s {scriptin} The script file "scriptin" is read. The characters in the @@ -475,9 +475,9 @@ accordingly. Vim proceeds in this order: Only when starting "gvim", the GUI initializations will be done. See |gui-init|. -9. Read the viminfo file +9. Read the ShaDa file If the 'viminfo' option is not empty, the viminfo file is read. See - |viminfo-file|. + |shada-file|. 10. Read the quickfix file If the "-q" flag was given to Vim, the quickfix file is read. If this @@ -564,10 +564,10 @@ just like executing a command from a vimrc/exrc in the current directory. If Vim takes a long time to start up, use the |--startuptime| argument to find out what happens. -If you have "viminfo" enabled, the loading of the viminfo file may take a +If you have "viminfo" enabled, the loading of the ShaDa file may take a while. You can find out if this is the problem by disabling viminfo for a moment (use the Vim argument "-i NONE", |-i|). Try reducing the number of -lines stored in a register with ":set viminfo='20,<50,s10". |viminfo-file|. +lines stored in a register with ":set viminfo='20,<50,s10". |shada-file|. *:intro* When Vim starts without a file name, an introductory message is displayed (for @@ -768,8 +768,8 @@ save a Session and when you restore it later the window layout looks the same. You can use a Session to quickly switch between different projects, automatically loading the files you were last working on in that project. -Views and Sessions are a nice addition to viminfo-files, which are used to -remember information for all Views and Sessions together |viminfo-file|. +Views and Sessions are a nice addition to ShaDa files, which are used to +remember information for all Views and Sessions together |shada-file|. You can quickly start editing with a previously saved View or Session with the |-S| argument: > @@ -865,7 +865,7 @@ The output of ":mkview" contains these items: Note that Views and Sessions are not perfect: - They don't restore everything. For example, defined functions, autocommands and ":syntax on" are not included. Things like register contents and - command line history are in viminfo, not in Sessions or Views. + command line history are in ShaDa, not in Sessions or Views. - Global option values are only set when they differ from the default value. When the current value is not the default value, loading a Session will not set it back to the default value. Local options will be set back to the @@ -896,15 +896,15 @@ To automatically save and restore views for *.c files: > au BufWinEnter *.c silent loadview ============================================================================== -8. The viminfo file *viminfo* *viminfo-file* *E136* +8. The ShaDa file *shada* *shada-file* *E136* *E575* *E576* *E577* If you exit Vim and later start it again, you would normally lose a lot of -information. The viminfo file can be used to remember that information, which +information. The ShaDa file can be used to remember that information, which enables you to continue where you left off. This is introduced in section |21.3| of the user manual. -The viminfo file is used to store: +The ShaDa file is used to store: - The command line history. - The search string history. - The input-line history. @@ -915,46 +915,43 @@ The viminfo file is used to store: - The buffer list. - Global variables. -The viminfo file is not supported when the |+viminfo| feature has been -disabled at compile time. - -You could also use a Session file. The difference is that the viminfo file +You could also use a Session file. The difference is that the ShaDa file does not depend on what you are working on. There normally is only one -viminfo file. Session files are used to save the state of a specific editing +ShaDa file. Session files are used to save the state of a specific editing Session. You could have several Session files, one for each project you are -working on. Viminfo and Session files together can be used to effectively +working on. ShaDa and Session files together can be used to effectively enter Vim and directly start working in your desired setup. |session-file| - *viminfo-read* + *shada-read* When Vim is started and the 'viminfo' option is non-empty, the contents of -the viminfo file are read and the info can be used in the appropriate places. +the ShaDa file are read and the info can be used in the appropriate places. The |v:oldfiles| variable is filled. The marks are not read in at startup (but file marks are). See |initialization| for how to set the 'viminfo' option upon startup. - *viminfo-write* -When Vim exits and 'viminfo' is non-empty, the info is stored in the viminfo + *shada-write* +When Vim exits and 'viminfo' is non-empty, the info is stored in the ShaDa file (it's actually merged with the existing one, if one exists). The 'viminfo' option is a string containing information about what info should be stored, and contains limits on how much should be stored (see 'viminfo'). Notes for Unix: -- The file protection for the viminfo file will be set to prevent other users +- The file protection for the ShaDa file will be set to prevent other users from being able to read it, because it may contain any text or commands that you have worked with. -- If you want to share the viminfo file with other users (e.g. when you "su" +- If you want to share the ShaDa file with other users (e.g. when you "su" to another user), you can make the file writable for the group or everybody. - Vim will preserve this when writing new viminfo files. Be careful, don't - allow just anybody to read and write your viminfo file! -- Vim will not overwrite a viminfo file that is not writable by the current + Vim will preserve this when writing new ShaDa files. Be careful, don't + allow just anybody to read and write your ShaDa file! +- Vim will not overwrite a ShaDa file that is not writable by the current "real" user. This helps for when you did "su" to become root, but your $HOME is still set to a normal user's home directory. Otherwise Vim would - create a viminfo file owned by root that nobody else can read. -- The viminfo file cannot be a symbolic link. This is to avoid security + create a ShaDa file owned by root that nobody else can read. +- The ShaDa file cannot be a symbolic link. This is to avoid security issues. Marks are stored for each file separately. When a file is read and 'viminfo' -is non-empty, the marks for that file are read from the viminfo file. NOTE: +is non-empty, the marks for that file are read from the ShaDa file. NOTE: The marks are only written when exiting Vim, which is fine because marks are remembered for all the files you have opened in the current editing session, unless ":bdel" is used. If you want to save the marks for a file that you are @@ -964,12 +961,12 @@ cursor position when the file was last exited. No marks are saved for files that start with any string given with the "r" flag in 'viminfo'. This can be used to avoid saving marks for files on removable media (for MS-DOS you would use "ra:,rb:". -The |v:oldfiles| variable is filled with the file names that the viminfo file +The |v:oldfiles| variable is filled with the file names that the ShaDa file has marks for. - *viminfo-file-marks* -Uppercase marks ('A to 'Z) are stored when writing the viminfo file. The -numbered marks ('0 to '9) are a bit special. When the viminfo file is written + *shada-file-marks* +Uppercase marks ('A to 'Z) are stored when writing the ShaDa file. The +numbered marks ('0 to '9) are a bit special. When the ShaDa file is written (when exiting or with the ":wviminfo" command), '0 is set to the current cursor position and file. The old '0 is moved to '1, '1 to '2, etc. This resembles what happens with the "1 to "9 delete registers. If the current @@ -992,87 +989,89 @@ Use the "r" flag in 'viminfo' to specify for which files no marks should be remembered. -VIMINFO FILE NAME *viminfo-file-name* +SHADA FILE NAME *shada-file-name* -- The default name of the viminfo file is "$HOME/.viminfo" for Unix, - "$HOME\_viminfo" for MS-DOS and Win32. For the last two, when $HOME is not - set, "$VIM\_viminfo" is used. When $VIM is also not set, "c:\_viminfo" is - used. -- The 'n' flag in the 'viminfo' option can be used to specify another viminfo +- The default name of the ShaDa file is "$HOME/.nvim/shada/main.shada" for + Unix, "$HOME\_nvim\shada\main.shada" for MS-DOS and Win32. For the last + two, when $HOME is not set, "$VIM\_nvim\shada\main.shada" is used. When + $VIM is also not set, "c:\_nvim\shada\main.shada" is used. +- The 'n' flag in the 'viminfo' option can be used to specify another ShaDa file name |'viminfo'|. - The "-i" Vim argument can be used to set another file name, |-i|. When the - file name given is "NONE" (all uppercase), no viminfo file is ever read or + file name given is "NONE" (all uppercase), no ShaDa file is ever read or written. Also not for the commands below! - For the commands below, another file name can be given, overriding the default and the name given with 'viminfo' or "-i" (unless it's NONE). -CHARACTER ENCODING *viminfo-encoding* +CHARACTER ENCODING *shada-encoding* + +The text in the ShaDa file is UTF-8-encoded. Normally you will always work +with the same 'encoding' value, and this works just fine. However, if you +read the ShaDa file with value for 'encoding' different from utf-8 and +'encoding' used when writing ShaDa file, some of the text (non-ASCII +characters) may be invalid as NeoVim always attempts to convert the text in +the ShaDa file from the UTF-8 to the current 'encoding' value. Filenames are +never converted, affected elements are: -The text in the viminfo file is encoded as specified with the 'encoding' -option. Normally you will always work with the same 'encoding' value, and -this works just fine. However, if you read the viminfo file with another -value for 'encoding' than what it was written with, some of the text -(non-ASCII characters) may be invalid. If this is unacceptable, add the 'c' -flag to the 'viminfo' option: > - :set viminfo+=c -Vim will then attempt to convert the text in the viminfo file from the -'encoding' value it was written with to the current 'encoding' value. This -requires Vim to be compiled with the |+iconv| feature. Filenames are not -converted. +- history strings; +- variable values; +- register values; +- last used search and substitute patterns; +- last used substitute replacement string. -MANUALLY READING AND WRITING *viminfo-read-write* +MANUALLY READING AND WRITING *shada-read-write* -Two commands can be used to read and write the viminfo file manually. This +Two commands can be used to read and write the ShaDa file manually. This can be used to exchange registers between two running Vim programs: First type ":wv" in one and then ":rv" in the other. Note that if the register already contained something, then ":rv!" would be required. Also note however that this means everything will be overwritten with information from the first Vim, including the command line history, etc. -The viminfo file itself can be edited by hand too, although we suggest you -start with an existing one to get the format right. It is reasonably -self-explanatory once you're in there. This can be useful in order to -create a second file, say "~/.my_viminfo" which could contain certain -settings that you always want when you first start Vim. For example, you -can preload registers with particular data, or put certain commands in the -command line history. A line in your .vimrc file like > - :rviminfo! ~/.my_viminfo -can be used to load this information. You could even have different viminfos -for different types of files (e.g., C code) and load them based on the file -name, using the ":autocmd" command (see |:autocmd|). - - *viminfo-errors* -When Vim detects an error while reading a viminfo file, it will not overwrite -that file. If there are more than 10 errors, Vim stops reading the viminfo -file. This was done to avoid accidentally destroying a file when the file -name of the viminfo file is wrong. This could happen when accidentally typing -"vim -i file" when you wanted "vim -R file" (yes, somebody accidentally did -that!). If you want to overwrite a viminfo file with an error in it, you will -either have to fix the error, or delete the file (while Vim is running, so -most of the information will be restored). +The ShaDa file itself can be edited by hand too, although we suggest you +start with an existing one to get the format right. You need to understand +MessagePack (or, more likely, find software that is able to use it) format to +do this. This can be useful in order to create a second file, say +"~/.my.shada" which could contain certain settings that you always want when +you first start NeoVim. For example, you can preload registers with +particular data, or put certain commands in the command line history. A line +in your .nvimrc file like > + :rviminfo! ~/.my.shada +can be used to load this information. You could even have different ShaDa +files for different types of files (e.g., C code) and load them based on the +file name, using the ":autocmd" command (see |:autocmd|). + + *shada-errors* +When Vim detects an error while reading a ShaDa file, it will not overwrite +that file. This was done to avoid accidentally destroying a file when the +file name of the ShaDa file is wrong. This could happen when accidentally +typing "nvim -i file" when you wanted "nvim -R file" (yes, somebody +accidentally did that!). If you want to overwrite a ShaDa file with an error +in it, you will either have to fix the error, or delete the file (while NeoVim +is running, so most of the information will be restored). *:rv* *:rviminfo* *E195* -:rv[iminfo][!] [file] Read from viminfo file [file] (default: see above). +:rv[iminfo][!] [file] Read from ShaDa file [file] (default: see above). If [!] is given, then any information that is already set (registers, marks, |v:oldfiles|, etc.) will be overwritten. *:wv* *:wviminfo* *E137* *E138* *E574* *E886* -:wv[iminfo][!] [file] Write to viminfo file [file] (default: see above). +:wv[iminfo][!] [file] Write to ShaDa file [file] (default: see above). The information in the file is first read in to make a merge between old and new info. When [!] is used, the old information is not read first, only the - internal info is written. If 'viminfo' is empty, marks - for up to 100 files will be written. - When you get error "E138: Can't write viminfo file" - check that no old temp files were left behind (e.g. - ~/.viminf*) and that you can write in the directory of - the .viminfo file. + internal info is written (also disables safety checks + described in |shada-errors|). If 'viminfo' is empty, + marks for up to 100 files will be written. + When you get error "E138: All .tmp.X files exist, + cannot write ShaDa file!" check that no old temp files + were left behind (e.g. ~/.nvim/shada/main.shada.tmp*). *:ol* *:oldfiles* -:ol[dfiles] List the files that have marks stored in the viminfo +:ol[dfiles] List the files that have marks stored in the ShaDa file. This list is read on startup and only changes afterwards with ":rviminfo!". Also see |v:oldfiles|. The number can be used with |c_#<|. diff --git a/runtime/doc/usr_21.txt b/runtime/doc/usr_21.txt index 2ce23f0abf..d2d67339ed 100644 --- a/runtime/doc/usr_21.txt +++ b/runtime/doc/usr_21.txt @@ -12,7 +12,7 @@ it later. |21.1| Suspend and resume |21.2| Executing shell commands -|21.3| Remembering information; viminfo +|21.3| Remembering information; ShaDa |21.4| Sessions |21.5| Views |21.6| Modelines @@ -78,13 +78,13 @@ This is similar to using CTRL-Z to suspend Vim. The difference is that a new shell is started. ============================================================================== -*21.3* Remembering information; viminfo +*21.3* Remembering information; ShaDa After editing for a while you will have text in registers, marks in various files, a command line history filled with carefully crafted commands. When you exit Vim all of this is lost. But you can get it back! -The viminfo file is designed to store status information: +The ShaDa file is designed to store status information: Command-line and Search pattern history Text in registers @@ -92,8 +92,8 @@ The viminfo file is designed to store status information: The buffer list Global variables -Each time you exit Vim it will store this information in a file, the viminfo -file. When Vim starts again, the viminfo file is read and the information +Each time you exit Vim it will store this information in a file, the ShaDa +file. When Vim starts again, the ShaDa file is read and the information restored. The 'viminfo' option is set by default to restore a limited number of items. @@ -120,7 +120,7 @@ the marks are stored. You want this feature, so now you have this: > The < option controls how many lines are saved for each of the registers. By default, all the lines are saved. If 0, nothing is saved. To avoid adding -thousands of lines to your viminfo file (which might never get used and makes +thousands of lines to your ShaDa file (which might never get used and makes starting Vim slower) you use a maximum of 500 lines: > :set viminfo='1000,f1,<500 @@ -137,9 +137,9 @@ Other options you might want to use: % the buffer list (only restored when starting Vim without file arguments) c convert the text using 'encoding' - n name used for the viminfo file (must be the last option) + n name used for the ShaDa file (must be the last option) -See the 'viminfo' option and |viminfo-file| for more information. +See the 'viminfo' option and |shada-file| for more information. When you run Vim multiple times, the last one exiting will store its information. This may cause information that previously exiting Vims stored @@ -209,21 +209,21 @@ You can use the ":wviminfo" and ":rviminfo" commands to save and restore the information while still running Vim. This is useful for exchanging register contents between two instances of Vim, for example. In the first Vim do: > - :wviminfo! ~/tmp/viminfo + :wviminfo! ~/tmp/shada And in the second Vim do: > - :rviminfo! ~/tmp/viminfo + :rviminfo! ~/tmp/shada Obviously, the "w" stands for "write" and the "r" for "read". The ! character is used by ":wviminfo" to forcefully overwrite an existing file. When it is omitted, and the file exists, the information is merged into the file. - The ! character used for ":rviminfo" means that all the information is -used, this may overwrite existing information. Without the ! only information -that wasn't set is used. + The ! character used for ":rviminfo" means that all the information in +ShaDa file has priority over existing information, this may overwrite it. +Without the ! only information that wasn't set is used. These commands can also be used to store info and use it again later. You -could make a directory full of viminfo files, each containing info for a +could make a directory full of ShaDa files, each containing info for a different purpose. ============================================================================== @@ -355,12 +355,12 @@ Similarly, MS-Windows Vim understands file names with / to separate names, but Unix Vim doesn't understand \. -SESSIONS AND VIMINFO +SESSIONS AND SHADA Sessions store many things, but not the position of marks, contents of -registers and the command line history. You need to use the viminfo feature +registers and the command line history. You need to use the shada feature for these things. - In most situations you will want to use sessions separately from viminfo. + In most situations you will want to use sessions separately from shada. This can be used to switch to another session, but keep the command line history. And yank text into registers in one session, and paste it back in another session. @@ -368,12 +368,12 @@ another session. this yourself then. Example: > :mksession! ~/.vim/secret.vim - :wviminfo! ~/.vim/secret.viminfo + :wviminfo! ~/.vim/secret.shada And to restore this again: > :source ~/.vim/secret.vim - :rviminfo! ~/.vim/secret.viminfo + :rviminfo! ~/.vim/secret.shada ============================================================================== *21.5* Views diff --git a/runtime/doc/usr_45.txt b/runtime/doc/usr_45.txt index ac697e4bd5..808a9fc725 100644 --- a/runtime/doc/usr_45.txt +++ b/runtime/doc/usr_45.txt @@ -235,7 +235,7 @@ actually view a file that way, if you have lots of time at hand. Note: Since 'encoding' is used for all text inside Vim, changing it makes all non-ASCII text invalid. You will notice this when using registers - and the 'viminfo' file (e.g., a remembered search pattern). It's + and the |shada-file| (e.g., a remembered search pattern). It's recommended to set 'encoding' in your vimrc file, and leave it alone. ============================================================================== diff --git a/runtime/doc/usr_toc.txt b/runtime/doc/usr_toc.txt index be9f0f1a77..77ea462a23 100644 --- a/runtime/doc/usr_toc.txt +++ b/runtime/doc/usr_toc.txt @@ -181,7 +181,7 @@ Subjects that can be read independently. |usr_21.txt| Go away and come back |21.1| Suspend and resume |21.2| Executing shell commands - |21.3| Remembering information; viminfo + |21.3| Remembering information; ShaDa |21.4| Sessions |21.5| Views |21.6| Modelines diff --git a/runtime/doc/various.txt b/runtime/doc/various.txt index 3cc0e7c8ab..4c44d45436 100644 --- a/runtime/doc/various.txt +++ b/runtime/doc/various.txt @@ -370,6 +370,7 @@ N *+reltime* |reltime()| function, 'hlsearch'/'incsearch' timeout, 'redrawtime' option B *+rightleft* Right to left typing |'rightleft'| N *+scrollbind* |'scrollbind'| +N *+shada* |'viminfo'| B *+signs* |:sign| N *+smartindent* |'smartindent'| N *+startuptime* |--startuptime| argument @@ -387,7 +388,6 @@ N *+textobjects* |text-objects| selection N *+title* Setting the window 'title' and 'icon' N *+toolbar* |gui-toolbar| N *+user_commands* User-defined commands. |user-commands| -N *+viminfo* |'viminfo'| N *+vertsplit* Vertically split windows |:vsplit| N *+virtualedit* |'virtualedit'| S *+visual* Visual mode |Visual-mode| Always enabled since 7.4.200. diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index de061d3828..5e4182fdae 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -23,7 +23,8 @@ these differences. - Use `.nvimrc` instead of `.vimrc` for storing configuration. - Use `.nvim` instead of `.vim` to store configuration files. -- Use `.nviminfo` instead of `.viminfo` for persistent session information. +- Use `.nvim/shada/main.shada` instead of `.viminfo` for persistent session + information. ============================================================================== 2. Option defaults *nvim-option-defaults* @@ -93,6 +94,14 @@ are always available and may be used simultaneously in separate plugins. The "{E724@level}"), but this is not reliable because |string()| continues to error out. +Viminfo text files were replaced with binary (messagepack) ShaDa files. +Additional differences: + +- |shada-c| has no effect. +- |shada-s| now limits size of every item and not just registers. +- When reading ShaDa files history, jump list and change list items are merged + with those in currently running NeoVim instance according to the timestamp. + ============================================================================== 4. New Features *nvim-features-new* diff --git a/runtime/doc/windows.txt b/runtime/doc/windows.txt index b649e8a319..95be125c33 100644 --- a/runtime/doc/windows.txt +++ b/runtime/doc/windows.txt @@ -53,7 +53,7 @@ hidden: The buffer is not displayed. If there is a file for this buffer, it *inactive-buffer* inactive: The buffer is not displayed and does not contain anything. Options for the buffer are remembered if the file was once loaded. It can - contain marks from the |viminfo| file. But the buffer doesn't + contain marks from the |shada| file. But the buffer doesn't contain text. In a table: -- cgit From 9cf9c4a5860212cc0f9b71d349849811fdaf61a1 Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 6 Jul 2015 02:16:05 +0300 Subject: Replace references to viminfo in various places --- runtime/doc/motion.txt | 2 +- runtime/doc/starting.txt | 6 +++--- runtime/doc/usr_21.txt | 4 ++-- runtime/optwin.vim | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/motion.txt b/runtime/doc/motion.txt index ff15de7d0e..7a29f8669c 100644 --- a/runtime/doc/motion.txt +++ b/runtime/doc/motion.txt @@ -1075,7 +1075,7 @@ if you stop editing a file without writing, like with ":n!". When you split a window, the jumplist will be copied to the new window. If you have included the ' item in the 'viminfo' option the jumplist will be -stored in the shada file and restored when starting Vim. +stored in the ShaDa file and restored when starting Vim. CHANGE LIST JUMPS *changelist* *change-list-jumps* *E664* diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt index 83351c1002..ee3b0220eb 100644 --- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -476,7 +476,7 @@ accordingly. Vim proceeds in this order: |gui-init|. 9. Read the ShaDa file - If the 'viminfo' option is not empty, the viminfo file is read. See + If the 'viminfo' option is not empty, the ShaDa file is read. See |shada-file|. 10. Read the quickfix file @@ -564,8 +564,8 @@ just like executing a command from a vimrc/exrc in the current directory. If Vim takes a long time to start up, use the |--startuptime| argument to find out what happens. -If you have "viminfo" enabled, the loading of the ShaDa file may take a -while. You can find out if this is the problem by disabling viminfo for a +If you have 'viminfo' enabled, the loading of the ShaDa file may take a +while. You can find out if this is the problem by disabling ShaDa for a moment (use the Vim argument "-i NONE", |-i|). Try reducing the number of lines stored in a register with ":set viminfo='20,<50,s10". |shada-file|. diff --git a/runtime/doc/usr_21.txt b/runtime/doc/usr_21.txt index d2d67339ed..d57381f5cd 100644 --- a/runtime/doc/usr_21.txt +++ b/runtime/doc/usr_21.txt @@ -168,7 +168,7 @@ exiting Vim, there is a slightly more complicated way. You can see a list of files by typing the command: > :oldfiles -< 1: ~/.viminfo ~ +< 1: ~/.vimrc ~ 2: ~/text/resume.txt ~ 3: /tmp/draft ~ @@ -188,7 +188,7 @@ That #<123 thing is a bit complicated when you just want to edit a file. Fortunately there is a simpler way: > :browse oldfiles -< 1: ~/.viminfo ~ +< 1: ~/.vimrc ~ 2: ~/text/resume.txt ~ 3: /tmp/draft ~ -- More -- diff --git a/runtime/optwin.vim b/runtime/optwin.vim index 636fa4b328..d1ab204180 100644 --- a/runtime/optwin.vim +++ b/runtime/optwin.vim @@ -1226,8 +1226,8 @@ if has("mksession") call append("$", "viewdir\tdirectory where to store files with :mkview") call OptionG("vdir", &vdir) endif -if has("viminfo") - call append("$", "viminfo\tlist that specifies what to write in the viminfo file") +if has("shada") + call append("$", "viminfo\tlist that specifies what to write in the ShaDa file") call OptionG("vi", &vi) endif if has("quickfix") -- cgit From 8663983cc4c2f66eb0ba58ad8e247ac0686cc79b Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 6 Jul 2015 02:26:44 +0300 Subject: Deprecate &viminfo and :[rw]v, add &shada and :[rw]sh --- runtime/doc/autocmd.txt | 2 +- runtime/doc/eval.txt | 4 +- runtime/doc/index.txt | 4 +- runtime/doc/motion.txt | 6 +- runtime/doc/options.txt | 242 ++++++++++++++++++++++++----------------------- runtime/doc/quickref.txt | 10 +- runtime/doc/starting.txt | 60 ++++++------ runtime/doc/usr_21.txt | 32 +++---- runtime/doc/various.txt | 2 +- runtime/doc/vim_diff.txt | 4 + runtime/macros/less.vim | 2 +- 11 files changed, 191 insertions(+), 177 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/autocmd.txt b/runtime/doc/autocmd.txt index f63c319c2f..e922d5b601 100644 --- a/runtime/doc/autocmd.txt +++ b/runtime/doc/autocmd.txt @@ -1375,7 +1375,7 @@ use search patterns normally, e.g., with the "n" command. If you want an autocommand to set the search pattern, such that it is used after the autocommand finishes, use the ":let @/ =" command. The search-highlighting cannot be switched off with ":nohlsearch" in an -autocommand. Use the 'h' flag in the 'viminfo' option to disable search- +autocommand. Use the 'h' flag in the 'shada' option to disable search- highlighting when starting Vim. *Cmd-event* diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 0475af6706..0a17521c08 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -557,7 +557,7 @@ Functions that can be used with a Dictionary: > If you need to know the type of a variable or expression, use the |type()| function. -When the '!' flag is included in the 'viminfo' option, global variables that +When the '!' flag is included in the 'shada' option, global variables that start with an uppercase letter, and don't contain a lowercase letter, are stored in the shada file |shada-file|. @@ -1527,7 +1527,7 @@ v:msgpack_types Dictionary containing msgpack types used by |msgpackparse()| v:oldfiles List of file names that is loaded from the |shada| file on startup. These are the files that Vim remembers marks for. The length of the List is limited by the ' argument of the - 'viminfo' option (default is 100). + 'shada' option (default is 100). When the |shada| file is not used the List is empty. Also see |:oldfiles| and |c_#<|. The List can be modified, but this has no effect on what is diff --git a/runtime/doc/index.txt b/runtime/doc/index.txt index 3cb69a11c5..5c1744c816 100644 --- a/runtime/doc/index.txt +++ b/runtime/doc/index.txt @@ -1418,9 +1418,9 @@ tag command action ~ |:rewind| :rew[ind] go to the first file in the argument list |:right| :ri[ght] right align text |:rightbelow| :rightb[elow] make split window appear right or below +|:rshada| :rsh[ada] read from ShaDa file |:rundo| :rund[o] read undo information from a file |:runtime| :ru[ntime] source vim scripts in 'runtimepath' -|:rviminfo| :rv[iminfo] read from ShaDa file |:substitute| :s[ubstitute] find and replace text |:sNext| :sN[ext] split window and go to previous file in argument list @@ -1579,8 +1579,8 @@ tag command action ~ argument list |:wq| :wq write to a file and quit window or Vim |:wqall| :wqa[ll] write all changed buffers and quit Vim +|:wshada| :wsh[ada] write to ShaDa file |:wundo| :wu[ndo] write undo information to a file -|:wviminfo| :wv[iminfo] write to ShaDa file |:xit| :x[it] write if buffer changed and quit window or Vim |:xall| :xa[ll] same as ":wqall" |:xmapclear| :xmapc[lear] remove all mappings for Visual mode diff --git a/runtime/doc/motion.txt b/runtime/doc/motion.txt index 7a29f8669c..2e8f0801dc 100644 --- a/runtime/doc/motion.txt +++ b/runtime/doc/motion.txt @@ -820,13 +820,13 @@ Uppercase marks 'A to 'Z include the file name. You can use them to jump from file to file. You can only use an uppercase mark with an operator if the mark is in the current file. The line number of the mark remains correct, even if you insert/delete lines or edit another file -for a moment. When the 'viminfo' option is not empty, uppercase marks are +for a moment. When the 'shada' option is not empty, uppercase marks are kept in the .shada file. See |shada-file-marks|. Numbered marks '0 to '9 are quite different. They can not be set directly. They are only present when using a shada file |shada-file|. Basically '0 is the location of the cursor when you last exited Vim, '1 the last but one -time, etc. Use the "r" flag in 'viminfo' to specify files for which no +time, etc. Use the "r" flag in 'shada' to specify files for which no Numbered mark should be stored. See |shada-file-marks|. @@ -1074,7 +1074,7 @@ if you stop editing a file without writing, like with ":n!". When you split a window, the jumplist will be copied to the new window. -If you have included the ' item in the 'viminfo' option the jumplist will be +If you have included the ' item in the 'shada' option the jumplist will be stored in the ShaDa file and restored when starting Vim. diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index c7a508ed3f..d65a8b9454 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -3409,7 +3409,7 @@ A jump table for the options with a short description can be found at |Q_op|. line below a closed fold. A match in a previous line which is not drawn may not continue in a newly drawn line. You can specify whether the highlight status is restored on startup - with the 'h' flag in 'viminfo' |shada-h|. + with the 'h' flag in 'shada' |shada-h|. *'history'* *'hi'* 'history' 'hi' number (Vim default: 10000, Vi default: 0) @@ -5291,6 +5291,124 @@ A jump table for the options with a short description can be found at |Q_op|. with Unix. The Unix version of Vim cannot source dos format scripts, but the Windows version of Vim can source unix format scripts. + *'shada'* *'sd'* *E526* *E527* *E528* +'shada' 'sd' string (Vim default for + Win32: '!,100,<50,s10,h,rA:,rB: + others: '!,100,<50,s10,h + Vi default: "") + global + When non-empty, the shada file is read upon startup and written + when exiting Vim (see |shada-file|). The string should be a comma + separated list of parameters, each consisting of a single character + identifying the particular parameter, followed by a number or string + which specifies the value of that parameter. If a particular + character is left out, then the default value is used for that + parameter. The following is a list of the identifying characters and + the effect of their value. + CHAR VALUE ~ + *shada-!* + ! When included, save and restore global variables that start + with an uppercase letter, and don't contain a lowercase + letter. Thus "KEEPTHIS and "K_L_M" are stored, but "KeepThis" + and "_K_L_M" are not. Nested List and Dict items may not be + read back correctly, you end up with an empty item. + *shada-quote* + " Maximum number of lines saved for each register. Old name of + the '<' item, with the disadvantage that you need to put a + backslash before the ", otherwise it will be recognized as the + start of a comment! + *shada-%* + % When included, save and restore the buffer list. If Vim is + started with a file name argument, the buffer list is not + restored. If Vim is started without a file name argument, the + buffer list is restored from the shada file. Buffers + without a file name and buffers for help files are not written + to the shada file. + When followed by a number, the number specifies the maximum + number of buffers that are stored. Without a number all + buffers are stored. + *shada-'* + ' Maximum number of previously edited files for which the marks + are remembered. This parameter must always be included when + 'shada' is non-empty. + Including this item also means that the |jumplist| and the + |changelist| are stored in the shada file. + *shada-/* + / Maximum number of items in the search pattern history to be + saved. If non-zero, then the previous search and substitute + patterns are also saved. When not included, the value of + 'history' is used. + *shada-:* + : Maximum number of items in the command-line history to be + saved. When not included, the value of 'history' is used. + *shada-<* + < Maximum number of lines saved for each register. If zero then + registers are not saved. When not included, all lines are + saved. '"' is the old name for this item. + Also see the 's' item below: limit specified in KiB. + *shada-@* + @ Maximum number of items in the input-line history to be + saved. When not included, the value of 'history' is used. + *shada-c* + c Dummy option, kept for compatibility reasons. Has no actual + effect. Current encoding state is described in + |shada-encoding|. + *shada-f* + f Whether file marks need to be stored. If zero, file marks ('0 + to '9, 'A to 'Z) are not stored. When not present or when + non-zero, they are all stored. '0 is used for the current + cursor position (when exiting or when doing |:wshada|). + *shada-h* + h Disable the effect of 'hlsearch' when loading the shada + file. When not included, it depends on whether ":nohlsearch" + has been used since the last search command. + *shada-n* + n Name of the shada file. The name must immediately follow + the 'n'. Must be the last one! If the "-i" argument was + given when starting Vim, that file name overrides the one + given here with 'shada'. Environment variables are expanded + when opening the file, not when setting the option. + *shada-r* + r Removable media. The argument is a string (up to the next + ','). This parameter can be given several times. Each + specifies the start of a path for which no marks will be + stored. This is to avoid removable media. For MS-DOS you + could use "ra:,rb:". You can also use it for temp files, + e.g., for Unix: "r/tmp". Case is ignored. Maximum length of + each 'r' argument is 50 characters. + *shada-s* + s Maximum size of an item contents in KiB. If zero then nothing + is saved. Unlike Vim this applies to all items, except for + the buffer list and header. Full item size is off by three + unsigned integers: with `s10` maximum item size may be 1 byte + (type: 7-bit integer) + 9 bytes (timestamp: up to 64-bit + integer) + 3 bytes (item size: up to 16-bit integer because + 2^8 < 10240 < 2^16) + 10240 bytes (requested maximum item + contents size) = 10253 bytes. + + Example: > + :set shada='50,<1000,s100,:0,n~/nvim/shada +< + '50 Marks will be remembered for the last 50 files you + edited. + <1000 Contents of registers (up to 1000 lines each) will be + remembered. + s100 Items with contents occupying more then 100 KiB are + skipped. + :0 Command-line history will not be saved. + n~/nvim/shada The name of the file to use is "~/nvim/shada". + no / Since '/' is not specified, the default will be used, + that is, save all of the search history, and also the + previous search and substitute patterns. + no % The buffer list will not be saved nor read back. + no h 'hlsearch' highlighting will be restored. + + When setting 'shada' from an empty value you can use |:rshada| to + load the contents of the file, this is not done automatically. + + This option cannot be set from a |modeline| or in the |sandbox|, for + security reasons. + *'shell'* *'sh'* *E91* 'shell' 'sh' string (default $SHELL or "sh", MS-DOS and Win32: "command.com" or @@ -6683,125 +6801,11 @@ A jump table for the options with a short description can be found at |Q_op|. with Unix. The Unix version of Vim cannot source dos format scripts, but the Windows version of Vim can source unix format scripts. - *'viminfo'* *'vi'* *E526* *E527* *E528* -'viminfo' 'vi' string (Vim default for - Win32: '!,100,<50,s10,h,rA:,rB: - others: '!,100,<50,s10,h - Vi default: "") + *'viminfo'* *'vi'* +'viminfo' 'vi' string global - {not available when compiled without the |+shada| - feature} - When non-empty, the shada file is read upon startup and written - when exiting Vim (see |shada-file|). The string should be a comma - separated list of parameters, each consisting of a single character - identifying the particular parameter, followed by a number or string - which specifies the value of that parameter. If a particular - character is left out, then the default value is used for that - parameter. The following is a list of the identifying characters and - the effect of their value. - CHAR VALUE ~ - *shada-!* - ! When included, save and restore global variables that start - with an uppercase letter, and don't contain a lowercase - letter. Thus "KEEPTHIS and "K_L_M" are stored, but "KeepThis" - and "_K_L_M" are not. Nested List and Dict items may not be - read back correctly, you end up with an empty item. - *shada-quote* - " Maximum number of lines saved for each register. Old name of - the '<' item, with the disadvantage that you need to put a - backslash before the ", otherwise it will be recognized as the - start of a comment! - *shada-%* - % When included, save and restore the buffer list. If Vim is - started with a file name argument, the buffer list is not - restored. If Vim is started without a file name argument, the - buffer list is restored from the shada file. Buffers - without a file name and buffers for help files are not written - to the shada file. - When followed by a number, the number specifies the maximum - number of buffers that are stored. Without a number all - buffers are stored. - *shada-'* - ' Maximum number of previously edited files for which the marks - are remembered. This parameter must always be included when - 'viminfo' is non-empty. - Including this item also means that the |jumplist| and the - |changelist| are stored in the shada file. - *shada-/* - / Maximum number of items in the search pattern history to be - saved. If non-zero, then the previous search and substitute - patterns are also saved. When not included, the value of - 'history' is used. - *shada-:* - : Maximum number of items in the command-line history to be - saved. When not included, the value of 'history' is used. - *shada-<* - < Maximum number of lines saved for each register. If zero then - registers are not saved. When not included, all lines are - saved. '"' is the old name for this item. - Also see the 's' item below: limit specified in Kbyte. - *shada-@* - @ Maximum number of items in the input-line history to be - saved. When not included, the value of 'history' is used. - *shada-c* - c Dumb option, kept for compatibility reasons. Has no actual - effect. Current encoding state is described in - |shada-encoding|. - *shada-f* - f Whether file marks need to be stored. If zero, file marks ('0 - to '9, 'A to 'Z) are not stored. When not present or when - non-zero, they are all stored. '0 is used for the current - cursor position (when exiting or when doing ":wviminfo"). - *shada-h* - h Disable the effect of 'hlsearch' when loading the shada - file. When not included, it depends on whether ":nohlsearch" - has been used since the last search command. - *shada-n* - n Name of the shada file. The name must immediately follow - the 'n'. Must be the last one! If the "-i" argument was - given when starting Vim, that file name overrides the one - given here with 'viminfo'. Environment variables are expanded - when opening the file, not when setting the option. - *shada-r* - r Removable media. The argument is a string (up to the next - ','). This parameter can be given several times. Each - specifies the start of a path for which no marks will be - stored. This is to avoid removable media. For MS-DOS you - could use "ra:,rb:". You can also use it for temp files, - e.g., for Unix: "r/tmp". Case is ignored. Maximum length of - each 'r' argument is 50 characters. - *shada-s* - s Maximum size of an item contents in KiB. If zero then nothing - is saved. Unlike Vim this applies to all items, except for - the buffer list and header. Full item size is off by three - unsigned integers: with `s10` maximum item size may be 1 byte - (type: 7-bit integer) + 9 bytes (timestamp: up to 64-bit - integer) + 3 bytes (item size: up to 16-bit integer because - 2^8 < 10240 < 2^16) + 10240 bytes (requested maximum item - contents size) = 10253 bytes. - - Example: > - :set viminfo='50,<1000,s100,:0,n~/nvim/shada -< - '50 Marks will be remembered for the last 50 files you - edited. - <1000 Contents of registers (up to 1000 lines each) will be - remembered. - s100 Items with contents occupying more then 100 KiB are - skipped. - :0 Command-line history will not be saved. - n~/nvim/shada The name of the file to use is "~/nvim/shada". - no / Since '/' is not specified, the default will be used, - that is, save all of the search history, and also the - previous search and substitute patterns. - no % The buffer list will not be saved nor read back. - no h 'hlsearch' highlighting will be restored. - - When setting 'viminfo' from an empty value you can use |:rviminfo| to - load the contents of the file, this is not done automatically. - - This option cannot be set from a |modeline| or in the |sandbox|, for - security reasons. + Deprecated alias for 'shada' option. Is kept for compatibility + reasons. *'virtualedit'* *'ve'* 'virtualedit' 've' string (default "") diff --git a/runtime/doc/quickref.txt b/runtime/doc/quickref.txt index 503ab07079..1b24efc4f9 100644 --- a/runtime/doc/quickref.txt +++ b/runtime/doc/quickref.txt @@ -838,6 +838,7 @@ Short explanation of each option: *option-list* 'selection' 'sel' what type of selection to use 'selectmode' 'slm' when to use Select mode instead of Visual mode 'sessionoptions' 'ssop' options for |:mksession| +'shada' 'sd' use .shada file upon startup and exiting 'shell' 'sh' name of shell to use for external commands 'shellcmdflag' 'shcf' flag to shell to execute one command 'shellpipe' 'sp' string to put output of ":make" in error file @@ -911,7 +912,6 @@ Short explanation of each option: *option-list* 'verbosefile' 'vfile' file to write messages in 'viewdir' 'vdir' directory where to store files with :mkview 'viewoptions' 'vop' specifies what to save for :mkview -'viminfo' 'vi' use .shada file upon startup and exiting 'virtualedit' 've' when to use virtual editing 'visualbell' 'vb' use visual bell instead of beeping 'warn' warn for shell command when buffer was changed @@ -1217,10 +1217,10 @@ Context-sensitive completion on the command-line: |shada-file| read registers, marks, history at startup, save when exiting. -|:rviminfo| :rv[iminfo] [file] read info from ShaDa file [file] -|:rviminfo| :rv[iminfo]! [file] idem, overwrite existing info -|:wviminfo| :wv[iminfo] [file] add info to ShaDa file [file] -|:wviminfo| :wv[iminfo]! [file] write info to ShaDa file [file] +|:rshada| :rsh[ada] [file] read info from ShaDa file [file] +|:rshada| :rsh[ada]! [file] idem, overwrite existing info +|:wshada| :wsh[ada] [file] add info to ShaDa file [file] +|:wshada| :wsh[ada]! [file] write info to ShaDa file [file] |modeline| Automatic option setting when editing a file diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt index ee3b0220eb..c5a0be3fff 100644 --- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -324,8 +324,8 @@ argument. *-i* -i {shada} The file {shada} is used instead of the default ShaDa file. If the name "NONE" is used (all uppercase), no ShaDa - file is read or written, even if 'viminfo' is set or when - ":rv" or ":wv" are used. See also |shada-file|. + file is read or written, even if 'shada' is set or when + ":rsh" or ":wsh" are used. See also |shada-file|. *-s* -s {scriptin} The script file "scriptin" is read. The characters in the @@ -476,7 +476,7 @@ accordingly. Vim proceeds in this order: |gui-init|. 9. Read the ShaDa file - If the 'viminfo' option is not empty, the ShaDa file is read. See + If the 'shada' option is not empty, the ShaDa file is read. See |shada-file|. 10. Read the quickfix file @@ -564,10 +564,10 @@ just like executing a command from a vimrc/exrc in the current directory. If Vim takes a long time to start up, use the |--startuptime| argument to find out what happens. -If you have 'viminfo' enabled, the loading of the ShaDa file may take a +If you have 'shada' enabled, the loading of the ShaDa file may take a while. You can find out if this is the problem by disabling ShaDa for a moment (use the Vim argument "-i NONE", |-i|). Try reducing the number of -lines stored in a register with ":set viminfo='20,<50,s10". |shada-file|. +lines stored in a register with ":set shada='20,<50,s10". |shada-file|. *:intro* When Vim starts without a file name, an introductory message is displayed (for @@ -923,17 +923,17 @@ working on. ShaDa and Session files together can be used to effectively enter Vim and directly start working in your desired setup. |session-file| *shada-read* -When Vim is started and the 'viminfo' option is non-empty, the contents of +When Vim is started and the 'shada' option is non-empty, the contents of the ShaDa file are read and the info can be used in the appropriate places. The |v:oldfiles| variable is filled. The marks are not read in at startup -(but file marks are). See |initialization| for how to set the 'viminfo' +(but file marks are). See |initialization| for how to set the 'shada' option upon startup. *shada-write* -When Vim exits and 'viminfo' is non-empty, the info is stored in the ShaDa +When Vim exits and 'shada' is non-empty, the info is stored in the ShaDa file (it's actually merged with the existing one, if one exists). The -'viminfo' option is a string containing information about what info should be -stored, and contains limits on how much should be stored (see 'viminfo'). +'shada' option is a string containing information about what info should be +stored, and contains limits on how much should be stored (see 'shada'). Notes for Unix: - The file protection for the ShaDa file will be set to prevent other users @@ -950,15 +950,15 @@ Notes for Unix: - The ShaDa file cannot be a symbolic link. This is to avoid security issues. -Marks are stored for each file separately. When a file is read and 'viminfo' +Marks are stored for each file separately. When a file is read and 'shada' is non-empty, the marks for that file are read from the ShaDa file. NOTE: The marks are only written when exiting Vim, which is fine because marks are remembered for all the files you have opened in the current editing session, unless ":bdel" is used. If you want to save the marks for a file that you are -about to abandon with ":bdel", use ":wv". The '[' and ']' marks are not +about to abandon with ":bdel", use ":wsh". The '[' and ']' marks are not stored, but the '"' mark is. The '"' mark is very useful for jumping to the cursor position when the file was last exited. No marks are saved for files -that start with any string given with the "r" flag in 'viminfo'. This can be +that start with any string given with the "r" flag in 'shada'. This can be used to avoid saving marks for files on removable media (for MS-DOS you would use "ra:,rb:". The |v:oldfiles| variable is filled with the file names that the ShaDa file @@ -967,7 +967,7 @@ has marks for. *shada-file-marks* Uppercase marks ('A to 'Z) are stored when writing the ShaDa file. The numbered marks ('0 to '9) are a bit special. When the ShaDa file is written -(when exiting or with the ":wviminfo" command), '0 is set to the current cursor +(when exiting or with the |:wshada| command), '0 is set to the current cursor position and file. The old '0 is moved to '1, '1 to '2, etc. This resembles what happens with the "1 to "9 delete registers. If the current cursor position is already present in '0 to '9, it is moved to '0, to avoid @@ -985,7 +985,7 @@ For a bash-like shell: > alias lvim='vim -c "normal '\''0"' -Use the "r" flag in 'viminfo' to specify for which files no marks should be +Use the "r" flag in 'shada' to specify for which files no marks should be remembered. @@ -995,13 +995,13 @@ SHADA FILE NAME *shada-file-name* Unix, "$HOME\_nvim\shada\main.shada" for MS-DOS and Win32. For the last two, when $HOME is not set, "$VIM\_nvim\shada\main.shada" is used. When $VIM is also not set, "c:\_nvim\shada\main.shada" is used. -- The 'n' flag in the 'viminfo' option can be used to specify another ShaDa - file name |'viminfo'|. +- The 'n' flag in the 'shada' option can be used to specify another ShaDa + file name |'shada'|. - The "-i" Vim argument can be used to set another file name, |-i|. When the file name given is "NONE" (all uppercase), no ShaDa file is ever read or written. Also not for the commands below! - For the commands below, another file name can be given, overriding the - default and the name given with 'viminfo' or "-i" (unless it's NONE). + default and the name given with 'shada' or "-i" (unless it's NONE). CHARACTER ENCODING *shada-encoding* @@ -1025,8 +1025,8 @@ MANUALLY READING AND WRITING *shada-read-write* Two commands can be used to read and write the ShaDa file manually. This can be used to exchange registers between two running Vim programs: First -type ":wv" in one and then ":rv" in the other. Note that if the register -already contained something, then ":rv!" would be required. Also note +type ":wsh" in one and then ":rsh" in the other. Note that if the register +already contained something, then ":rsh!" would be required. Also note however that this means everything will be overwritten with information from the first Vim, including the command line history, etc. @@ -1038,7 +1038,7 @@ do this. This can be useful in order to create a second file, say you first start NeoVim. For example, you can preload registers with particular data, or put certain commands in the command line history. A line in your .nvimrc file like > - :rviminfo! ~/.my.shada + :rshada! ~/.my.shada can be used to load this information. You could even have different ShaDa files for different types of files (e.g., C code) and load them based on the file name, using the ":autocmd" command (see |:autocmd|). @@ -1052,28 +1052,34 @@ accidentally did that!). If you want to overwrite a ShaDa file with an error in it, you will either have to fix the error, or delete the file (while NeoVim is running, so most of the information will be restored). - *:rv* *:rviminfo* *E195* -:rv[iminfo][!] [file] Read from ShaDa file [file] (default: see above). + *:rsh* *:rshada* *E195* +:rsh[ada][!] [file] Read from ShaDa file [file] (default: see above). If [!] is given, then any information that is already set (registers, marks, |v:oldfiles|, etc.) will be overwritten. - *:wv* *:wviminfo* *E137* *E138* *E574* *E886* -:wv[iminfo][!] [file] Write to ShaDa file [file] (default: see above). + *:rv* *:rviminfo* +:rv[iminfo][!] [file] Deprecated alias to |:rshada| command. + + *:wsh* *:wshada* *E137* *E138* *E574* *E886* +:wsh[ada][!] [file] Write to ShaDa file [file] (default: see above). The information in the file is first read in to make a merge between old and new info. When [!] is used, the old information is not read first, only the internal info is written (also disables safety checks - described in |shada-errors|). If 'viminfo' is empty, + described in |shada-errors|). If 'shada' is empty, marks for up to 100 files will be written. When you get error "E138: All .tmp.X files exist, cannot write ShaDa file!" check that no old temp files were left behind (e.g. ~/.nvim/shada/main.shada.tmp*). + *:wv* *:wviminfo* +:wv[iminfo][!] [file] Deprecated alias to |:wshada| command. + *:ol* *:oldfiles* :ol[dfiles] List the files that have marks stored in the ShaDa file. This list is read on startup and only changes - afterwards with ":rviminfo!". Also see |v:oldfiles|. + afterwards with ":rshada!". Also see |v:oldfiles|. The number can be used with |c_#<|. :bro[wse] ol[dfiles][!] diff --git a/runtime/doc/usr_21.txt b/runtime/doc/usr_21.txt index d57381f5cd..96797a745c 100644 --- a/runtime/doc/usr_21.txt +++ b/runtime/doc/usr_21.txt @@ -96,34 +96,34 @@ Each time you exit Vim it will store this information in a file, the ShaDa file. When Vim starts again, the ShaDa file is read and the information restored. -The 'viminfo' option is set by default to restore a limited number of items. +The 'shada' option is set by default to restore a limited number of items. You might want to set it to remember more information. This is done through the following command: > - :set viminfo=string + :set shada=string The string specifies what to save. The syntax of this string is an option character followed by an argument. The option/argument pairs are separated by commas. - Take a look at how you can build up your own viminfo string. First, the ' + Take a look at how you can build up your own shada string. First, the ' option is used to specify how many files for which you save marks (a-z). Pick a nice even number for this option (1000, for instance). Your command now looks like this: > - :set viminfo='1000 + :set shada='1000 The f option controls whether global marks (A-Z and 0-9) are stored. If this option is 0, none are stored. If it is 1 or you do not specify an f option, the marks are stored. You want this feature, so now you have this: > - :set viminfo='1000,f1 + :set shada='1000,f1 The < option controls how many lines are saved for each of the registers. By default, all the lines are saved. If 0, nothing is saved. To avoid adding thousands of lines to your ShaDa file (which might never get used and makes starting Vim slower) you use a maximum of 500 lines: > - :set viminfo='1000,f1,<500 + :set shada='1000,f1,<500 < Other options you might want to use: : number of lines to save from the command line history @@ -139,7 +139,7 @@ Other options you might want to use: c convert the text using 'encoding' n name used for the ShaDa file (must be the last option) -See the 'viminfo' option and |shada-file| for more information. +See the 'shada' option and |shada-file| for more information. When you run Vim multiple times, the last one exiting will store its information. This may cause information that previously exiting Vims stored @@ -205,23 +205,23 @@ More info at |:oldfiles|, |v:oldfiles| and |c_#<|. MOVE INFO FROM ONE VIM TO ANOTHER -You can use the ":wviminfo" and ":rviminfo" commands to save and restore the +You can use the ":wshada" and ":rshada" commands to save and restore the information while still running Vim. This is useful for exchanging register contents between two instances of Vim, for example. In the first Vim do: > - :wviminfo! ~/tmp/shada + :wshada! ~/tmp/shada And in the second Vim do: > - :rviminfo! ~/tmp/shada + :rshada! ~/tmp/shada Obviously, the "w" stands for "write" and the "r" for "read". - The ! character is used by ":wviminfo" to forcefully overwrite an existing + The ! character is used by ":wshada" to forcefully overwrite an existing file. When it is omitted, and the file exists, the information is merged into the file. - The ! character used for ":rviminfo" means that all the information in -ShaDa file has priority over existing information, this may overwrite it. -Without the ! only information that wasn't set is used. + The ! character used for ":rshada" means that all the information in ShaDa +file has priority over existing information, this may overwrite it. Without +the ! only information that wasn't set is used. These commands can also be used to store info and use it again later. You could make a directory full of ShaDa files, each containing info for a different purpose. @@ -368,12 +368,12 @@ another session. this yourself then. Example: > :mksession! ~/.vim/secret.vim - :wviminfo! ~/.vim/secret.shada + :wshada! ~/.vim/secret.shada And to restore this again: > :source ~/.vim/secret.vim - :rviminfo! ~/.vim/secret.shada + :rshada! ~/.vim/secret.shada ============================================================================== *21.5* Views diff --git a/runtime/doc/various.txt b/runtime/doc/various.txt index 4c44d45436..df5d367469 100644 --- a/runtime/doc/various.txt +++ b/runtime/doc/various.txt @@ -370,7 +370,7 @@ N *+reltime* |reltime()| function, 'hlsearch'/'incsearch' timeout, 'redrawtime' option B *+rightleft* Right to left typing |'rightleft'| N *+scrollbind* |'scrollbind'| -N *+shada* |'viminfo'| +N *+shada* |'shada'| B *+signs* |:sign| N *+smartindent* |'smartindent'| N *+startuptime* |--startuptime| argument diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index 5e4182fdae..f93175cccf 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -101,6 +101,10 @@ Additional differences: - |shada-s| now limits size of every item and not just registers. - When reading ShaDa files history, jump list and change list items are merged with those in currently running NeoVim instance according to the timestamp. +- 'viminfo' option got renamed to 'shada'. Old option is kept as an alias for + compatibility reasons. +- |:wviminfo| was renamed to |:wshada|, |:rviminfo| to |:rshada|. Old commands + are still kept. ============================================================================== 4. New Features *nvim-features-new* diff --git a/runtime/macros/less.vim b/runtime/macros/less.vim index 9042e849ca..d38bd3781d 100644 --- a/runtime/macros/less.vim +++ b/runtime/macros/less.vim @@ -42,7 +42,7 @@ set hlsearch set incsearch nohlsearch " Don't remember file names and positions -set viminfo= +set shada= set nows " Inhibit screen updates while searching let s:lz = &lz -- cgit From 5e7a7fc2da682f62648034920020c9da6366ef4d Mon Sep 17 00:00:00 2001 From: ZyX Date: Sat, 18 Jul 2015 21:58:44 +0300 Subject: documentation: Document how ShaDa entries should be merged --- runtime/doc/starting.txt | 37 +++++++++++++++++++++++++++++++++---- runtime/doc/vim_diff.txt | 2 ++ 2 files changed, 35 insertions(+), 4 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt index c5a0be3fff..1679ff170d 100644 --- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -930,10 +930,10 @@ The |v:oldfiles| variable is filled. The marks are not read in at startup option upon startup. *shada-write* -When Vim exits and 'shada' is non-empty, the info is stored in the ShaDa -file (it's actually merged with the existing one, if one exists). The -'shada' option is a string containing information about what info should be -stored, and contains limits on how much should be stored (see 'shada'). +When Vim exits and 'shada' is non-empty, the info is stored in the ShaDa file +(it's actually merged with the existing one, if one exists |shada-merging|). +The 'shada' option is a string containing information about what info should +be stored, and contains limits on how much should be stored (see 'shada'). Notes for Unix: - The file protection for the ShaDa file will be set to prevent other users @@ -988,6 +988,35 @@ For a bash-like shell: > Use the "r" flag in 'shada' to specify for which files no marks should be remembered. + *shada-merging* +When writing ShaDa files with |:wshada| without bang or at regular exit +information in the existing ShaDa file is merged with information from current +NeoVim instance. For this purpose ShaDa files store timestamps associated +with ShaDa entries. Specifically the following is being done: + +1. History lines are merged, ordered by timestamp. Maximum amount of items in + ShaDa file is defined by 'shada' option (|shada-/|, |shada-:|, |shada-@|, + etc: one suboption for each character that represents history name + (|:history|)). +2. Local marks and changes for files that were not opened by NeoVim are copied + to new ShaDa file. Marks for files that were opened by NeoVim are merged, + changes to files opened by NeoVim are ignored. |shada-'| +3. Jump list is merged: jumps are ordered by timestamp, identical jumps + (identical position AND timestamp) are squashed. +4. Search patterns and substitute strings are not merged: search pattern or + substitute string which has greatest timestamp will be the only one copied + to ShaDa file. +5. For each register entity with greatest timestamp is the only saved. + |shada-<| +6. All saved variables are saved from current NeoVim instance. Additionally + existing variable values are copied, meaning that the only way to remove + variable from a ShaDa file is either removing it by hand or disabling + writing variables completely. |shada-!| +7. For each global mark entity with greatest timestamp is the only saved. +8. Buffer list and header are the only entries which are not merged in any + fashion: the only header and buffer list present are the ones from the + NeoVim instance which was last writing the file. |shada-%| + SHADA FILE NAME *shada-file-name* diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index f93175cccf..94996477ab 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -105,6 +105,8 @@ Additional differences: compatibility reasons. - |:wviminfo| was renamed to |:wshada|, |:rviminfo| to |:rshada|. Old commands are still kept. +- When writing (|:wshada| without bang or at exit) it merges much more data. + Vim merges only marks. ============================================================================== 4. New Features *nvim-features-new* -- cgit From 8dafa533dbd505a6a2cf2e009bf440e2bde342f4 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sat, 25 Jul 2015 19:42:04 +0300 Subject: shada: Translate errors and add error codes Notes: - E136 code greatly changed its meaning: now it is write error and not read error. - E195 was removed because shada_read_everything will already do all the necessary error reporting. - E886 can be reported by both :rshada and :wshada, but :rshada comes first and AFAIR it is the only error which is not E575 and can be reported by :rshada. --- runtime/doc/starting.txt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt index 1679ff170d..68f4ff2e64 100644 --- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -896,8 +896,7 @@ To automatically save and restore views for *.c files: > au BufWinEnter *.c silent loadview ============================================================================== -8. The ShaDa file *shada* *shada-file* *E136* - *E575* *E576* *E577* +8. The ShaDa file *shada* *shada-file* *E575* If you exit Vim and later start it again, you would normally lose a lot of information. The ShaDa file can be used to remember that information, which enables you to continue where you left off. @@ -1081,7 +1080,7 @@ accidentally did that!). If you want to overwrite a ShaDa file with an error in it, you will either have to fix the error, or delete the file (while NeoVim is running, so most of the information will be restored). - *:rsh* *:rshada* *E195* + *:rsh* *:rshada* *E886* :rsh[ada][!] [file] Read from ShaDa file [file] (default: see above). If [!] is given, then any information that is already set (registers, marks, |v:oldfiles|, etc.) @@ -1090,7 +1089,7 @@ is running, so most of the information will be restored). *:rv* *:rviminfo* :rv[iminfo][!] [file] Deprecated alias to |:rshada| command. - *:wsh* *:wshada* *E137* *E138* *E574* *E886* + *:wsh* *:wshada* *E136* *E137* *E138* :wsh[ada][!] [file] Write to ShaDa file [file] (default: see above). The information in the file is first read in to make a merge between old and new info. When [!] is used, -- cgit From f8169ff24db20d9420eae0c6044da86fa09378a9 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 26 Jul 2015 21:02:56 +0300 Subject: documentation: Document ShaDa compatibility features --- runtime/doc/starting.txt | 35 ++++++++++++++++++++++++++++++++++- runtime/doc/vim_diff.txt | 2 ++ 2 files changed, 36 insertions(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt index 68f4ff2e64..7d38fb68a4 100644 --- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -987,7 +987,8 @@ For a bash-like shell: > Use the "r" flag in 'shada' to specify for which files no marks should be remembered. - *shada-merging* +MERGING *shada-merging* + {Nvim} When writing ShaDa files with |:wshada| without bang or at regular exit information in the existing ShaDa file is merged with information from current NeoVim instance. For this purpose ShaDa files store timestamps associated @@ -1016,6 +1017,38 @@ with ShaDa entries. Specifically the following is being done: fashion: the only header and buffer list present are the ones from the NeoVim instance which was last writing the file. |shada-%| +COMPATIBILITY *shada-compatibility* + {Nvim} +ShaDa files are forward and backward compatible. This means that + +1. Entries which have unknown type (i.e. that hold unidentified data) are + ignored when reading and blindly copied when writing. +2. Register entries with unknown register name are ignored when reading and + blindly copied when writing. |registers| +3. Register entries with unknown register type are ignored when reading and + merged as usual when writing. |getregtype()| +4. Local and global mark entries with unknown mark names are ignored when + reading. When writing global mark entries are blindly copied and local mark + entries are also blindly copied, but only if file they are attached to fits + in the |shada-'| limit. Unknown local mark entry's timestamp is also taken + into account when calculating which files exactly should fit into this + limit. |mark-motions| +5. History entries with unknown history type are ignored when reading and + blindly copied when writing. |history| +6. Unknown keys found in register, local mark, global mark, change, jump and + search pattern entries are saved internally and dumped when writing. + Entries created during NeoVim session never have such additions. +7. Additional elements found in replacement string and history entries are + saved internally and dumped. Entries created during NeoVim session never + have such additions. +8. Additional elements found in variable entries are simply ignored when + reading. When writing new variables they will be preserved during merging, + but that's all. Variable values dumped from current NeoVim session never + have additional elements, even if variables themselves were obtained by + reading ShaDa files. + +"Blindly" here means that there will be no attempts to somehow merge them, +even if other entries (with known name/type/etc) are merged. |shada-merging| SHADA FILE NAME *shada-file-name* diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index 94996477ab..d5ff27d8c5 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -107,6 +107,8 @@ Additional differences: are still kept. - When writing (|:wshada| without bang or at exit) it merges much more data. Vim merges only marks. +- ShaDa file format was designed with forward and backward compatibility in + mind. |shada-compatibility| ============================================================================== 4. New Features *nvim-features-new* -- cgit From 56174572bc70947ab1e9e6ef48112272682ad6d8 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 2 Aug 2015 02:49:44 +0300 Subject: shada,documentation: Extend read error handling, handle write errors Modifications: - If file was not written due to write error then writing stops and temporary file will not be renamed. - If NeoVim detects that target file is not a ShaDa file then temporary file will not be renamed. --- runtime/doc/starting.txt | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt index 7d38fb68a4..a3af862ad6 100644 --- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -896,7 +896,7 @@ To automatically save and restore views for *.c files: > au BufWinEnter *.c silent loadview ============================================================================== -8. The ShaDa file *shada* *shada-file* *E575* +8. The ShaDa file *shada* *shada-file* *E575* *E576* If you exit Vim and later start it again, you would normally lose a lot of information. The ShaDa file can be used to remember that information, which enables you to continue where you left off. @@ -1110,8 +1110,19 @@ that file. This was done to avoid accidentally destroying a file when the file name of the ShaDa file is wrong. This could happen when accidentally typing "nvim -i file" when you wanted "nvim -R file" (yes, somebody accidentally did that!). If you want to overwrite a ShaDa file with an error -in it, you will either have to fix the error, or delete the file (while NeoVim -is running, so most of the information will be restored). +in it, you will either have to fix the error, delete the file (while NeoVim is +running, so most of the information will be restored) or write it explicitly +with |:wshada| and a bang. + *E136* *E138* +Note: when NeoVim finds out that it failed to write part of the ShaDa file +(e.g. because there is no space left to write the file) or when it appears +that already present ShaDa file contains errors that indicate that this file +is likely not a ShaDa file then ShaDa file with `.tmp.X` suffix is left on the +file system (where X is any latin small letter: from U+0061 to U+007A). You +may use such file to recover the data if you want, but in any case it needs to +be cleaned up after you resolve the issue that prevented old ShaDa file from +being overwritten. If NeoVim fails to find unexisting `.tmp.X` file it will +not write ShaDa file at all. *:rsh* *:rshada* *E886* :rsh[ada][!] [file] Read from ShaDa file [file] (default: see above). @@ -1122,7 +1133,7 @@ is running, so most of the information will be restored). *:rv* *:rviminfo* :rv[iminfo][!] [file] Deprecated alias to |:rshada| command. - *:wsh* *:wshada* *E136* *E137* *E138* + *:wsh* *:wshada* *E137* :wsh[ada][!] [file] Write to ShaDa file [file] (default: see above). The information in the file is first read in to make a merge between old and new info. When [!] is used, -- cgit From 21056bad57bc239d27639c087ed113f8e512cc76 Mon Sep 17 00:00:00 2001 From: ZyX Date: Wed, 5 Aug 2015 07:17:48 +0300 Subject: documentation: Describe forward compatibility limitations --- runtime/doc/starting.txt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt index a3af862ad6..c75970db56 100644 --- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -1024,7 +1024,8 @@ ShaDa files are forward and backward compatible. This means that 1. Entries which have unknown type (i.e. that hold unidentified data) are ignored when reading and blindly copied when writing. 2. Register entries with unknown register name are ignored when reading and - blindly copied when writing. |registers| + blindly copied when writing. Limitation: only registers that use name with + code in interval [1, 255] are supported. |registers| 3. Register entries with unknown register type are ignored when reading and merged as usual when writing. |getregtype()| 4. Local and global mark entries with unknown mark names are ignored when @@ -1032,9 +1033,11 @@ ShaDa files are forward and backward compatible. This means that entries are also blindly copied, but only if file they are attached to fits in the |shada-'| limit. Unknown local mark entry's timestamp is also taken into account when calculating which files exactly should fit into this - limit. |mark-motions| + limit. Limitation: only marks that use name with code in interval [1, 255] + are supported. |mark-motions| 5. History entries with unknown history type are ignored when reading and - blindly copied when writing. |history| + blindly copied when writing. Limitation: there can be only up to 256 + history types. |history| 6. Unknown keys found in register, local mark, global mark, change, jump and search pattern entries are saved internally and dumped when writing. Entries created during NeoVim session never have such additions. -- cgit From d8b0cd5c173d6255a100977bd18204ecf989f5d4 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sat, 8 Aug 2015 04:52:42 +0300 Subject: documentation: Add extended ShaDa format description --- runtime/doc/starting.txt | 157 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 154 insertions(+), 3 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt index c75970db56..e96a014041 100644 --- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -896,7 +896,7 @@ To automatically save and restore views for *.c files: > au BufWinEnter *.c silent loadview ============================================================================== -8. The ShaDa file *shada* *shada-file* *E575* *E576* +8. The ShaDa file *shada* *shada-file* If you exit Vim and later start it again, you would normally lose a lot of information. The ShaDa file can be used to remember that information, which enables you to continue where you left off. @@ -1105,7 +1105,8 @@ in your .nvimrc file like > :rshada! ~/.my.shada can be used to load this information. You could even have different ShaDa files for different types of files (e.g., C code) and load them based on the -file name, using the ":autocmd" command (see |:autocmd|). +file name, using the ":autocmd" command (see |:autocmd|). More information on +ShaDa file format is contained in |shada-format| section. *shada-errors* When Vim detects an error while reading a ShaDa file, it will not overwrite @@ -1116,7 +1117,7 @@ accidentally did that!). If you want to overwrite a ShaDa file with an error in it, you will either have to fix the error, delete the file (while NeoVim is running, so most of the information will be restored) or write it explicitly with |:wshada| and a bang. - *E136* *E138* + *E136* *E138* *shada-error-handling* Note: when NeoVim finds out that it failed to write part of the ShaDa file (e.g. because there is no space left to write the file) or when it appears that already present ShaDa file contains errors that indicate that this file @@ -1165,4 +1166,154 @@ not write ShaDa file at all. and still get the prompt to enter a file number. Use ! to abandon a modified buffer. |abandon| +SHADA FILE FORMAT *shada-format* + +ShaDa files are concats of MessagePack entries. Each entry is a concat of +exactly four MessagePack objects: + +1. First goes type of the entry. Object type must be an unsigned integer. + Object type must not be equal to zero. +2. Second goes entry timestamp. It must also be an unsigned integer. +3. Third goes the length of the fourth entry. Unsigned integer as well, used + for fast skipping without parsing. +4. Fourth is actual entry data. All currently used ShaDa entries use + containers to hold data: either map or array. Exact format depends on the + entry type: + + Entry type (name) Entry data ~ + 1 (Header) Map containing data that describes the NeoVim instance + that written this ShaDa file. It is ignored when + reading ShaDa files. Contains the following data: + Key Data ~ + version Binary, NeoVim version. + encoding Binary, effective 'encoding' value. + max_kbyte Integer, effective |shada-s| limit value. + pid Integer, instance process ID. + 2 (SearchPattern) Map containing data describing last used search or + substitute pattern. Normally ShaDa file contains two + such entries: one with "ss" key set to true (describes + substitute pattern, see |:substitute|), and one set to + false (describes search pattern, see + |search-commands|). "su" key should be true on one of + the entries. If key value is equal to default then it + is normally not present. Keys: + Key Type Default Description ~ + sm Boolean true Effective 'magic' value. + sc Boolean false Effective 'smartcase' value. + sl Boolean true True if search pattern comes + with a line offset. See + |search-offset|. + se Boolean false True if |search-offset| + requested to place cursor at + (relative to) the end of the + pattern. + so Integer 0 Offset value. |search-offset| + su Boolean false True if current entry was the + last used search pattern. + ss Boolean false True if current entry describes + |:substitute| pattern. + sh Boolean false True if |v:hlsearch| is on. + With |shada-h| or 'nohlsearch' + this key is always false. + sp Binary N/A Actual pattern. Required. + * any none Other keys are allowed for + compatibility reasons, see + |shada-compatibility|. + 3 (SubString) Array containing last |:substitute| replacement string. + Contains single entry: binary, replacement string used. + More entries are allowed for compatibility reasons, see + |shada-compatibility|. + 4 (HistoryEntry) Array containing one entry from history. Should have + two or three entries. First one is history type + (unsigned integer), second is history line (binary), + third is the separator character (unsigned integer, + must be in interval [0, 255]). Third item is only + valid for search history. Possible history types are + listed in |hist-names|, here are the corresponding + numbers: 0 - cmd, 1 - search, 2 - expr, 3 - input, + 4 - debug. + 5 (Register) Map describing one register (|registers|). If key + value is equal to default then it is normally not + present. Keys: + Key Type Def Description ~ + rt UInteger 0 Register type: + No Description ~ + 0 |characterwise-register| + 1 |linewise-register| + 2 |blockwise-register| + rw UInteger 0 Register width. Only valid + for |blockwise-register|s. + rc Array of binary N/A Register contents. Each + entry in the array + represents its own line. + NUL characters inside the + line should be represented + as NL according to + |NL-used-for-Nul|. + n UInteger N/A Register name: character + code in range [1, 255]. + Example: |quote0| register + has name 48 (ASCII code for + zero character). + * any none Other keys are allowed + for compatibility reasons, + see |shada-compatibility|. + 6 (Variable) Array containing two items: variable name (binary) and + variable value (any object). Values are converted + using the same code |msgpackparse()| uses when reading, + |msgpackdump()| when writing, so there may appear + |msgpack-special-dict|s. If there are more then two + entries then the rest are ignored + (|shada-compatibility|). + 7 (GlobalMark) + 8 (Jump) + 10 (LocalMark) + 11 (Change) Map containing some position description: + Entry Position ~ + GlobaMark Global mark position. |'A| + LocalMark Local mark position. |'a| + Jump One position from the |jumplist|. + Change One position from the |changelist|. + + Data contained in the map: + Key Type Default Description ~ + l UInteger 1 Position line number. Must be + greater then zero. + c UInteger 0 Position column number. + n UInteger 34 ('"') Mark name. Only valid for + GlobalMark and LocalMark + entries. + f Binary N/A File name. Required. + * any none Other keys are allowed for + compatibility reasons, see + |shada-compatibility|. + 9 (BufferList) Array containing maps. Each map in the array + represents one buffer. Possible keys: + Key Type Default Description ~ + l UInteger 1 Position line number. Must be + greater then zero. + c UInteger 0 Position column number. + f Binary N/A File name. Required. + * any none Other keys are allowed for + compatibility reasons, see + |shada-compatibility|. + * (Unknown) Any other entry type is allowed for compatibility + reasons, see |shada-compatibility|. + + *E575* *E576* +Errors in ShaDa file may have two types: E575 used for all “logical” errors +and E576 used for all “critical” errors. Critical errors trigger behaviour +described in |shada-error-handling| when writing and skipping the rest of the +file when reading and include: + +- Any of first three MessagePack objects being not an unsigned integer. +- Third object requesting amount of bytes greater then bytes left in the ShaDa + file. +- Entry with zero type. I.e. first object being equal to zero. +- MessagePack parser failing to parse the entry data. +- MessagePack parser consuming less or requesting greater bytes then described + in the third object for parsing fourth object. I.e. when fourth object + either contains more then one MessagePack object or it does not contain + complete MessagePack object. + vim:tw=78:ts=8:ft=help:norl: -- cgit From 8f7ddfb9a4c5ca0889bc78f617628d5c91cbe772 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sat, 15 Aug 2015 14:50:04 +0300 Subject: documentation: Update vim differences list, reference critical errors --- runtime/doc/starting.txt | 9 +++++---- runtime/doc/vim_diff.txt | 18 ++++++++++++------ 2 files changed, 17 insertions(+), 10 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt index e96a014041..dfb80b7f98 100644 --- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -1122,11 +1122,12 @@ Note: when NeoVim finds out that it failed to write part of the ShaDa file (e.g. because there is no space left to write the file) or when it appears that already present ShaDa file contains errors that indicate that this file is likely not a ShaDa file then ShaDa file with `.tmp.X` suffix is left on the -file system (where X is any latin small letter: from U+0061 to U+007A). You +file system (where X is any latin small letter: from U+0061 to U+007A). You may use such file to recover the data if you want, but in any case it needs to be cleaned up after you resolve the issue that prevented old ShaDa file from -being overwritten. If NeoVim fails to find unexisting `.tmp.X` file it will -not write ShaDa file at all. +being overwritten. If NeoVim fails to find unexisting `.tmp.X` file it will +not write ShaDa file at all. Errors which trigger this behaviour are listed +at |shada-keeping-tmpfile|. *:rsh* *:rshada* *E886* :rsh[ada][!] [file] Read from ShaDa file [file] (default: see above). @@ -1305,7 +1306,7 @@ Errors in ShaDa file may have two types: E575 used for all “logical” errors and E576 used for all “critical” errors. Critical errors trigger behaviour described in |shada-error-handling| when writing and skipping the rest of the file when reading and include: - + *shada-keeping-tmpfile* - Any of first three MessagePack objects being not an unsigned integer. - Third object requesting amount of bytes greater then bytes left in the ShaDa file. diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index d5ff27d8c5..3b3f257351 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -99,16 +99,22 @@ Additional differences: - |shada-c| has no effect. - |shada-s| now limits size of every item and not just registers. -- When reading ShaDa files history, jump list and change list items are merged - with those in currently running NeoVim instance according to the timestamp. +- When reading ShaDa files items are merged according to the timestamp. + |shada-merging| - 'viminfo' option got renamed to 'shada'. Old option is kept as an alias for compatibility reasons. -- |:wviminfo| was renamed to |:wshada|, |:rviminfo| to |:rshada|. Old commands - are still kept. -- When writing (|:wshada| without bang or at exit) it merges much more data. - Vim merges only marks. +- |:wviminfo| was renamed to |:wshada|, |:rviminfo| to |:rshada|. Old + commands are still kept. +- When writing (|:wshada| without bang or at exit) it merges much more data, + and does this according to the timestamp. Vim merges only marks. + |shada-merging| - ShaDa file format was designed with forward and backward compatibility in mind. |shada-compatibility| +- Some errors make ShaDa code keep temporary file in-place for user to decide + what to do with it. Vim deletes temporary file in these cases. + |shada-error-handling| +- Vim keeps no timestamps at all, neither in viminfo file nor in the instance + itself. ============================================================================== 4. New Features *nvim-features-new* -- cgit From 0fe11fe70a1927356bf3c2edc01741c1cd65e614 Mon Sep 17 00:00:00 2001 From: ZyX Date: Tue, 18 Aug 2015 19:32:31 +0300 Subject: shada: Add generator key to the header MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For use in viminfo→shada converters, plugins that allow editing ShaDa files or any other software which generates ShaDa files for whatever purpose. --- runtime/doc/starting.txt | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt index dfb80b7f98..2078e9761b 100644 --- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -1182,14 +1182,19 @@ exactly four MessagePack objects: entry type: Entry type (name) Entry data ~ - 1 (Header) Map containing data that describes the NeoVim instance - that written this ShaDa file. It is ignored when - reading ShaDa files. Contains the following data: + 1 (Header) Map containing data that describes the generator + instance that wrote this ShaDa file. It is ignored + when reading ShaDa files. Contains the following data: Key Data ~ - version Binary, NeoVim version. + generator Binary, software used to generate ShaDa + file. Is equal to "nvim" when ShaDa file was + written by NeoVim. + version Binary, generator version. encoding Binary, effective 'encoding' value. max_kbyte Integer, effective |shada-s| limit value. pid Integer, instance process ID. + * It is allowed to have any number of + additional keys with any data. 2 (SearchPattern) Map containing data describing last used search or substitute pattern. Normally ShaDa file contains two such entries: one with "ss" key set to true (describes -- cgit From 48ba2f0109ad2b5bc51b08c55848d526b37fd8d0 Mon Sep 17 00:00:00 2001 From: ZyX Date: Tue, 18 Aug 2015 21:20:48 +0300 Subject: documentation/functests: Replace NeoVim with Neovim --- runtime/doc/starting.txt | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt index 2078e9761b..cfd3d2c9d2 100644 --- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -991,16 +991,16 @@ MERGING *shada-merging* {Nvim} When writing ShaDa files with |:wshada| without bang or at regular exit information in the existing ShaDa file is merged with information from current -NeoVim instance. For this purpose ShaDa files store timestamps associated +Neovim instance. For this purpose ShaDa files store timestamps associated with ShaDa entries. Specifically the following is being done: 1. History lines are merged, ordered by timestamp. Maximum amount of items in ShaDa file is defined by 'shada' option (|shada-/|, |shada-:|, |shada-@|, etc: one suboption for each character that represents history name (|:history|)). -2. Local marks and changes for files that were not opened by NeoVim are copied - to new ShaDa file. Marks for files that were opened by NeoVim are merged, - changes to files opened by NeoVim are ignored. |shada-'| +2. Local marks and changes for files that were not opened by Neovim are copied + to new ShaDa file. Marks for files that were opened by Neovim are merged, + changes to files opened by Neovim are ignored. |shada-'| 3. Jump list is merged: jumps are ordered by timestamp, identical jumps (identical position AND timestamp) are squashed. 4. Search patterns and substitute strings are not merged: search pattern or @@ -1008,14 +1008,14 @@ with ShaDa entries. Specifically the following is being done: to ShaDa file. 5. For each register entity with greatest timestamp is the only saved. |shada-<| -6. All saved variables are saved from current NeoVim instance. Additionally +6. All saved variables are saved from current Neovim instance. Additionally existing variable values are copied, meaning that the only way to remove variable from a ShaDa file is either removing it by hand or disabling writing variables completely. |shada-!| 7. For each global mark entity with greatest timestamp is the only saved. 8. Buffer list and header are the only entries which are not merged in any fashion: the only header and buffer list present are the ones from the - NeoVim instance which was last writing the file. |shada-%| + Neovim instance which was last writing the file. |shada-%| COMPATIBILITY *shada-compatibility* {Nvim} @@ -1040,13 +1040,13 @@ ShaDa files are forward and backward compatible. This means that history types. |history| 6. Unknown keys found in register, local mark, global mark, change, jump and search pattern entries are saved internally and dumped when writing. - Entries created during NeoVim session never have such additions. + Entries created during Neovim session never have such additions. 7. Additional elements found in replacement string and history entries are - saved internally and dumped. Entries created during NeoVim session never + saved internally and dumped. Entries created during Neovim session never have such additions. 8. Additional elements found in variable entries are simply ignored when reading. When writing new variables they will be preserved during merging, - but that's all. Variable values dumped from current NeoVim session never + but that's all. Variable values dumped from current Neovim session never have additional elements, even if variables themselves were obtained by reading ShaDa files. @@ -1074,7 +1074,7 @@ The text in the ShaDa file is UTF-8-encoded. Normally you will always work with the same 'encoding' value, and this works just fine. However, if you read the ShaDa file with value for 'encoding' different from utf-8 and 'encoding' used when writing ShaDa file, some of the text (non-ASCII -characters) may be invalid as NeoVim always attempts to convert the text in +characters) may be invalid as Neovim always attempts to convert the text in the ShaDa file from the UTF-8 to the current 'encoding' value. Filenames are never converted, affected elements are: @@ -1099,7 +1099,7 @@ start with an existing one to get the format right. You need to understand MessagePack (or, more likely, find software that is able to use it) format to do this. This can be useful in order to create a second file, say "~/.my.shada" which could contain certain settings that you always want when -you first start NeoVim. For example, you can preload registers with +you first start Neovim. For example, you can preload registers with particular data, or put certain commands in the command line history. A line in your .nvimrc file like > :rshada! ~/.my.shada @@ -1114,18 +1114,18 @@ that file. This was done to avoid accidentally destroying a file when the file name of the ShaDa file is wrong. This could happen when accidentally typing "nvim -i file" when you wanted "nvim -R file" (yes, somebody accidentally did that!). If you want to overwrite a ShaDa file with an error -in it, you will either have to fix the error, delete the file (while NeoVim is +in it, you will either have to fix the error, delete the file (while Neovim is running, so most of the information will be restored) or write it explicitly with |:wshada| and a bang. *E136* *E138* *shada-error-handling* -Note: when NeoVim finds out that it failed to write part of the ShaDa file +Note: when Neovim finds out that it failed to write part of the ShaDa file (e.g. because there is no space left to write the file) or when it appears that already present ShaDa file contains errors that indicate that this file is likely not a ShaDa file then ShaDa file with `.tmp.X` suffix is left on the file system (where X is any latin small letter: from U+0061 to U+007A). You may use such file to recover the data if you want, but in any case it needs to be cleaned up after you resolve the issue that prevented old ShaDa file from -being overwritten. If NeoVim fails to find unexisting `.tmp.X` file it will +being overwritten. If Neovim fails to find unexisting `.tmp.X` file it will not write ShaDa file at all. Errors which trigger this behaviour are listed at |shada-keeping-tmpfile|. @@ -1188,7 +1188,7 @@ exactly four MessagePack objects: Key Data ~ generator Binary, software used to generate ShaDa file. Is equal to "nvim" when ShaDa file was - written by NeoVim. + written by Neovim. version Binary, generator version. encoding Binary, effective 'encoding' value. max_kbyte Integer, effective |shada-s| limit value. -- cgit From 6de5900c50c5fc7d8149ff7114d8114357e4e7f9 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 23 Aug 2015 17:59:18 +0300 Subject: documentation: Extend shada error handling documentation --- runtime/doc/starting.txt | 64 +++++++++++++++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 22 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt index cfd3d2c9d2..03e64db430 100644 --- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -1108,26 +1108,46 @@ files for different types of files (e.g., C code) and load them based on the file name, using the ":autocmd" command (see |:autocmd|). More information on ShaDa file format is contained in |shada-format| section. - *shada-errors* -When Vim detects an error while reading a ShaDa file, it will not overwrite -that file. This was done to avoid accidentally destroying a file when the -file name of the ShaDa file is wrong. This could happen when accidentally -typing "nvim -i file" when you wanted "nvim -R file" (yes, somebody -accidentally did that!). If you want to overwrite a ShaDa file with an error -in it, you will either have to fix the error, delete the file (while Neovim is -running, so most of the information will be restored) or write it explicitly -with |:wshada| and a bang. *E136* *E138* *shada-error-handling* -Note: when Neovim finds out that it failed to write part of the ShaDa file -(e.g. because there is no space left to write the file) or when it appears -that already present ShaDa file contains errors that indicate that this file -is likely not a ShaDa file then ShaDa file with `.tmp.X` suffix is left on the -file system (where X is any latin small letter: from U+0061 to U+007A). You -may use such file to recover the data if you want, but in any case it needs to -be cleaned up after you resolve the issue that prevented old ShaDa file from -being overwritten. If Neovim fails to find unexisting `.tmp.X` file it will -not write ShaDa file at all. Errors which trigger this behaviour are listed -at |shada-keeping-tmpfile|. +Some errors make Neovim leave temporary file named `{basename}.tmp.X` (X is +any free letter from `a` to `z`) while normally it will create this file, +write to it and then rename `{basename}.tmp.X` to `{basename}`. Such errors +include: + +- Errors which make Neovim think that read file is not a ShaDa file at all: + non-ShaDa files are not overwritten for safety reasons to avoid accidentally + destroying an unrelated file. This could happen e.g. when typing "nvim -i + file" in place of "nvim -R file" (yes, somebody did that at least with Vim). + Such errors are listed at |shada-critical-contents-errors|. +- If writing to the temporary file failed: e.g. because of the insufficient + space left. +- If renaming file failed: e.g. because of insufficient permissions. On Unix + permissions are checked before trying to create even the temporary file, so + permission error can only happen if permissions were changed after starting + to edit the temporary file and before renaming it. +- If target ShaDa file has different from the Neovim instance's owners (user + and group) and changing them failed. Unix-specific, applies only when + Neovim was launched from root. + +Do not forget to remove the temporary file or replace the target file with +temporary one after getting one of the above errors or all attempts to create +a ShaDa file may fail with |E138|. If you got one of them when using +|:wshada| (and not when exiting Neovim: i.e. when you have Neovim session +running) you have additional options: + +- First thing which you should consider if you got any error, except failure + to write to the temporary file: remove existing file and replace it with the + temporary file. Do it even if you have running Neovim instance. +- Fix the permissions and/or file ownership, free some space and attempt to + write again. Do not remove the existing file. +- Use |:wshada| with bang. Does not help in case of permission error. If + target file was actually the ShaDa file some information may be lost in this + case. To make the matters slightly better use |:rshada| prior to writing, + but this still will loose buffer-local marks and change list entries for any + file which is not opened in the current Neovim instance. +- Remove the target file from shell and use |:wshada|. Consequences are not + different from using |:wshada| with bang, but "rm -f" works in some cases + when you don't have write permissions. *:rsh* *:rshada* *E886* :rsh[ada][!] [file] Read from ShaDa file [file] (default: see above). @@ -1144,8 +1164,8 @@ at |shada-keeping-tmpfile|. a merge between old and new info. When [!] is used, the old information is not read first, only the internal info is written (also disables safety checks - described in |shada-errors|). If 'shada' is empty, - marks for up to 100 files will be written. + described in |shada-error-handling|). If 'shada' is + empty, marks for up to 100 files will be written. When you get error "E138: All .tmp.X files exist, cannot write ShaDa file!" check that no old temp files were left behind (e.g. ~/.nvim/shada/main.shada.tmp*). @@ -1311,7 +1331,7 @@ Errors in ShaDa file may have two types: E575 used for all “logical” errors and E576 used for all “critical” errors. Critical errors trigger behaviour described in |shada-error-handling| when writing and skipping the rest of the file when reading and include: - *shada-keeping-tmpfile* + *shada-critical-contents-errors* - Any of first three MessagePack objects being not an unsigned integer. - Third object requesting amount of bytes greater then bytes left in the ShaDa file. -- cgit From e1dc9ed4641953977028650d8b7300a8680bdf55 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 23 Aug 2015 18:10:40 +0300 Subject: shada: First write temporary file and only then check any permissions It is not logical that on UNIX permissions can prevent even writing temporary file, while on other OS it will first write temporary file and then fail during rename. --- runtime/doc/starting.txt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt index 03e64db430..0712888284 100644 --- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -1121,10 +1121,7 @@ include: Such errors are listed at |shada-critical-contents-errors|. - If writing to the temporary file failed: e.g. because of the insufficient space left. -- If renaming file failed: e.g. because of insufficient permissions. On Unix - permissions are checked before trying to create even the temporary file, so - permission error can only happen if permissions were changed after starting - to edit the temporary file and before renaming it. +- If renaming file failed: e.g. because of insufficient permissions. - If target ShaDa file has different from the Neovim instance's owners (user and group) and changing them failed. Unix-specific, applies only when Neovim was launched from root. -- cgit From 0966e92cf441bbae1d50c68f56809fbb08fab7b6 Mon Sep 17 00:00:00 2001 From: ZyX Date: Tue, 22 Sep 2015 15:03:27 +0300 Subject: shada: When using shada-r normalize option path --- runtime/doc/options.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index d65a8b9454..579fced314 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -5374,8 +5374,7 @@ A jump table for the options with a short description can be found at |Q_op|. specifies the start of a path for which no marks will be stored. This is to avoid removable media. For MS-DOS you could use "ra:,rb:". You can also use it for temp files, - e.g., for Unix: "r/tmp". Case is ignored. Maximum length of - each 'r' argument is 50 characters. + e.g., for Unix: "r/tmp". Case is ignored. *shada-s* s Maximum size of an item contents in KiB. If zero then nothing is saved. Unlike Vim this applies to all items, except for -- cgit From db6cba7d5759e02379005702c7a9d760137f4389 Mon Sep 17 00:00:00 2001 From: ZyX Date: Thu, 8 Oct 2015 21:11:38 +0300 Subject: documentation: Disambiguate ShaDa abbreviation --- runtime/doc/starting.txt | 4 +++- runtime/doc/usr_21.txt | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt index 0712888284..84bd70db62 100644 --- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -897,9 +897,11 @@ To automatically save and restore views for *.c files: > ============================================================================== 8. The ShaDa file *shada* *shada-file* + If you exit Vim and later start it again, you would normally lose a lot of information. The ShaDa file can be used to remember that information, which -enables you to continue where you left off. +enables you to continue where you left off. Its name is the abbreviation of +SHAred DAta because it is used for sharing data between Neovim sessions. This is introduced in section |21.3| of the user manual. diff --git a/runtime/doc/usr_21.txt b/runtime/doc/usr_21.txt index 96797a745c..8bc208dc30 100644 --- a/runtime/doc/usr_21.txt +++ b/runtime/doc/usr_21.txt @@ -84,7 +84,8 @@ After editing for a while you will have text in registers, marks in various files, a command line history filled with carefully crafted commands. When you exit Vim all of this is lost. But you can get it back! -The ShaDa file is designed to store status information: +The ShaDa (abbreviation of SHAred DAta) file is designed to store status +information: Command-line and Search pattern history Text in registers -- cgit