From 460019366e58e1bcd42959f76494e38bd895e762 Mon Sep 17 00:00:00 2001 From: Gregory Anders Date: Thu, 19 Aug 2021 20:34:43 -0600 Subject: feat: defaults: auto-create backup dir Copy the behavior of 'undodir' and create the last specified directory in the 'backupdir' option if it doesn't exist. Use trailing slashes for 'backupdir' as well as 'viewdir' and 'undodir' by default. Note that 'undodir' always behaves as though it has the trailing slashes, regardless of whether or not they are present. They are added to the default option value to minimize surprise. The '.' value in 'backupdir' is kept because the default behavior for backups is solely to have a backup if the save of the main file to disk fails. As soon as that save is completed the backup file is removed, so generally there is no need to put them in a central location. Co-authored by: murphy66 --- runtime/doc/options.txt | 6 +++--- runtime/doc/vim_diff.txt | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 364d4c5167..48fdf66d7b 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -824,7 +824,7 @@ A jump table for the options with a short description can be found at |Q_op|. again not rename the file. *'backupdir'* *'bdir'* -'backupdir' 'bdir' string (default ".,$XDG_DATA_HOME/nvim/backup") +'backupdir' 'bdir' string (default ".,$XDG_DATA_HOME/nvim/backup//") global List of directories for the backup file, separated with commas. - The backup file will be created in the first directory in the list @@ -6533,7 +6533,7 @@ A jump table for the options with a short description can be found at |Q_op|. 'ttyfast' 'tf' Removed. |vim-differences| *'undodir'* *'udir'* *E5003* -'undodir' 'udir' string (default "$XDG_DATA_HOME/nvim/undo") +'undodir' 'udir' string (default "$XDG_DATA_HOME/nvim/undo//") global List of directory names for undo files, separated with commas. See |'backupdir'| for details of the format. @@ -6692,7 +6692,7 @@ A jump table for the options with a short description can be found at |Q_op|. displayed when 'verbosefile' is set. *'viewdir'* *'vdir'* -'viewdir' 'vdir' string (default: "$XDG_DATA_HOME/nvim/view") +'viewdir' 'vdir' string (default: "$XDG_DATA_HOME/nvim/view//") global Name of the directory where to store files for |:mkview|. This option cannot be set from a |modeline| or in the |sandbox|, for diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index 166c0c17aa..918b35439d 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -30,7 +30,7 @@ the differences. - 'autoread' is enabled - 'background' defaults to "dark" (unless set automatically by the terminal/UI) - 'backspace' defaults to "indent,eol,start" -- 'backupdir' defaults to .,~/.local/share/nvim/backup (|xdg|) +- 'backupdir' defaults to .,~/.local/share/nvim/backup// (|xdg|), auto-created - 'belloff' defaults to "all" - 'compatible' is always disabled - 'complete' excludes "i" @@ -63,7 +63,7 @@ the differences. - 'tags' defaults to "./tags;,tags" - 'ttimeoutlen' defaults to 50 - 'ttyfast' is always set -- 'undodir' defaults to ~/.local/share/nvim/undo (|xdg|), auto-created +- 'undodir' defaults to ~/.local/share/nvim/undo// (|xdg|), auto-created - 'viewoptions' includes "unix,slash", excludes "options" - 'viminfo' includes "!" - 'wildmenu' is enabled -- cgit From e5d464d8e04e0745dfcbd9fc8b0e06d66cfffcbe Mon Sep 17 00:00:00 2001 From: Gregory Anders Date: Fri, 27 Aug 2021 10:38:20 -0600 Subject: docs: update 'backupdir' and 'undodir' descriptions --- runtime/doc/options.txt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 48fdf66d7b..475ccb66b3 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -828,8 +828,8 @@ A jump table for the options with a short description can be found at |Q_op|. global List of directories for the backup file, separated with commas. - The backup file will be created in the first directory in the list - where this is possible. The directory must exist, Vim will not - create it for you. + where this is possible. If none of the directories exist Nvim will + attempt to create the last directory in the list. - Empty means that no backup file will be created ('patchmode' is impossible!). Writing may fail because of this. - A directory "." means to put the backup file in the same directory @@ -6536,14 +6536,14 @@ A jump table for the options with a short description can be found at |Q_op|. 'undodir' 'udir' string (default "$XDG_DATA_HOME/nvim/undo//") global List of directory names for undo files, separated with commas. - See |'backupdir'| for details of the format. + See 'backupdir' for details of the format. "." means using the directory of the file. The undo file name for "file.txt" is ".file.txt.un~". For other directories the file name is the full path of the edited file, with path separators replaced with "%". When writing: The first directory that exists is used. "." always - works, no directories after "." will be used for writing. If none of - the directories exist Neovim will attempt to create last directory in + works, no directories after "." will be used for writing. If none of + the directories exist Nvim will attempt to create the last directory in the list. When reading all entries are tried to find an undo file. The first undo file that exists is used. When it cannot be read an error is @@ -6552,6 +6552,10 @@ A jump table for the options with a short description can be found at |Q_op|. This option cannot be set from a |modeline| or in the |sandbox|, for security reasons. + Note that unlike 'directory' and 'backupdir', 'undodir' always acts as + though the trailing slashes are present (see 'backupdir' for what this + means). + *'undofile'* *'noundofile'* *'udf'* *'noudf'* 'undofile' 'udf' boolean (default off) local to buffer -- cgit