-*options.txt* For Vim version 9.1. Last change: 2025 Dec 23
+*options.txt* For Vim version 9.1. Last change: 2025 Dec 27
VIM REFERENCE MANUAL by Bram Moolenaar
*'fsync'* *'fs'* *'nofsync'* *'nofs'*
'fsync' 'fs' boolean (default on)
- global
+ global or local to buffer |global-local|
When on, the library function fsync() will be called after writing a
file. This will flush a file to disk, ensuring that it is safely
written even on filesystems which do metadata-only journaling. This
turning this off increases the chances of data loss after a crash. On
systems without an fsync() implementation, this variable is always
off.
+ This is a |global-local| option, so it can be set per buffer, for
+ example when writing to a slow filesystem.
Also see 'swapsync' for controlling fsync() on swap files.
'fsync' also applies to |writefile()| (unless a flag is used to
overrule it) and when writing undo files (see |undo-persistence|).
-*version9.txt* For Vim version 9.1. Last change: 2025 Dec 21
+*version9.txt* For Vim version 9.1. Last change: 2025 Dec 27
VIM REFERENCE MANUAL by Bram Moolenaar
- 'guioptions': New value |'go-s'| to support fullscreen on MS-Windows GUI
(see also the below platform specific change).
- 'completepopup': Add more values to style popup windows.
+- 'fsync' is now a |global-local| option.
Ex commands: ~
- allow to specify a priority when defining a new sign |:sign-define|
clear_string_option(&buf->b_p_qe);
buf->b_p_ac = -1;
buf->b_p_ar = -1;
+#ifdef HAVE_FSYNC
+ buf->b_p_fs = -1;
+#endif
buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
clear_string_option(&buf->b_p_lw);
clear_string_option(&buf->b_p_bkc);
// For a device do try the fsync() but don't complain if it does not
// work (could be a pipe).
// If the 'fsync' option is FALSE, don't fsync(). Useful for laptops.
- if (p_fs && vim_fsync(fd) != 0 && !device)
+ if ((buf->b_p_fs >= 0 ? buf->b_p_fs : p_fs) && vim_fsync(fd) != 0
+ && !device)
{
errmsg = (char_u *)_(e_fsync_failed);
end = 0;
curbuf->b_p_initialized = TRUE;
curbuf->b_p_ac = -1;
curbuf->b_p_ar = -1; // no local 'autoread' value
+#ifdef HAVE_FSYNC
+ curbuf->b_p_fs = -1; // no local 'fsync' value
+#endif
curbuf->b_p_ul = NO_LOCAL_UNDOLEVEL;
check_buf_options(curbuf);
check_win_options(curwin);
value = -1;
else if ((int *)varp == &curbuf->b_p_ac && opt_flags == OPT_LOCAL)
value = -1;
+#ifdef HAVE_FSYNC
+ else if ((int *)varp == &curbuf->b_p_fs && opt_flags == OPT_LOCAL)
+ value = -1;
+#endif
else
value = *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL);
}
case PV_AR:
buf->b_p_ar = -1;
break;
+#ifdef HAVE_FSYNC
+ case PV_FS:
+ buf->b_p_fs = -1;
+ break;
+#endif
case PV_BKC:
clear_string_option(&buf->b_p_bkc);
buf->b_bkc_flags = 0;
switch ((int)p->indir)
{
case PV_FP: return (char_u *)&(curbuf->b_p_fp);
+#ifdef HAVE_FSYNC
+ case PV_FS: return (char_u *)&(curbuf->b_p_fs);
+#endif
#ifdef FEAT_EVAL
case PV_FFU: return (char_u *)&(curbuf->b_p_ffu);
#endif
#endif
case PV_FP: return *curbuf->b_p_fp != NUL
? (char_u *)&(curbuf->b_p_fp) : p->var;
+#ifdef HAVE_FSYNC
+ case PV_FS: return curbuf->b_p_fs >= 0
+ ? (char_u *)&(curbuf->b_p_fs) : p->var;
+#endif
#ifdef FEAT_EVAL
case PV_FFU: return *curbuf->b_p_ffu != NUL
? (char_u *)&(curbuf->b_p_ffu) : p->var;
// are not copied, start using the global value
buf->b_p_ac = -1;
buf->b_p_ar = -1;
+#ifdef HAVE_FSYNC
+ buf->b_p_fs = -1;
+#endif
buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
buf->b_p_bkc = empty_option;
buf->b_bkc_flags = 0;
, BV_FF
, BV_FLP
, BV_FO
+#ifdef HAVE_FSYNC
+ , BV_FS
+#endif
, BV_FT
, BV_IMI
, BV_IMS
#define PV_FF OPT_BUF(BV_FF)
#define PV_FLP OPT_BUF(BV_FLP)
#define PV_FO OPT_BUF(BV_FO)
+#ifdef HAVE_FSYNC
+# define PV_FS OPT_BOTH(OPT_BUF(BV_FS))
+#endif
#define PV_FT OPT_BUF(BV_FT)
#define PV_IMI OPT_BUF(BV_IMI)
#define PV_IMS OPT_BUF(BV_IMS)
{(char_u *)"", (char_u *)0L} SCTX_INIT},
{"fsync", "fs", P_BOOL|P_SECURE|P_VI_DEF,
#ifdef HAVE_FSYNC
- (char_u *)&p_fs, PV_NONE, NULL, NULL,
+ (char_u *)&p_fs, PV_FS, NULL, NULL,
{(char_u *)TRUE, (char_u *)0L}
#else
(char_u *)NULL, PV_NONE, NULL, NULL,
char_u *b_p_fex; // 'formatexpr'
long_u b_p_fex_flags; // flags for 'formatexpr'
#endif
+#ifdef HAVE_FSYNC
+ int b_p_fs; // 'fsync'
+#endif
#ifdef FEAT_CRYPT
char_u *b_p_key; // 'key'
#endif
" Test for setting boolean global-local option value
func Test_set_boolean_global_local_option()
- setglobal autoread
- setlocal noautoread
+ CheckUnix
+
+ setglobal autoread fsync
+ setlocal noautoread nofsync
call assert_equal(1, &g:autoread)
call assert_equal(0, &l:autoread)
call assert_equal(0, &autoread)
+ call assert_equal(1, &g:fsync)
+ call assert_equal(0, &l:fsync)
+ call assert_equal(0, &fsync)
" :set {option}< set the effective value of {option} to its global value.
- set autoread<
+ set autoread< fsync<
call assert_equal(1, &l:autoread)
call assert_equal(1, &autoread)
+ call assert_equal(1, &l:fsync)
+ call assert_equal(1, &fsync)
" :setlocal {option}< removes the local value, so that the global value will be used.
- setglobal noautoread
- setlocal autoread
- setlocal autoread<
+ setglobal noautoread nofsync
+ setlocal autoread fsync
+ setlocal autoread< fsync<
call assert_equal(-1, &l:autoread)
call assert_equal(0, &autoread)
+ call assert_equal(-1, &l:fsync)
+ call assert_equal(0, &fsync)
- set autoread&
+ set autoread& fsync&
endfunc
func Test_set_in_sandbox()
#endif
#if defined(UNIX) && defined(HAVE_FSYNC)
- if (p_fs && fflush(fp) == 0 && vim_fsync(fd) != 0)
+ if ((buf->b_p_fs >= 0 ? buf->b_p_fs : p_fs) && fflush(fp) == 0
+ && vim_fsync(fd) != 0)
write_ok = FALSE;
#endif
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 2024,
/**/
2023,
/**/