blob: fdb99adddfbba3a74efb3c84422808fc8a61d140 [file] [log] [blame]
Bram Moolenaaredf3f972016-08-29 22:49:24 +02001/* vi:set ts=8 sts=4 sw=4 noet:
Bram Moolenaar071d4272004-06-13 20:20:40 +00002 *
3 * VIM - Vi IMproved by Bram Moolenaar
4 *
5 * Do ":help uganda" in Vim to read copying and usage conditions.
6 * Do ":help credits" in Vim to see a list of people who contributed.
7 * See README.txt for an overview of the Vim source code.
8 */
9
10/*
11 * Code to handle user-settable options. This is all pretty much table-
12 * driven. Checklist for adding a new option:
13 * - Put it in the options array below (copy an existing entry).
14 * - For a global option: Add a variable for it in option.h.
15 * - For a buffer or window local option:
16 * - Add a PV_XX entry to the enum below.
17 * - Add a variable to the window or buffer struct in structs.h.
18 * - For a window option, add some code to copy_winopt().
19 * - For a buffer option, add some code to buf_copy_options().
20 * - For a buffer string option, add code to check_buf_options().
21 * - If it's a numeric option, add any necessary bounds checks to do_set().
22 * - If it's a list of flags, add some code in do_set(), search for WW_ALL.
23 * - When adding an option with expansion (P_EXPAND), but with a different
24 * default for Vi and Vim (no P_VI_DEF), add some code at VIMEXP.
Bram Moolenaarcea912a2016-10-12 14:20:24 +020025 * - Add documentation! One line in doc/quickref.txt, full description in
Bram Moolenaar071d4272004-06-13 20:20:40 +000026 * options.txt, and any other related places.
27 * - Add an entry in runtime/optwin.vim.
28 * When making changes:
29 * - Adjust the help for the option in doc/option.txt.
30 * - When an entry has the P_VIM flag, or is lacking the P_VI_DEF flag, add a
31 * comment at the help for the 'compatible' option.
32 */
33
34#define IN_OPTION_C
35#include "vim.h"
36
37/*
38 * The options that are local to a window or buffer have "indir" set to one of
39 * these values. Special values:
40 * PV_NONE: global option.
Bram Moolenaara23ccb82006-02-27 00:08:02 +000041 * PV_WIN is added: window-local option
42 * PV_BUF is added: buffer-local option
Bram Moolenaar071d4272004-06-13 20:20:40 +000043 * PV_BOTH is added: global option which also has a local value.
44 */
45#define PV_BOTH 0x1000
Bram Moolenaara23ccb82006-02-27 00:08:02 +000046#define PV_WIN 0x2000
47#define PV_BUF 0x4000
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000048#define PV_MASK 0x0fff
Bram Moolenaara23ccb82006-02-27 00:08:02 +000049#define OPT_WIN(x) (idopt_T)(PV_WIN + (int)(x))
50#define OPT_BUF(x) (idopt_T)(PV_BUF + (int)(x))
Bram Moolenaar071d4272004-06-13 20:20:40 +000051#define OPT_BOTH(x) (idopt_T)(PV_BOTH + (int)(x))
52
Bram Moolenaara23ccb82006-02-27 00:08:02 +000053/*
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000054 * Definition of the PV_ values for buffer-local options.
55 * The BV_ values are defined in option.h.
Bram Moolenaara23ccb82006-02-27 00:08:02 +000056 */
Bram Moolenaara23ccb82006-02-27 00:08:02 +000057#define PV_AI OPT_BUF(BV_AI)
58#define PV_AR OPT_BOTH(OPT_BUF(BV_AR))
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020059#define PV_BKC OPT_BOTH(OPT_BUF(BV_BKC))
Bram Moolenaar81bdd6a2017-07-23 22:57:00 +020060#define PV_BH OPT_BUF(BV_BH)
61#define PV_BT OPT_BUF(BV_BT)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000062#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000063# define PV_EFM OPT_BOTH(OPT_BUF(BV_EFM))
64# define PV_GP OPT_BOTH(OPT_BUF(BV_GP))
65# define PV_MP OPT_BOTH(OPT_BUF(BV_MP))
Bram Moolenaara23ccb82006-02-27 00:08:02 +000066#endif
67#define PV_BIN OPT_BUF(BV_BIN)
68#define PV_BL OPT_BUF(BV_BL)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000069#ifdef FEAT_MBYTE
70# define PV_BOMB OPT_BUF(BV_BOMB)
71#endif
72#define PV_CI OPT_BUF(BV_CI)
73#ifdef FEAT_CINDENT
74# define PV_CIN OPT_BUF(BV_CIN)
75# define PV_CINK OPT_BUF(BV_CINK)
76# define PV_CINO OPT_BUF(BV_CINO)
77#endif
78#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
79# define PV_CINW OPT_BUF(BV_CINW)
80#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020081#define PV_CM OPT_BOTH(OPT_BUF(BV_CM))
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000082#ifdef FEAT_FOLDING
83# define PV_CMS OPT_BUF(BV_CMS)
84#endif
85#ifdef FEAT_COMMENTS
86# define PV_COM OPT_BUF(BV_COM)
87#endif
88#ifdef FEAT_INS_EXPAND
89# define PV_CPT OPT_BUF(BV_CPT)
90# define PV_DICT OPT_BOTH(OPT_BUF(BV_DICT))
91# define PV_TSR OPT_BOTH(OPT_BUF(BV_TSR))
92#endif
93#ifdef FEAT_COMPL_FUNC
94# define PV_CFU OPT_BUF(BV_CFU)
95#endif
96#ifdef FEAT_FIND_ID
97# define PV_DEF OPT_BOTH(OPT_BUF(BV_DEF))
98# define PV_INC OPT_BOTH(OPT_BUF(BV_INC))
99#endif
100#define PV_EOL OPT_BUF(BV_EOL)
Bram Moolenaar34d72d42015-07-17 14:18:08 +0200101#define PV_FIXEOL OPT_BUF(BV_FIXEOL)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000102#define PV_EP OPT_BOTH(OPT_BUF(BV_EP))
103#define PV_ET OPT_BUF(BV_ET)
104#ifdef FEAT_MBYTE
105# define PV_FENC OPT_BUF(BV_FENC)
106#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +0000107#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
108# define PV_BEXPR OPT_BOTH(OPT_BUF(BV_BEXPR))
109#endif
Bram Moolenaar9be7c042017-01-14 14:28:30 +0100110#define PV_FP OPT_BOTH(OPT_BUF(BV_FP))
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000111#ifdef FEAT_EVAL
112# define PV_FEX OPT_BUF(BV_FEX)
113#endif
114#define PV_FF OPT_BUF(BV_FF)
115#define PV_FLP OPT_BUF(BV_FLP)
116#define PV_FO OPT_BUF(BV_FO)
Bram Moolenaarf2bd8ef2018-03-04 18:08:14 +0100117#define PV_FT OPT_BUF(BV_FT)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000118#define PV_IMI OPT_BUF(BV_IMI)
119#define PV_IMS OPT_BUF(BV_IMS)
120#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
121# define PV_INDE OPT_BUF(BV_INDE)
122# define PV_INDK OPT_BUF(BV_INDK)
123#endif
124#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
125# define PV_INEX OPT_BUF(BV_INEX)
126#endif
127#define PV_INF OPT_BUF(BV_INF)
128#define PV_ISK OPT_BUF(BV_ISK)
129#ifdef FEAT_CRYPT
130# define PV_KEY OPT_BUF(BV_KEY)
131#endif
132#ifdef FEAT_KEYMAP
133# define PV_KMAP OPT_BUF(BV_KMAP)
134#endif
135#define PV_KP OPT_BOTH(OPT_BUF(BV_KP))
136#ifdef FEAT_LISP
137# define PV_LISP OPT_BUF(BV_LISP)
Bram Moolenaaraf6c1312014-03-12 18:55:58 +0100138# define PV_LW OPT_BOTH(OPT_BUF(BV_LW))
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000139#endif
Bram Moolenaar2c7292d2017-03-05 17:43:31 +0100140#ifdef FEAT_MBYTE
141# define PV_MENC OPT_BOTH(OPT_BUF(BV_MENC))
142#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000143#define PV_MA OPT_BUF(BV_MA)
144#define PV_ML OPT_BUF(BV_ML)
145#define PV_MOD OPT_BUF(BV_MOD)
146#define PV_MPS OPT_BUF(BV_MPS)
147#define PV_NF OPT_BUF(BV_NF)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000148#ifdef FEAT_COMPL_FUNC
149# define PV_OFU OPT_BUF(BV_OFU)
150#endif
151#define PV_PATH OPT_BOTH(OPT_BUF(BV_PATH))
152#define PV_PI OPT_BUF(BV_PI)
153#ifdef FEAT_TEXTOBJ
154# define PV_QE OPT_BUF(BV_QE)
155#endif
156#define PV_RO OPT_BUF(BV_RO)
157#ifdef FEAT_SMARTINDENT
158# define PV_SI OPT_BUF(BV_SI)
159#endif
Bram Moolenaar48e330a2016-02-23 14:53:34 +0100160#define PV_SN OPT_BUF(BV_SN)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000161#ifdef FEAT_SYN_HL
162# define PV_SMC OPT_BUF(BV_SMC)
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000163# define PV_SYN OPT_BUF(BV_SYN)
164#endif
165#ifdef FEAT_SPELL
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000166# define PV_SPC OPT_BUF(BV_SPC)
167# define PV_SPF OPT_BUF(BV_SPF)
168# define PV_SPL OPT_BUF(BV_SPL)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000169#endif
170#define PV_STS OPT_BUF(BV_STS)
171#ifdef FEAT_SEARCHPATH
172# define PV_SUA OPT_BUF(BV_SUA)
173#endif
174#define PV_SW OPT_BUF(BV_SW)
175#define PV_SWF OPT_BUF(BV_SWF)
176#define PV_TAGS OPT_BOTH(OPT_BUF(BV_TAGS))
Bram Moolenaar0f6562e2015-11-24 18:48:14 +0100177#define PV_TC OPT_BOTH(OPT_BUF(BV_TC))
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000178#define PV_TS OPT_BUF(BV_TS)
179#define PV_TW OPT_BUF(BV_TW)
180#define PV_TX OPT_BUF(BV_TX)
Bram Moolenaar55debbe2010-05-23 23:34:36 +0200181#ifdef FEAT_PERSISTENT_UNDO
182# define PV_UDF OPT_BUF(BV_UDF)
183#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000184#define PV_WM OPT_BUF(BV_WM)
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200185#ifdef FEAT_VARTABS
186# define PV_VSTS OPT_BUF(BV_VSTS)
187# define PV_VTS OPT_BUF(BV_VTS)
188#endif
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000189
190/*
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000191 * Definition of the PV_ values for window-local options.
192 * The WV_ values are defined in option.h.
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000193 */
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000194#define PV_LIST OPT_WIN(WV_LIST)
195#ifdef FEAT_ARABIC
196# define PV_ARAB OPT_WIN(WV_ARAB)
197#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +0200198#ifdef FEAT_LINEBREAK
199# define PV_BRI OPT_WIN(WV_BRI)
200# define PV_BRIOPT OPT_WIN(WV_BRIOPT)
201#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000202#ifdef FEAT_DIFF
203# define PV_DIFF OPT_WIN(WV_DIFF)
204#endif
205#ifdef FEAT_FOLDING
206# define PV_FDC OPT_WIN(WV_FDC)
207# define PV_FEN OPT_WIN(WV_FEN)
208# define PV_FDI OPT_WIN(WV_FDI)
209# define PV_FDL OPT_WIN(WV_FDL)
210# define PV_FDM OPT_WIN(WV_FDM)
211# define PV_FML OPT_WIN(WV_FML)
212# define PV_FDN OPT_WIN(WV_FDN)
213# ifdef FEAT_EVAL
214# define PV_FDE OPT_WIN(WV_FDE)
215# define PV_FDT OPT_WIN(WV_FDT)
216# endif
217# define PV_FMR OPT_WIN(WV_FMR)
218#endif
219#ifdef FEAT_LINEBREAK
220# define PV_LBR OPT_WIN(WV_LBR)
221#endif
222#define PV_NU OPT_WIN(WV_NU)
Bram Moolenaar64486672010-05-16 15:46:46 +0200223#define PV_RNU OPT_WIN(WV_RNU)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000224#ifdef FEAT_LINEBREAK
225# define PV_NUW OPT_WIN(WV_NUW)
226#endif
Bram Moolenaar4033c552017-09-16 20:54:51 +0200227#if defined(FEAT_QUICKFIX)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000228# define PV_PVW OPT_WIN(WV_PVW)
229#endif
230#ifdef FEAT_RIGHTLEFT
231# define PV_RL OPT_WIN(WV_RL)
232# define PV_RLC OPT_WIN(WV_RLC)
233#endif
Bram Moolenaar8a3bb562018-03-04 20:14:14 +0100234#define PV_SCBIND OPT_WIN(WV_SCBIND)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000235#define PV_SCROLL OPT_WIN(WV_SCROLL)
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000236#ifdef FEAT_SPELL
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000237# define PV_SPELL OPT_WIN(WV_SPELL)
238#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000239#ifdef FEAT_SYN_HL
240# define PV_CUC OPT_WIN(WV_CUC)
241# define PV_CUL OPT_WIN(WV_CUL)
Bram Moolenaar1a384422010-07-14 19:53:30 +0200242# define PV_CC OPT_WIN(WV_CC)
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000243#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000244#ifdef FEAT_STL_OPT
245# define PV_STL OPT_BOTH(OPT_WIN(WV_STL))
246#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +0100247#define PV_UL OPT_BOTH(OPT_BUF(BV_UL))
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000248# define PV_WFH OPT_WIN(WV_WFH)
Bram Moolenaar97b2ad32006-03-18 21:40:56 +0000249# define PV_WFW OPT_WIN(WV_WFW)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000250#define PV_WRAP OPT_WIN(WV_WRAP)
Bram Moolenaar8a3bb562018-03-04 20:14:14 +0100251#define PV_CRBIND OPT_WIN(WV_CRBIND)
Bram Moolenaar860cae12010-06-05 23:22:07 +0200252#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +0200253# define PV_COCU OPT_WIN(WV_COCU)
254# define PV_COLE OPT_WIN(WV_COLE)
Bram Moolenaar860cae12010-06-05 23:22:07 +0200255#endif
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200256#ifdef FEAT_TERMINAL
Bram Moolenaar6d150f72018-04-21 20:03:20 +0200257# define PV_TWK OPT_WIN(WV_TWK)
258# define PV_TWS OPT_WIN(WV_TWS)
259# define PV_TWSL OPT_BUF(BV_TWSL)
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200260#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +0200261#ifdef FEAT_SIGNS
262# define PV_SCL OPT_WIN(WV_SCL)
263#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000264
265/* WV_ and BV_ values get typecasted to this for the "indir" field */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000266typedef enum
267{
Bram Moolenaar7d96acd2008-06-09 15:07:54 +0000268 PV_NONE = 0,
269 PV_MAXVAL = 0xffff /* to avoid warnings for value out of range */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000270} idopt_T;
271
272/*
273 * Options local to a window have a value local to a buffer and global to all
274 * buffers. Indicate this by setting "var" to VAR_WIN.
275 */
276#define VAR_WIN ((char_u *)-1)
277
278/*
Bram Moolenaar9b2200a2006-03-20 21:55:45 +0000279 * These are the global values for options which are also local to a buffer.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000280 * Only to be used in option.c!
281 */
282static int p_ai;
283static int p_bin;
284#ifdef FEAT_MBYTE
285static int p_bomb;
286#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000287static char_u *p_bh;
288static char_u *p_bt;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000289static int p_bl;
290static int p_ci;
291#ifdef FEAT_CINDENT
292static int p_cin;
293static char_u *p_cink;
294static char_u *p_cino;
295#endif
296#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
297static char_u *p_cinw;
298#endif
299#ifdef FEAT_COMMENTS
300static char_u *p_com;
301#endif
302#ifdef FEAT_FOLDING
303static char_u *p_cms;
304#endif
305#ifdef FEAT_INS_EXPAND
306static char_u *p_cpt;
307#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000308#ifdef FEAT_COMPL_FUNC
309static char_u *p_cfu;
Bram Moolenaare344bea2005-09-01 20:46:49 +0000310static char_u *p_ofu;
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000311#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000312static int p_eol;
Bram Moolenaar34d72d42015-07-17 14:18:08 +0200313static int p_fixeol;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000314static int p_et;
315#ifdef FEAT_MBYTE
316static char_u *p_fenc;
317#endif
318static char_u *p_ff;
319static char_u *p_fo;
Bram Moolenaar86b68352004-12-27 21:59:20 +0000320static char_u *p_flp;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000321static char_u *p_ft;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000322static long p_iminsert;
323static long p_imsearch;
324#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
325static char_u *p_inex;
326#endif
327#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
328static char_u *p_inde;
329static char_u *p_indk;
330#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +0000331#if defined(FEAT_EVAL)
332static char_u *p_fex;
333#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000334static int p_inf;
335static char_u *p_isk;
336#ifdef FEAT_CRYPT
337static char_u *p_key;
338#endif
339#ifdef FEAT_LISP
340static int p_lisp;
341#endif
342static int p_ml;
343static int p_ma;
344static int p_mod;
345static char_u *p_mps;
346static char_u *p_nf;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000347static int p_pi;
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000348#ifdef FEAT_TEXTOBJ
349static char_u *p_qe;
350#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000351static int p_ro;
352#ifdef FEAT_SMARTINDENT
353static int p_si;
354#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000355static int p_sn;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000356static long p_sts;
357#if defined(FEAT_SEARCHPATH)
358static char_u *p_sua;
359#endif
360static long p_sw;
361static int p_swf;
362#ifdef FEAT_SYN_HL
Bram Moolenaar3b56eb32005-07-11 22:40:32 +0000363static long p_smc;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000364static char_u *p_syn;
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000365#endif
366#ifdef FEAT_SPELL
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +0000367static char_u *p_spc;
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000368static char_u *p_spf;
Bram Moolenaar217ad922005-03-20 22:37:15 +0000369static char_u *p_spl;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000370#endif
371static long p_ts;
372static long p_tw;
373static int p_tx;
Bram Moolenaar55debbe2010-05-23 23:34:36 +0200374#ifdef FEAT_PERSISTENT_UNDO
375static int p_udf;
376#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000377static long p_wm;
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200378#ifdef FEAT_VARTABS
379static char_u *p_vsts;
380static char_u *p_vts;
381#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000382#ifdef FEAT_KEYMAP
383static char_u *p_keymap;
384#endif
Bram Moolenaar6d150f72018-04-21 20:03:20 +0200385#ifdef FEAT_TERMINAL
Bram Moolenaarb833c1e2018-05-05 16:36:06 +0200386static long p_twsl; /* 'termwinscroll' */
Bram Moolenaar6d150f72018-04-21 20:03:20 +0200387#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000388
389/* Saved values for when 'bin' is set. */
390static int p_et_nobin;
391static int p_ml_nobin;
392static long p_tw_nobin;
393static long p_wm_nobin;
394
395/* Saved values for when 'paste' is set */
Bram Moolenaar54f018c2015-09-15 17:30:40 +0200396static int p_ai_nopaste;
397static int p_et_nopaste;
398static long p_sts_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000399static long p_tw_nopaste;
400static long p_wm_nopaste;
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200401#ifdef FEAT_VARTABS
402static char_u *p_vsts_nopaste;
403#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000404
405struct vimoption
406{
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200407 char *fullname; // full option name
408 char *shortname; // permissible abbreviation
409 long_u flags; // see below
410 char_u *var; // global option: pointer to variable;
411 // window-local option: VAR_WIN;
412 // buffer-local option: global value
413 idopt_T indir; // global option: PV_NONE;
414 // local option: indirect option index
415 char_u *def_val[2]; // default values for variable (vi and vim)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000416#ifdef FEAT_EVAL
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200417 sctx_T script_ctx; // script context where the option was last set
Bram Moolenaarded5f1b2018-11-10 17:33:29 +0100418# define SCTX_INIT , {0, 0, 0}
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000419#else
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200420# define SCTX_INIT
Bram Moolenaar071d4272004-06-13 20:20:40 +0000421#endif
422};
423
424#define VI_DEFAULT 0 /* def_val[VI_DEFAULT] is Vi default value */
425#define VIM_DEFAULT 1 /* def_val[VIM_DEFAULT] is Vim default value */
426
427/*
428 * Flags
429 */
430#define P_BOOL 0x01 /* the option is boolean */
431#define P_NUM 0x02 /* the option is numeric */
432#define P_STRING 0x04 /* the option is a string */
433#define P_ALLOCED 0x08 /* the string option is in allocated memory,
Bram Moolenaar363cb672009-07-22 12:28:17 +0000434 must use free_string_option() when
435 assigning new value. Not set if default is
436 the same. */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000437#define P_EXPAND 0x10 /* environment expansion. NOTE: P_EXPAND can
438 never be used for local or hidden options! */
439#define P_NODEFAULT 0x40 /* don't set to default value */
440#define P_DEF_ALLOCED 0x80 /* default value is in allocated memory, must
441 use vim_free() when assigning new value */
442#define P_WAS_SET 0x100 /* option has been set/reset */
443#define P_NO_MKRC 0x200 /* don't include in :mkvimrc output */
444#define P_VI_DEF 0x400 /* Use Vi default for Vim */
445#define P_VIM 0x800 /* Vim option, reset when 'cp' set */
446
447 /* when option changed, what to display: */
448#define P_RSTAT 0x1000 /* redraw status lines */
Bram Moolenaara2477fd2016-12-03 15:13:20 +0100449#define P_RWIN 0x2000 /* redraw current window and recompute text */
450#define P_RBUF 0x4000 /* redraw current buffer and recompute text */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000451#define P_RALL 0x6000 /* redraw all windows */
452#define P_RCLR 0x7000 /* clear and redraw all */
453
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200454#define P_COMMA 0x8000 /* comma separated list */
455#define P_ONECOMMA 0x18000L /* P_COMMA and cannot have two consecutive
456 * commas */
457#define P_NODUP 0x20000L /* don't allow duplicate strings */
458#define P_FLAGLIST 0x40000L /* list of single-char flags */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000459
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200460#define P_SECURE 0x80000L /* cannot change in modeline or secure mode */
461#define P_GETTEXT 0x100000L /* expand default value with _() */
462#define P_NOGLOB 0x200000L /* do not use local value for global vimrc */
463#define P_NFNAME 0x400000L /* only normal file name chars allowed */
464#define P_INSECURE 0x800000L /* option was set from a modeline */
465#define P_PRI_MKRC 0x1000000L /* priority for :mkvimrc (setting option has
Bram Moolenaar7554da42016-11-25 22:04:13 +0100466 side effects) */
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200467#define P_NO_ML 0x2000000L /* not allowed in modeline */
468#define P_CURSWANT 0x4000000L /* update curswant required; not needed when
Bram Moolenaar913077c2012-03-28 19:59:04 +0200469 * there is a redraw flag */
Bram Moolenaar7554da42016-11-25 22:04:13 +0100470#define P_NDNAME 0x8000000L /* only normal dir name chars allowed */
Bram Moolenaara2477fd2016-12-03 15:13:20 +0100471#define P_RWINONLY 0x10000000L /* only redraw current window */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000472
Bram Moolenaar362e1a32006-03-06 23:29:24 +0000473#define ISK_LATIN1 (char_u *)"@,48-57,_,192-255"
474
Bram Moolenaar910f66f2006-04-05 20:41:53 +0000475/* 'isprint' for latin1 is also used for MS-Windows cp1252, where 0x80 is used
476 * for the currency sign. */
Bram Moolenaar48e330a2016-02-23 14:53:34 +0100477#if defined(MSWIN)
Bram Moolenaare2f98b92006-03-29 21:18:24 +0000478# define ISP_LATIN1 (char_u *)"@,~-255"
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +0000479#else
480# define ISP_LATIN1 (char_u *)"@,161-255"
481#endif
482
Bram Moolenaar05fbfdc2017-08-14 22:35:08 +0200483# define HIGHLIGHT_INIT "8:SpecialKey,~:EndOfBuffer,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,m:MoreMsg,M:ModeMsg,n:LineNr,N:CursorLineNr,r:Question,s:StatusLine,S:StatusLineNC,c:VertSplit,t:Title,v:Visual,V:VisualNOS,w:WarningMsg,W:WildMenu,f:Folded,F:FoldColumn,A:DiffAdd,C:DiffChange,D:DiffDelete,T:DiffText,>:SignColumn,-:Conceal,B:SpellBad,P:SpellCap,R:SpellRare,L:SpellLocal,+:Pmenu,=:PmenuSel,x:PmenuSbar,X:PmenuThumb,*:TabLine,#:TabLineSel,_:TabLineFill,!:CursorColumn,.:CursorLine,o:ColorColumn,q:QuickFixLine,z:StatusLineTerm,Z:StatusLineTermNC"
Bram Moolenaar3991dab2006-03-27 17:01:56 +0000484
Bram Moolenaarf42dd3c2017-01-28 16:06:38 +0100485/* Default python version for pyx* commands */
486#if defined(FEAT_PYTHON) && defined(FEAT_PYTHON3)
487# define DEFAULT_PYTHON_VER 0
488#elif defined(FEAT_PYTHON3)
489# define DEFAULT_PYTHON_VER 3
490#elif defined(FEAT_PYTHON)
491# define DEFAULT_PYTHON_VER 2
492#else
493# define DEFAULT_PYTHON_VER 0
494#endif
495
Bram Moolenaar071d4272004-06-13 20:20:40 +0000496/*
497 * options[] is initialized here.
498 * The order of the options MUST be alphabetic for ":set all" and findoption().
499 * All option names MUST start with a lowercase letter (for findoption()).
500 * Exception: "t_" options are at the end.
501 * The options with a NULL variable are 'hidden': a set command for them is
502 * ignored and they are not printed.
503 */
Bram Moolenaare89ff042016-02-20 22:17:05 +0100504static struct vimoption options[] =
Bram Moolenaar071d4272004-06-13 20:20:40 +0000505{
Bram Moolenaar913077c2012-03-28 19:59:04 +0200506 {"aleph", "al", P_NUM|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000507#ifdef FEAT_RIGHTLEFT
508 (char_u *)&p_aleph, PV_NONE,
509#else
510 (char_u *)NULL, PV_NONE,
511#endif
512 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +0100513#if (defined(WIN3264)) && !defined(FEAT_GUI_W32)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000514 (char_u *)128L,
515#else
516 (char_u *)224L,
517#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200518 (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000519 {"antialias", "anti", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
Bram Moolenaard0573012017-10-28 21:11:06 +0200520#if defined(FEAT_GUI_MAC)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000521 (char_u *)&p_antialias, PV_NONE,
522 {(char_u *)FALSE, (char_u *)FALSE}
523#else
524 (char_u *)NULL, PV_NONE,
525 {(char_u *)FALSE, (char_u *)FALSE}
526#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200527 SCTX_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +0200528 {"arabic", "arab", P_BOOL|P_VI_DEF|P_VIM|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000529#ifdef FEAT_ARABIC
530 (char_u *)VAR_WIN, PV_ARAB,
531#else
532 (char_u *)NULL, PV_NONE,
533#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200534 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000535 {"arabicshape", "arshape", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
536#ifdef FEAT_ARABIC
537 (char_u *)&p_arshape, PV_NONE,
538#else
539 (char_u *)NULL, PV_NONE,
540#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200541 {(char_u *)TRUE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000542 {"allowrevins", "ari", P_BOOL|P_VI_DEF|P_VIM,
543#ifdef FEAT_RIGHTLEFT
544 (char_u *)&p_ari, PV_NONE,
545#else
546 (char_u *)NULL, PV_NONE,
547#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200548 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000549 {"altkeymap", "akm", P_BOOL|P_VI_DEF,
550#ifdef FEAT_FKMAP
551 (char_u *)&p_altkeymap, PV_NONE,
552#else
553 (char_u *)NULL, PV_NONE,
554#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200555 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000556 {"ambiwidth", "ambw", P_STRING|P_VI_DEF|P_RCLR,
557#if defined(FEAT_MBYTE)
558 (char_u *)&p_ambw, PV_NONE,
559 {(char_u *)"single", (char_u *)0L}
560#else
561 (char_u *)NULL, PV_NONE,
562 {(char_u *)0L, (char_u *)0L}
563#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200564 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000565 {"autochdir", "acd", P_BOOL|P_VI_DEF,
Bram Moolenaara713ff82017-02-25 22:18:43 +0100566#ifdef FEAT_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +0000567 (char_u *)&p_acd, PV_NONE,
Bram Moolenaara713ff82017-02-25 22:18:43 +0100568 {(char_u *)FALSE, (char_u *)0L}
569#else
570 (char_u *)NULL, PV_NONE,
571 {(char_u *)0L, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000572#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200573 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000574 {"autoindent", "ai", P_BOOL|P_VI_DEF,
575 (char_u *)&p_ai, PV_AI,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200576 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000577 {"autoprint", "ap", P_BOOL|P_VI_DEF,
578 (char_u *)NULL, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200579 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000580 {"autoread", "ar", P_BOOL|P_VI_DEF,
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000581 (char_u *)&p_ar, PV_AR,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200582 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000583 {"autowrite", "aw", P_BOOL|P_VI_DEF,
584 (char_u *)&p_aw, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200585 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000586 {"autowriteall","awa", P_BOOL|P_VI_DEF,
587 (char_u *)&p_awa, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200588 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000589 {"background", "bg", P_STRING|P_VI_DEF|P_RCLR,
590 (char_u *)&p_bg, PV_NONE,
591 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +0100592#if (defined(WIN3264)) && !defined(FEAT_GUI)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000593 (char_u *)"dark",
594#else
595 (char_u *)"light",
596#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200597 (char_u *)0L} SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200598 {"backspace", "bs", P_STRING|P_VI_DEF|P_VIM|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000599 (char_u *)&p_bs, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200600 {(char_u *)"", (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000601 {"backup", "bk", P_BOOL|P_VI_DEF|P_VIM,
602 (char_u *)&p_bk, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200603 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200604 {"backupcopy", "bkc", P_STRING|P_VIM|P_ONECOMMA|P_NODUP,
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +0200605 (char_u *)&p_bkc, PV_BKC,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000606#ifdef UNIX
607 {(char_u *)"yes", (char_u *)"auto"}
608#else
609 {(char_u *)"auto", (char_u *)"auto"}
610#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200611 SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200612 {"backupdir", "bdir", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA
613 |P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000614 (char_u *)&p_bdir, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200615 {(char_u *)DFLT_BDIR, (char_u *)0L} SCTX_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +0000616 {"backupext", "bex", P_STRING|P_VI_DEF|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000617 (char_u *)&p_bex, PV_NONE,
618 {
619#ifdef VMS
620 (char_u *)"_",
621#else
622 (char_u *)"~",
623#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200624 (char_u *)0L} SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200625 {"backupskip", "bsk", P_STRING|P_VI_DEF|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000626#ifdef FEAT_WILDIGN
627 (char_u *)&p_bsk, PV_NONE,
628 {(char_u *)"", (char_u *)0L}
629#else
630 (char_u *)NULL, PV_NONE,
631 {(char_u *)0L, (char_u *)0L}
632#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200633 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000634 {"balloondelay","bdlay",P_NUM|P_VI_DEF,
Bram Moolenaarc43a8b82017-02-25 21:12:29 +0100635#ifdef FEAT_BEVAL
Bram Moolenaar071d4272004-06-13 20:20:40 +0000636 (char_u *)&p_bdlay, PV_NONE,
Bram Moolenaarc43a8b82017-02-25 21:12:29 +0100637 {(char_u *)600L, (char_u *)0L}
638#else
639 (char_u *)NULL, PV_NONE,
640 {(char_u *)0L, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000641#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200642 SCTX_INIT},
Bram Moolenaarc43a8b82017-02-25 21:12:29 +0100643 {"ballooneval", "beval",P_BOOL|P_VI_DEF|P_NO_MKRC,
Bram Moolenaarc3719bd2017-11-18 22:13:31 +0100644#ifdef FEAT_BEVAL_GUI
Bram Moolenaarc43a8b82017-02-25 21:12:29 +0100645 (char_u *)&p_beval, PV_NONE,
646 {(char_u *)FALSE, (char_u *)0L}
647#else
648 (char_u *)NULL, PV_NONE,
649 {(char_u *)0L, (char_u *)0L}
650#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200651 SCTX_INIT},
Bram Moolenaar51b0f372017-11-18 18:52:04 +0100652 {"balloonevalterm", "bevalterm",P_BOOL|P_VI_DEF|P_NO_MKRC,
Bram Moolenaarc3719bd2017-11-18 22:13:31 +0100653#ifdef FEAT_BEVAL_TERM
Bram Moolenaar51b0f372017-11-18 18:52:04 +0100654 (char_u *)&p_bevalterm, PV_NONE,
655 {(char_u *)FALSE, (char_u *)0L}
656#else
657 (char_u *)NULL, PV_NONE,
658 {(char_u *)0L, (char_u *)0L}
659#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200660 SCTX_INIT},
Bram Moolenaarc43a8b82017-02-25 21:12:29 +0100661 {"balloonexpr", "bexpr", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
662#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
663 (char_u *)&p_bexpr, PV_BEXPR,
664 {(char_u *)"", (char_u *)0L}
665#else
666 (char_u *)NULL, PV_NONE,
667 {(char_u *)0L, (char_u *)0L}
668#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200669 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000670 {"beautify", "bf", P_BOOL|P_VI_DEF,
671 (char_u *)NULL, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200672 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar165bc692015-07-21 17:53:25 +0200673 {"belloff", "bo", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
674 (char_u *)&p_bo, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200675 {(char_u *)"", (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000676 {"binary", "bin", P_BOOL|P_VI_DEF|P_RSTAT,
677 (char_u *)&p_bin, PV_BIN,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200678 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000679 {"bioskey", "biosk",P_BOOL|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000680 (char_u *)NULL, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200681 {(char_u *)TRUE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000682 {"bomb", NULL, P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
683#ifdef FEAT_MBYTE
684 (char_u *)&p_bomb, PV_BOMB,
685#else
686 (char_u *)NULL, PV_NONE,
687#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200688 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000689 {"breakat", "brk", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST,
690#ifdef FEAT_LINEBREAK
691 (char_u *)&p_breakat, PV_NONE,
692 {(char_u *)" \t!@*-+;:,./?", (char_u *)0L}
693#else
694 (char_u *)NULL, PV_NONE,
695 {(char_u *)0L, (char_u *)0L}
696#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200697 SCTX_INIT},
Bram Moolenaar597a4222014-06-25 14:39:50 +0200698 {"breakindent", "bri", P_BOOL|P_VI_DEF|P_VIM|P_RWIN,
699#ifdef FEAT_LINEBREAK
700 (char_u *)VAR_WIN, PV_BRI,
701 {(char_u *)FALSE, (char_u *)0L}
702#else
703 (char_u *)NULL, PV_NONE,
704 {(char_u *)0L, (char_u *)0L}
705#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200706 SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200707 {"breakindentopt", "briopt", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF
708 |P_ONECOMMA|P_NODUP,
Bram Moolenaar597a4222014-06-25 14:39:50 +0200709#ifdef FEAT_LINEBREAK
710 (char_u *)VAR_WIN, PV_BRIOPT,
711 {(char_u *)"", (char_u *)NULL}
712#else
713 (char_u *)NULL, PV_NONE,
714 {(char_u *)"", (char_u *)NULL}
715#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200716 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000717 {"browsedir", "bsdir",P_STRING|P_VI_DEF,
718#ifdef FEAT_BROWSE
719 (char_u *)&p_bsdir, PV_NONE,
720 {(char_u *)"last", (char_u *)0L}
721#else
722 (char_u *)NULL, PV_NONE,
723 {(char_u *)0L, (char_u *)0L}
724#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200725 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000726 {"bufhidden", "bh", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000727 (char_u *)&p_bh, PV_BH,
728 {(char_u *)"", (char_u *)0L}
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200729 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000730 {"buflisted", "bl", P_BOOL|P_VI_DEF|P_NOGLOB,
731 (char_u *)&p_bl, PV_BL,
732 {(char_u *)1L, (char_u *)0L}
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200733 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000734 {"buftype", "bt", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000735 (char_u *)&p_bt, PV_BT,
736 {(char_u *)"", (char_u *)0L}
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200737 SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200738 {"casemap", "cmp", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaarfa1d1402006-03-25 21:59:56 +0000739#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +0000740 (char_u *)&p_cmp, PV_NONE,
741 {(char_u *)"internal,keepascii", (char_u *)0L}
Bram Moolenaarfa1d1402006-03-25 21:59:56 +0000742#else
743 (char_u *)NULL, PV_NONE,
744 {(char_u *)0L, (char_u *)0L}
745#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200746 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000747 {"cdpath", "cd", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
748#ifdef FEAT_SEARCHPATH
749 (char_u *)&p_cdpath, PV_NONE,
750 {(char_u *)",,", (char_u *)0L}
751#else
752 (char_u *)NULL, PV_NONE,
753 {(char_u *)0L, (char_u *)0L}
754#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200755 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000756 {"cedit", NULL, P_STRING,
757#ifdef FEAT_CMDWIN
758 (char_u *)&p_cedit, PV_NONE,
759 {(char_u *)"", (char_u *)CTRL_F_STR}
760#else
761 (char_u *)NULL, PV_NONE,
762 {(char_u *)0L, (char_u *)0L}
763#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200764 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000765 {"charconvert", "ccv", P_STRING|P_VI_DEF|P_SECURE,
766#if defined(FEAT_MBYTE) && defined(FEAT_EVAL)
767 (char_u *)&p_ccv, PV_NONE,
768 {(char_u *)"", (char_u *)0L}
769#else
770 (char_u *)NULL, PV_NONE,
771 {(char_u *)0L, (char_u *)0L}
772#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200773 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000774 {"cindent", "cin", P_BOOL|P_VI_DEF|P_VIM,
775#ifdef FEAT_CINDENT
776 (char_u *)&p_cin, PV_CIN,
777#else
778 (char_u *)NULL, PV_NONE,
779#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200780 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200781 {"cinkeys", "cink", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000782#ifdef FEAT_CINDENT
783 (char_u *)&p_cink, PV_CINK,
784 {(char_u *)"0{,0},0),:,0#,!^F,o,O,e", (char_u *)0L}
785#else
786 (char_u *)NULL, PV_NONE,
787 {(char_u *)0L, (char_u *)0L}
788#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200789 SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200790 {"cinoptions", "cino", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000791#ifdef FEAT_CINDENT
792 (char_u *)&p_cino, PV_CINO,
793#else
794 (char_u *)NULL, PV_NONE,
795#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200796 {(char_u *)"", (char_u *)0L} SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200797 {"cinwords", "cinw", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000798#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
799 (char_u *)&p_cinw, PV_CINW,
800 {(char_u *)"if,else,while,do,for,switch",
801 (char_u *)0L}
802#else
803 (char_u *)NULL, PV_NONE,
804 {(char_u *)0L, (char_u *)0L}
805#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200806 SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200807 {"clipboard", "cb", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000808#ifdef FEAT_CLIPBOARD
809 (char_u *)&p_cb, PV_NONE,
810# ifdef FEAT_XCLIPBOARD
811 {(char_u *)"autoselect,exclude:cons\\|linux",
812 (char_u *)0L}
813# else
814 {(char_u *)"", (char_u *)0L}
815# endif
816#else
817 (char_u *)NULL, PV_NONE,
818 {(char_u *)"", (char_u *)0L}
819#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200820 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000821 {"cmdheight", "ch", P_NUM|P_VI_DEF|P_RALL,
822 (char_u *)&p_ch, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200823 {(char_u *)1L, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000824 {"cmdwinheight", "cwh", P_NUM|P_VI_DEF,
825#ifdef FEAT_CMDWIN
826 (char_u *)&p_cwh, PV_NONE,
827#else
828 (char_u *)NULL, PV_NONE,
829#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200830 {(char_u *)7L, (char_u *)0L} SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200831 {"colorcolumn", "cc", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_RWIN,
Bram Moolenaar1a384422010-07-14 19:53:30 +0200832#ifdef FEAT_SYN_HL
833 (char_u *)VAR_WIN, PV_CC,
834#else
835 (char_u *)NULL, PV_NONE,
836#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200837 {(char_u *)"", (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000838 {"columns", "co", P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR,
839 (char_u *)&Columns, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200840 {(char_u *)80L, (char_u *)0L} SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200841 {"comments", "com", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA
842 |P_NODUP|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000843#ifdef FEAT_COMMENTS
844 (char_u *)&p_com, PV_COM,
845 {(char_u *)"s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-",
846 (char_u *)0L}
847#else
848 (char_u *)NULL, PV_NONE,
849 {(char_u *)0L, (char_u *)0L}
850#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200851 SCTX_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +0200852 {"commentstring", "cms", P_STRING|P_ALLOCED|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000853#ifdef FEAT_FOLDING
854 (char_u *)&p_cms, PV_CMS,
855 {(char_u *)"/*%s*/", (char_u *)0L}
856#else
857 (char_u *)NULL, PV_NONE,
858 {(char_u *)0L, (char_u *)0L}
859#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200860 SCTX_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +0000861 /* P_PRI_MKRC isn't needed here, optval_default()
862 * always returns TRUE for 'compatible' */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000863 {"compatible", "cp", P_BOOL|P_RALL,
864 (char_u *)&p_cp, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200865 {(char_u *)TRUE, (char_u *)FALSE} SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200866 {"complete", "cpt", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000867#ifdef FEAT_INS_EXPAND
868 (char_u *)&p_cpt, PV_CPT,
869 {(char_u *)".,w,b,u,t,i", (char_u *)0L}
870#else
871 (char_u *)NULL, PV_NONE,
872 {(char_u *)0L, (char_u *)0L}
873#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200874 SCTX_INIT},
Bram Moolenaarf5963f72010-07-23 22:10:27 +0200875 {"concealcursor","cocu", P_STRING|P_ALLOCED|P_RWIN|P_VI_DEF,
Bram Moolenaar860cae12010-06-05 23:22:07 +0200876#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +0200877 (char_u *)VAR_WIN, PV_COCU,
878 {(char_u *)"", (char_u *)NULL}
879#else
880 (char_u *)NULL, PV_NONE,
881 {(char_u *)NULL, (char_u *)0L}
882#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200883 SCTX_INIT},
Bram Moolenaarf5963f72010-07-23 22:10:27 +0200884 {"conceallevel","cole", P_NUM|P_RWIN|P_VI_DEF,
885#ifdef FEAT_CONCEAL
886 (char_u *)VAR_WIN, PV_COLE,
Bram Moolenaar860cae12010-06-05 23:22:07 +0200887#else
888 (char_u *)NULL, PV_NONE,
889#endif
890 {(char_u *)0L, (char_u *)0L}
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200891 SCTX_INIT},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000892 {"completefunc", "cfu", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE,
893#ifdef FEAT_COMPL_FUNC
894 (char_u *)&p_cfu, PV_CFU,
895 {(char_u *)"", (char_u *)0L}
896#else
897 (char_u *)NULL, PV_NONE,
898 {(char_u *)0L, (char_u *)0L}
899#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200900 SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200901 {"completeopt", "cot", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar1c7715d2005-10-03 22:02:18 +0000902#ifdef FEAT_INS_EXPAND
903 (char_u *)&p_cot, PV_NONE,
Bram Moolenaarc270d802006-03-11 21:29:41 +0000904 {(char_u *)"menu,preview", (char_u *)0L}
Bram Moolenaar1c7715d2005-10-03 22:02:18 +0000905#else
906 (char_u *)NULL, PV_NONE,
907 {(char_u *)0L, (char_u *)0L}
908#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200909 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000910 {"confirm", "cf", P_BOOL|P_VI_DEF,
911#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
912 (char_u *)&p_confirm, PV_NONE,
913#else
914 (char_u *)NULL, PV_NONE,
915#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200916 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000917 {"conskey", "consk",P_BOOL|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000918 (char_u *)NULL, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200919 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000920 {"copyindent", "ci", P_BOOL|P_VI_DEF|P_VIM,
921 (char_u *)&p_ci, PV_CI,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200922 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000923 {"cpoptions", "cpo", P_STRING|P_VIM|P_RALL|P_FLAGLIST,
924 (char_u *)&p_cpo, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000925 {(char_u *)CPO_VI, (char_u *)CPO_VIM}
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200926 SCTX_INIT},
Bram Moolenaar49771f42010-07-20 17:32:38 +0200927 {"cryptmethod", "cm", P_STRING|P_ALLOCED|P_VI_DEF,
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200928#ifdef FEAT_CRYPT
Bram Moolenaar40e6a712010-05-16 22:32:54 +0200929 (char_u *)&p_cm, PV_CM,
Bram Moolenaar49771f42010-07-20 17:32:38 +0200930 {(char_u *)"zip", (char_u *)0L}
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200931#else
932 (char_u *)NULL, PV_NONE,
Bram Moolenaar49771f42010-07-20 17:32:38 +0200933 {(char_u *)0L, (char_u *)0L}
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200934#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200935 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000936 {"cscopepathcomp", "cspc", P_NUM|P_VI_DEF|P_VIM,
937#ifdef FEAT_CSCOPE
938 (char_u *)&p_cspc, PV_NONE,
939#else
940 (char_u *)NULL, PV_NONE,
941#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200942 {(char_u *)0L, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000943 {"cscopeprg", "csprg", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
944#ifdef FEAT_CSCOPE
945 (char_u *)&p_csprg, PV_NONE,
946 {(char_u *)"cscope", (char_u *)0L}
947#else
948 (char_u *)NULL, PV_NONE,
949 {(char_u *)0L, (char_u *)0L}
950#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200951 SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200952 {"cscopequickfix", "csqf", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000953#if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX)
954 (char_u *)&p_csqf, PV_NONE,
955 {(char_u *)"", (char_u *)0L}
956#else
957 (char_u *)NULL, PV_NONE,
958 {(char_u *)0L, (char_u *)0L}
959#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200960 SCTX_INIT},
Bram Moolenaarf7befa92011-06-12 22:13:40 +0200961 {"cscoperelative", "csre", P_BOOL|P_VI_DEF|P_VIM,
962#ifdef FEAT_CSCOPE
963 (char_u *)&p_csre, PV_NONE,
964#else
965 (char_u *)NULL, PV_NONE,
966#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200967 {(char_u *)0L, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000968 {"cscopetag", "cst", P_BOOL|P_VI_DEF|P_VIM,
969#ifdef FEAT_CSCOPE
970 (char_u *)&p_cst, PV_NONE,
971#else
972 (char_u *)NULL, PV_NONE,
973#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200974 {(char_u *)0L, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000975 {"cscopetagorder", "csto", P_NUM|P_VI_DEF|P_VIM,
976#ifdef FEAT_CSCOPE
977 (char_u *)&p_csto, PV_NONE,
978#else
979 (char_u *)NULL, PV_NONE,
980#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200981 {(char_u *)0L, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000982 {"cscopeverbose", "csverb", P_BOOL|P_VI_DEF|P_VIM,
983#ifdef FEAT_CSCOPE
984 (char_u *)&p_csverbose, PV_NONE,
985#else
986 (char_u *)NULL, PV_NONE,
987#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200988 {(char_u *)0L, (char_u *)0L} SCTX_INIT},
Bram Moolenaar860cae12010-06-05 23:22:07 +0200989 {"cursorbind", "crb", P_BOOL|P_VI_DEF,
Bram Moolenaar860cae12010-06-05 23:22:07 +0200990 (char_u *)VAR_WIN, PV_CRBIND,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200991 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000992 {"cursorcolumn", "cuc", P_BOOL|P_VI_DEF|P_RWIN,
993#ifdef FEAT_SYN_HL
994 (char_u *)VAR_WIN, PV_CUC,
995#else
996 (char_u *)NULL, PV_NONE,
997#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +0200998 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaara2477fd2016-12-03 15:13:20 +0100999 {"cursorline", "cul", P_BOOL|P_VI_DEF|P_RWINONLY,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00001000#ifdef FEAT_SYN_HL
1001 (char_u *)VAR_WIN, PV_CUL,
1002#else
1003 (char_u *)NULL, PV_NONE,
1004#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001005 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001006 {"debug", NULL, P_STRING|P_VI_DEF,
1007 (char_u *)&p_debug, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001008 {(char_u *)"", (char_u *)0L} SCTX_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001009 {"define", "def", P_STRING|P_ALLOCED|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001010#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001011 (char_u *)&p_def, PV_DEF,
Bram Moolenaard4755bb2004-09-02 19:12:26 +00001012 {(char_u *)"^\\s*#\\s*define", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001013#else
1014 (char_u *)NULL, PV_NONE,
1015 {(char_u *)NULL, (char_u *)0L}
1016#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001017 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001018 {"delcombine", "deco", P_BOOL|P_VI_DEF|P_VIM,
1019#ifdef FEAT_MBYTE
1020 (char_u *)&p_deco, PV_NONE,
1021#else
1022 (char_u *)NULL, PV_NONE,
1023#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001024 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar7554da42016-11-25 22:04:13 +01001025 {"dictionary", "dict", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP|P_NDNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001026#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001027 (char_u *)&p_dict, PV_DICT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001028#else
1029 (char_u *)NULL, PV_NONE,
1030#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001031 {(char_u *)"", (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001032 {"diff", NULL, P_BOOL|P_VI_DEF|P_RWIN|P_NOGLOB,
1033#ifdef FEAT_DIFF
1034 (char_u *)VAR_WIN, PV_DIFF,
1035#else
1036 (char_u *)NULL, PV_NONE,
1037#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001038 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001039 {"diffexpr", "dex", P_STRING|P_VI_DEF|P_SECURE|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001040#if defined(FEAT_DIFF) && defined(FEAT_EVAL)
1041 (char_u *)&p_dex, PV_NONE,
1042 {(char_u *)"", (char_u *)0L}
1043#else
1044 (char_u *)NULL, PV_NONE,
1045 {(char_u *)0L, (char_u *)0L}
1046#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001047 SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001048 {"diffopt", "dip", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN|P_ONECOMMA
1049 |P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001050#ifdef FEAT_DIFF
1051 (char_u *)&p_dip, PV_NONE,
Bram Moolenaarc93262b2018-09-10 21:15:40 +02001052 {(char_u *)"internal,filler", (char_u *)NULL}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001053#else
1054 (char_u *)NULL, PV_NONE,
1055 {(char_u *)"", (char_u *)NULL}
1056#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001057 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001058 {"digraph", "dg", P_BOOL|P_VI_DEF|P_VIM,
1059#ifdef FEAT_DIGRAPHS
1060 (char_u *)&p_dg, PV_NONE,
1061#else
1062 (char_u *)NULL, PV_NONE,
1063#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001064 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001065 {"directory", "dir", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA
1066 |P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001067 (char_u *)&p_dir, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001068 {(char_u *)DFLT_DIR, (char_u *)0L} SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001069 {"display", "dy", P_STRING|P_VI_DEF|P_ONECOMMA|P_RALL|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001070 (char_u *)&p_dy, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001071 {(char_u *)"", (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001072 {"eadirection", "ead", P_STRING|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001073 (char_u *)&p_ead, PV_NONE,
1074 {(char_u *)"both", (char_u *)0L}
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001075 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001076 {"edcompatible","ed", P_BOOL|P_VI_DEF,
1077 (char_u *)&p_ed, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001078 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar3848e002016-03-19 18:42:29 +01001079 {"emoji", "emo", P_BOOL|P_VI_DEF|P_RCLR,
1080#if defined(FEAT_MBYTE)
1081 (char_u *)&p_emoji, PV_NONE,
1082 {(char_u *)TRUE, (char_u *)0L}
1083#else
1084 (char_u *)NULL, PV_NONE,
1085 {(char_u *)0L, (char_u *)0L}
1086#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001087 SCTX_INIT},
Bram Moolenaar865242e2010-07-14 21:12:05 +02001088 {"encoding", "enc", P_STRING|P_VI_DEF|P_RCLR|P_NO_ML,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001089#ifdef FEAT_MBYTE
1090 (char_u *)&p_enc, PV_NONE,
1091 {(char_u *)ENC_DFLT, (char_u *)0L}
1092#else
1093 (char_u *)NULL, PV_NONE,
1094 {(char_u *)0L, (char_u *)0L}
1095#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001096 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001097 {"endofline", "eol", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
1098 (char_u *)&p_eol, PV_EOL,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001099 {(char_u *)TRUE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001100 {"equalalways", "ea", P_BOOL|P_VI_DEF|P_RALL,
1101 (char_u *)&p_ea, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001102 {(char_u *)TRUE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001103 {"equalprg", "ep", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001104 (char_u *)&p_ep, PV_EP,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001105 {(char_u *)"", (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001106 {"errorbells", "eb", P_BOOL|P_VI_DEF,
1107 (char_u *)&p_eb, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001108 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001109 {"errorfile", "ef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1110#ifdef FEAT_QUICKFIX
1111 (char_u *)&p_ef, PV_NONE,
1112 {(char_u *)DFLT_ERRORFILE, (char_u *)0L}
1113#else
1114 (char_u *)NULL, PV_NONE,
1115 {(char_u *)NULL, (char_u *)0L}
1116#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001117 SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001118 {"errorformat", "efm", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001119#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001120 (char_u *)&p_efm, PV_EFM,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001121 {(char_u *)DFLT_EFM, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001122#else
1123 (char_u *)NULL, PV_NONE,
1124 {(char_u *)NULL, (char_u *)0L}
1125#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001126 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001127 {"esckeys", "ek", P_BOOL|P_VIM,
1128 (char_u *)&p_ek, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001129 {(char_u *)FALSE, (char_u *)TRUE} SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001130 {"eventignore", "ei", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001131 (char_u *)&p_ei, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001132 {(char_u *)"", (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001133 {"expandtab", "et", P_BOOL|P_VI_DEF|P_VIM,
1134 (char_u *)&p_et, PV_ET,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001135 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001136 {"exrc", "ex", P_BOOL|P_VI_DEF|P_SECURE,
1137 (char_u *)&p_exrc, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001138 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001139 {"fileencoding","fenc", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_RBUF
1140 |P_NO_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001141#ifdef FEAT_MBYTE
1142 (char_u *)&p_fenc, PV_FENC,
1143 {(char_u *)"", (char_u *)0L}
1144#else
1145 (char_u *)NULL, PV_NONE,
1146 {(char_u *)0L, (char_u *)0L}
1147#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001148 SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001149 {"fileencodings","fencs", P_STRING|P_VI_DEF|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001150#ifdef FEAT_MBYTE
1151 (char_u *)&p_fencs, PV_NONE,
1152 {(char_u *)"ucs-bom", (char_u *)0L}
1153#else
1154 (char_u *)NULL, PV_NONE,
1155 {(char_u *)0L, (char_u *)0L}
1156#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001157 SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001158 {"fileformat", "ff", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_NO_MKRC
1159 |P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001160 (char_u *)&p_ff, PV_FF,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001161 {(char_u *)DFLT_FF, (char_u *)0L} SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001162 {"fileformats", "ffs", P_STRING|P_VIM|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001163 (char_u *)&p_ffs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001164 {(char_u *)DFLT_FFS_VI, (char_u *)DFLT_FFS_VIM}
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001165 SCTX_INIT},
Bram Moolenaar71afbfe2013-03-19 16:49:16 +01001166 {"fileignorecase", "fic", P_BOOL|P_VI_DEF,
1167 (char_u *)&p_fic, PV_NONE,
1168 {
1169#ifdef CASE_INSENSITIVE_FILENAME
1170 (char_u *)TRUE,
1171#else
1172 (char_u *)FALSE,
1173#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001174 (char_u *)0L} SCTX_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001175 {"filetype", "ft", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001176 (char_u *)&p_ft, PV_FT,
1177 {(char_u *)"", (char_u *)0L}
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001178 SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001179 {"fillchars", "fcs", P_STRING|P_VI_DEF|P_RALL|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001180 (char_u *)&p_fcs, PV_NONE,
1181 {(char_u *)"vert:|,fold:-", (char_u *)0L}
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001182 SCTX_INIT},
Bram Moolenaar34d72d42015-07-17 14:18:08 +02001183 {"fixendofline", "fixeol", P_BOOL|P_VI_DEF|P_RSTAT,
1184 (char_u *)&p_fixeol, PV_FIXEOL,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001185 {(char_u *)TRUE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001186 {"fkmap", "fk", P_BOOL|P_VI_DEF,
1187#ifdef FEAT_FKMAP
1188 (char_u *)&p_fkmap, PV_NONE,
1189#else
1190 (char_u *)NULL, PV_NONE,
1191#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001192 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001193 {"flash", "fl", P_BOOL|P_VI_DEF,
1194 (char_u *)NULL, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001195 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001196 {"foldclose", "fcl", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_RWIN,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001197#ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00001198 (char_u *)&p_fcl, PV_NONE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001199 {(char_u *)"", (char_u *)0L}
1200#else
Bram Moolenaar071d4272004-06-13 20:20:40 +00001201 (char_u *)NULL, PV_NONE,
1202 {(char_u *)NULL, (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01001203#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001204 SCTX_INIT},
Bram Moolenaara713ff82017-02-25 22:18:43 +01001205 {"foldcolumn", "fdc", P_NUM|P_VI_DEF|P_RWIN,
1206#ifdef FEAT_FOLDING
1207 (char_u *)VAR_WIN, PV_FDC,
1208 {(char_u *)FALSE, (char_u *)0L}
1209#else
1210 (char_u *)NULL, PV_NONE,
1211 {(char_u *)NULL, (char_u *)0L}
1212#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001213 SCTX_INIT},
Bram Moolenaara713ff82017-02-25 22:18:43 +01001214 {"foldenable", "fen", P_BOOL|P_VI_DEF|P_RWIN,
1215#ifdef FEAT_FOLDING
1216 (char_u *)VAR_WIN, PV_FEN,
1217 {(char_u *)TRUE, (char_u *)0L}
1218#else
1219 (char_u *)NULL, PV_NONE,
1220 {(char_u *)NULL, (char_u *)0L}
1221#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001222 SCTX_INIT},
Bram Moolenaara713ff82017-02-25 22:18:43 +01001223 {"foldexpr", "fde", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1224#if defined(FEAT_FOLDING) && defined(FEAT_EVAL)
1225 (char_u *)VAR_WIN, PV_FDE,
1226 {(char_u *)"0", (char_u *)NULL}
1227#else
1228 (char_u *)NULL, PV_NONE,
1229 {(char_u *)NULL, (char_u *)0L}
1230#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001231 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001232 {"foldignore", "fdi", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001233#ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00001234 (char_u *)VAR_WIN, PV_FDI,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001235 {(char_u *)"#", (char_u *)NULL}
1236#else
1237 (char_u *)NULL, PV_NONE,
1238 {(char_u *)NULL, (char_u *)0L}
1239#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001240 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001241 {"foldlevel", "fdl", P_NUM|P_VI_DEF|P_RWIN,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001242#ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00001243 (char_u *)VAR_WIN, PV_FDL,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001244 {(char_u *)0L, (char_u *)0L}
1245#else
1246 (char_u *)NULL, PV_NONE,
1247 {(char_u *)NULL, (char_u *)0L}
1248#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001249 SCTX_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001250 {"foldlevelstart","fdls", P_NUM|P_VI_DEF|P_CURSWANT,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001251#ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00001252 (char_u *)&p_fdls, PV_NONE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001253 {(char_u *)-1L, (char_u *)0L}
1254#else
1255 (char_u *)NULL, PV_NONE,
1256 {(char_u *)NULL, (char_u *)0L}
1257#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001258 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001259 {"foldmarker", "fmr", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001260 P_RWIN|P_ONECOMMA|P_NODUP,
Bram Moolenaar37640762017-02-25 22:37:15 +01001261#ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00001262 (char_u *)VAR_WIN, PV_FMR,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001263 {(char_u *)"{{{,}}}", (char_u *)NULL}
Bram Moolenaara713ff82017-02-25 22:18:43 +01001264#else
Bram Moolenaar071d4272004-06-13 20:20:40 +00001265 (char_u *)NULL, PV_NONE,
1266 {(char_u *)NULL, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001267#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001268 SCTX_INIT},
Bram Moolenaara713ff82017-02-25 22:18:43 +01001269 {"foldmethod", "fdm", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1270#ifdef FEAT_FOLDING
1271 (char_u *)VAR_WIN, PV_FDM,
1272 {(char_u *)"manual", (char_u *)NULL}
1273#else
1274 (char_u *)NULL, PV_NONE,
1275 {(char_u *)NULL, (char_u *)0L}
1276#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001277 SCTX_INIT},
Bram Moolenaara713ff82017-02-25 22:18:43 +01001278 {"foldminlines","fml", P_NUM|P_VI_DEF|P_RWIN,
1279#ifdef FEAT_FOLDING
1280 (char_u *)VAR_WIN, PV_FML,
1281 {(char_u *)1L, (char_u *)0L}
1282#else
1283 (char_u *)NULL, PV_NONE,
1284 {(char_u *)NULL, (char_u *)0L}
1285#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001286 SCTX_INIT},
Bram Moolenaara713ff82017-02-25 22:18:43 +01001287 {"foldnestmax", "fdn", P_NUM|P_VI_DEF|P_RWIN,
1288#ifdef FEAT_FOLDING
1289 (char_u *)VAR_WIN, PV_FDN,
1290 {(char_u *)20L, (char_u *)0L}
1291#else
1292 (char_u *)NULL, PV_NONE,
1293 {(char_u *)NULL, (char_u *)0L}
1294#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001295 SCTX_INIT},
Bram Moolenaara713ff82017-02-25 22:18:43 +01001296 {"foldopen", "fdo", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_CURSWANT,
1297#ifdef FEAT_FOLDING
1298 (char_u *)&p_fdo, PV_NONE,
1299 {(char_u *)"block,hor,mark,percent,quickfix,search,tag,undo",
1300 (char_u *)0L}
1301#else
1302 (char_u *)NULL, PV_NONE,
1303 {(char_u *)NULL, (char_u *)0L}
1304#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001305 SCTX_INIT},
Bram Moolenaara713ff82017-02-25 22:18:43 +01001306 {"foldtext", "fdt", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1307#if defined(FEAT_FOLDING) && defined(FEAT_EVAL)
1308 (char_u *)VAR_WIN, PV_FDT,
1309 {(char_u *)"foldtext()", (char_u *)NULL}
1310#else
1311 (char_u *)NULL, PV_NONE,
1312 {(char_u *)NULL, (char_u *)0L}
1313#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001314 SCTX_INIT},
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00001315 {"formatexpr", "fex", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001316#ifdef FEAT_EVAL
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00001317 (char_u *)&p_fex, PV_FEX,
1318 {(char_u *)"", (char_u *)0L}
1319#else
1320 (char_u *)NULL, PV_NONE,
1321 {(char_u *)0L, (char_u *)0L}
1322#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001323 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001324 {"formatoptions","fo", P_STRING|P_ALLOCED|P_VIM|P_FLAGLIST,
1325 (char_u *)&p_fo, PV_FO,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001326 {(char_u *)DFLT_FO_VI, (char_u *)DFLT_FO_VIM}
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001327 SCTX_INIT},
Bram Moolenaar86b68352004-12-27 21:59:20 +00001328 {"formatlistpat","flp", P_STRING|P_ALLOCED|P_VI_DEF,
1329 (char_u *)&p_flp, PV_FLP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001330 {(char_u *)"^\\s*\\d\\+[\\]:.)}\\t ]\\s*",
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001331 (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001332 {"formatprg", "fp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar9be7c042017-01-14 14:28:30 +01001333 (char_u *)&p_fp, PV_FP,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001334 {(char_u *)"", (char_u *)0L} SCTX_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001335 {"fsync", "fs", P_BOOL|P_SECURE|P_VI_DEF,
1336#ifdef HAVE_FSYNC
1337 (char_u *)&p_fs, PV_NONE,
1338 {(char_u *)TRUE, (char_u *)0L}
1339#else
1340 (char_u *)NULL, PV_NONE,
1341 {(char_u *)FALSE, (char_u *)0L}
1342#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001343 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001344 {"gdefault", "gd", P_BOOL|P_VI_DEF|P_VIM,
1345 (char_u *)&p_gd, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001346 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001347 {"graphic", "gr", P_BOOL|P_VI_DEF,
1348 (char_u *)NULL, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001349 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001350 {"grepformat", "gfm", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001351#ifdef FEAT_QUICKFIX
1352 (char_u *)&p_gefm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001353 {(char_u *)DFLT_GREPFORMAT, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001354#else
1355 (char_u *)NULL, PV_NONE,
1356 {(char_u *)NULL, (char_u *)0L}
1357#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001358 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001359 {"grepprg", "gp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1360#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001361 (char_u *)&p_gp, PV_GP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001362 {
1363# ifdef WIN3264
1364 /* may be changed to "grep -n" in os_win32.c */
1365 (char_u *)"findstr /n",
1366# else
1367# ifdef UNIX
1368 /* Add an extra file name so that grep will always
1369 * insert a file name in the match line. */
1370 (char_u *)"grep -n $* /dev/null",
1371# else
1372# ifdef VMS
1373 (char_u *)"SEARCH/NUMBERS ",
1374# else
1375 (char_u *)"grep -n ",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001376# endif
1377# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00001378# endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001379 (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001380#else
1381 (char_u *)NULL, PV_NONE,
1382 {(char_u *)NULL, (char_u *)0L}
1383#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001384 SCTX_INIT},
Bram Moolenaar8a633e32016-04-21 21:10:14 +02001385 {"guicursor", "gcr", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001386#ifdef CURSOR_SHAPE
1387 (char_u *)&p_guicursor, PV_NONE,
1388 {
1389# ifdef FEAT_GUI
1390 (char_u *)"n-v-c:block-Cursor/lCursor,ve:ver35-Cursor,o:hor50-Cursor,i-ci:ver25-Cursor/lCursor,r-cr:hor20-Cursor/lCursor,sm:block-Cursor-blinkwait175-blinkoff150-blinkon175",
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001391# else /* Win32 console */
Bram Moolenaar071d4272004-06-13 20:20:40 +00001392 (char_u *)"n-v-c:block,o:hor50,i-ci:hor15,r-cr:hor30,sm:block",
1393# endif
1394 (char_u *)0L}
1395#else
1396 (char_u *)NULL, PV_NONE,
1397 {(char_u *)NULL, (char_u *)0L}
1398#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001399 SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001400 {"guifont", "gfn", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001401#ifdef FEAT_GUI
1402 (char_u *)&p_guifont, PV_NONE,
1403 {(char_u *)"", (char_u *)0L}
1404#else
1405 (char_u *)NULL, PV_NONE,
1406 {(char_u *)NULL, (char_u *)0L}
1407#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001408 SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001409 {"guifontset", "gfs", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001410#if defined(FEAT_GUI) && defined(FEAT_XFONTSET)
1411 (char_u *)&p_guifontset, PV_NONE,
1412 {(char_u *)"", (char_u *)0L}
1413#else
1414 (char_u *)NULL, PV_NONE,
1415 {(char_u *)NULL, (char_u *)0L}
1416#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001417 SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001418 {"guifontwide", "gfw", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001419#if defined(FEAT_GUI) && defined(FEAT_MBYTE)
1420 (char_u *)&p_guifontwide, PV_NONE,
1421 {(char_u *)"", (char_u *)0L}
1422#else
1423 (char_u *)NULL, PV_NONE,
1424 {(char_u *)NULL, (char_u *)0L}
1425#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001426 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001427 {"guiheadroom", "ghr", P_NUM|P_VI_DEF,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001428#if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001429 (char_u *)&p_ghr, PV_NONE,
1430#else
1431 (char_u *)NULL, PV_NONE,
1432#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001433 {(char_u *)50L, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001434 {"guioptions", "go", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001435#if defined(FEAT_GUI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001436 (char_u *)&p_go, PV_NONE,
Bram Moolenaard0573012017-10-28 21:11:06 +02001437# if defined(UNIX) && !defined(FEAT_GUI_MAC)
Bram Moolenaar32466aa2006-02-24 23:53:04 +00001438 {(char_u *)"aegimrLtT", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001439# else
Bram Moolenaar32466aa2006-02-24 23:53:04 +00001440 {(char_u *)"egmrLtT", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001441# endif
1442#else
1443 (char_u *)NULL, PV_NONE,
1444 {(char_u *)NULL, (char_u *)0L}
1445#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001446 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001447 {"guipty", NULL, P_BOOL|P_VI_DEF,
1448#if defined(FEAT_GUI)
1449 (char_u *)&p_guipty, PV_NONE,
1450#else
1451 (char_u *)NULL, PV_NONE,
1452#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001453 {(char_u *)TRUE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar18144c82006-04-12 21:52:12 +00001454 {"guitablabel", "gtl", P_STRING|P_VI_DEF|P_RWIN,
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00001455#if defined(FEAT_GUI_TABLINE)
1456 (char_u *)&p_gtl, PV_NONE,
1457 {(char_u *)"", (char_u *)0L}
1458#else
1459 (char_u *)NULL, PV_NONE,
1460 {(char_u *)NULL, (char_u *)0L}
1461#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001462 SCTX_INIT},
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001463 {"guitabtooltip", "gtt", P_STRING|P_VI_DEF|P_RWIN,
Bram Moolenaar57657d82006-04-21 22:12:41 +00001464#if defined(FEAT_GUI_TABLINE)
1465 (char_u *)&p_gtt, PV_NONE,
1466 {(char_u *)"", (char_u *)0L}
1467#else
1468 (char_u *)NULL, PV_NONE,
1469 {(char_u *)NULL, (char_u *)0L}
1470#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001471 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001472 {"hardtabs", "ht", P_NUM|P_VI_DEF,
1473 (char_u *)NULL, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001474 {(char_u *)0L, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001475 {"helpfile", "hf", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1476 (char_u *)&p_hf, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001477 {(char_u *)DFLT_HELPFILE, (char_u *)0L}
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001478 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001479 {"helpheight", "hh", P_NUM|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001480 (char_u *)&p_hh, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001481 {(char_u *)20L, (char_u *)0L} SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001482 {"helplang", "hlg", P_STRING|P_VI_DEF|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001483#ifdef FEAT_MULTI_LANG
1484 (char_u *)&p_hlg, PV_NONE,
1485 {(char_u *)"", (char_u *)0L}
1486#else
1487 (char_u *)NULL, PV_NONE,
1488 {(char_u *)0L, (char_u *)0L}
1489#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001490 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001491 {"hidden", "hid", P_BOOL|P_VI_DEF,
1492 (char_u *)&p_hid, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001493 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001494 {"highlight", "hl", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001495 (char_u *)&p_hl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001496 {(char_u *)HIGHLIGHT_INIT, (char_u *)0L}
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001497 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001498 {"history", "hi", P_NUM|P_VIM,
1499 (char_u *)&p_hi, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001500 {(char_u *)0L, (char_u *)50L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001501 {"hkmap", "hk", P_BOOL|P_VI_DEF|P_VIM,
1502#ifdef FEAT_RIGHTLEFT
1503 (char_u *)&p_hkmap, PV_NONE,
1504#else
1505 (char_u *)NULL, PV_NONE,
1506#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001507 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001508 {"hkmapp", "hkp", P_BOOL|P_VI_DEF|P_VIM,
1509#ifdef FEAT_RIGHTLEFT
1510 (char_u *)&p_hkmapp, PV_NONE,
1511#else
1512 (char_u *)NULL, PV_NONE,
1513#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001514 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001515 {"hlsearch", "hls", P_BOOL|P_VI_DEF|P_VIM|P_RALL,
1516 (char_u *)&p_hls, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001517 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001518 {"icon", NULL, P_BOOL|P_VI_DEF,
1519#ifdef FEAT_TITLE
1520 (char_u *)&p_icon, PV_NONE,
1521#else
1522 (char_u *)NULL, PV_NONE,
1523#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001524 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001525 {"iconstring", NULL, P_STRING|P_VI_DEF,
1526#ifdef FEAT_TITLE
1527 (char_u *)&p_iconstring, PV_NONE,
1528#else
1529 (char_u *)NULL, PV_NONE,
1530#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001531 {(char_u *)"", (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001532 {"ignorecase", "ic", P_BOOL|P_VI_DEF,
1533 (char_u *)&p_ic, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001534 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaarabab85a2013-06-26 19:18:05 +02001535 {"imactivatefunc","imaf",P_STRING|P_VI_DEF|P_SECURE,
Bram Moolenaar819edbe2017-11-25 17:14:33 +01001536#if defined(FEAT_EVAL) && defined(FEAT_MBYTE)
Bram Moolenaarabab85a2013-06-26 19:18:05 +02001537 (char_u *)&p_imaf, PV_NONE,
1538 {(char_u *)"", (char_u *)NULL}
1539# else
1540 (char_u *)NULL, PV_NONE,
1541 {(char_u *)NULL, (char_u *)0L}
1542# endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001543 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001544 {"imactivatekey","imak",P_STRING|P_VI_DEF,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001545#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001546 (char_u *)&p_imak, PV_NONE,
1547#else
1548 (char_u *)NULL, PV_NONE,
1549#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001550 {(char_u *)"", (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001551 {"imcmdline", "imc", P_BOOL|P_VI_DEF,
Bram Moolenaar819edbe2017-11-25 17:14:33 +01001552#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +00001553 (char_u *)&p_imcmdline, PV_NONE,
1554#else
1555 (char_u *)NULL, PV_NONE,
1556#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001557 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001558 {"imdisable", "imd", P_BOOL|P_VI_DEF,
Bram Moolenaar819edbe2017-11-25 17:14:33 +01001559#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +00001560 (char_u *)&p_imdisable, PV_NONE,
1561#else
1562 (char_u *)NULL, PV_NONE,
1563#endif
1564#ifdef __sgi
1565 {(char_u *)TRUE, (char_u *)0L}
1566#else
1567 {(char_u *)FALSE, (char_u *)0L}
1568#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001569 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001570 {"iminsert", "imi", P_NUM|P_VI_DEF,
1571 (char_u *)&p_iminsert, PV_IMI,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001572 {(char_u *)B_IMODE_NONE, (char_u *)0L}
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001573 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001574 {"imsearch", "ims", P_NUM|P_VI_DEF,
1575 (char_u *)&p_imsearch, PV_IMS,
Bram Moolenaar4cf56bb2017-09-16 15:50:32 +02001576 {(char_u *)B_IMODE_USE_INSERT, (char_u *)0L}
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001577 SCTX_INIT},
Bram Moolenaar4a460702013-06-29 14:42:26 +02001578 {"imstatusfunc","imsf",P_STRING|P_VI_DEF|P_SECURE,
Bram Moolenaar819edbe2017-11-25 17:14:33 +01001579#if defined(FEAT_EVAL) && defined(FEAT_MBYTE)
Bram Moolenaarabab85a2013-06-26 19:18:05 +02001580 (char_u *)&p_imsf, PV_NONE,
1581 {(char_u *)"", (char_u *)NULL}
Bram Moolenaar5c6dbcb2017-08-30 22:00:20 +02001582#else
Bram Moolenaarabab85a2013-06-26 19:18:05 +02001583 (char_u *)NULL, PV_NONE,
1584 {(char_u *)NULL, (char_u *)0L}
Bram Moolenaar5c6dbcb2017-08-30 22:00:20 +02001585#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001586 SCTX_INIT},
Bram Moolenaar5c6dbcb2017-08-30 22:00:20 +02001587 {"imstyle", "imst", P_NUM|P_VI_DEF|P_SECURE,
1588#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
1589 (char_u *)&p_imst, PV_NONE,
1590 {(char_u *)IM_OVER_THE_SPOT, (char_u *)0L}
1591#else
1592 (char_u *)NULL, PV_NONE,
1593 {(char_u *)0L, (char_u *)0L}
1594#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001595 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001596 {"include", "inc", P_STRING|P_ALLOCED|P_VI_DEF,
1597#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001598 (char_u *)&p_inc, PV_INC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001599 {(char_u *)"^\\s*#\\s*include", (char_u *)0L}
1600#else
1601 (char_u *)NULL, PV_NONE,
1602 {(char_u *)0L, (char_u *)0L}
1603#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001604 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001605 {"includeexpr", "inex", P_STRING|P_ALLOCED|P_VI_DEF,
1606#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
1607 (char_u *)&p_inex, PV_INEX,
1608 {(char_u *)"", (char_u *)0L}
1609#else
1610 (char_u *)NULL, PV_NONE,
1611 {(char_u *)0L, (char_u *)0L}
1612#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001613 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001614 {"incsearch", "is", P_BOOL|P_VI_DEF|P_VIM,
1615 (char_u *)&p_is, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001616 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001617 {"indentexpr", "inde", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
1618#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
1619 (char_u *)&p_inde, PV_INDE,
1620 {(char_u *)"", (char_u *)0L}
1621#else
1622 (char_u *)NULL, PV_NONE,
1623 {(char_u *)0L, (char_u *)0L}
1624#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001625 SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001626 {"indentkeys", "indk", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001627#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
1628 (char_u *)&p_indk, PV_INDK,
1629 {(char_u *)"0{,0},:,0#,!^F,o,O,e", (char_u *)0L}
1630#else
1631 (char_u *)NULL, PV_NONE,
1632 {(char_u *)0L, (char_u *)0L}
1633#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001634 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001635 {"infercase", "inf", P_BOOL|P_VI_DEF,
1636 (char_u *)&p_inf, PV_INF,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001637 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001638 {"insertmode", "im", P_BOOL|P_VI_DEF|P_VIM,
1639 (char_u *)&p_im, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001640 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001641 {"isfname", "isf", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1642 (char_u *)&p_isf, PV_NONE,
1643 {
1644#ifdef BACKSLASH_IN_FILENAME
1645 /* Excluded are: & and ^ are special in cmd.exe
1646 * ( and ) are used in text separating fnames */
1647 (char_u *)"@,48-57,/,\\,.,-,_,+,,,#,$,%,{,},[,],:,@-@,!,~,=",
1648#else
1649# ifdef AMIGA
1650 (char_u *)"@,48-57,/,.,-,_,+,,,$,:",
1651# else
1652# ifdef VMS
1653 (char_u *)"@,48-57,/,.,-,_,+,,,#,$,%,<,>,[,],:,;,~",
1654# else /* UNIX et al. */
1655# ifdef EBCDIC
1656 (char_u *)"@,240-249,/,.,-,_,+,,,#,$,%,~,=",
1657# else
1658 (char_u *)"@,48-57,/,.,-,_,+,,,#,$,%,~,=",
1659# endif
1660# endif
1661# endif
1662#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001663 (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001664 {"isident", "isi", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1665 (char_u *)&p_isi, PV_NONE,
1666 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001667#if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001668 (char_u *)"@,48-57,_,128-167,224-235",
1669#else
1670# ifdef EBCDIC
1671 /* TODO: EBCDIC Check this! @ == isalpha()*/
1672 (char_u *)"@,240-249,_,66-73,81-89,98-105,"
1673 "112-120,128,140-142,156,158,172,"
1674 "174,186,191,203-207,219-225,235-239,"
1675 "251-254",
1676# else
1677 (char_u *)"@,48-57,_,192-255",
1678# endif
1679#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001680 (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001681 {"iskeyword", "isk", P_STRING|P_ALLOCED|P_VIM|P_COMMA|P_NODUP,
1682 (char_u *)&p_isk, PV_ISK,
1683 {
1684#ifdef EBCDIC
1685 (char_u *)"@,240-249,_",
1686 /* TODO: EBCDIC Check this! @ == isalpha()*/
1687 (char_u *)"@,240-249,_,66-73,81-89,98-105,"
1688 "112-120,128,140-142,156,158,172,"
1689 "174,186,191,203-207,219-225,235-239,"
1690 "251-254",
1691#else
1692 (char_u *)"@,48-57,_",
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001693# if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001694 (char_u *)"@,48-57,_,128-167,224-235"
1695# else
Bram Moolenaar362e1a32006-03-06 23:29:24 +00001696 ISK_LATIN1
Bram Moolenaar071d4272004-06-13 20:20:40 +00001697# endif
1698#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001699 } SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001700 {"isprint", "isp", P_STRING|P_VI_DEF|P_RALL|P_COMMA|P_NODUP,
1701 (char_u *)&p_isp, PV_NONE,
1702 {
Bram Moolenaard0573012017-10-28 21:11:06 +02001703#if defined(MSWIN) || defined(VMS)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001704 (char_u *)"@,~-255",
1705#else
1706# ifdef EBCDIC
1707 /* all chars above 63 are printable */
1708 (char_u *)"63-255",
1709# else
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +00001710 ISP_LATIN1,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001711# endif
1712#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001713 (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001714 {"joinspaces", "js", P_BOOL|P_VI_DEF|P_VIM,
1715 (char_u *)&p_js, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001716 {(char_u *)TRUE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001717 {"key", NULL, P_STRING|P_ALLOCED|P_VI_DEF|P_NO_MKRC,
1718#ifdef FEAT_CRYPT
1719 (char_u *)&p_key, PV_KEY,
1720 {(char_u *)"", (char_u *)0L}
1721#else
1722 (char_u *)NULL, PV_NONE,
1723 {(char_u *)0L, (char_u *)0L}
1724#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001725 SCTX_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +00001726 {"keymap", "kmp", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF|P_RSTAT|P_NFNAME|P_PRI_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001727#ifdef FEAT_KEYMAP
1728 (char_u *)&p_keymap, PV_KMAP,
1729 {(char_u *)"", (char_u *)0L}
1730#else
1731 (char_u *)NULL, PV_NONE,
1732 {(char_u *)"", (char_u *)0L}
1733#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001734 SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001735 {"keymodel", "km", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001736 (char_u *)&p_km, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001737 {(char_u *)"", (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001738 {"keywordprg", "kp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001739 (char_u *)&p_kp, PV_KP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001740 {
Bram Moolenaarfd89d7e2016-06-04 20:25:05 +02001741#ifdef MSWIN
Bram Moolenaar071d4272004-06-13 20:20:40 +00001742 (char_u *)":help",
1743#else
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001744# ifdef VMS
Bram Moolenaar071d4272004-06-13 20:20:40 +00001745 (char_u *)"help",
Bram Moolenaare7fedb62015-12-31 19:07:19 +01001746# else
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001747# ifdef USEMAN_S
1748 (char_u *)"man -s",
1749# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00001750 (char_u *)"man",
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001751# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00001752# endif
1753#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001754 (char_u *)0L} SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001755 {"langmap", "lmap", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001756#ifdef FEAT_LANGMAP
1757 (char_u *)&p_langmap, PV_NONE,
Bram Moolenaar35bc7d62018-10-02 14:45:10 +02001758 {(char_u *)"", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001759#else
1760 (char_u *)NULL, PV_NONE,
Bram Moolenaar35bc7d62018-10-02 14:45:10 +02001761 {(char_u *)NULL, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001762#endif
Bram Moolenaar35bc7d62018-10-02 14:45:10 +02001763 SCTX_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001764 {"langmenu", "lm", P_STRING|P_VI_DEF|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001765#if defined(FEAT_MENU) && defined(FEAT_MULTI_LANG)
1766 (char_u *)&p_lm, PV_NONE,
1767#else
1768 (char_u *)NULL, PV_NONE,
1769#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001770 {(char_u *)"", (char_u *)0L} SCTX_INIT},
Bram Moolenaar4391cf92014-11-05 17:44:52 +01001771 {"langnoremap", "lnr", P_BOOL|P_VI_DEF,
1772#ifdef FEAT_LANGMAP
1773 (char_u *)&p_lnr, PV_NONE,
1774#else
1775 (char_u *)NULL, PV_NONE,
1776#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001777 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar920694c2016-08-21 17:45:02 +02001778 {"langremap", "lrm", P_BOOL|P_VI_DEF,
1779#ifdef FEAT_LANGMAP
1780 (char_u *)&p_lrm, PV_NONE,
1781#else
1782 (char_u *)NULL, PV_NONE,
1783#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001784 {(char_u *)TRUE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001785 {"laststatus", "ls", P_NUM|P_VI_DEF|P_RALL,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001786 (char_u *)&p_ls, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001787 {(char_u *)1L, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001788 {"lazyredraw", "lz", P_BOOL|P_VI_DEF,
1789 (char_u *)&p_lz, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001790 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001791 {"linebreak", "lbr", P_BOOL|P_VI_DEF|P_RWIN,
1792#ifdef FEAT_LINEBREAK
1793 (char_u *)VAR_WIN, PV_LBR,
1794#else
1795 (char_u *)NULL, PV_NONE,
1796#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001797 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001798 {"lines", NULL, P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR,
1799 (char_u *)&Rows, PV_NONE,
1800 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001801#if defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001802 (char_u *)25L,
1803#else
1804 (char_u *)24L,
1805#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001806 (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001807 {"linespace", "lsp", P_NUM|P_VI_DEF|P_RCLR,
1808#ifdef FEAT_GUI
1809 (char_u *)&p_linespace, PV_NONE,
1810#else
1811 (char_u *)NULL, PV_NONE,
1812#endif
1813#ifdef FEAT_GUI_W32
1814 {(char_u *)1L, (char_u *)0L}
1815#else
1816 {(char_u *)0L, (char_u *)0L}
1817#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001818 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001819 {"lisp", NULL, P_BOOL|P_VI_DEF,
1820#ifdef FEAT_LISP
1821 (char_u *)&p_lisp, PV_LISP,
1822#else
1823 (char_u *)NULL, PV_NONE,
1824#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001825 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001826 {"lispwords", "lw", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001827#ifdef FEAT_LISP
Bram Moolenaaraf6c1312014-03-12 18:55:58 +01001828 (char_u *)&p_lispwords, PV_LW,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001829 {(char_u *)LISPWORD_VALUE, (char_u *)0L}
1830#else
1831 (char_u *)NULL, PV_NONE,
1832 {(char_u *)"", (char_u *)0L}
1833#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001834 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001835 {"list", NULL, P_BOOL|P_VI_DEF|P_RWIN,
1836 (char_u *)VAR_WIN, PV_LIST,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001837 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001838 {"listchars", "lcs", P_STRING|P_VI_DEF|P_RALL|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001839 (char_u *)&p_lcs, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001840 {(char_u *)"eol:$", (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001841 {"loadplugins", "lpl", P_BOOL|P_VI_DEF,
1842 (char_u *)&p_lpl, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001843 {(char_u *)TRUE, (char_u *)0L} SCTX_INIT},
Bram Moolenaara6e42502016-04-20 16:19:52 +02001844 {"luadll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001845#if defined(DYNAMIC_LUA)
Bram Moolenaard94464e2015-11-02 15:28:18 +01001846 (char_u *)&p_luadll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01001847 {(char_u *)DYNAMIC_LUA_DLL, (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01001848#else
1849 (char_u *)NULL, PV_NONE,
1850 {(char_u *)"", (char_u *)0L}
1851#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001852 SCTX_INIT},
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001853 {"macatsui", NULL, P_BOOL|P_VI_DEF|P_RCLR,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001854#ifdef FEAT_GUI_MAC
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001855 (char_u *)&p_macatsui, PV_NONE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001856 {(char_u *)TRUE, (char_u *)0L}
1857#else
1858 (char_u *)NULL, PV_NONE,
1859 {(char_u *)"", (char_u *)0L}
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001860#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001861 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001862 {"magic", NULL, P_BOOL|P_VI_DEF,
1863 (char_u *)&p_magic, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001864 {(char_u *)TRUE, (char_u *)0L} SCTX_INIT},
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00001865 {"makeef", "mef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001866#ifdef FEAT_QUICKFIX
1867 (char_u *)&p_mef, PV_NONE,
1868 {(char_u *)"", (char_u *)0L}
1869#else
1870 (char_u *)NULL, PV_NONE,
1871 {(char_u *)NULL, (char_u *)0L}
1872#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001873 SCTX_INIT},
Bram Moolenaar2c7292d2017-03-05 17:43:31 +01001874 {"makeencoding","menc", P_STRING|P_VI_DEF,
1875#ifdef FEAT_MBYTE
1876 (char_u *)&p_menc, PV_MENC,
1877 {(char_u *)"", (char_u *)0L}
1878#else
1879 (char_u *)NULL, PV_NONE,
1880 {(char_u *)0L, (char_u *)0L}
1881#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001882 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001883 {"makeprg", "mp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1884#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001885 (char_u *)&p_mp, PV_MP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001886# ifdef VMS
1887 {(char_u *)"MMS", (char_u *)0L}
1888# else
1889 {(char_u *)"make", (char_u *)0L}
1890# endif
1891#else
1892 (char_u *)NULL, PV_NONE,
1893 {(char_u *)NULL, (char_u *)0L}
1894#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001895 SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001896 {"matchpairs", "mps", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001897 (char_u *)&p_mps, PV_MPS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001898 {(char_u *)"(:),{:},[:]", (char_u *)0L}
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001899 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001900 {"matchtime", "mat", P_NUM|P_VI_DEF,
1901 (char_u *)&p_mat, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001902 {(char_u *)5L, (char_u *)0L} SCTX_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001903 {"maxcombine", "mco", P_NUM|P_VI_DEF|P_CURSWANT,
Bram Moolenaar362e1a32006-03-06 23:29:24 +00001904#ifdef FEAT_MBYTE
1905 (char_u *)&p_mco, PV_NONE,
1906#else
1907 (char_u *)NULL, PV_NONE,
1908#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001909 {(char_u *)2, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001910 {"maxfuncdepth", "mfd", P_NUM|P_VI_DEF,
1911#ifdef FEAT_EVAL
1912 (char_u *)&p_mfd, PV_NONE,
1913#else
1914 (char_u *)NULL, PV_NONE,
1915#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001916 {(char_u *)100L, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001917 {"maxmapdepth", "mmd", P_NUM|P_VI_DEF,
1918 (char_u *)&p_mmd, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001919 {(char_u *)1000L, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001920 {"maxmem", "mm", P_NUM|P_VI_DEF,
1921 (char_u *)&p_mm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001922 {(char_u *)DFLT_MAXMEM, (char_u *)0L}
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001923 SCTX_INIT},
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00001924 {"maxmempattern","mmp", P_NUM|P_VI_DEF,
1925 (char_u *)&p_mmp, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001926 {(char_u *)1000L, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001927 {"maxmemtot", "mmt", P_NUM|P_VI_DEF,
1928 (char_u *)&p_mmt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001929 {(char_u *)DFLT_MAXMEMTOT, (char_u *)0L}
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001930 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001931 {"menuitems", "mis", P_NUM|P_VI_DEF,
1932#ifdef FEAT_MENU
1933 (char_u *)&p_mis, PV_NONE,
1934#else
1935 (char_u *)NULL, PV_NONE,
1936#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001937 {(char_u *)25L, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001938 {"mesg", NULL, P_BOOL|P_VI_DEF,
1939 (char_u *)NULL, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001940 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001941 {"mkspellmem", "msm", P_STRING|P_VI_DEF|P_EXPAND|P_SECURE,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00001942#ifdef FEAT_SPELL
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001943 (char_u *)&p_msm, PV_NONE,
1944 {(char_u *)"460000,2000,500", (char_u *)0L}
1945#else
1946 (char_u *)NULL, PV_NONE,
1947 {(char_u *)0L, (char_u *)0L}
1948#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001949 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001950 {"modeline", "ml", P_BOOL|P_VIM,
1951 (char_u *)&p_ml, PV_ML,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001952 {(char_u *)FALSE, (char_u *)TRUE} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001953 {"modelines", "mls", P_NUM|P_VI_DEF,
1954 (char_u *)&p_mls, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001955 {(char_u *)5L, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001956 {"modifiable", "ma", P_BOOL|P_VI_DEF|P_NOGLOB,
1957 (char_u *)&p_ma, PV_MA,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001958 {(char_u *)TRUE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001959 {"modified", "mod", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
1960 (char_u *)&p_mod, PV_MOD,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001961 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001962 {"more", NULL, P_BOOL|P_VIM,
1963 (char_u *)&p_more, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001964 {(char_u *)FALSE, (char_u *)TRUE} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001965 {"mouse", NULL, P_STRING|P_VI_DEF|P_FLAGLIST,
1966 (char_u *)&p_mouse, PV_NONE,
1967 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001968#if defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001969 (char_u *)"a",
1970#else
1971 (char_u *)"",
1972#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001973 (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001974 {"mousefocus", "mousef", P_BOOL|P_VI_DEF,
1975#ifdef FEAT_GUI
1976 (char_u *)&p_mousef, PV_NONE,
1977#else
1978 (char_u *)NULL, PV_NONE,
1979#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001980 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001981 {"mousehide", "mh", P_BOOL|P_VI_DEF,
1982#ifdef FEAT_GUI
1983 (char_u *)&p_mh, PV_NONE,
1984#else
1985 (char_u *)NULL, PV_NONE,
1986#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02001987 {(char_u *)TRUE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001988 {"mousemodel", "mousem", P_STRING|P_VI_DEF,
1989 (char_u *)&p_mousem, PV_NONE,
1990 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001991#if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001992 (char_u *)"popup",
1993#else
Bram Moolenaard0573012017-10-28 21:11:06 +02001994# if defined(MACOS_X)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001995 (char_u *)"popup_setpos",
1996# else
1997 (char_u *)"extend",
1998# endif
1999#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002000 (char_u *)0L} SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002001 {"mouseshape", "mouses", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002002#ifdef FEAT_MOUSESHAPE
2003 (char_u *)&p_mouseshape, PV_NONE,
2004 {(char_u *)"i-r:beam,s:updown,sd:udsizing,vs:leftright,vd:lrsizing,m:no,ml:up-arrow,v:rightup-arrow", (char_u *)0L}
2005#else
2006 (char_u *)NULL, PV_NONE,
2007 {(char_u *)NULL, (char_u *)0L}
2008#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002009 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002010 {"mousetime", "mouset", P_NUM|P_VI_DEF,
2011 (char_u *)&p_mouset, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002012 {(char_u *)500L, (char_u *)0L} SCTX_INIT},
Bram Moolenaar0ab35b22017-10-08 17:41:37 +02002013 {"mzschemedll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2014#if defined(DYNAMIC_MZSCHEME)
2015 (char_u *)&p_mzschemedll, PV_NONE,
2016 {(char_u *)DYNAMIC_MZSCH_DLL, (char_u *)0L}
2017#else
2018 (char_u *)NULL, PV_NONE,
2019 {(char_u *)"", (char_u *)0L}
2020#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002021 SCTX_INIT},
Bram Moolenaar0ab35b22017-10-08 17:41:37 +02002022 {"mzschemegcdll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2023#if defined(DYNAMIC_MZSCHEME)
2024 (char_u *)&p_mzschemegcdll, PV_NONE,
2025 {(char_u *)DYNAMIC_MZGC_DLL, (char_u *)0L}
2026#else
2027 (char_u *)NULL, PV_NONE,
2028 {(char_u *)"", (char_u *)0L}
2029#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002030 SCTX_INIT},
Bram Moolenaar325b7a22004-07-05 15:58:32 +00002031 {"mzquantum", "mzq", P_NUM,
2032#ifdef FEAT_MZSCHEME
2033 (char_u *)&p_mzq, PV_NONE,
2034#else
2035 (char_u *)NULL, PV_NONE,
2036#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002037 {(char_u *)100L, (char_u *)100L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002038 {"novice", NULL, P_BOOL|P_VI_DEF,
2039 (char_u *)NULL, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002040 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002041 {"nrformats", "nf", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002042 (char_u *)&p_nf, PV_NF,
Bram Moolenaar887c1fe2016-01-02 17:56:35 +01002043 {(char_u *)"bin,octal,hex", (char_u *)0L}
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002044 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002045 {"number", "nu", P_BOOL|P_VI_DEF|P_RWIN,
2046 (char_u *)VAR_WIN, PV_NU,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002047 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar592e0a22004-07-03 16:05:59 +00002048 {"numberwidth", "nuw", P_NUM|P_RWIN|P_VIM,
2049#ifdef FEAT_LINEBREAK
2050 (char_u *)VAR_WIN, PV_NUW,
2051#else
2052 (char_u *)NULL, PV_NONE,
2053#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002054 {(char_u *)8L, (char_u *)4L} SCTX_INIT},
Bram Moolenaarf75a9632005-09-13 21:20:47 +00002055 {"omnifunc", "ofu", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE,
Bram Moolenaare344bea2005-09-01 20:46:49 +00002056#ifdef FEAT_COMPL_FUNC
2057 (char_u *)&p_ofu, PV_OFU,
2058 {(char_u *)"", (char_u *)0L}
2059#else
2060 (char_u *)NULL, PV_NONE,
2061 {(char_u *)0L, (char_u *)0L}
2062#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002063 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002064 {"open", NULL, P_BOOL|P_VI_DEF,
2065 (char_u *)NULL, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002066 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar043545e2006-10-10 16:44:07 +00002067 {"opendevice", "odev", P_BOOL|P_VI_DEF,
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002068#if defined(MSWIN)
Bram Moolenaar043545e2006-10-10 16:44:07 +00002069 (char_u *)&p_odev, PV_NONE,
2070#else
2071 (char_u *)NULL, PV_NONE,
2072#endif
2073 {(char_u *)FALSE, (char_u *)FALSE}
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002074 SCTX_INIT},
Bram Moolenaar2c7a29c2005-12-12 22:02:31 +00002075 {"operatorfunc", "opfunc", P_STRING|P_VI_DEF|P_SECURE,
2076 (char_u *)&p_opfunc, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002077 {(char_u *)"", (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002078 {"optimize", "opt", P_BOOL|P_VI_DEF,
2079 (char_u *)NULL, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002080 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002081 {"osfiletype", "oft", P_STRING|P_ALLOCED|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002082 (char_u *)NULL, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002083 {(char_u *)0L, (char_u *)0L} SCTX_INIT},
Bram Moolenaarf6fee0e2016-02-21 23:02:49 +01002084 {"packpath", "pp", P_STRING|P_VI_DEF|P_EXPAND|P_ONECOMMA|P_NODUP
2085 |P_SECURE,
2086 (char_u *)&p_pp, PV_NONE,
2087 {(char_u *)DFLT_RUNTIMEPATH, (char_u *)0L}
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002088 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002089 {"paragraphs", "para", P_STRING|P_VI_DEF,
2090 (char_u *)&p_para, PV_NONE,
Bram Moolenaar57e48462008-03-12 16:38:55 +00002091 {(char_u *)"IPLPPPQPP TPHPLIPpLpItpplpipbp",
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002092 (char_u *)0L} SCTX_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +00002093 {"paste", NULL, P_BOOL|P_VI_DEF|P_PRI_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002094 (char_u *)&p_paste, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002095 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002096 {"pastetoggle", "pt", P_STRING|P_VI_DEF,
2097 (char_u *)&p_pt, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002098 {(char_u *)"", (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002099 {"patchexpr", "pex", P_STRING|P_VI_DEF|P_SECURE,
2100#if defined(FEAT_DIFF) && defined(FEAT_EVAL)
2101 (char_u *)&p_pex, PV_NONE,
2102 {(char_u *)"", (char_u *)0L}
2103#else
2104 (char_u *)NULL, PV_NONE,
2105 {(char_u *)0L, (char_u *)0L}
2106#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002107 SCTX_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002108 {"patchmode", "pm", P_STRING|P_VI_DEF|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002109 (char_u *)&p_pm, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002110 {(char_u *)"", (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002111 {"path", "pa", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002112 (char_u *)&p_path, PV_PATH,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002113 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002114#if defined(AMIGA) || defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002115 (char_u *)".,,",
2116#else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002117 (char_u *)".,/usr/include,,",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002118#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002119 (char_u *)0L} SCTX_INIT},
Bram Moolenaara6e42502016-04-20 16:19:52 +02002120 {"perldll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002121#if defined(DYNAMIC_PERL)
Bram Moolenaard94464e2015-11-02 15:28:18 +01002122 (char_u *)&p_perldll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002123 {(char_u *)DYNAMIC_PERL_DLL, (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01002124#else
2125 (char_u *)NULL, PV_NONE,
2126 {(char_u *)0L, (char_u *)0L}
Bram Moolenaard94464e2015-11-02 15:28:18 +01002127#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002128 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002129 {"preserveindent", "pi", P_BOOL|P_VI_DEF|P_VIM,
2130 (char_u *)&p_pi, PV_PI,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002131 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar592e0a22004-07-03 16:05:59 +00002132 {"previewheight", "pvh", P_NUM|P_VI_DEF,
Bram Moolenaar4033c552017-09-16 20:54:51 +02002133#if defined(FEAT_QUICKFIX)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002134 (char_u *)&p_pvh, PV_NONE,
2135#else
2136 (char_u *)NULL, PV_NONE,
2137#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002138 {(char_u *)12L, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002139 {"previewwindow", "pvw", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB,
Bram Moolenaar4033c552017-09-16 20:54:51 +02002140#if defined(FEAT_QUICKFIX)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002141 (char_u *)VAR_WIN, PV_PVW,
2142#else
2143 (char_u *)NULL, PV_NONE,
2144#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002145 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002146 {"printdevice", "pdev", P_STRING|P_VI_DEF|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002147#ifdef FEAT_PRINTER
2148 (char_u *)&p_pdev, PV_NONE,
2149 {(char_u *)"", (char_u *)0L}
2150#else
2151 (char_u *)NULL, PV_NONE,
2152 {(char_u *)NULL, (char_u *)0L}
2153#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002154 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002155 {"printencoding", "penc", P_STRING|P_VI_DEF,
2156#ifdef FEAT_POSTSCRIPT
2157 (char_u *)&p_penc, PV_NONE,
2158 {(char_u *)"", (char_u *)0L}
2159#else
2160 (char_u *)NULL, PV_NONE,
2161 {(char_u *)NULL, (char_u *)0L}
2162#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002163 SCTX_INIT},
Bram Moolenaar031cb742016-11-24 21:46:19 +01002164 {"printexpr", "pexpr", P_STRING|P_VI_DEF|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002165#ifdef FEAT_POSTSCRIPT
2166 (char_u *)&p_pexpr, PV_NONE,
2167 {(char_u *)"", (char_u *)0L}
2168#else
2169 (char_u *)NULL, PV_NONE,
2170 {(char_u *)NULL, (char_u *)0L}
2171#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002172 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002173 {"printfont", "pfn", P_STRING|P_VI_DEF,
2174#ifdef FEAT_PRINTER
2175 (char_u *)&p_pfn, PV_NONE,
2176 {
2177# ifdef MSWIN
2178 (char_u *)"Courier_New:h10",
2179# else
2180 (char_u *)"courier",
2181# endif
2182 (char_u *)0L}
2183#else
2184 (char_u *)NULL, PV_NONE,
2185 {(char_u *)NULL, (char_u *)0L}
2186#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002187 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002188 {"printheader", "pheader", P_STRING|P_VI_DEF|P_GETTEXT,
2189#ifdef FEAT_PRINTER
2190 (char_u *)&p_header, PV_NONE,
Bram Moolenaar0903d562017-08-26 22:30:15 +02002191 /* untranslated to avoid problems when 'encoding'
2192 * is changed */
2193 {(char_u *)"%<%f%h%m%=Page %N", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002194#else
2195 (char_u *)NULL, PV_NONE,
2196 {(char_u *)NULL, (char_u *)0L}
2197#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002198 SCTX_INIT},
Bram Moolenaar8299df92004-07-10 09:47:34 +00002199 {"printmbcharset", "pmbcs", P_STRING|P_VI_DEF,
2200#if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE)
2201 (char_u *)&p_pmcs, PV_NONE,
2202 {(char_u *)"", (char_u *)0L}
2203#else
2204 (char_u *)NULL, PV_NONE,
2205 {(char_u *)NULL, (char_u *)0L}
2206#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002207 SCTX_INIT},
Bram Moolenaar8299df92004-07-10 09:47:34 +00002208 {"printmbfont", "pmbfn", P_STRING|P_VI_DEF,
2209#if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE)
2210 (char_u *)&p_pmfn, PV_NONE,
2211 {(char_u *)"", (char_u *)0L}
2212#else
2213 (char_u *)NULL, PV_NONE,
2214 {(char_u *)NULL, (char_u *)0L}
2215#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002216 SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002217 {"printoptions", "popt", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002218#ifdef FEAT_PRINTER
2219 (char_u *)&p_popt, PV_NONE,
2220 {(char_u *)"", (char_u *)0L}
2221#else
2222 (char_u *)NULL, PV_NONE,
2223 {(char_u *)NULL, (char_u *)0L}
2224#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002225 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002226 {"prompt", NULL, P_BOOL|P_VI_DEF,
Bram Moolenaar26a60b42005-02-22 08:49:11 +00002227 (char_u *)&p_prompt, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002228 {(char_u *)TRUE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar9d47f172006-03-15 23:03:01 +00002229 {"pumheight", "ph", P_NUM|P_VI_DEF,
2230#ifdef FEAT_INS_EXPAND
2231 (char_u *)&p_ph, PV_NONE,
2232#else
2233 (char_u *)NULL, PV_NONE,
2234#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002235 {(char_u *)0L, (char_u *)0L} SCTX_INIT},
Bram Moolenaara8f04aa2018-02-10 15:36:55 +01002236 {"pumwidth", "pw", P_NUM|P_VI_DEF,
2237#ifdef FEAT_INS_EXPAND
2238 (char_u *)&p_pw, PV_NONE,
2239#else
2240 (char_u *)NULL, PV_NONE,
2241#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002242 {(char_u *)15L, (char_u *)15L} SCTX_INIT},
Bram Moolenaara6e42502016-04-20 16:19:52 +02002243 {"pythonthreedll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002244#if defined(DYNAMIC_PYTHON3)
Bram Moolenaard94464e2015-11-02 15:28:18 +01002245 (char_u *)&p_py3dll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002246 {(char_u *)DYNAMIC_PYTHON3_DLL, (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01002247#else
2248 (char_u *)NULL, PV_NONE,
2249 {(char_u *)NULL, (char_u *)0L}
Bram Moolenaard94464e2015-11-02 15:28:18 +01002250#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002251 SCTX_INIT},
Bram Moolenaar94073162018-01-31 21:49:05 +01002252 {"pythonthreehome", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2253#if defined(FEAT_PYTHON3)
2254 (char_u *)&p_py3home, PV_NONE,
2255 {(char_u *)"", (char_u *)0L}
2256#else
2257 (char_u *)NULL, PV_NONE,
2258 {(char_u *)NULL, (char_u *)0L}
2259#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002260 SCTX_INIT},
Bram Moolenaara6e42502016-04-20 16:19:52 +02002261 {"pythondll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002262#if defined(DYNAMIC_PYTHON)
Bram Moolenaard94464e2015-11-02 15:28:18 +01002263 (char_u *)&p_pydll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002264 {(char_u *)DYNAMIC_PYTHON_DLL, (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01002265#else
2266 (char_u *)NULL, PV_NONE,
2267 {(char_u *)NULL, (char_u *)0L}
Bram Moolenaard94464e2015-11-02 15:28:18 +01002268#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002269 SCTX_INIT},
Bram Moolenaar94073162018-01-31 21:49:05 +01002270 {"pythonhome", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2271#if defined(FEAT_PYTHON)
2272 (char_u *)&p_pyhome, PV_NONE,
2273 {(char_u *)"", (char_u *)0L}
2274#else
2275 (char_u *)NULL, PV_NONE,
2276 {(char_u *)NULL, (char_u *)0L}
2277#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002278 SCTX_INIT},
Bram Moolenaarf42dd3c2017-01-28 16:06:38 +01002279 {"pyxversion", "pyx", P_NUM|P_VI_DEF|P_SECURE,
2280#if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3)
2281 (char_u *)&p_pyx, PV_NONE,
2282#else
2283 (char_u *)NULL, PV_NONE,
2284#endif
2285 {(char_u *)DEFAULT_PYTHON_VER, (char_u *)0L}
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002286 SCTX_INIT},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00002287 {"quoteescape", "qe", P_STRING|P_ALLOCED|P_VI_DEF,
2288#ifdef FEAT_TEXTOBJ
2289 (char_u *)&p_qe, PV_QE,
2290 {(char_u *)"\\", (char_u *)0L}
2291#else
2292 (char_u *)NULL, PV_NONE,
2293 {(char_u *)NULL, (char_u *)0L}
2294#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002295 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002296 {"readonly", "ro", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB,
2297 (char_u *)&p_ro, PV_RO,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002298 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002299 {"redraw", NULL, P_BOOL|P_VI_DEF,
2300 (char_u *)NULL, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002301 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar91a4e822008-01-19 14:59:58 +00002302 {"redrawtime", "rdt", P_NUM|P_VI_DEF,
2303#ifdef FEAT_RELTIME
2304 (char_u *)&p_rdt, PV_NONE,
2305#else
2306 (char_u *)NULL, PV_NONE,
2307#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002308 {(char_u *)2000L, (char_u *)0L} SCTX_INIT},
Bram Moolenaarfbc0d2e2013-05-19 19:40:29 +02002309 {"regexpengine", "re", P_NUM|P_VI_DEF,
2310 (char_u *)&p_re, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002311 {(char_u *)0L, (char_u *)0L} SCTX_INIT},
Bram Moolenaar64486672010-05-16 15:46:46 +02002312 {"relativenumber", "rnu", P_BOOL|P_VI_DEF|P_RWIN,
2313 (char_u *)VAR_WIN, PV_RNU,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002314 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002315 {"remap", NULL, P_BOOL|P_VI_DEF,
2316 (char_u *)&p_remap, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002317 {(char_u *)TRUE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002318 {"renderoptions", "rop", P_STRING|P_ONECOMMA|P_RCLR|P_VI_DEF,
Bram Moolenaarb5a7a8b2014-08-06 14:52:30 +02002319#ifdef FEAT_RENDER_OPTIONS
2320 (char_u *)&p_rop, PV_NONE,
2321 {(char_u *)"", (char_u *)0L}
2322#else
2323 (char_u *)NULL, PV_NONE,
2324 {(char_u *)NULL, (char_u *)0L}
2325#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002326 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002327 {"report", NULL, P_NUM|P_VI_DEF,
2328 (char_u *)&p_report, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002329 {(char_u *)2L, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002330 {"restorescreen", "rs", P_BOOL|P_VI_DEF,
2331#ifdef WIN3264
2332 (char_u *)&p_rs, PV_NONE,
2333#else
2334 (char_u *)NULL, PV_NONE,
2335#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002336 {(char_u *)TRUE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002337 {"revins", "ri", P_BOOL|P_VI_DEF|P_VIM,
2338#ifdef FEAT_RIGHTLEFT
2339 (char_u *)&p_ri, PV_NONE,
2340#else
2341 (char_u *)NULL, PV_NONE,
2342#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002343 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002344 {"rightleft", "rl", P_BOOL|P_VI_DEF|P_RWIN,
2345#ifdef FEAT_RIGHTLEFT
2346 (char_u *)VAR_WIN, PV_RL,
2347#else
2348 (char_u *)NULL, PV_NONE,
2349#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002350 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002351 {"rightleftcmd", "rlc", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN,
2352#ifdef FEAT_RIGHTLEFT
2353 (char_u *)VAR_WIN, PV_RLC,
2354 {(char_u *)"search", (char_u *)NULL}
2355#else
2356 (char_u *)NULL, PV_NONE,
2357 {(char_u *)NULL, (char_u *)0L}
2358#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002359 SCTX_INIT},
Bram Moolenaara6e42502016-04-20 16:19:52 +02002360 {"rubydll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002361#if defined(DYNAMIC_RUBY)
Bram Moolenaard94464e2015-11-02 15:28:18 +01002362 (char_u *)&p_rubydll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002363 {(char_u *)DYNAMIC_RUBY_DLL, (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01002364#else
2365 (char_u *)NULL, PV_NONE,
2366 {(char_u *)NULL, (char_u *)0L}
Bram Moolenaard94464e2015-11-02 15:28:18 +01002367#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002368 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002369 {"ruler", "ru", P_BOOL|P_VI_DEF|P_VIM|P_RSTAT,
2370#ifdef FEAT_CMDL_INFO
2371 (char_u *)&p_ru, PV_NONE,
2372#else
2373 (char_u *)NULL, PV_NONE,
2374#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002375 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002376 {"rulerformat", "ruf", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT,
2377#ifdef FEAT_STL_OPT
2378 (char_u *)&p_ruf, PV_NONE,
2379#else
2380 (char_u *)NULL, PV_NONE,
2381#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002382 {(char_u *)"", (char_u *)0L} SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002383 {"runtimepath", "rtp", P_STRING|P_VI_DEF|P_EXPAND|P_ONECOMMA|P_NODUP
2384 |P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002385 (char_u *)&p_rtp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002386 {(char_u *)DFLT_RUNTIMEPATH, (char_u *)0L}
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002387 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002388 {"scroll", "scr", P_NUM|P_NO_MKRC|P_VI_DEF,
2389 (char_u *)VAR_WIN, PV_SCROLL,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002390 {(char_u *)0L, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002391 {"scrollbind", "scb", P_BOOL|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002392 (char_u *)VAR_WIN, PV_SCBIND,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002393 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002394 {"scrolljump", "sj", P_NUM|P_VI_DEF|P_VIM,
2395 (char_u *)&p_sj, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002396 {(char_u *)1L, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002397 {"scrolloff", "so", P_NUM|P_VI_DEF|P_VIM|P_RALL,
2398 (char_u *)&p_so, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002399 {(char_u *)0L, (char_u *)0L} SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002400 {"scrollopt", "sbo", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002401 (char_u *)&p_sbo, PV_NONE,
2402 {(char_u *)"ver,jump", (char_u *)0L}
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002403 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002404 {"sections", "sect", P_STRING|P_VI_DEF,
2405 (char_u *)&p_sections, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002406 {(char_u *)"SHNHH HUnhsh", (char_u *)0L}
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002407 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002408 {"secure", NULL, P_BOOL|P_VI_DEF|P_SECURE,
2409 (char_u *)&p_secure, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002410 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002411 {"selection", "sel", P_STRING|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002412 (char_u *)&p_sel, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002413 {(char_u *)"inclusive", (char_u *)0L}
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002414 SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002415 {"selectmode", "slm", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002416 (char_u *)&p_slm, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002417 {(char_u *)"", (char_u *)0L} SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002418 {"sessionoptions", "ssop", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002419#ifdef FEAT_SESSION
2420 (char_u *)&p_ssop, PV_NONE,
Bram Moolenaar4d8bac82018-03-09 21:33:34 +01002421 {(char_u *)"blank,buffers,curdir,folds,help,options,tabpages,winsize,terminal",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002422 (char_u *)0L}
2423#else
2424 (char_u *)NULL, PV_NONE,
2425 {(char_u *)0L, (char_u *)0L}
2426#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002427 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002428 {"shell", "sh", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2429 (char_u *)&p_sh, PV_NONE,
2430 {
2431#ifdef VMS
2432 (char_u *)"-",
2433#else
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002434# if defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002435 (char_u *)"", /* set in set_init_1() */
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002436# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002437 (char_u *)"sh",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002438# endif
2439#endif /* VMS */
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002440 (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002441 {"shellcmdflag","shcf", P_STRING|P_VI_DEF|P_SECURE,
2442 (char_u *)&p_shcf, PV_NONE,
2443 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002444#if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002445 (char_u *)"/c",
2446#else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002447 (char_u *)"-c",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002448#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002449 (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002450 {"shellpipe", "sp", P_STRING|P_VI_DEF|P_SECURE,
2451#ifdef FEAT_QUICKFIX
2452 (char_u *)&p_sp, PV_NONE,
2453 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01002454#if defined(UNIX)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002455 (char_u *)"| tee",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002456#else
2457 (char_u *)">",
2458#endif
2459 (char_u *)0L}
2460#else
2461 (char_u *)NULL, PV_NONE,
2462 {(char_u *)0L, (char_u *)0L}
2463#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002464 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002465 {"shellquote", "shq", P_STRING|P_VI_DEF|P_SECURE,
2466 (char_u *)&p_shq, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002467 {(char_u *)"", (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002468 {"shellredir", "srr", P_STRING|P_VI_DEF|P_SECURE,
2469 (char_u *)&p_srr, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002470 {(char_u *)">", (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002471 {"shellslash", "ssl", P_BOOL|P_VI_DEF,
2472#ifdef BACKSLASH_IN_FILENAME
2473 (char_u *)&p_ssl, PV_NONE,
2474#else
2475 (char_u *)NULL, PV_NONE,
2476#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002477 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar26a60b42005-02-22 08:49:11 +00002478 {"shelltemp", "stmp", P_BOOL,
2479 (char_u *)&p_stmp, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002480 {(char_u *)FALSE, (char_u *)TRUE} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002481 {"shelltype", "st", P_NUM|P_VI_DEF,
2482#ifdef AMIGA
2483 (char_u *)&p_st, PV_NONE,
2484#else
2485 (char_u *)NULL, PV_NONE,
2486#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002487 {(char_u *)0L, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002488 {"shellxquote", "sxq", P_STRING|P_VI_DEF|P_SECURE,
2489 (char_u *)&p_sxq, PV_NONE,
2490 {
Bram Moolenaara06ecab2016-07-16 14:47:36 +02002491#if defined(UNIX) && defined(USE_SYSTEM)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002492 (char_u *)"\"",
2493#else
2494 (char_u *)"",
2495#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002496 (char_u *)0L} SCTX_INIT},
Bram Moolenaarf66b3fc2012-02-20 22:18:30 +01002497 {"shellxescape", "sxe", P_STRING|P_VI_DEF|P_SECURE,
2498 (char_u *)&p_sxe, PV_NONE,
2499 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002500#if defined(WIN3264)
Bram Moolenaarf66b3fc2012-02-20 22:18:30 +01002501 (char_u *)"\"&|<>()@^",
2502#else
2503 (char_u *)"",
2504#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002505 (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002506 {"shiftround", "sr", P_BOOL|P_VI_DEF|P_VIM,
2507 (char_u *)&p_sr, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002508 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002509 {"shiftwidth", "sw", P_NUM|P_VI_DEF,
2510 (char_u *)&p_sw, PV_SW,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002511 {(char_u *)8L, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002512 {"shortmess", "shm", P_STRING|P_VIM|P_FLAGLIST,
2513 (char_u *)&p_shm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002514 {(char_u *)"", (char_u *)"filnxtToO"}
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002515 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002516 {"shortname", "sn", P_BOOL|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002517 (char_u *)&p_sn, PV_SN,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002518 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002519 {"showbreak", "sbr", P_STRING|P_VI_DEF|P_RALL,
2520#ifdef FEAT_LINEBREAK
2521 (char_u *)&p_sbr, PV_NONE,
2522#else
2523 (char_u *)NULL, PV_NONE,
2524#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002525 {(char_u *)"", (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002526 {"showcmd", "sc", P_BOOL|P_VIM,
2527#ifdef FEAT_CMDL_INFO
2528 (char_u *)&p_sc, PV_NONE,
2529#else
2530 (char_u *)NULL, PV_NONE,
2531#endif
2532 {(char_u *)FALSE,
2533#ifdef UNIX
2534 (char_u *)FALSE
2535#else
2536 (char_u *)TRUE
2537#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002538 } SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002539 {"showfulltag", "sft", P_BOOL|P_VI_DEF,
2540 (char_u *)&p_sft, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002541 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002542 {"showmatch", "sm", P_BOOL|P_VI_DEF,
2543 (char_u *)&p_sm, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002544 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002545 {"showmode", "smd", P_BOOL|P_VIM,
2546 (char_u *)&p_smd, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002547 {(char_u *)FALSE, (char_u *)TRUE} SCTX_INIT},
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00002548 {"showtabline", "stal", P_NUM|P_VI_DEF|P_RALL,
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00002549 (char_u *)&p_stal, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002550 {(char_u *)1L, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002551 {"sidescroll", "ss", P_NUM|P_VI_DEF,
2552 (char_u *)&p_ss, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002553 {(char_u *)0L, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002554 {"sidescrolloff", "siso", P_NUM|P_VI_DEF|P_VIM|P_RBUF,
2555 (char_u *)&p_siso, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002556 {(char_u *)0L, (char_u *)0L} SCTX_INIT},
Bram Moolenaar95ec9d62016-08-12 18:29:59 +02002557 {"signcolumn", "scl", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN,
2558#ifdef FEAT_SIGNS
2559 (char_u *)VAR_WIN, PV_SCL,
Bram Moolenaarb3384832016-08-12 18:51:58 +02002560 {(char_u *)"auto", (char_u *)0L}
Bram Moolenaar95ec9d62016-08-12 18:29:59 +02002561#else
2562 (char_u *)NULL, PV_NONE,
2563 {(char_u *)NULL, (char_u *)0L}
2564#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002565 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002566 {"slowopen", "slow", P_BOOL|P_VI_DEF,
2567 (char_u *)NULL, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002568 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002569 {"smartcase", "scs", P_BOOL|P_VI_DEF|P_VIM,
2570 (char_u *)&p_scs, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002571 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002572 {"smartindent", "si", P_BOOL|P_VI_DEF|P_VIM,
2573#ifdef FEAT_SMARTINDENT
2574 (char_u *)&p_si, PV_SI,
2575#else
2576 (char_u *)NULL, PV_NONE,
2577#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002578 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002579 {"smarttab", "sta", P_BOOL|P_VI_DEF|P_VIM,
2580 (char_u *)&p_sta, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002581 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002582 {"softtabstop", "sts", P_NUM|P_VI_DEF|P_VIM,
2583 (char_u *)&p_sts, PV_STS,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002584 {(char_u *)0L, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002585 {"sourceany", NULL, P_BOOL|P_VI_DEF,
2586 (char_u *)NULL, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002587 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar217ad922005-03-20 22:37:15 +00002588 {"spell", NULL, P_BOOL|P_VI_DEF|P_RWIN,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002589#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +00002590 (char_u *)VAR_WIN, PV_SPELL,
2591#else
2592 (char_u *)NULL, PV_NONE,
2593#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002594 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar488c6512005-08-11 20:09:58 +00002595 {"spellcapcheck", "spc", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002596#ifdef FEAT_SPELL
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00002597 (char_u *)&p_spc, PV_SPC,
Bram Moolenaar0dc065e2005-07-04 22:49:24 +00002598 {(char_u *)"[.?!]\\_[\\])'\" ]\\+", (char_u *)0L}
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00002599#else
2600 (char_u *)NULL, PV_NONE,
2601 {(char_u *)0L, (char_u *)0L}
2602#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002603 SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002604 {"spellfile", "spf", P_STRING|P_EXPAND|P_ALLOCED|P_VI_DEF|P_SECURE
2605 |P_ONECOMMA,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002606#ifdef FEAT_SPELL
Bram Moolenaar82cf9b62005-06-07 21:09:25 +00002607 (char_u *)&p_spf, PV_SPF,
2608 {(char_u *)"", (char_u *)0L}
2609#else
2610 (char_u *)NULL, PV_NONE,
2611 {(char_u *)0L, (char_u *)0L}
2612#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002613 SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002614 {"spelllang", "spl", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA
2615 |P_RBUF|P_EXPAND,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002616#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +00002617 (char_u *)&p_spl, PV_SPL,
Bram Moolenaar82cf9b62005-06-07 21:09:25 +00002618 {(char_u *)"en", (char_u *)0L}
Bram Moolenaar217ad922005-03-20 22:37:15 +00002619#else
2620 (char_u *)NULL, PV_NONE,
2621 {(char_u *)0L, (char_u *)0L}
2622#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002623 SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002624 {"spellsuggest", "sps", P_STRING|P_VI_DEF|P_EXPAND|P_SECURE|P_ONECOMMA,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002625#ifdef FEAT_SPELL
Bram Moolenaard857f0e2005-06-21 22:37:39 +00002626 (char_u *)&p_sps, PV_NONE,
2627 {(char_u *)"best", (char_u *)0L}
2628#else
2629 (char_u *)NULL, PV_NONE,
2630 {(char_u *)0L, (char_u *)0L}
2631#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002632 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002633 {"splitbelow", "sb", P_BOOL|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002634 (char_u *)&p_sb, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002635 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002636 {"splitright", "spr", P_BOOL|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002637 (char_u *)&p_spr, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002638 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002639 {"startofline", "sol", P_BOOL|P_VI_DEF|P_VIM,
2640 (char_u *)&p_sol, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002641 {(char_u *)TRUE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002642 {"statusline" ,"stl", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT,
2643#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002644 (char_u *)&p_stl, PV_STL,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002645#else
2646 (char_u *)NULL, PV_NONE,
2647#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002648 {(char_u *)"", (char_u *)0L} SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002649 {"suffixes", "su", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002650 (char_u *)&p_su, PV_NONE,
2651 {(char_u *)".bak,~,.o,.h,.info,.swp,.obj",
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002652 (char_u *)0L} SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002653 {"suffixesadd", "sua", P_STRING|P_VI_DEF|P_ALLOCED|P_ONECOMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002654#ifdef FEAT_SEARCHPATH
Bram Moolenaar071d4272004-06-13 20:20:40 +00002655 (char_u *)&p_sua, PV_SUA,
2656 {(char_u *)"", (char_u *)0L}
2657#else
2658 (char_u *)NULL, PV_NONE,
2659 {(char_u *)0L, (char_u *)0L}
2660#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002661 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002662 {"swapfile", "swf", P_BOOL|P_VI_DEF|P_RSTAT,
2663 (char_u *)&p_swf, PV_SWF,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002664 {(char_u *)TRUE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002665 {"swapsync", "sws", P_STRING|P_VI_DEF,
2666 (char_u *)&p_sws, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002667 {(char_u *)"fsync", (char_u *)0L} SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002668 {"switchbuf", "swb", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002669 (char_u *)&p_swb, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002670 {(char_u *)"", (char_u *)0L} SCTX_INIT},
Bram Moolenaar3b56eb32005-07-11 22:40:32 +00002671 {"synmaxcol", "smc", P_NUM|P_VI_DEF|P_RBUF,
2672#ifdef FEAT_SYN_HL
2673 (char_u *)&p_smc, PV_SMC,
2674 {(char_u *)3000L, (char_u *)0L}
2675#else
2676 (char_u *)NULL, PV_NONE,
2677 {(char_u *)0L, (char_u *)0L}
2678#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002679 SCTX_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002680 {"syntax", "syn", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002681#ifdef FEAT_SYN_HL
2682 (char_u *)&p_syn, PV_SYN,
2683 {(char_u *)"", (char_u *)0L}
2684#else
2685 (char_u *)NULL, PV_NONE,
2686 {(char_u *)0L, (char_u *)0L}
2687#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002688 SCTX_INIT},
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00002689 {"tabline", "tal", P_STRING|P_VI_DEF|P_RALL,
2690#ifdef FEAT_STL_OPT
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00002691 (char_u *)&p_tal, PV_NONE,
2692#else
2693 (char_u *)NULL, PV_NONE,
2694#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002695 {(char_u *)"", (char_u *)0L} SCTX_INIT},
Bram Moolenaarfd2ac762006-03-01 22:09:21 +00002696 {"tabpagemax", "tpm", P_NUM|P_VI_DEF,
Bram Moolenaarfd2ac762006-03-01 22:09:21 +00002697 (char_u *)&p_tpm, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002698 {(char_u *)10L, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002699 {"tabstop", "ts", P_NUM|P_VI_DEF|P_RBUF,
2700 (char_u *)&p_ts, PV_TS,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002701 {(char_u *)8L, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002702 {"tagbsearch", "tbs", P_BOOL|P_VI_DEF,
2703 (char_u *)&p_tbs, PV_NONE,
2704#ifdef VMS /* binary searching doesn't appear to work on VMS */
2705 {(char_u *)0L, (char_u *)0L}
2706#else
2707 {(char_u *)TRUE, (char_u *)0L}
2708#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002709 SCTX_INIT},
Bram Moolenaar0f6562e2015-11-24 18:48:14 +01002710 {"tagcase", "tc", P_STRING|P_VIM,
2711 (char_u *)&p_tc, PV_TC,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002712 {(char_u *)"followic", (char_u *)"followic"} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002713 {"taglength", "tl", P_NUM|P_VI_DEF,
2714 (char_u *)&p_tl, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002715 {(char_u *)0L, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002716 {"tagrelative", "tr", P_BOOL|P_VIM,
2717 (char_u *)&p_tr, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002718 {(char_u *)FALSE, (char_u *)TRUE} SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002719 {"tags", "tag", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002720 (char_u *)&p_tags, PV_TAGS,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002721 {
2722#if defined(FEAT_EMACS_TAGS) && !defined(CASE_INSENSITIVE_FILENAME)
2723 (char_u *)"./tags,./TAGS,tags,TAGS",
2724#else
2725 (char_u *)"./tags,tags",
2726#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002727 (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002728 {"tagstack", "tgst", P_BOOL|P_VI_DEF,
2729 (char_u *)&p_tgst, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002730 {(char_u *)TRUE, (char_u *)0L} SCTX_INIT},
Bram Moolenaara6e42502016-04-20 16:19:52 +02002731 {"tcldll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002732#if defined(DYNAMIC_TCL)
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01002733 (char_u *)&p_tcldll, PV_NONE,
2734 {(char_u *)DYNAMIC_TCL_DLL, (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01002735#else
2736 (char_u *)NULL, PV_NONE,
2737 {(char_u *)0L, (char_u *)0L}
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01002738#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002739 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002740 {"term", NULL, P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL,
2741 (char_u *)&T_NAME, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002742 {(char_u *)"", (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002743 {"termbidi", "tbidi", P_BOOL|P_VI_DEF,
2744#ifdef FEAT_ARABIC
2745 (char_u *)&p_tbidi, PV_NONE,
2746#else
2747 (char_u *)NULL, PV_NONE,
2748#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002749 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002750 {"termencoding", "tenc", P_STRING|P_VI_DEF|P_RCLR,
2751#ifdef FEAT_MBYTE
2752 (char_u *)&p_tenc, PV_NONE,
2753 {(char_u *)"", (char_u *)0L}
2754#else
2755 (char_u *)NULL, PV_NONE,
2756 {(char_u *)0L, (char_u *)0L}
2757#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002758 SCTX_INIT},
Bram Moolenaar61be73b2016-04-29 22:59:22 +02002759 {"termguicolors", "tgc", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
2760#ifdef FEAT_TERMGUICOLORS
2761 (char_u *)&p_tgc, PV_NONE,
2762 {(char_u *)FALSE, (char_u *)FALSE}
2763#else
2764 (char_u*)NULL, PV_NONE,
2765 {(char_u *)FALSE, (char_u *)FALSE}
2766#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002767 SCTX_INIT},
Bram Moolenaar6d150f72018-04-21 20:03:20 +02002768 {"termwinkey", "twk", P_STRING|P_ALLOCED|P_RWIN|P_VI_DEF,
2769#ifdef FEAT_TERMINAL
2770 (char_u *)VAR_WIN, PV_TWK,
2771 {(char_u *)"", (char_u *)NULL}
2772#else
2773 (char_u *)NULL, PV_NONE,
2774 {(char_u *)NULL, (char_u *)0L}
2775#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002776 SCTX_INIT},
Bram Moolenaar6d150f72018-04-21 20:03:20 +02002777 {"termwinscroll", "twsl", P_NUM|P_VI_DEF|P_VIM|P_RBUF,
2778#ifdef FEAT_TERMINAL
2779 (char_u *)&p_twsl, PV_TWSL,
2780 {(char_u *)10000L, (char_u *)10000L}
2781#else
2782 (char_u *)NULL, PV_NONE,
2783 {(char_u *)NULL, (char_u *)0L}
2784#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002785 SCTX_INIT},
Bram Moolenaar6d150f72018-04-21 20:03:20 +02002786 {"termwinsize", "tws", P_STRING|P_ALLOCED|P_RWIN|P_VI_DEF,
2787#ifdef FEAT_TERMINAL
2788 (char_u *)VAR_WIN, PV_TWS,
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002789 {(char_u *)"", (char_u *)NULL}
2790#else
2791 (char_u *)NULL, PV_NONE,
2792 {(char_u *)NULL, (char_u *)0L}
2793#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002794 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002795 {"terse", NULL, P_BOOL|P_VI_DEF,
2796 (char_u *)&p_terse, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002797 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002798 {"textauto", "ta", P_BOOL|P_VIM,
2799 (char_u *)&p_ta, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002800 {(char_u *)DFLT_TEXTAUTO, (char_u *)TRUE}
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002801 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002802 {"textmode", "tx", P_BOOL|P_VI_DEF|P_NO_MKRC,
2803 (char_u *)&p_tx, PV_TX,
2804 {
2805#ifdef USE_CRNL
2806 (char_u *)TRUE,
2807#else
2808 (char_u *)FALSE,
2809#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002810 (char_u *)0L} SCTX_INIT},
Bram Moolenaar1a384422010-07-14 19:53:30 +02002811 {"textwidth", "tw", P_NUM|P_VI_DEF|P_VIM|P_RBUF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002812 (char_u *)&p_tw, PV_TW,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002813 {(char_u *)0L, (char_u *)0L} SCTX_INIT},
Bram Moolenaarf422bcc2016-11-26 17:45:53 +01002814 {"thesaurus", "tsr", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP|P_NDNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002815#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002816 (char_u *)&p_tsr, PV_TSR,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002817#else
2818 (char_u *)NULL, PV_NONE,
2819#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002820 {(char_u *)"", (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002821 {"tildeop", "top", P_BOOL|P_VI_DEF|P_VIM,
2822 (char_u *)&p_to, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002823 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002824 {"timeout", "to", P_BOOL|P_VI_DEF,
2825 (char_u *)&p_timeout, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002826 {(char_u *)TRUE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002827 {"timeoutlen", "tm", P_NUM|P_VI_DEF,
2828 (char_u *)&p_tm, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002829 {(char_u *)1000L, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002830 {"title", NULL, P_BOOL|P_VI_DEF,
2831#ifdef FEAT_TITLE
2832 (char_u *)&p_title, PV_NONE,
2833#else
2834 (char_u *)NULL, PV_NONE,
2835#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002836 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002837 {"titlelen", NULL, P_NUM|P_VI_DEF,
2838#ifdef FEAT_TITLE
2839 (char_u *)&p_titlelen, PV_NONE,
2840#else
2841 (char_u *)NULL, PV_NONE,
2842#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002843 {(char_u *)85L, (char_u *)0L} SCTX_INIT},
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00002844 {"titleold", NULL, P_STRING|P_VI_DEF|P_GETTEXT|P_SECURE|P_NO_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002845#ifdef FEAT_TITLE
2846 (char_u *)&p_titleold, PV_NONE,
2847 {(char_u *)N_("Thanks for flying Vim"),
2848 (char_u *)0L}
2849#else
2850 (char_u *)NULL, PV_NONE,
2851 {(char_u *)0L, (char_u *)0L}
2852#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002853 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002854 {"titlestring", NULL, P_STRING|P_VI_DEF,
2855#ifdef FEAT_TITLE
2856 (char_u *)&p_titlestring, PV_NONE,
2857#else
2858 (char_u *)NULL, PV_NONE,
2859#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002860 {(char_u *)"", (char_u *)0L} SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002861 {"toolbar", "tb", P_STRING|P_ONECOMMA|P_VI_DEF|P_NODUP,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002862#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002863 (char_u *)&p_toolbar, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002864 {(char_u *)"icons,tooltips", (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01002865#else
2866 (char_u *)NULL, PV_NONE,
2867 {(char_u *)0L, (char_u *)0L}
2868#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002869 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002870 {"toolbariconsize", "tbis", P_STRING|P_VI_DEF,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002871#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002872 (char_u *)&p_tbis, PV_NONE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002873 {(char_u *)"small", (char_u *)0L}
2874#else
2875 (char_u *)NULL, PV_NONE,
2876 {(char_u *)0L, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002877#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002878 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002879 {"ttimeout", NULL, P_BOOL|P_VI_DEF|P_VIM,
2880 (char_u *)&p_ttimeout, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002881 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002882 {"ttimeoutlen", "ttm", P_NUM|P_VI_DEF,
2883 (char_u *)&p_ttm, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002884 {(char_u *)-1L, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002885 {"ttybuiltin", "tbi", P_BOOL|P_VI_DEF,
2886 (char_u *)&p_tbi, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002887 {(char_u *)TRUE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002888 {"ttyfast", "tf", P_BOOL|P_NO_MKRC|P_VI_DEF,
2889 (char_u *)&p_tf, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002890 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002891 {"ttymouse", "ttym", P_STRING|P_NODEFAULT|P_NO_MKRC|P_VI_DEF,
2892#if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
2893 (char_u *)&p_ttym, PV_NONE,
2894#else
2895 (char_u *)NULL, PV_NONE,
2896#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002897 {(char_u *)"", (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002898 {"ttyscroll", "tsl", P_NUM|P_VI_DEF,
2899 (char_u *)&p_ttyscroll, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002900 {(char_u *)999L, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002901 {"ttytype", "tty", P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL,
2902 (char_u *)&T_NAME, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002903 {(char_u *)"", (char_u *)0L} SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002904 {"undodir", "udir", P_STRING|P_EXPAND|P_ONECOMMA|P_NODUP|P_SECURE
2905 |P_VI_DEF,
Bram Moolenaar55debbe2010-05-23 23:34:36 +02002906#ifdef FEAT_PERSISTENT_UNDO
2907 (char_u *)&p_udir, PV_NONE,
2908 {(char_u *)".", (char_u *)0L}
2909#else
2910 (char_u *)NULL, PV_NONE,
2911 {(char_u *)0L, (char_u *)0L}
2912#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002913 SCTX_INIT},
Bram Moolenaar55debbe2010-05-23 23:34:36 +02002914 {"undofile", "udf", P_BOOL|P_VI_DEF|P_VIM,
2915#ifdef FEAT_PERSISTENT_UNDO
2916 (char_u *)&p_udf, PV_UDF,
2917#else
2918 (char_u *)NULL, PV_NONE,
2919#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002920 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002921 {"undolevels", "ul", P_NUM|P_VI_DEF,
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01002922 (char_u *)&p_ul, PV_UL,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002923 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01002924#if defined(UNIX) || defined(WIN3264) || defined(VMS)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002925 (char_u *)1000L,
2926#else
2927 (char_u *)100L,
2928#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002929 (char_u *)0L} SCTX_INIT},
Bram Moolenaar59f931e2010-07-24 20:27:03 +02002930 {"undoreload", "ur", P_NUM|P_VI_DEF,
2931 (char_u *)&p_ur, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002932 { (char_u *)10000L, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002933 {"updatecount", "uc", P_NUM|P_VI_DEF,
2934 (char_u *)&p_uc, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002935 {(char_u *)200L, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002936 {"updatetime", "ut", P_NUM|P_VI_DEF,
2937 (char_u *)&p_ut, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002938 {(char_u *)4000L, (char_u *)0L} SCTX_INIT},
Bram Moolenaar04958cb2018-06-23 19:23:02 +02002939 {"varsofttabstop", "vsts", P_STRING|P_VI_DEF|P_VIM|P_COMMA,
2940#ifdef FEAT_VARTABS
2941 (char_u *)&p_vsts, PV_VSTS,
2942 {(char_u *)"", (char_u *)0L}
2943#else
2944 (char_u *)NULL, PV_NONE,
2945 {(char_u *)"", (char_u *)NULL}
2946#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002947 SCTX_INIT},
Bram Moolenaar04958cb2018-06-23 19:23:02 +02002948 {"vartabstop", "vts", P_STRING|P_VI_DEF|P_VIM|P_RBUF|P_COMMA,
2949#ifdef FEAT_VARTABS
2950 (char_u *)&p_vts, PV_VTS,
2951 {(char_u *)"", (char_u *)0L}
2952#else
2953 (char_u *)NULL, PV_NONE,
2954 {(char_u *)"", (char_u *)NULL}
2955#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002956 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002957 {"verbose", "vbs", P_NUM|P_VI_DEF,
2958 (char_u *)&p_verbose, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002959 {(char_u *)0L, (char_u *)0L} SCTX_INIT},
Bram Moolenaar54ee7752005-05-31 22:22:17 +00002960 {"verbosefile", "vfile", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2961 (char_u *)&p_vfile, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002962 {(char_u *)"", (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002963 {"viewdir", "vdir", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2964#ifdef FEAT_SESSION
2965 (char_u *)&p_vdir, PV_NONE,
2966 {(char_u *)DFLT_VDIR, (char_u *)0L}
2967#else
2968 (char_u *)NULL, PV_NONE,
2969 {(char_u *)0L, (char_u *)0L}
2970#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002971 SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002972 {"viewoptions", "vop", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002973#ifdef FEAT_SESSION
2974 (char_u *)&p_vop, PV_NONE,
Bram Moolenaar13e90412017-11-11 18:16:48 +01002975 {(char_u *)"folds,options,cursor,curdir",
2976 (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002977#else
2978 (char_u *)NULL, PV_NONE,
2979 {(char_u *)0L, (char_u *)0L}
2980#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002981 SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002982 {"viminfo", "vi", P_STRING|P_ONECOMMA|P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002983#ifdef FEAT_VIMINFO
2984 (char_u *)&p_viminfo, PV_NONE,
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002985#if defined(MSWIN)
Bram Moolenaard812df62008-11-09 12:46:09 +00002986 {(char_u *)"", (char_u *)"'100,<50,s10,h,rA:,rB:"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002987#else
2988# ifdef AMIGA
2989 {(char_u *)"",
Bram Moolenaard812df62008-11-09 12:46:09 +00002990 (char_u *)"'100,<50,s10,h,rdf0:,rdf1:,rdf2:"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002991# else
Bram Moolenaard812df62008-11-09 12:46:09 +00002992 {(char_u *)"", (char_u *)"'100,<50,s10,h"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002993# endif
2994#endif
2995#else
2996 (char_u *)NULL, PV_NONE,
2997 {(char_u *)0L, (char_u *)0L}
2998#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02002999 SCTX_INIT},
Bram Moolenaarc229e542018-07-08 21:46:56 +02003000 {"viminfofile", "vif", P_STRING|P_EXPAND|P_ONECOMMA|P_NODUP
3001 |P_SECURE|P_VI_DEF,
Bram Moolenaarc4da1132017-07-15 19:39:43 +02003002#ifdef FEAT_VIMINFO
3003 (char_u *)&p_viminfofile, PV_NONE,
3004 {(char_u *)"", (char_u *)0L}
3005#else
3006 (char_u *)NULL, PV_NONE,
3007 {(char_u *)0L, (char_u *)0L}
3008#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02003009 SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02003010 {"virtualedit", "ve", P_STRING|P_ONECOMMA|P_NODUP|P_VI_DEF
3011 |P_VIM|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00003012#ifdef FEAT_VIRTUALEDIT
3013 (char_u *)&p_ve, PV_NONE,
3014 {(char_u *)"", (char_u *)""}
3015#else
3016 (char_u *)NULL, PV_NONE,
3017 {(char_u *)0L, (char_u *)0L}
3018#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02003019 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003020 {"visualbell", "vb", P_BOOL|P_VI_DEF,
3021 (char_u *)&p_vb, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02003022 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003023 {"w300", NULL, P_NUM|P_VI_DEF,
3024 (char_u *)NULL, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02003025 {(char_u *)0L, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003026 {"w1200", NULL, P_NUM|P_VI_DEF,
3027 (char_u *)NULL, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02003028 {(char_u *)0L, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003029 {"w9600", NULL, P_NUM|P_VI_DEF,
3030 (char_u *)NULL, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02003031 {(char_u *)0L, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003032 {"warn", NULL, P_BOOL|P_VI_DEF,
3033 (char_u *)&p_warn, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02003034 {(char_u *)TRUE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003035 {"weirdinvert", "wiv", P_BOOL|P_VI_DEF|P_RCLR,
3036 (char_u *)&p_wiv, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02003037 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02003038 {"whichwrap", "ww", P_STRING|P_VIM|P_ONECOMMA|P_FLAGLIST,
Bram Moolenaar071d4272004-06-13 20:20:40 +00003039 (char_u *)&p_ww, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02003040 {(char_u *)"", (char_u *)"b,s"} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003041 {"wildchar", "wc", P_NUM|P_VIM,
3042 (char_u *)&p_wc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003043 {(char_u *)(long)Ctrl_E, (char_u *)(long)TAB}
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02003044 SCTX_INIT},
Bram Moolenaar94950a92010-12-02 16:01:29 +01003045 {"wildcharm", "wcm", P_NUM|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00003046 (char_u *)&p_wcm, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02003047 {(char_u *)0L, (char_u *)0L} SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02003048 {"wildignore", "wig", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00003049#ifdef FEAT_WILDIGN
3050 (char_u *)&p_wig, PV_NONE,
3051#else
3052 (char_u *)NULL, PV_NONE,
3053#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02003054 {(char_u *)"", (char_u *)0L} SCTX_INIT},
Bram Moolenaar94950a92010-12-02 16:01:29 +01003055 {"wildignorecase", "wic", P_BOOL|P_VI_DEF,
3056 (char_u *)&p_wic, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02003057 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003058 {"wildmenu", "wmnu", P_BOOL|P_VI_DEF,
3059#ifdef FEAT_WILDMENU
3060 (char_u *)&p_wmnu, PV_NONE,
3061#else
3062 (char_u *)NULL, PV_NONE,
3063#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02003064 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02003065 {"wildmode", "wim", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00003066 (char_u *)&p_wim, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02003067 {(char_u *)"full", (char_u *)0L} SCTX_INIT},
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00003068 {"wildoptions", "wop", P_STRING|P_VI_DEF,
3069#ifdef FEAT_CMDL_COMPL
3070 (char_u *)&p_wop, PV_NONE,
3071 {(char_u *)"", (char_u *)0L}
3072#else
3073 (char_u *)NULL, PV_NONE,
3074 {(char_u *)NULL, (char_u *)0L}
3075#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02003076 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003077 {"winaltkeys", "wak", P_STRING|P_VI_DEF,
3078#ifdef FEAT_WAK
3079 (char_u *)&p_wak, PV_NONE,
3080 {(char_u *)"menu", (char_u *)0L}
3081#else
3082 (char_u *)NULL, PV_NONE,
3083 {(char_u *)NULL, (char_u *)0L}
3084#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02003085 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003086 {"window", "wi", P_NUM|P_VI_DEF,
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003087 (char_u *)&p_window, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02003088 {(char_u *)0L, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003089 {"winheight", "wh", P_NUM|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00003090 (char_u *)&p_wh, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02003091 {(char_u *)1L, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003092 {"winfixheight", "wfh", P_BOOL|P_VI_DEF|P_RSTAT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00003093 (char_u *)VAR_WIN, PV_WFH,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02003094 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00003095 {"winfixwidth", "wfw", P_BOOL|P_VI_DEF|P_RSTAT,
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00003096 (char_u *)VAR_WIN, PV_WFW,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02003097 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003098 {"winminheight", "wmh", P_NUM|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00003099 (char_u *)&p_wmh, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02003100 {(char_u *)1L, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003101 {"winminwidth", "wmw", P_NUM|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00003102 (char_u *)&p_wmw, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02003103 {(char_u *)1L, (char_u *)0L} SCTX_INIT},
Bram Moolenaar9e13aa72017-08-16 23:14:08 +02003104 {"winptydll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar84ed4ad2017-08-17 11:33:42 +02003105#if defined(WIN3264) && defined(FEAT_TERMINAL)
Bram Moolenaar9e13aa72017-08-16 23:14:08 +02003106 (char_u *)&p_winptydll, PV_NONE, {
3107# ifdef _WIN64
3108 (char_u *)"winpty64.dll",
3109# else
3110 (char_u *)"winpty32.dll",
3111# endif
3112 (char_u *)0L}
3113#else
3114 (char_u *)NULL, PV_NONE,
3115 {(char_u *)0L, (char_u *)0L}
3116#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02003117 SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003118 {"winwidth", "wiw", P_NUM|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00003119 (char_u *)&p_wiw, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02003120 {(char_u *)20L, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003121 {"wrap", NULL, P_BOOL|P_VI_DEF|P_RWIN,
3122 (char_u *)VAR_WIN, PV_WRAP,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02003123 {(char_u *)TRUE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003124 {"wrapmargin", "wm", P_NUM|P_VI_DEF,
3125 (char_u *)&p_wm, PV_WM,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02003126 {(char_u *)0L, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003127 {"wrapscan", "ws", P_BOOL|P_VI_DEF,
3128 (char_u *)&p_ws, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02003129 {(char_u *)TRUE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003130 {"write", NULL, P_BOOL|P_VI_DEF,
3131 (char_u *)&p_write, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02003132 {(char_u *)TRUE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003133 {"writeany", "wa", P_BOOL|P_VI_DEF,
3134 (char_u *)&p_wa, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02003135 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003136 {"writebackup", "wb", P_BOOL|P_VI_DEF|P_VIM,
3137 (char_u *)&p_wb, PV_NONE,
3138 {
3139#ifdef FEAT_WRITEBACKUP
3140 (char_u *)TRUE,
3141#else
3142 (char_u *)FALSE,
3143#endif
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02003144 (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003145 {"writedelay", "wd", P_NUM|P_VI_DEF,
3146 (char_u *)&p_wd, PV_NONE,
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02003147 {(char_u *)0L, (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003148
3149/* terminal output codes */
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00003150#define p_term(sss, vvv) {sss, NULL, P_STRING|P_VI_DEF|P_RALL|P_SECURE, \
Bram Moolenaar071d4272004-06-13 20:20:40 +00003151 (char_u *)&vvv, PV_NONE, \
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02003152 {(char_u *)"", (char_u *)0L} SCTX_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003153
3154 p_term("t_AB", T_CAB)
3155 p_term("t_AF", T_CAF)
3156 p_term("t_AL", T_CAL)
3157 p_term("t_al", T_AL)
3158 p_term("t_bc", T_BC)
Bram Moolenaarce1c3272017-08-20 15:05:15 +02003159 p_term("t_BE", T_BE)
3160 p_term("t_BD", T_BD)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003161 p_term("t_cd", T_CD)
3162 p_term("t_ce", T_CE)
3163 p_term("t_cl", T_CL)
3164 p_term("t_cm", T_CM)
Bram Moolenaar450ca432015-11-10 13:30:39 +01003165 p_term("t_Ce", T_UCE)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003166 p_term("t_Co", T_CCO)
3167 p_term("t_CS", T_CCS)
Bram Moolenaar450ca432015-11-10 13:30:39 +01003168 p_term("t_Cs", T_UCS)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003169 p_term("t_cs", T_CS)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003170 p_term("t_CV", T_CSV)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003171 p_term("t_da", T_DA)
3172 p_term("t_db", T_DB)
3173 p_term("t_DL", T_CDL)
3174 p_term("t_dl", T_DL)
Bram Moolenaarce1c3272017-08-20 15:05:15 +02003175 p_term("t_EC", T_CEC)
Bram Moolenaare5401222015-06-25 19:16:56 +02003176 p_term("t_EI", T_CEI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003177 p_term("t_fs", T_FS)
Bram Moolenaarce1c3272017-08-20 15:05:15 +02003178 p_term("t_GP", T_CGP)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003179 p_term("t_IE", T_CIE)
3180 p_term("t_IS", T_CIS)
3181 p_term("t_ke", T_KE)
3182 p_term("t_ks", T_KS)
3183 p_term("t_le", T_LE)
3184 p_term("t_mb", T_MB)
3185 p_term("t_md", T_MD)
3186 p_term("t_me", T_ME)
3187 p_term("t_mr", T_MR)
3188 p_term("t_ms", T_MS)
3189 p_term("t_nd", T_ND)
3190 p_term("t_op", T_OP)
Bram Moolenaara20f83d2017-10-15 13:35:01 +02003191 p_term("t_RF", T_RFG)
Bram Moolenaare5401222015-06-25 19:16:56 +02003192 p_term("t_RB", T_RBG)
Bram Moolenaar4db25542017-08-28 22:43:05 +02003193 p_term("t_RC", T_CRC)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003194 p_term("t_RI", T_CRI)
Bram Moolenaar40385db2018-08-07 22:31:44 +02003195 p_term("t_Ri", T_SRI)
Bram Moolenaarce1c3272017-08-20 15:05:15 +02003196 p_term("t_RS", T_CRS)
Bram Moolenaar40385db2018-08-07 22:31:44 +02003197 p_term("t_RT", T_CRT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003198 p_term("t_RV", T_CRV)
3199 p_term("t_Sb", T_CSB)
Bram Moolenaarce1c3272017-08-20 15:05:15 +02003200 p_term("t_SC", T_CSC)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003201 p_term("t_se", T_SE)
Bram Moolenaare5401222015-06-25 19:16:56 +02003202 p_term("t_Sf", T_CSF)
Bram Moolenaarce1c3272017-08-20 15:05:15 +02003203 p_term("t_SH", T_CSH)
Bram Moolenaare5401222015-06-25 19:16:56 +02003204 p_term("t_SI", T_CSI)
Bram Moolenaar40385db2018-08-07 22:31:44 +02003205 p_term("t_Si", T_SSI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003206 p_term("t_so", T_SO)
Bram Moolenaare5401222015-06-25 19:16:56 +02003207 p_term("t_SR", T_CSR)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003208 p_term("t_sr", T_SR)
Bram Moolenaar40385db2018-08-07 22:31:44 +02003209 p_term("t_ST", T_CST)
Bram Moolenaarcf4b00c2017-09-02 18:33:56 +02003210 p_term("t_Te", T_STE)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003211 p_term("t_te", T_TE)
3212 p_term("t_ti", T_TI)
Bram Moolenaarcf4b00c2017-09-02 18:33:56 +02003213 p_term("t_Ts", T_STS)
Bram Moolenaare5401222015-06-25 19:16:56 +02003214 p_term("t_ts", T_TS)
3215 p_term("t_u7", T_U7)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003216 p_term("t_ue", T_UE)
3217 p_term("t_us", T_US)
Bram Moolenaare5401222015-06-25 19:16:56 +02003218 p_term("t_ut", T_UT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003219 p_term("t_vb", T_VB)
3220 p_term("t_ve", T_VE)
3221 p_term("t_vi", T_VI)
Bram Moolenaarce1c3272017-08-20 15:05:15 +02003222 p_term("t_VS", T_CVS)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003223 p_term("t_vs", T_VS)
3224 p_term("t_WP", T_CWP)
3225 p_term("t_WS", T_CWS)
Bram Moolenaar494838a2015-02-10 19:20:37 +01003226 p_term("t_xn", T_XN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003227 p_term("t_xs", T_XS)
3228 p_term("t_ZH", T_CZH)
3229 p_term("t_ZR", T_CZR)
Bram Moolenaar8a633e32016-04-21 21:10:14 +02003230 p_term("t_8f", T_8F)
3231 p_term("t_8b", T_8B)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003232
3233/* terminal key codes are not in here */
3234
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003235 /* end marker */
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02003236 {NULL, NULL, 0, NULL, PV_NONE, {NULL, NULL} SCTX_INIT}
Bram Moolenaar071d4272004-06-13 20:20:40 +00003237};
3238
3239#define PARAM_COUNT (sizeof(options) / sizeof(struct vimoption))
3240
3241#ifdef FEAT_MBYTE
3242static char *(p_ambw_values[]) = {"single", "double", NULL};
3243#endif
3244static char *(p_bg_values[]) = {"light", "dark", NULL};
Bram Moolenaar887c1fe2016-01-02 17:56:35 +01003245static char *(p_nf_values[]) = {"bin", "octal", "hex", "alpha", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003246static char *(p_ff_values[]) = {FF_UNIX, FF_DOS, FF_MAC, NULL};
Bram Moolenaar49771f42010-07-20 17:32:38 +02003247#ifdef FEAT_CRYPT
Bram Moolenaar8f4ac012014-08-10 13:38:34 +02003248static char *(p_cm_values[]) = {"zip", "blowfish", "blowfish2", NULL};
Bram Moolenaar49771f42010-07-20 17:32:38 +02003249#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00003250#ifdef FEAT_CMDL_COMPL
3251static char *(p_wop_values[]) = {"tagfile", NULL};
3252#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003253#ifdef FEAT_WAK
3254static char *(p_wak_values[]) = {"yes", "menu", "no", NULL};
3255#endif
3256static char *(p_mousem_values[]) = {"extend", "popup", "popup_setpos", "mac", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003257static char *(p_sel_values[]) = {"inclusive", "exclusive", "old", NULL};
3258static char *(p_slm_values[]) = {"mouse", "key", "cmd", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003259static char *(p_km_values[]) = {"startsel", "stopsel", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003260#ifdef FEAT_BROWSE
3261static char *(p_bsdir_values[]) = {"current", "last", "buffer", NULL};
3262#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003263static char *(p_scbopt_values[]) = {"ver", "hor", "jump", NULL};
Bram Moolenaar57657d82006-04-21 22:12:41 +00003264static char *(p_debug_values[]) = {"msg", "throw", "beep", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003265static char *(p_ead_values[]) = {"both", "ver", "hor", NULL};
Bram Moolenaarf2732452018-06-03 14:47:35 +02003266static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", "terminal", "acwrite", "prompt", NULL};
Bram Moolenaar1f2903c2017-07-23 19:51:01 +02003267static char *(p_bufhidden_values[]) = {"hide", "unload", "delete", "wipe", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003268static char *(p_bs_values[]) = {"indent", "eol", "start", NULL};
3269#ifdef FEAT_FOLDING
3270static char *(p_fdm_values[]) = {"manual", "expr", "marker", "indent", "syntax",
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003271# ifdef FEAT_DIFF
Bram Moolenaar071d4272004-06-13 20:20:40 +00003272 "diff",
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003273# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003274 NULL};
3275static char *(p_fcl_values[]) = {"all", NULL};
3276#endif
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003277#ifdef FEAT_INS_EXPAND
Bram Moolenaarb6be1e22015-07-10 18:18:40 +02003278static char *(p_cot_values[]) = {"menu", "menuone", "longest", "preview", "noinsert", "noselect", NULL};
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003279#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +02003280#ifdef FEAT_SIGNS
3281static char *(p_scl_values[]) = {"yes", "no", "auto", NULL};
3282#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003283
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003284static void set_options_default(int opt_flags);
Bram Moolenaar4bfa8af2018-02-03 15:14:46 +01003285static void set_string_default_esc(char *name, char_u *val, int escape);
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003286static char_u *term_bg_default(void);
3287static void did_set_option(int opt_idx, int opt_flags, int new_value);
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003288static char_u *option_expand(int opt_idx, char_u *val);
3289static void didset_options(void);
3290static void didset_options2(void);
3291static void check_string_option(char_u **pp);
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003292#if defined(FEAT_EVAL) || defined(PROTO)
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003293static long_u *insecure_flag(int opt_idx, int opt_flags);
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003294#else
3295# define insecure_flag(opt_idx, opt_flags) (&options[opt_idx].flags)
3296#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003297static void set_string_option_global(int opt_idx, char_u **varp);
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003298static char_u *did_set_string_option(int opt_idx, char_u **varp, int new_value_alloced, char_u *oldval, char_u *errbuf, int opt_flags);
3299static char_u *set_chars_option(char_u **varp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003300#ifdef FEAT_CLIPBOARD
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003301static char_u *check_clipboard_option(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003302#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00003303#ifdef FEAT_SPELL
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003304static char_u *did_set_spell_option(int is_spellfile);
3305static char_u *compile_cap_prog(synblock_T *synblock);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00003306#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003307#ifdef FEAT_EVAL
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02003308static void set_option_sctx_idx(int opt_idx, int opt_flags, sctx_T script_ctx);
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003309#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003310static char_u *set_bool_option(int opt_idx, char_u *varp, int value, int opt_flags);
3311static char_u *set_num_option(int opt_idx, char_u *varp, long value, char_u *errbuf, size_t errbuflen, int opt_flags);
3312static void check_redraw(long_u flags);
3313static int findoption(char_u *);
Bram Moolenaar9cf4b502018-07-23 04:12:03 +02003314static int find_key_option(char_u *arg_arg, int has_lt);
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003315static void showoptions(int all, int opt_flags);
3316static int optval_default(struct vimoption *, char_u *varp);
3317static void showoneopt(struct vimoption *, int opt_flags);
3318static int put_setstring(FILE *fd, char *cmd, char *name, char_u **valuep, int expand);
3319static int put_setnum(FILE *fd, char *cmd, char *name, long *valuep);
3320static int put_setbool(FILE *fd, char *cmd, char *name, int value);
3321static int istermoption(struct vimoption *);
3322static char_u *get_varp_scope(struct vimoption *p, int opt_flags);
3323static char_u *get_varp(struct vimoption *);
3324static void option_value2string(struct vimoption *, int opt_flags);
3325static void check_winopt(winopt_T *wop);
3326static int wc_use_keyname(char_u *varp, long *wcp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003327#ifdef FEAT_LANGMAP
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003328static void langmap_init(void);
3329static void langmap_set(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003330#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003331static void paste_option_changed(void);
3332static void compatible_set(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003333#ifdef FEAT_LINEBREAK
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003334static void fill_breakat_flags(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003335#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003336static int opt_strings_flags(char_u *val, char **values, unsigned *flagp, int list);
3337static int check_opt_strings(char_u *val, char **values, int);
3338static int check_opt_wim(void);
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02003339#ifdef FEAT_LINEBREAK
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003340static int briopt_check(win_T *wp);
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02003341#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003342
3343/*
3344 * Initialize the options, first part.
3345 *
3346 * Called only once from main(), just after creating the first buffer.
Bram Moolenaar07268702018-03-01 21:57:32 +01003347 * If "clean_arg" is TRUE Vim was started with --clean.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003348 */
3349 void
Bram Moolenaar07268702018-03-01 21:57:32 +01003350set_init_1(int clean_arg)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003351{
3352 char_u *p;
3353 int opt_idx;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00003354 long_u n;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003355
3356#ifdef FEAT_LANGMAP
3357 langmap_init();
3358#endif
3359
3360 /* Be Vi compatible by default */
3361 p_cp = TRUE;
3362
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003363 /* Use POSIX compatibility when $VIM_POSIX is set. */
3364 if (mch_getenv((char_u *)"VIM_POSIX") != NULL)
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003365 {
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003366 set_string_default("cpo", (char_u *)CPO_ALL);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003367 set_string_default("shm", (char_u *)"A");
3368 }
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003369
Bram Moolenaar071d4272004-06-13 20:20:40 +00003370 /*
3371 * Find default value for 'shell' option.
Bram Moolenaar7c626922005-02-07 22:01:03 +00003372 * Don't use it if it is empty.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003373 */
Bram Moolenaar7c626922005-02-07 22:01:03 +00003374 if (((p = mch_getenv((char_u *)"SHELL")) != NULL && *p != NUL)
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003375#if defined(MSWIN)
Bram Moolenaar7c626922005-02-07 22:01:03 +00003376 || ((p = mch_getenv((char_u *)"COMSPEC")) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003377# ifdef WIN3264
Bram Moolenaar6aa2cd42016-02-16 15:06:59 +01003378 || ((p = (char_u *)default_shell()) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003379# endif
3380#endif
Bram Moolenaar7c626922005-02-07 22:01:03 +00003381 )
Bram Moolenaar4bfa8af2018-02-03 15:14:46 +01003382 set_string_default_esc("sh", p, TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003383
3384#ifdef FEAT_WILDIGN
3385 /*
3386 * Set the default for 'backupskip' to include environment variables for
3387 * temp files.
3388 */
3389 {
3390# ifdef UNIX
3391 static char *(names[4]) = {"", "TMPDIR", "TEMP", "TMP"};
3392# else
3393 static char *(names[3]) = {"TMPDIR", "TEMP", "TMP"};
3394# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003395 int len;
3396 garray_T ga;
3397 int mustfree;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003398
3399 ga_init2(&ga, 1, 100);
3400 for (n = 0; n < (long)(sizeof(names) / sizeof(char *)); ++n)
3401 {
Bram Moolenaar05159a02005-02-26 23:04:13 +00003402 mustfree = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003403# ifdef UNIX
3404 if (*names[n] == NUL)
Bram Moolenaarb8e22a02018-04-12 21:37:34 +02003405# ifdef MACOS_X
3406 p = (char_u *)"/private/tmp";
3407# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00003408 p = (char_u *)"/tmp";
Bram Moolenaarb8e22a02018-04-12 21:37:34 +02003409# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003410 else
3411# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003412 p = vim_getenv((char_u *)names[n], &mustfree);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003413 if (p != NULL && *p != NUL)
3414 {
3415 /* First time count the NUL, otherwise count the ','. */
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00003416 len = (int)STRLEN(p) + 3;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003417 if (ga_grow(&ga, len) == OK)
3418 {
3419 if (ga.ga_len > 0)
3420 STRCAT(ga.ga_data, ",");
3421 STRCAT(ga.ga_data, p);
3422 add_pathsep(ga.ga_data);
3423 STRCAT(ga.ga_data, "*");
Bram Moolenaar071d4272004-06-13 20:20:40 +00003424 ga.ga_len += len;
3425 }
3426 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00003427 if (mustfree)
3428 vim_free(p);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003429 }
3430 if (ga.ga_data != NULL)
3431 {
3432 set_string_default("bsk", ga.ga_data);
3433 vim_free(ga.ga_data);
3434 }
3435 }
3436#endif
3437
3438 /*
3439 * 'maxmemtot' and 'maxmem' may have to be adjusted for available memory
3440 */
3441 opt_idx = findoption((char_u *)"maxmemtot");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003442 if (opt_idx >= 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003443 {
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003444#if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM)
3445 if (options[opt_idx].def_val[VI_DEFAULT] == (char_u *)0L)
3446#endif
3447 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00003448#ifdef HAVE_AVAIL_MEM
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003449 /* Use amount of memory available at this moment. */
Bram Moolenaar11b73d62012-06-29 15:51:30 +02003450 n = (mch_avail_mem(FALSE) >> 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003451#else
3452# ifdef HAVE_TOTAL_MEM
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003453 /* Use amount of memory available to Vim. */
Bram Moolenaar914572a2007-05-01 11:37:47 +00003454 n = (mch_total_mem(FALSE) >> 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003455# else
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003456 n = (0x7fffffff >> 11);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003457# endif
3458#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003459 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n;
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003460 opt_idx = findoption((char_u *)"maxmem");
3461 if (opt_idx >= 0)
3462 {
3463#if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM)
Bram Moolenaar35be4532015-12-11 22:38:36 +01003464 if ((long)(long_i)options[opt_idx].def_val[VI_DEFAULT] > (long)n
3465 || (long)(long_i)options[opt_idx].def_val[VI_DEFAULT] == 0L)
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003466#endif
3467 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n;
3468 }
3469 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003470 }
3471
Bram Moolenaar071d4272004-06-13 20:20:40 +00003472#ifdef FEAT_SEARCHPATH
3473 {
3474 char_u *cdpath;
3475 char_u *buf;
3476 int i;
3477 int j;
Bram Moolenaar05159a02005-02-26 23:04:13 +00003478 int mustfree = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003479
3480 /* Initialize the 'cdpath' option's default value. */
Bram Moolenaar05159a02005-02-26 23:04:13 +00003481 cdpath = vim_getenv((char_u *)"CDPATH", &mustfree);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003482 if (cdpath != NULL)
3483 {
3484 buf = alloc((unsigned)((STRLEN(cdpath) << 1) + 2));
3485 if (buf != NULL)
3486 {
3487 buf[0] = ','; /* start with ",", current dir first */
3488 j = 1;
3489 for (i = 0; cdpath[i] != NUL; ++i)
3490 {
3491 if (vim_ispathlistsep(cdpath[i]))
3492 buf[j++] = ',';
3493 else
3494 {
3495 if (cdpath[i] == ' ' || cdpath[i] == ',')
3496 buf[j++] = '\\';
3497 buf[j++] = cdpath[i];
3498 }
3499 }
3500 buf[j] = NUL;
3501 opt_idx = findoption((char_u *)"cdpath");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003502 if (opt_idx >= 0)
3503 {
3504 options[opt_idx].def_val[VI_DEFAULT] = buf;
3505 options[opt_idx].flags |= P_DEF_ALLOCED;
3506 }
Bram Moolenaara9d52e32010-07-31 16:44:19 +02003507 else
3508 vim_free(buf); /* cannot happen */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003509 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00003510 if (mustfree)
3511 vim_free(cdpath);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003512 }
3513 }
3514#endif
3515
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003516#if defined(FEAT_POSTSCRIPT) && (defined(MSWIN) || defined(VMS) || defined(EBCDIC) || defined(MAC) || defined(hpux))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003517 /* Set print encoding on platforms that don't default to latin1 */
3518 set_string_default("penc",
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003519# if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003520 (char_u *)"cp1252"
3521# else
3522# ifdef VMS
3523 (char_u *)"dec-mcs"
3524# else
3525# ifdef EBCDIC
3526 (char_u *)"ebcdic-uk"
3527# else
3528# ifdef MAC
3529 (char_u *)"mac-roman"
3530# else /* HPUX */
3531 (char_u *)"hp-roman8"
3532# endif
3533# endif
3534# endif
3535# endif
3536 );
3537#endif
3538
3539#ifdef FEAT_POSTSCRIPT
3540 /* 'printexpr' must be allocated to be able to evaluate it. */
3541 set_string_default("pexpr",
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003542# if defined(MSWIN)
Bram Moolenaared203462004-06-16 11:19:22 +00003543 (char_u *)"system('copy' . ' ' . v:fname_in . (&printdevice == '' ? ' LPT1:' : (' \"' . &printdevice . '\"'))) . delete(v:fname_in)"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003544# else
3545# ifdef VMS
3546 (char_u *)"system('print/delete' . (&printdevice == '' ? '' : ' /queue=' . &printdevice) . ' ' . v:fname_in)"
3547
3548# else
3549 (char_u *)"system('lpr' . (&printdevice == '' ? '' : ' -P' . &printdevice) . ' ' . v:fname_in) . delete(v:fname_in) + v:shell_error"
3550# endif
3551# endif
3552 );
3553#endif
3554
3555 /*
3556 * Set all the options (except the terminal options) to their default
3557 * value. Also set the global value for local options.
3558 */
3559 set_options_default(0);
3560
Bram Moolenaar07268702018-03-01 21:57:32 +01003561#ifdef CLEAN_RUNTIMEPATH
3562 if (clean_arg)
3563 {
3564 opt_idx = findoption((char_u *)"runtimepath");
3565 if (opt_idx >= 0)
3566 {
3567 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)CLEAN_RUNTIMEPATH;
3568 p_rtp = (char_u *)CLEAN_RUNTIMEPATH;
3569 }
3570 opt_idx = findoption((char_u *)"packpath");
3571 if (opt_idx >= 0)
3572 {
3573 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)CLEAN_RUNTIMEPATH;
3574 p_pp = (char_u *)CLEAN_RUNTIMEPATH;
3575 }
3576 }
3577#endif
3578
Bram Moolenaar071d4272004-06-13 20:20:40 +00003579#ifdef FEAT_GUI
3580 if (found_reverse_arg)
3581 set_option_value((char_u *)"bg", 0L, (char_u *)"dark", 0);
3582#endif
3583
3584 curbuf->b_p_initialized = TRUE;
3585 curbuf->b_p_ar = -1; /* no local 'autoread' value */
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01003586 curbuf->b_p_ul = NO_LOCAL_UNDOLEVEL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003587 check_buf_options(curbuf);
3588 check_win_options(curwin);
3589 check_options();
3590
3591 /* Must be before option_expand(), because that one needs vim_isIDc() */
3592 didset_options();
3593
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00003594#ifdef FEAT_SPELL
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003595 /* Use the current chartab for the generic chartab. This is not in
3596 * didset_options() because it only depends on 'encoding'. */
Bram Moolenaar6bb68362005-03-22 23:03:44 +00003597 init_spell_chartab();
3598#endif
3599
Bram Moolenaar071d4272004-06-13 20:20:40 +00003600 /*
3601 * Expand environment variables and things like "~" for the defaults.
3602 * If option_expand() returns non-NULL the variable is expanded. This can
3603 * only happen for non-indirect options.
3604 * Also set the default to the expanded value, so ":set" does not list
3605 * them.
3606 * Don't set the P_ALLOCED flag, because we don't want to free the
3607 * default.
3608 */
3609 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
3610 {
3611 if ((options[opt_idx].flags & P_GETTEXT)
3612 && options[opt_idx].var != NULL)
3613 p = (char_u *)_(*(char **)options[opt_idx].var);
3614 else
3615 p = option_expand(opt_idx, NULL);
3616 if (p != NULL && (p = vim_strsave(p)) != NULL)
3617 {
3618 *(char_u **)options[opt_idx].var = p;
3619 /* VIMEXP
3620 * Defaults for all expanded options are currently the same for Vi
3621 * and Vim. When this changes, add some code here! Also need to
3622 * split P_DEF_ALLOCED in two.
3623 */
3624 if (options[opt_idx].flags & P_DEF_ALLOCED)
3625 vim_free(options[opt_idx].def_val[VI_DEFAULT]);
3626 options[opt_idx].def_val[VI_DEFAULT] = p;
3627 options[opt_idx].flags |= P_DEF_ALLOCED;
3628 }
3629 }
3630
Bram Moolenaar071d4272004-06-13 20:20:40 +00003631 save_file_ff(curbuf); /* Buffer is unchanged */
3632
Bram Moolenaar071d4272004-06-13 20:20:40 +00003633#if defined(FEAT_ARABIC)
3634 /* Detect use of mlterm.
3635 * Mlterm is a terminal emulator akin to xterm that has some special
3636 * abilities (bidi namely).
3637 * NOTE: mlterm's author is being asked to 'set' a variable
3638 * instead of an environment variable due to inheritance.
3639 */
3640 if (mch_getenv((char_u *)"MLTERM") != NULL)
3641 set_option_value((char_u *)"tbidi", 1L, NULL, 0);
3642#endif
3643
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003644 didset_options2();
Bram Moolenaar071d4272004-06-13 20:20:40 +00003645
3646#ifdef FEAT_MBYTE
3647# if defined(WIN3264) && defined(FEAT_GETTEXT)
3648 /*
3649 * If $LANG isn't set, try to get a good value for it. This makes the
3650 * right language be used automatically. Don't do this for English.
3651 */
3652 if (mch_getenv((char_u *)"LANG") == NULL)
3653 {
3654 char buf[20];
3655
3656 /* Could use LOCALE_SISO639LANGNAME, but it's not in Win95.
3657 * LOCALE_SABBREVLANGNAME gives us three letters, like "enu", we use
3658 * only the first two. */
3659 n = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME,
3660 (LPTSTR)buf, 20);
3661 if (n >= 2 && STRNICMP(buf, "en", 2) != 0)
3662 {
3663 /* There are a few exceptions (probably more) */
3664 if (STRNICMP(buf, "cht", 3) == 0 || STRNICMP(buf, "zht", 3) == 0)
3665 STRCPY(buf, "zh_TW");
3666 else if (STRNICMP(buf, "chs", 3) == 0
3667 || STRNICMP(buf, "zhc", 3) == 0)
3668 STRCPY(buf, "zh_CN");
3669 else if (STRNICMP(buf, "jp", 2) == 0)
3670 STRCPY(buf, "ja");
3671 else
3672 buf[2] = NUL; /* truncate to two-letter code */
Bram Moolenaar6aa2cd42016-02-16 15:06:59 +01003673 vim_setenv((char_u *)"LANG", (char_u *)buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003674 }
3675 }
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003676# else
Bram Moolenaar9d47f172006-03-15 23:03:01 +00003677# ifdef MACOS_CONVERT
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00003678 /* Moved to os_mac_conv.c to avoid dependency problems. */
3679 mac_lang_init();
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003680# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003681# endif
3682
3683 /* enc_locale() will try to find the encoding of the current locale. */
3684 p = enc_locale();
3685 if (p != NULL)
3686 {
3687 char_u *save_enc;
3688
3689 /* Try setting 'encoding' and check if the value is valid.
3690 * If not, go back to the default "latin1". */
3691 save_enc = p_enc;
3692 p_enc = p;
Bram Moolenaar733f0a22007-03-02 18:56:27 +00003693 if (STRCMP(p_enc, "gb18030") == 0)
3694 {
3695 /* We don't support "gb18030", but "cp936" is a good substitute
3696 * for practical purposes, thus use that. It's not an alias to
3697 * still support conversion between gb18030 and utf-8. */
3698 p_enc = vim_strsave((char_u *)"cp936");
3699 vim_free(p);
3700 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003701 if (mb_init() == NULL)
3702 {
3703 opt_idx = findoption((char_u *)"encoding");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003704 if (opt_idx >= 0)
3705 {
3706 options[opt_idx].def_val[VI_DEFAULT] = p_enc;
3707 options[opt_idx].flags |= P_DEF_ALLOCED;
3708 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003709
Bram Moolenaard0573012017-10-28 21:11:06 +02003710#if defined(MSWIN) || defined(MACOS_X) || defined(VMS)
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003711 if (STRCMP(p_enc, "latin1") == 0
3712# ifdef FEAT_MBYTE
3713 || enc_utf8
3714# endif
3715 )
3716 {
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003717 /* Adjust the default for 'isprint' and 'iskeyword' to match
3718 * latin1. Also set the defaults for when 'nocompatible' is
3719 * set. */
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003720 set_string_option_direct((char_u *)"isp", -1,
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +00003721 ISP_LATIN1, OPT_FREE, SID_NONE);
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003722 set_string_option_direct((char_u *)"isk", -1,
3723 ISK_LATIN1, OPT_FREE, SID_NONE);
3724 opt_idx = findoption((char_u *)"isp");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003725 if (opt_idx >= 0)
3726 options[opt_idx].def_val[VIM_DEFAULT] = ISP_LATIN1;
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003727 opt_idx = findoption((char_u *)"isk");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003728 if (opt_idx >= 0)
3729 options[opt_idx].def_val[VIM_DEFAULT] = ISK_LATIN1;
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003730 (void)init_chartab();
3731 }
3732#endif
3733
Bram Moolenaar071d4272004-06-13 20:20:40 +00003734# if defined(WIN3264) && !defined(FEAT_GUI)
3735 /* Win32 console: When GetACP() returns a different value from
3736 * GetConsoleCP() set 'termencoding'. */
3737 if (GetACP() != GetConsoleCP())
3738 {
3739 char buf[50];
3740
3741 sprintf(buf, "cp%ld", (long)GetConsoleCP());
3742 p_tenc = vim_strsave((char_u *)buf);
3743 if (p_tenc != NULL)
3744 {
3745 opt_idx = findoption((char_u *)"termencoding");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003746 if (opt_idx >= 0)
3747 {
3748 options[opt_idx].def_val[VI_DEFAULT] = p_tenc;
3749 options[opt_idx].flags |= P_DEF_ALLOCED;
3750 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003751 convert_setup(&input_conv, p_tenc, p_enc);
3752 convert_setup(&output_conv, p_enc, p_tenc);
3753 }
3754 else
3755 p_tenc = empty_option;
3756 }
3757# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003758# if defined(WIN3264) && defined(FEAT_MBYTE)
3759 /* $HOME may have characters in active code page. */
3760 init_homedir();
3761# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003762 }
3763 else
3764 {
3765 vim_free(p_enc);
3766 p_enc = save_enc;
3767 }
3768 }
3769#endif
3770
3771#ifdef FEAT_MULTI_LANG
3772 /* Set the default for 'helplang'. */
3773 set_helplang_default(get_mess_lang());
3774#endif
3775}
3776
3777/*
3778 * Set an option to its default value.
3779 * This does not take care of side effects!
3780 */
3781 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003782set_option_default(
3783 int opt_idx,
3784 int opt_flags, /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
3785 int compatible) /* use Vi default value */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003786{
3787 char_u *varp; /* pointer to variable for current option */
3788 int dvi; /* index in def_val[] */
3789 long_u flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003790 long_u *flagsp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003791 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
3792
3793 varp = get_varp_scope(&(options[opt_idx]), both ? OPT_LOCAL : opt_flags);
3794 flags = options[opt_idx].flags;
Bram Moolenaar3638c682005-06-08 22:05:14 +00003795 if (varp != NULL) /* skip hidden option, nothing to do for it */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003796 {
3797 dvi = ((flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT;
3798 if (flags & P_STRING)
3799 {
Bram Moolenaarb833c1e2018-05-05 16:36:06 +02003800 /* Use set_string_option_direct() for local options to handle
3801 * freeing and allocating the value. */
3802 if (options[opt_idx].indir != PV_NONE)
3803 set_string_option_direct(NULL, opt_idx,
3804 options[opt_idx].def_val[dvi], opt_flags, 0);
3805 else
Bram Moolenaar071d4272004-06-13 20:20:40 +00003806 {
Bram Moolenaarb833c1e2018-05-05 16:36:06 +02003807 if ((opt_flags & OPT_FREE) && (flags & P_ALLOCED))
3808 free_string_option(*(char_u **)(varp));
3809 *(char_u **)varp = options[opt_idx].def_val[dvi];
3810 options[opt_idx].flags &= ~P_ALLOCED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003811 }
3812 }
3813 else if (flags & P_NUM)
3814 {
Bram Moolenaar5fc1a8b2006-10-17 16:34:24 +00003815 if (options[opt_idx].indir == PV_SCROLL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003816 win_comp_scroll(curwin);
3817 else
3818 {
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003819 *(long *)varp = (long)(long_i)options[opt_idx].def_val[dvi];
Bram Moolenaar071d4272004-06-13 20:20:40 +00003820 /* May also set global value for local option. */
3821 if (both)
3822 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) =
3823 *(long *)varp;
3824 }
3825 }
3826 else /* P_BOOL */
3827 {
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003828 /* the cast to long is required for Manx C, long_i is needed for
3829 * MSVC */
3830 *(int *)varp = (int)(long)(long_i)options[opt_idx].def_val[dvi];
Bram Moolenaar8243a792007-05-01 17:05:03 +00003831#ifdef UNIX
3832 /* 'modeline' defaults to off for root */
3833 if (options[opt_idx].indir == PV_ML && getuid() == ROOT_UID)
3834 *(int *)varp = FALSE;
3835#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003836 /* May also set global value for local option. */
3837 if (both)
3838 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) =
3839 *(int *)varp;
3840 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00003841
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003842 /* The default value is not insecure. */
3843 flagsp = insecure_flag(opt_idx, opt_flags);
3844 *flagsp = *flagsp & ~P_INSECURE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003845 }
3846
3847#ifdef FEAT_EVAL
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02003848 set_option_sctx_idx(opt_idx, opt_flags, current_sctx);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003849#endif
3850}
3851
3852/*
3853 * Set all options (except terminal options) to their default value.
Bram Moolenaarb341dda2015-08-25 12:56:31 +02003854 * When "opt_flags" is non-zero skip 'encoding'.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003855 */
3856 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003857set_options_default(
3858 int opt_flags) /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003859{
3860 int i;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003861 win_T *wp;
Bram Moolenaarf740b292006-02-16 22:11:02 +00003862 tabpage_T *tp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003863
3864 for (i = 0; !istermoption(&options[i]); i++)
Bram Moolenaarb341dda2015-08-25 12:56:31 +02003865 if (!(options[i].flags & P_NODEFAULT)
Bram Moolenaar5ea87a02015-08-26 23:24:09 +02003866#if defined(FEAT_MBYTE) || defined(FEAT_CRYPT)
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003867 && (opt_flags == 0
Bram Moolenaar5ea87a02015-08-26 23:24:09 +02003868 || (TRUE
3869# if defined(FEAT_MBYTE)
3870 && options[i].var != (char_u *)&p_enc
3871# endif
3872# if defined(FEAT_CRYPT)
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003873 && options[i].var != (char_u *)&p_cm
Bram Moolenaar80606872015-08-25 21:27:35 +02003874 && options[i].var != (char_u *)&p_key
Bram Moolenaar5ea87a02015-08-26 23:24:09 +02003875# endif
3876 ))
Bram Moolenaar80606872015-08-25 21:27:35 +02003877#endif
Bram Moolenaar5ea87a02015-08-26 23:24:09 +02003878 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00003879 set_option_default(i, opt_flags, p_cp);
3880
Bram Moolenaar071d4272004-06-13 20:20:40 +00003881 /* The 'scroll' option must be computed for all windows. */
Bram Moolenaarf740b292006-02-16 22:11:02 +00003882 FOR_ALL_TAB_WINDOWS(tp, wp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003883 win_comp_scroll(wp);
Bram Moolenaar5a4eceb2014-09-09 17:33:07 +02003884#ifdef FEAT_CINDENT
3885 parse_cino(curbuf);
3886#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003887}
3888
3889/*
3890 * Set the Vi-default value of a string option.
3891 * Used for 'sh', 'backupskip' and 'term'.
Bram Moolenaar4bfa8af2018-02-03 15:14:46 +01003892 * When "escape" is TRUE escape spaces with a backslash.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003893 */
Bram Moolenaar4bfa8af2018-02-03 15:14:46 +01003894 static void
3895set_string_default_esc(char *name, char_u *val, int escape)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003896{
3897 char_u *p;
3898 int opt_idx;
3899
Bram Moolenaar4bfa8af2018-02-03 15:14:46 +01003900 if (escape && vim_strchr(val, ' ') != NULL)
3901 p = vim_strsave_escaped(val, (char_u *)" ");
3902 else
3903 p = vim_strsave(val);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003904 if (p != NULL) /* we don't want a NULL */
3905 {
3906 opt_idx = findoption((char_u *)name);
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003907 if (opt_idx >= 0)
3908 {
3909 if (options[opt_idx].flags & P_DEF_ALLOCED)
3910 vim_free(options[opt_idx].def_val[VI_DEFAULT]);
3911 options[opt_idx].def_val[VI_DEFAULT] = p;
3912 options[opt_idx].flags |= P_DEF_ALLOCED;
3913 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003914 }
3915}
3916
Bram Moolenaar4bfa8af2018-02-03 15:14:46 +01003917 void
3918set_string_default(char *name, char_u *val)
3919{
3920 set_string_default_esc(name, val, FALSE);
3921}
3922
Bram Moolenaar071d4272004-06-13 20:20:40 +00003923/*
3924 * Set the Vi-default value of a number option.
3925 * Used for 'lines' and 'columns'.
3926 */
3927 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003928set_number_default(char *name, long val)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003929{
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003930 int opt_idx;
3931
3932 opt_idx = findoption((char_u *)name);
3933 if (opt_idx >= 0)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003934 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003935}
3936
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00003937#if defined(EXITFREE) || defined(PROTO)
3938/*
3939 * Free all options.
3940 */
3941 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003942free_all_options(void)
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00003943{
3944 int i;
3945
3946 for (i = 0; !istermoption(&options[i]); i++)
3947 {
3948 if (options[i].indir == PV_NONE)
3949 {
3950 /* global option: free value and default value. */
Bram Moolenaar67391142017-02-19 21:07:04 +01003951 if ((options[i].flags & P_ALLOCED) && options[i].var != NULL)
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00003952 free_string_option(*(char_u **)options[i].var);
3953 if (options[i].flags & P_DEF_ALLOCED)
3954 free_string_option(options[i].def_val[VI_DEFAULT]);
3955 }
3956 else if (options[i].var != VAR_WIN
3957 && (options[i].flags & P_STRING))
3958 /* buffer-local option: free global value */
3959 free_string_option(*(char_u **)options[i].var);
3960 }
3961}
3962#endif
3963
3964
Bram Moolenaar071d4272004-06-13 20:20:40 +00003965/*
3966 * Initialize the options, part two: After getting Rows and Columns and
3967 * setting 'term'.
3968 */
3969 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003970set_init_2(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003971{
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003972 int idx;
3973
Bram Moolenaar071d4272004-06-13 20:20:40 +00003974 /*
Bram Moolenaaraf2d20c2017-10-29 15:26:57 +01003975 * 'scroll' defaults to half the window height. The stored default is zero,
3976 * which results in the actual value computed from the window height.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003977 */
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003978 idx = findoption((char_u *)"scroll");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003979 if (idx >= 0 && !(options[idx].flags & P_WAS_SET))
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003980 set_option_default(idx, OPT_LOCAL, p_cp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003981 comp_col();
3982
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003983 /*
3984 * 'window' is only for backwards compatibility with Vi.
3985 * Default is Rows - 1.
3986 */
Bram Moolenaard68071d2006-05-02 22:08:30 +00003987 if (!option_was_set((char_u *)"window"))
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003988 p_window = Rows - 1;
3989 set_number_default("window", Rows - 1);
3990
Bram Moolenaarf740b292006-02-16 22:11:02 +00003991 /* For DOS console the default is always black. */
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003992#if !((defined(WIN3264)) && !defined(FEAT_GUI))
Bram Moolenaarf740b292006-02-16 22:11:02 +00003993 /*
3994 * If 'background' wasn't set by the user, try guessing the value,
3995 * depending on the terminal name. Only need to check for terminals
3996 * with a dark background, that can handle color.
3997 */
3998 idx = findoption((char_u *)"bg");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003999 if (idx >= 0 && !(options[idx].flags & P_WAS_SET)
4000 && *term_bg_default() == 'd')
Bram Moolenaar071d4272004-06-13 20:20:40 +00004001 {
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00004002 set_string_option_direct(NULL, idx, (char_u *)"dark", OPT_FREE, 0);
Bram Moolenaarf740b292006-02-16 22:11:02 +00004003 /* don't mark it as set, when starting the GUI it may be
4004 * changed again */
4005 options[idx].flags &= ~P_WAS_SET;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004006 }
4007#endif
Bram Moolenaar58d98232005-07-23 22:25:46 +00004008
4009#ifdef CURSOR_SHAPE
4010 parse_shape_opt(SHAPE_CURSOR); /* set cursor shapes from 'guicursor' */
4011#endif
4012#ifdef FEAT_MOUSESHAPE
4013 parse_shape_opt(SHAPE_MOUSE); /* set mouse shapes from 'mouseshape' */
4014#endif
4015#ifdef FEAT_PRINTER
4016 (void)parse_printoptions(); /* parse 'printoptions' default value */
4017#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004018}
4019
4020/*
Bram Moolenaarf740b292006-02-16 22:11:02 +00004021 * Return "dark" or "light" depending on the kind of terminal.
4022 * This is just guessing! Recognized are:
4023 * "linux" Linux console
4024 * "screen.linux" Linux console with screen
Bram Moolenaarc6da01a2017-09-07 22:37:36 +02004025 * "cygwin.*" Cygwin shell
4026 * "putty.*" Putty program
Bram Moolenaarf740b292006-02-16 22:11:02 +00004027 * We also check the COLORFGBG environment variable, which is set by
4028 * rxvt and derivatives. This variable contains either two or three
4029 * values separated by semicolons; we want the last value in either
4030 * case. If this value is 0-6 or 8, our background is dark.
4031 */
4032 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01004033term_bg_default(void)
Bram Moolenaarf740b292006-02-16 22:11:02 +00004034{
Bram Moolenaar48e330a2016-02-23 14:53:34 +01004035#if defined(WIN3264)
Bram Moolenaarc6da01a2017-09-07 22:37:36 +02004036 /* DOS console is nearly always black */
Bram Moolenaarf740b292006-02-16 22:11:02 +00004037 return (char_u *)"dark";
4038#else
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00004039 char_u *p;
4040
Bram Moolenaarf740b292006-02-16 22:11:02 +00004041 if (STRCMP(T_NAME, "linux") == 0
4042 || STRCMP(T_NAME, "screen.linux") == 0
Bram Moolenaarc6da01a2017-09-07 22:37:36 +02004043 || STRNCMP(T_NAME, "cygwin", 6) == 0
4044 || STRNCMP(T_NAME, "putty", 5) == 0
Bram Moolenaarf740b292006-02-16 22:11:02 +00004045 || ((p = mch_getenv((char_u *)"COLORFGBG")) != NULL
4046 && (p = vim_strrchr(p, ';')) != NULL
4047 && ((p[1] >= '0' && p[1] <= '6') || p[1] == '8')
4048 && p[2] == NUL))
4049 return (char_u *)"dark";
4050 return (char_u *)"light";
4051#endif
4052}
4053
4054/*
Bram Moolenaar071d4272004-06-13 20:20:40 +00004055 * Initialize the options, part three: After reading the .vimrc
4056 */
4057 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01004058set_init_3(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004059{
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004060#if defined(UNIX) || defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004061/*
4062 * Set 'shellpipe' and 'shellredir', depending on the 'shell' option.
4063 * This is done after other initializations, where 'shell' might have been
4064 * set, but only if they have not been set before.
4065 */
4066 char_u *p;
4067 int idx_srr;
4068 int do_srr;
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004069# ifdef FEAT_QUICKFIX
Bram Moolenaar071d4272004-06-13 20:20:40 +00004070 int idx_sp;
4071 int do_sp;
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004072# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004073
4074 idx_srr = findoption((char_u *)"srr");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004075 if (idx_srr < 0)
4076 do_srr = FALSE;
4077 else
4078 do_srr = !(options[idx_srr].flags & P_WAS_SET);
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004079# ifdef FEAT_QUICKFIX
Bram Moolenaar071d4272004-06-13 20:20:40 +00004080 idx_sp = findoption((char_u *)"sp");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004081 if (idx_sp < 0)
4082 do_sp = FALSE;
4083 else
4084 do_sp = !(options[idx_sp].flags & P_WAS_SET);
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004085# endif
Bram Moolenaar75a8d742014-05-07 15:10:21 +02004086 p = get_isolated_shell_name();
Bram Moolenaar071d4272004-06-13 20:20:40 +00004087 if (p != NULL)
4088 {
4089 /*
4090 * Default for p_sp is "| tee", for p_srr is ">".
4091 * For known shells it is changed here to include stderr.
4092 */
4093 if ( fnamecmp(p, "csh") == 0
4094 || fnamecmp(p, "tcsh") == 0
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004095# if defined(WIN3264) /* also check with .exe extension */
Bram Moolenaar071d4272004-06-13 20:20:40 +00004096 || fnamecmp(p, "csh.exe") == 0
4097 || fnamecmp(p, "tcsh.exe") == 0
4098# endif
4099 )
4100 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004101# if defined(FEAT_QUICKFIX)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004102 if (do_sp)
4103 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004104# ifdef WIN3264
Bram Moolenaar071d4272004-06-13 20:20:40 +00004105 p_sp = (char_u *)">&";
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004106# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00004107 p_sp = (char_u *)"|& tee";
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004108# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004109 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
4110 }
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004111# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004112 if (do_srr)
4113 {
4114 p_srr = (char_u *)">&";
4115 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
4116 }
4117 }
4118 else
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004119 /* Always use bourne shell style redirection if we reach this */
Bram Moolenaar071d4272004-06-13 20:20:40 +00004120 if ( fnamecmp(p, "sh") == 0
4121 || fnamecmp(p, "ksh") == 0
Bram Moolenaarf1fda2d2011-04-28 12:57:36 +02004122 || fnamecmp(p, "mksh") == 0
4123 || fnamecmp(p, "pdksh") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00004124 || fnamecmp(p, "zsh") == 0
Bram Moolenaarc1e37902006-04-18 21:55:01 +00004125 || fnamecmp(p, "zsh-beta") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00004126 || fnamecmp(p, "bash") == 0
Bram Moolenaar75a8d742014-05-07 15:10:21 +02004127 || fnamecmp(p, "fish") == 0
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004128# ifdef WIN3264
Bram Moolenaar071d4272004-06-13 20:20:40 +00004129 || fnamecmp(p, "cmd") == 0
4130 || fnamecmp(p, "sh.exe") == 0
4131 || fnamecmp(p, "ksh.exe") == 0
Bram Moolenaarf1fda2d2011-04-28 12:57:36 +02004132 || fnamecmp(p, "mksh.exe") == 0
4133 || fnamecmp(p, "pdksh.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00004134 || fnamecmp(p, "zsh.exe") == 0
Bram Moolenaarc1e37902006-04-18 21:55:01 +00004135 || fnamecmp(p, "zsh-beta.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00004136 || fnamecmp(p, "bash.exe") == 0
4137 || fnamecmp(p, "cmd.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00004138# endif
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004139 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00004140 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004141# if defined(FEAT_QUICKFIX)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004142 if (do_sp)
4143 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004144# ifdef WIN3264
Bram Moolenaar071d4272004-06-13 20:20:40 +00004145 p_sp = (char_u *)">%s 2>&1";
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004146# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00004147 p_sp = (char_u *)"2>&1| tee";
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004148# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004149 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
4150 }
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004151# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004152 if (do_srr)
4153 {
4154 p_srr = (char_u *)">%s 2>&1";
4155 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
4156 }
4157 }
4158 vim_free(p);
4159 }
4160#endif
4161
Bram Moolenaar48e330a2016-02-23 14:53:34 +01004162#if defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004163 /*
Bram Moolenaara64ba222012-02-12 23:23:31 +01004164 * Set 'shellcmdflag', 'shellxquote', and 'shellquote' depending on the
4165 * 'shell' option.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004166 * This is done after other initializations, where 'shell' might have been
4167 * set, but only if they have not been set before. Default for p_shcf is
4168 * "/c", for p_shq is "". For "sh" like shells it is changed here to
Bram Moolenaar48e330a2016-02-23 14:53:34 +01004169 * "-c" and "\"". And for Win32 we need to set p_sxq instead.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004170 */
Bram Moolenaarf4b8e572004-06-24 15:53:16 +00004171 if (strstr((char *)gettail(p_sh), "sh") != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004172 {
4173 int idx3;
4174
4175 idx3 = findoption((char_u *)"shcf");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004176 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004177 {
4178 p_shcf = (char_u *)"-c";
4179 options[idx3].def_val[VI_DEFAULT] = p_shcf;
4180 }
4181
Bram Moolenaar071d4272004-06-13 20:20:40 +00004182 /* Somehow Win32 requires the quotes around the redirection too */
4183 idx3 = findoption((char_u *)"sxq");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004184 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004185 {
4186 p_sxq = (char_u *)"\"";
4187 options[idx3].def_val[VI_DEFAULT] = p_sxq;
4188 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004189 }
Bram Moolenaara64ba222012-02-12 23:23:31 +01004190 else if (strstr((char *)gettail(p_sh), "cmd.exe") != NULL)
4191 {
4192 int idx3;
4193
4194 /*
4195 * cmd.exe on Windows will strip the first and last double quote given
4196 * on the command line, e.g. most of the time things like:
4197 * cmd /c "my path/to/echo" "my args to echo"
4198 * become:
4199 * my path/to/echo" "my args to echo
4200 * when executed.
4201 *
Bram Moolenaar034b1152012-02-19 18:19:30 +01004202 * To avoid this, set shellxquote to surround the command in
4203 * parenthesis. This appears to make most commands work, without
4204 * breaking commands that worked previously, such as
4205 * '"path with spaces/cmd" "a&b"'.
Bram Moolenaara64ba222012-02-12 23:23:31 +01004206 */
Bram Moolenaara64ba222012-02-12 23:23:31 +01004207 idx3 = findoption((char_u *)"sxq");
4208 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
4209 {
Bram Moolenaar034b1152012-02-19 18:19:30 +01004210 p_sxq = (char_u *)"(";
Bram Moolenaara64ba222012-02-12 23:23:31 +01004211 options[idx3].def_val[VI_DEFAULT] = p_sxq;
4212 }
4213
Bram Moolenaara64ba222012-02-12 23:23:31 +01004214 idx3 = findoption((char_u *)"shcf");
4215 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
4216 {
Bram Moolenaar034b1152012-02-19 18:19:30 +01004217 p_shcf = (char_u *)"/c";
Bram Moolenaara64ba222012-02-12 23:23:31 +01004218 options[idx3].def_val[VI_DEFAULT] = p_shcf;
4219 }
4220 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004221#endif
4222
Bram Moolenaarb5aedf32017-03-12 18:23:53 +01004223 if (BUFEMPTY())
Bram Moolenaar364fa5c2016-03-20 17:53:25 +01004224 {
4225 int idx_ffs = findoption((char_u *)"ffs");
4226
4227 /* Apply the first entry of 'fileformats' to the initial buffer. */
4228 if (idx_ffs >= 0 && (options[idx_ffs].flags & P_WAS_SET))
4229 set_fileformat(default_fileformat(), OPT_LOCAL);
4230 }
4231
Bram Moolenaar071d4272004-06-13 20:20:40 +00004232#ifdef FEAT_TITLE
4233 set_title_defaults();
4234#endif
4235}
4236
4237#if defined(FEAT_MULTI_LANG) || defined(PROTO)
4238/*
4239 * When 'helplang' is still at its default value, set it to "lang".
4240 * Only the first two characters of "lang" are used.
4241 */
4242 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01004243set_helplang_default(char_u *lang)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004244{
4245 int idx;
4246
4247 if (lang == NULL || STRLEN(lang) < 2) /* safety check */
4248 return;
4249 idx = findoption((char_u *)"hlg");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004250 if (idx >= 0 && !(options[idx].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004251 {
4252 if (options[idx].flags & P_ALLOCED)
4253 free_string_option(p_hlg);
4254 p_hlg = vim_strsave(lang);
4255 if (p_hlg == NULL)
4256 p_hlg = empty_option;
4257 else
Bram Moolenaarab79bcb2004-07-18 21:34:53 +00004258 {
Bram Moolenaardcd71cb2018-11-04 14:40:47 +01004259 // zh_CN becomes "cn", zh_TW becomes "tw"
Bram Moolenaarab79bcb2004-07-18 21:34:53 +00004260 if (STRNICMP(p_hlg, "zh_", 3) == 0 && STRLEN(p_hlg) >= 5)
4261 {
4262 p_hlg[0] = TOLOWER_ASC(p_hlg[3]);
4263 p_hlg[1] = TOLOWER_ASC(p_hlg[4]);
4264 }
Bram Moolenaardcd71cb2018-11-04 14:40:47 +01004265 // any C like setting, such as C.UTF-8, becomes "en"
4266 else if (STRLEN(p_hlg) >= 1 && *p_hlg == 'C')
4267 {
4268 p_hlg[0] = 'e';
4269 p_hlg[1] = 'n';
4270 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004271 p_hlg[2] = NUL;
Bram Moolenaarab79bcb2004-07-18 21:34:53 +00004272 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004273 options[idx].flags |= P_ALLOCED;
4274 }
4275}
4276#endif
4277
4278#ifdef FEAT_GUI
Bram Moolenaar071d4272004-06-13 20:20:40 +00004279 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01004280gui_bg_default(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004281{
4282 if (gui_get_lightness(gui.back_pixel) < 127)
4283 return (char_u *)"dark";
4284 return (char_u *)"light";
4285}
4286
4287/*
4288 * Option initializations that can only be done after opening the GUI window.
4289 */
4290 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01004291init_gui_options(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004292{
4293 /* Set the 'background' option according to the lightness of the
4294 * background color, unless the user has set it already. */
4295 if (!option_was_set((char_u *)"bg") && STRCMP(p_bg, gui_bg_default()) != 0)
4296 {
4297 set_option_value((char_u *)"bg", 0L, gui_bg_default(), 0);
4298 highlight_changed();
4299 }
4300}
4301#endif
4302
4303#ifdef FEAT_TITLE
4304/*
4305 * 'title' and 'icon' only default to true if they have not been set or reset
4306 * in .vimrc and we can read the old value.
4307 * When 'title' and 'icon' have been reset in .vimrc, we won't even check if
4308 * they can be reset. This reduces startup time when using X on a remote
4309 * machine.
4310 */
4311 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01004312set_title_defaults(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004313{
4314 int idx1;
4315 long val;
4316
4317 /*
4318 * If GUI is (going to be) used, we can always set the window title and
4319 * icon name. Saves a bit of time, because the X11 display server does
4320 * not need to be contacted.
4321 */
4322 idx1 = findoption((char_u *)"title");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004323 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004324 {
4325#ifdef FEAT_GUI
4326 if (gui.starting || gui.in_use)
4327 val = TRUE;
4328 else
4329#endif
4330 val = mch_can_restore_title();
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004331 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004332 p_title = val;
4333 }
4334 idx1 = findoption((char_u *)"icon");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004335 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004336 {
4337#ifdef FEAT_GUI
4338 if (gui.starting || gui.in_use)
4339 val = TRUE;
4340 else
4341#endif
4342 val = mch_can_restore_icon();
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004343 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004344 p_icon = val;
4345 }
4346}
4347#endif
4348
Bram Moolenaarf2bd8ef2018-03-04 18:08:14 +01004349#if defined(FEAT_EVAL)
Bram Moolenaar182a17b2017-06-25 20:57:18 +02004350 static void
4351trigger_optionsset_string(
4352 int opt_idx,
4353 int opt_flags,
4354 char_u *oldval,
4355 char_u *newval)
4356{
Bram Moolenaar3f3fb0b2018-09-21 11:59:32 +02004357 // Don't do this recursively.
4358 if (oldval != NULL && newval != NULL
4359 && *get_vim_var_str(VV_OPTION_TYPE) == NUL)
Bram Moolenaar182a17b2017-06-25 20:57:18 +02004360 {
4361 char_u buf_type[7];
4362
4363 sprintf((char *)buf_type, "%s",
4364 (opt_flags & OPT_LOCAL) ? "local" : "global");
4365 set_vim_var_string(VV_OPTION_OLD, oldval, -1);
4366 set_vim_var_string(VV_OPTION_NEW, newval, -1);
4367 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
4368 apply_autocmds(EVENT_OPTIONSET,
4369 (char_u *)options[opt_idx].fullname, NULL, FALSE, NULL);
4370 reset_v_option_vars();
4371 }
Bram Moolenaar182a17b2017-06-25 20:57:18 +02004372}
4373#endif
4374
Bram Moolenaar071d4272004-06-13 20:20:40 +00004375/*
4376 * Parse 'arg' for option settings.
4377 *
4378 * 'arg' may be IObuff, but only when no errors can be present and option
4379 * does not need to be expanded with option_expand().
4380 * "opt_flags":
4381 * 0 for ":set"
Bram Moolenaara3227e22006-03-08 21:32:40 +00004382 * OPT_GLOBAL for ":setglobal"
4383 * OPT_LOCAL for ":setlocal" and a modeline
Bram Moolenaar071d4272004-06-13 20:20:40 +00004384 * OPT_MODELINE for a modeline
Bram Moolenaara3227e22006-03-08 21:32:40 +00004385 * OPT_WINONLY to only set window-local options
4386 * OPT_NOWIN to skip setting window-local options
Bram Moolenaar071d4272004-06-13 20:20:40 +00004387 *
4388 * returns FAIL if an error is detected, OK otherwise
4389 */
4390 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01004391do_set(
4392 char_u *arg, /* option string (may be written to!) */
4393 int opt_flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004394{
4395 int opt_idx;
4396 char_u *errmsg;
4397 char_u errbuf[80];
4398 char_u *startarg;
4399 int prefix; /* 1: nothing, 0: "no", 2: "inv" in front of name */
4400 int nextchar; /* next non-white char after option name */
4401 int afterchar; /* character just after option name */
4402 int len;
4403 int i;
Bram Moolenaar22fcfad2016-07-01 18:17:26 +02004404 varnumber_T value;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004405 int key;
4406 long_u flags; /* flags for current option */
4407 char_u *varp = NULL; /* pointer to variable for current option */
4408 int did_show = FALSE; /* already showed one value */
4409 int adding; /* "opt+=arg" */
4410 int prepending; /* "opt^=arg" */
4411 int removing; /* "opt-=arg" */
4412 int cp_val = 0;
4413 char_u key_name[2];
4414
4415 if (*arg == NUL)
4416 {
4417 showoptions(0, opt_flags);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004418 did_show = TRUE;
4419 goto theend;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004420 }
4421
4422 while (*arg != NUL) /* loop to process all options */
4423 {
4424 errmsg = NULL;
4425 startarg = arg; /* remember for error message */
4426
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00004427 if (STRNCMP(arg, "all", 3) == 0 && !isalpha(arg[3])
4428 && !(opt_flags & OPT_MODELINE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004429 {
4430 /*
4431 * ":set all" show all options.
4432 * ":set all&" set all options to their default value.
4433 */
4434 arg += 3;
4435 if (*arg == '&')
4436 {
4437 ++arg;
4438 /* Only for :set command set global value of local options. */
4439 set_options_default(OPT_FREE | opt_flags);
Bram Moolenaare68c25c2015-08-25 15:39:55 +02004440 didset_options();
4441 didset_options2();
Bram Moolenaarb341dda2015-08-25 12:56:31 +02004442 redraw_all_later(CLEAR);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004443 }
4444 else
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004445 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00004446 showoptions(1, opt_flags);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004447 did_show = TRUE;
4448 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004449 }
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00004450 else if (STRNCMP(arg, "termcap", 7) == 0 && !(opt_flags & OPT_MODELINE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004451 {
4452 showoptions(2, opt_flags);
4453 show_termcodes();
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004454 did_show = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004455 arg += 7;
4456 }
4457 else
4458 {
4459 prefix = 1;
Bram Moolenaar2a7b9ee2009-06-16 15:50:33 +00004460 if (STRNCMP(arg, "no", 2) == 0 && STRNCMP(arg, "novice", 6) != 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004461 {
4462 prefix = 0;
4463 arg += 2;
4464 }
4465 else if (STRNCMP(arg, "inv", 3) == 0)
4466 {
4467 prefix = 2;
4468 arg += 3;
4469 }
4470
4471 /* find end of name */
4472 key = 0;
4473 if (*arg == '<')
4474 {
4475 nextchar = 0;
4476 opt_idx = -1;
4477 /* look out for <t_>;> */
4478 if (arg[1] == 't' && arg[2] == '_' && arg[3] && arg[4])
4479 len = 5;
4480 else
4481 {
4482 len = 1;
4483 while (arg[len] != NUL && arg[len] != '>')
4484 ++len;
4485 }
4486 if (arg[len] != '>')
4487 {
4488 errmsg = e_invarg;
4489 goto skip;
4490 }
4491 arg[len] = NUL; /* put NUL after name */
4492 if (arg[1] == 't' && arg[2] == '_') /* could be term code */
4493 opt_idx = findoption(arg + 1);
4494 arg[len++] = '>'; /* restore '>' */
4495 if (opt_idx == -1)
Bram Moolenaar9cf4b502018-07-23 04:12:03 +02004496 key = find_key_option(arg + 1, TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004497 }
4498 else
4499 {
4500 len = 0;
4501 /*
4502 * The two characters after "t_" may not be alphanumeric.
4503 */
4504 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
4505 len = 4;
4506 else
4507 while (ASCII_ISALNUM(arg[len]) || arg[len] == '_')
4508 ++len;
4509 nextchar = arg[len];
4510 arg[len] = NUL; /* put NUL after name */
4511 opt_idx = findoption(arg);
4512 arg[len] = nextchar; /* restore nextchar */
4513 if (opt_idx == -1)
Bram Moolenaar9cf4b502018-07-23 04:12:03 +02004514 key = find_key_option(arg, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004515 }
4516
4517 /* remember character after option name */
4518 afterchar = arg[len];
4519
4520 /* skip white space, allow ":set ai ?" */
Bram Moolenaar1c465442017-03-12 20:10:05 +01004521 while (VIM_ISWHITE(arg[len]))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004522 ++len;
4523
4524 adding = FALSE;
4525 prepending = FALSE;
4526 removing = FALSE;
4527 if (arg[len] != NUL && arg[len + 1] == '=')
4528 {
4529 if (arg[len] == '+')
4530 {
4531 adding = TRUE; /* "+=" */
4532 ++len;
4533 }
4534 else if (arg[len] == '^')
4535 {
4536 prepending = TRUE; /* "^=" */
4537 ++len;
4538 }
4539 else if (arg[len] == '-')
4540 {
4541 removing = TRUE; /* "-=" */
4542 ++len;
4543 }
4544 }
4545 nextchar = arg[len];
4546
4547 if (opt_idx == -1 && key == 0) /* found a mismatch: skip */
4548 {
4549 errmsg = (char_u *)N_("E518: Unknown option");
4550 goto skip;
4551 }
4552
4553 if (opt_idx >= 0)
4554 {
4555 if (options[opt_idx].var == NULL) /* hidden option: skip */
4556 {
4557 /* Only give an error message when requesting the value of
4558 * a hidden option, ignore setting it. */
4559 if (vim_strchr((char_u *)"=:!&<", nextchar) == NULL
4560 && (!(options[opt_idx].flags & P_BOOL)
4561 || nextchar == '?'))
4562 errmsg = (char_u *)N_("E519: Option not supported");
4563 goto skip;
4564 }
4565
4566 flags = options[opt_idx].flags;
4567 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
4568 }
4569 else
4570 {
4571 flags = P_STRING;
4572 if (key < 0)
4573 {
4574 key_name[0] = KEY2TERMCAP0(key);
4575 key_name[1] = KEY2TERMCAP1(key);
4576 }
4577 else
4578 {
4579 key_name[0] = KS_KEY;
4580 key_name[1] = (key & 0xff);
4581 }
4582 }
4583
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004584 /* Skip all options that are not window-local (used when showing
4585 * an already loaded buffer in a window). */
4586 if ((opt_flags & OPT_WINONLY)
4587 && (opt_idx < 0 || options[opt_idx].var != VAR_WIN))
4588 goto skip;
4589
Bram Moolenaara3227e22006-03-08 21:32:40 +00004590 /* Skip all options that are window-local (used for :vimgrep). */
4591 if ((opt_flags & OPT_NOWIN) && opt_idx >= 0
4592 && options[opt_idx].var == VAR_WIN)
4593 goto skip;
4594
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004595 /* Disallow changing some options from modelines. */
4596 if (opt_flags & OPT_MODELINE)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004597 {
Bram Moolenaar865242e2010-07-14 21:12:05 +02004598 if (flags & (P_SECURE | P_NO_ML))
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004599 {
4600 errmsg = (char_u *)_("E520: Not allowed in a modeline");
4601 goto skip;
4602 }
Bram Moolenaarf69d9a32009-02-11 21:48:40 +00004603#ifdef FEAT_DIFF
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004604 /* In diff mode some options are overruled. This avoids that
4605 * 'foldmethod' becomes "marker" instead of "diff" and that
4606 * "wrap" gets set. */
4607 if (curwin->w_p_diff
Bram Moolenaara9d52e32010-07-31 16:44:19 +02004608 && opt_idx >= 0 /* shut up coverity warning */
Bram Moolenaara6c07602017-03-05 21:18:27 +01004609 && (
4610#ifdef FEAT_FOLDING
4611 options[opt_idx].indir == PV_FDM ||
4612#endif
4613 options[opt_idx].indir == PV_WRAP))
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004614 goto skip;
Bram Moolenaarf69d9a32009-02-11 21:48:40 +00004615#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004616 }
4617
4618#ifdef HAVE_SANDBOX
4619 /* Disallow changing some options in the sandbox */
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004620 if (sandbox != 0 && (flags & P_SECURE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004621 {
4622 errmsg = (char_u *)_(e_sandbox);
4623 goto skip;
4624 }
4625#endif
4626
4627 if (vim_strchr((char_u *)"?=:!&<", nextchar) != NULL)
4628 {
4629 arg += len;
4630 cp_val = p_cp;
4631 if (nextchar == '&' && arg[1] == 'v' && arg[2] == 'i')
4632 {
4633 if (arg[3] == 'm') /* "opt&vim": set to Vim default */
4634 {
4635 cp_val = FALSE;
4636 arg += 3;
4637 }
4638 else /* "opt&vi": set to Vi default */
4639 {
4640 cp_val = TRUE;
4641 arg += 2;
4642 }
4643 }
4644 if (vim_strchr((char_u *)"?!&<", nextchar) != NULL
Bram Moolenaar1c465442017-03-12 20:10:05 +01004645 && arg[1] != NUL && !VIM_ISWHITE(arg[1]))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004646 {
4647 errmsg = e_trailing;
4648 goto skip;
4649 }
4650 }
4651
4652 /*
Bram Moolenaar48e330a2016-02-23 14:53:34 +01004653 * allow '=' and ':' for hystorical reasons (MSDOS command.com
4654 * allows only one '=' character per "set" command line. grrr. (jw)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004655 */
4656 if (nextchar == '?'
4657 || (prefix == 1
4658 && vim_strchr((char_u *)"=:&<", nextchar) == NULL
4659 && !(flags & P_BOOL)))
4660 {
4661 /*
4662 * print value
4663 */
4664 if (did_show)
4665 msg_putchar('\n'); /* cursor below last one */
4666 else
4667 {
4668 gotocmdline(TRUE); /* cursor at status line */
4669 did_show = TRUE; /* remember that we did a line */
4670 }
4671 if (opt_idx >= 0)
4672 {
4673 showoneopt(&options[opt_idx], opt_flags);
4674#ifdef FEAT_EVAL
4675 if (p_verbose > 0)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00004676 {
4677 /* Mention where the option was last set. */
4678 if (varp == options[opt_idx].var)
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02004679 last_set_msg(options[opt_idx].script_ctx);
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00004680 else if ((int)options[opt_idx].indir & PV_WIN)
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02004681 last_set_msg(curwin->w_p_script_ctx[
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00004682 (int)options[opt_idx].indir & PV_MASK]);
4683 else if ((int)options[opt_idx].indir & PV_BUF)
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02004684 last_set_msg(curbuf->b_p_script_ctx[
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00004685 (int)options[opt_idx].indir & PV_MASK]);
4686 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004687#endif
4688 }
4689 else
4690 {
4691 char_u *p;
4692
4693 p = find_termcode(key_name);
4694 if (p == NULL)
4695 {
Bram Moolenaar0b2f94d2011-03-22 14:35:05 +01004696 errmsg = (char_u *)N_("E846: Key code not set");
Bram Moolenaar071d4272004-06-13 20:20:40 +00004697 goto skip;
4698 }
4699 else
4700 (void)show_one_termcode(key_name, p, TRUE);
4701 }
4702 if (nextchar != '?'
Bram Moolenaar1c465442017-03-12 20:10:05 +01004703 && nextchar != NUL && !VIM_ISWHITE(afterchar))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004704 errmsg = e_trailing;
4705 }
4706 else
4707 {
Bram Moolenaar247bb7e2018-11-20 14:27:07 +01004708 int value_is_replaced = !prepending && !adding && !removing;
4709
Bram Moolenaar071d4272004-06-13 20:20:40 +00004710 if (flags & P_BOOL) /* boolean */
4711 {
4712 if (nextchar == '=' || nextchar == ':')
4713 {
4714 errmsg = e_invarg;
4715 goto skip;
4716 }
4717
4718 /*
4719 * ":set opt!": invert
4720 * ":set opt&": reset to default value
4721 * ":set opt<": reset to global value
4722 */
4723 if (nextchar == '!')
4724 value = *(int *)(varp) ^ 1;
4725 else if (nextchar == '&')
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004726 value = (int)(long)(long_i)options[opt_idx].def_val[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004727 ((flags & P_VI_DEF) || cp_val)
4728 ? VI_DEFAULT : VIM_DEFAULT];
4729 else if (nextchar == '<')
4730 {
4731 /* For 'autoread' -1 means to use global value. */
4732 if ((int *)varp == &curbuf->b_p_ar
4733 && opt_flags == OPT_LOCAL)
4734 value = -1;
4735 else
4736 value = *(int *)get_varp_scope(&(options[opt_idx]),
4737 OPT_GLOBAL);
4738 }
4739 else
4740 {
4741 /*
4742 * ":set invopt": invert
4743 * ":set opt" or ":set noopt": set or reset
4744 */
Bram Moolenaar1c465442017-03-12 20:10:05 +01004745 if (nextchar != NUL && !VIM_ISWHITE(afterchar))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004746 {
4747 errmsg = e_trailing;
4748 goto skip;
4749 }
4750 if (prefix == 2) /* inv */
4751 value = *(int *)(varp) ^ 1;
4752 else
4753 value = prefix;
4754 }
4755
4756 errmsg = set_bool_option(opt_idx, varp, (int)value,
4757 opt_flags);
4758 }
4759 else /* numeric or string */
4760 {
4761 if (vim_strchr((char_u *)"=:&<", nextchar) == NULL
4762 || prefix != 1)
4763 {
4764 errmsg = e_invarg;
4765 goto skip;
4766 }
4767
4768 if (flags & P_NUM) /* numeric */
4769 {
4770 /*
4771 * Different ways to set a number option:
4772 * & set to default value
4773 * < set to global value
4774 * <xx> accept special key codes for 'wildchar'
4775 * c accept any non-digit for 'wildchar'
4776 * [-]0-9 set number
4777 * other error
4778 */
4779 ++arg;
4780 if (nextchar == '&')
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004781 value = (long)(long_i)options[opt_idx].def_val[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004782 ((flags & P_VI_DEF) || cp_val)
4783 ? VI_DEFAULT : VIM_DEFAULT];
4784 else if (nextchar == '<')
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01004785 {
4786 /* For 'undolevels' NO_LOCAL_UNDOLEVEL means to
4787 * use the global value. */
4788 if ((long *)varp == &curbuf->b_p_ul
4789 && opt_flags == OPT_LOCAL)
4790 value = NO_LOCAL_UNDOLEVEL;
4791 else
4792 value = *(long *)get_varp_scope(
4793 &(options[opt_idx]), OPT_GLOBAL);
4794 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004795 else if (((long *)varp == &p_wc
4796 || (long *)varp == &p_wcm)
4797 && (*arg == '<'
4798 || *arg == '^'
Bram Moolenaar1c465442017-03-12 20:10:05 +01004799 || (*arg != NUL
4800 && (!arg[1] || VIM_ISWHITE(arg[1]))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004801 && !VIM_ISDIGIT(*arg))))
4802 {
Bram Moolenaardbe948d2017-07-23 22:50:51 +02004803 value = string_to_key(arg, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004804 if (value == 0 && (long *)varp != &p_wcm)
4805 {
4806 errmsg = e_invarg;
4807 goto skip;
4808 }
4809 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004810 else if (*arg == '-' || VIM_ISDIGIT(*arg))
4811 {
Bram Moolenaar18400e62015-01-27 15:58:40 +01004812 /* Allow negative (for 'undolevels'), octal and
4813 * hex numbers. */
Bram Moolenaar887c1fe2016-01-02 17:56:35 +01004814 vim_str2nr(arg, NULL, &i, STR2NR_ALL,
4815 &value, NULL, 0);
Bram Moolenaar1c465442017-03-12 20:10:05 +01004816 if (arg[i] != NUL && !VIM_ISWHITE(arg[i]))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004817 {
4818 errmsg = e_invarg;
4819 goto skip;
4820 }
4821 }
4822 else
4823 {
4824 errmsg = (char_u *)N_("E521: Number required after =");
4825 goto skip;
4826 }
4827
4828 if (adding)
4829 value = *(long *)varp + value;
4830 if (prepending)
4831 value = *(long *)varp * value;
4832 if (removing)
4833 value = *(long *)varp - value;
4834 errmsg = set_num_option(opt_idx, varp, value,
Bram Moolenaar555b2802005-05-19 21:08:39 +00004835 errbuf, sizeof(errbuf), opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004836 }
4837 else if (opt_idx >= 0) /* string */
4838 {
Bram Moolenaar8efa0262017-08-20 15:47:20 +02004839 char_u *save_arg = NULL;
4840 char_u *s = NULL;
4841 char_u *oldval = NULL; /* previous value if *varp */
4842 char_u *newval;
4843 char_u *origval = NULL;
Bram Moolenaarf2bd8ef2018-03-04 18:08:14 +01004844#if defined(FEAT_EVAL)
Bram Moolenaar8efa0262017-08-20 15:47:20 +02004845 char_u *saved_origval = NULL;
4846 char_u *saved_newval = NULL;
Bram Moolenaar53744302015-07-17 17:38:22 +02004847#endif
Bram Moolenaar8efa0262017-08-20 15:47:20 +02004848 unsigned newlen;
4849 int comma;
4850 int bs;
4851 int new_value_alloced; /* new string option
Bram Moolenaar071d4272004-06-13 20:20:40 +00004852 was allocated */
4853
4854 /* When using ":set opt=val" for a global option
4855 * with a local value the local value will be
4856 * reset, use the global value here. */
4857 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00004858 && ((int)options[opt_idx].indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004859 varp = options[opt_idx].var;
4860
4861 /* The old value is kept until we are sure that the
4862 * new value is valid. */
4863 oldval = *(char_u **)varp;
Bram Moolenaar8efa0262017-08-20 15:47:20 +02004864
4865 /* When setting the local value of a global
4866 * option, the old value may be the global value. */
4867 if (((int)options[opt_idx].indir & PV_BOTH)
4868 && (opt_flags & OPT_LOCAL))
4869 origval = *(char_u **)get_varp(
4870 &options[opt_idx]);
4871 else
4872 origval = oldval;
4873
Bram Moolenaar071d4272004-06-13 20:20:40 +00004874 if (nextchar == '&') /* set to default val */
4875 {
4876 newval = options[opt_idx].def_val[
4877 ((flags & P_VI_DEF) || cp_val)
4878 ? VI_DEFAULT : VIM_DEFAULT];
4879 if ((char_u **)varp == &p_bg)
4880 {
4881 /* guess the value of 'background' */
4882#ifdef FEAT_GUI
4883 if (gui.in_use)
4884 newval = gui_bg_default();
4885 else
4886#endif
Bram Moolenaarf740b292006-02-16 22:11:02 +00004887 newval = term_bg_default();
Bram Moolenaar071d4272004-06-13 20:20:40 +00004888 }
4889
4890 /* expand environment variables and ~ (since the
4891 * default value was already expanded, only
4892 * required when an environment variable was set
4893 * later */
4894 if (newval == NULL)
4895 newval = empty_option;
4896 else
4897 {
4898 s = option_expand(opt_idx, newval);
4899 if (s == NULL)
4900 s = newval;
4901 newval = vim_strsave(s);
4902 }
4903 new_value_alloced = TRUE;
4904 }
4905 else if (nextchar == '<') /* set to global val */
4906 {
4907 newval = vim_strsave(*(char_u **)get_varp_scope(
4908 &(options[opt_idx]), OPT_GLOBAL));
4909 new_value_alloced = TRUE;
4910 }
4911 else
4912 {
4913 ++arg; /* jump to after the '=' or ':' */
4914
4915 /*
4916 * Set 'keywordprg' to ":help" if an empty
4917 * value was passed to :set by the user.
4918 * Misuse errbuf[] for the resulting string.
4919 */
4920 if (varp == (char_u *)&p_kp
4921 && (*arg == NUL || *arg == ' '))
4922 {
4923 STRCPY(errbuf, ":help");
4924 save_arg = arg;
4925 arg = errbuf;
4926 }
4927 /*
Bram Moolenaar4e5ccfa2011-11-30 11:15:47 +01004928 * Convert 'backspace' number to string, for
4929 * adding, prepending and removing string.
4930 */
4931 else if (varp == (char_u *)&p_bs
4932 && VIM_ISDIGIT(**(char_u **)varp))
4933 {
4934 i = getdigits((char_u **)varp);
4935 switch (i)
4936 {
4937 case 0:
4938 *(char_u **)varp = empty_option;
4939 break;
4940 case 1:
4941 *(char_u **)varp = vim_strsave(
4942 (char_u *)"indent,eol");
4943 break;
4944 case 2:
4945 *(char_u **)varp = vim_strsave(
4946 (char_u *)"indent,eol,start");
4947 break;
4948 }
4949 vim_free(oldval);
Bram Moolenaaredbc0d42017-08-20 16:11:51 +02004950 if (origval == oldval)
4951 origval = *(char_u **)varp;
Bram Moolenaar4e5ccfa2011-11-30 11:15:47 +01004952 oldval = *(char_u **)varp;
4953 }
4954 /*
Bram Moolenaar071d4272004-06-13 20:20:40 +00004955 * Convert 'whichwrap' number to string, for
4956 * backwards compatibility with Vim 3.0.
4957 * Misuse errbuf[] for the resulting string.
4958 */
4959 else if (varp == (char_u *)&p_ww
4960 && VIM_ISDIGIT(*arg))
4961 {
4962 *errbuf = NUL;
4963 i = getdigits(&arg);
4964 if (i & 1)
4965 STRCAT(errbuf, "b,");
4966 if (i & 2)
4967 STRCAT(errbuf, "s,");
4968 if (i & 4)
4969 STRCAT(errbuf, "h,l,");
4970 if (i & 8)
4971 STRCAT(errbuf, "<,>,");
4972 if (i & 16)
4973 STRCAT(errbuf, "[,],");
4974 if (*errbuf != NUL) /* remove trailing , */
4975 errbuf[STRLEN(errbuf) - 1] = NUL;
4976 save_arg = arg;
4977 arg = errbuf;
4978 }
4979 /*
4980 * Remove '>' before 'dir' and 'bdir', for
4981 * backwards compatibility with version 3.0
4982 */
4983 else if ( *arg == '>'
4984 && (varp == (char_u *)&p_dir
4985 || varp == (char_u *)&p_bdir))
4986 {
4987 ++arg;
4988 }
4989
Bram Moolenaar071d4272004-06-13 20:20:40 +00004990 /*
4991 * Copy the new string into allocated memory.
4992 * Can't use set_string_option_direct(), because
4993 * we need to remove the backslashes.
4994 */
4995 /* get a bit too much */
4996 newlen = (unsigned)STRLEN(arg) + 1;
4997 if (adding || prepending || removing)
4998 newlen += (unsigned)STRLEN(origval) + 1;
4999 newval = alloc(newlen);
5000 if (newval == NULL) /* out of mem, don't change */
5001 break;
5002 s = newval;
5003
5004 /*
5005 * Copy the string, skip over escaped chars.
5006 * For MS-DOS and WIN32 backslashes before normal
5007 * file name characters are not removed, and keep
5008 * backslash at start, for "\\machine\path", but
5009 * do remove it for "\\\\machine\\path".
5010 * The reverse is found in ExpandOldSetting().
5011 */
Bram Moolenaar1c465442017-03-12 20:10:05 +01005012 while (*arg && !VIM_ISWHITE(*arg))
Bram Moolenaar071d4272004-06-13 20:20:40 +00005013 {
5014 if (*arg == '\\' && arg[1] != NUL
5015#ifdef BACKSLASH_IN_FILENAME
5016 && !((flags & P_EXPAND)
5017 && vim_isfilec(arg[1])
5018 && (arg[1] != '\\'
5019 || (s == newval
5020 && arg[2] != '\\')))
5021#endif
5022 )
5023 ++arg; /* remove backslash */
5024#ifdef FEAT_MBYTE
5025 if (has_mbyte
Bram Moolenaar0fa313a2005-08-10 21:07:57 +00005026 && (i = (*mb_ptr2len)(arg)) > 1)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005027 {
5028 /* copy multibyte char */
5029 mch_memmove(s, arg, (size_t)i);
5030 arg += i;
5031 s += i;
5032 }
5033 else
5034#endif
5035 *s++ = *arg++;
5036 }
5037 *s = NUL;
5038
5039 /*
5040 * Expand environment variables and ~.
5041 * Don't do it when adding without inserting a
5042 * comma.
5043 */
5044 if (!(adding || prepending || removing)
5045 || (flags & P_COMMA))
5046 {
5047 s = option_expand(opt_idx, newval);
5048 if (s != NULL)
5049 {
5050 vim_free(newval);
5051 newlen = (unsigned)STRLEN(s) + 1;
5052 if (adding || prepending || removing)
5053 newlen += (unsigned)STRLEN(origval) + 1;
5054 newval = alloc(newlen);
5055 if (newval == NULL)
5056 break;
5057 STRCPY(newval, s);
5058 }
5059 }
5060
5061 /* locate newval[] in origval[] when removing it
5062 * and when adding to avoid duplicates */
5063 i = 0; /* init for GCC */
5064 if (removing || (flags & P_NODUP))
5065 {
5066 i = (int)STRLEN(newval);
5067 bs = 0;
5068 for (s = origval; *s; ++s)
5069 {
5070 if ((!(flags & P_COMMA)
5071 || s == origval
5072 || (s[-1] == ',' && !(bs & 1)))
5073 && STRNCMP(s, newval, i) == 0
5074 && (!(flags & P_COMMA)
5075 || s[i] == ','
5076 || s[i] == NUL))
5077 break;
Bram Moolenaar0b2f94d2011-03-22 14:35:05 +01005078 /* Count backslashes. Only a comma with an
Bram Moolenaar8f79acd2016-01-01 14:48:20 +01005079 * even number of backslashes or a single
5080 * backslash preceded by a comma before it
5081 * is recognized as a separator */
5082 if ((s > origval + 1
5083 && s[-1] == '\\'
5084 && s[-2] != ',')
5085 || (s == origval + 1
5086 && s[-1] == '\\'))
5087
Bram Moolenaar071d4272004-06-13 20:20:40 +00005088 ++bs;
5089 else
5090 bs = 0;
5091 }
5092
5093 /* do not add if already there */
5094 if ((adding || prepending) && *s)
5095 {
5096 prepending = FALSE;
5097 adding = FALSE;
5098 STRCPY(newval, origval);
5099 }
5100 }
5101
5102 /* concatenate the two strings; add a ',' if
5103 * needed */
5104 if (adding || prepending)
5105 {
5106 comma = ((flags & P_COMMA) && *origval != NUL
5107 && *newval != NUL);
5108 if (adding)
5109 {
5110 i = (int)STRLEN(origval);
Bram Moolenaara7b7b1c2015-06-19 14:06:43 +02005111 /* strip a trailing comma, would get 2 */
Bram Moolenaar17467472015-11-10 17:50:24 +01005112 if (comma && i > 1
5113 && (flags & P_ONECOMMA) == P_ONECOMMA
5114 && origval[i - 1] == ','
5115 && origval[i - 2] != '\\')
Bram Moolenaara7b7b1c2015-06-19 14:06:43 +02005116 i--;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005117 mch_memmove(newval + i + comma, newval,
5118 STRLEN(newval) + 1);
5119 mch_memmove(newval, origval, (size_t)i);
5120 }
5121 else
5122 {
5123 i = (int)STRLEN(newval);
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00005124 STRMOVE(newval + i + comma, origval);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005125 }
5126 if (comma)
5127 newval[i] = ',';
5128 }
5129
5130 /* Remove newval[] from origval[]. (Note: "i" has
5131 * been set above and is used here). */
5132 if (removing)
5133 {
5134 STRCPY(newval, origval);
5135 if (*s)
5136 {
5137 /* may need to remove a comma */
5138 if (flags & P_COMMA)
5139 {
5140 if (s == origval)
5141 {
5142 /* include comma after string */
5143 if (s[i] == ',')
5144 ++i;
5145 }
5146 else
5147 {
5148 /* include comma before string */
5149 --s;
5150 ++i;
5151 }
5152 }
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00005153 STRMOVE(newval + (s - origval), s + i);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005154 }
5155 }
5156
5157 if (flags & P_FLAGLIST)
5158 {
5159 /* Remove flags that appear twice. */
Bram Moolenaaraaaf57d2017-02-05 14:13:20 +01005160 for (s = newval; *s;)
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02005161 {
5162 /* if options have P_FLAGLIST and
5163 * P_ONECOMMA such as 'whichwrap' */
5164 if (flags & P_ONECOMMA)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005165 {
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02005166 if (*s != ',' && *(s + 1) == ','
5167 && vim_strchr(s + 2, *s) != NULL)
5168 {
5169 /* Remove the duplicated value and
5170 * the next comma. */
5171 STRMOVE(s, s + 2);
Bram Moolenaaraaaf57d2017-02-05 14:13:20 +01005172 continue;
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02005173 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005174 }
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02005175 else
5176 {
5177 if ((!(flags & P_COMMA) || *s != ',')
5178 && vim_strchr(s + 1, *s) != NULL)
5179 {
5180 STRMOVE(s, s + 1);
Bram Moolenaaraaaf57d2017-02-05 14:13:20 +01005181 continue;
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02005182 }
5183 }
Bram Moolenaaraaaf57d2017-02-05 14:13:20 +01005184 ++s;
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02005185 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005186 }
5187
5188 if (save_arg != NULL) /* number for 'whichwrap' */
5189 arg = save_arg;
5190 new_value_alloced = TRUE;
5191 }
5192
Bram Moolenaar8efa0262017-08-20 15:47:20 +02005193 /*
5194 * Set the new value.
5195 */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005196 *(char_u **)(varp) = newval;
5197
Bram Moolenaarf2bd8ef2018-03-04 18:08:14 +01005198#if defined(FEAT_EVAL)
Bram Moolenaar5cbb8db2015-07-17 23:08:29 +02005199 if (!starting
5200# ifdef FEAT_CRYPT
5201 && options[opt_idx].indir != PV_KEY
5202# endif
Bram Moolenaar182a17b2017-06-25 20:57:18 +02005203 && origval != NULL && newval != NULL)
5204 {
Bram Moolenaar53744302015-07-17 17:38:22 +02005205 /* origval may be freed by
5206 * did_set_string_option(), make a copy. */
5207 saved_origval = vim_strsave(origval);
Bram Moolenaar182a17b2017-06-25 20:57:18 +02005208 /* newval (and varp) may become invalid if the
5209 * buffer is closed by autocommands. */
5210 saved_newval = vim_strsave(newval);
5211 }
Bram Moolenaar53744302015-07-17 17:38:22 +02005212#endif
5213
Bram Moolenaar247bb7e2018-11-20 14:27:07 +01005214 {
5215 long_u *p = insecure_flag(opt_idx, opt_flags);
5216 int did_inc_secure = FALSE;
5217
5218 // When an option is set in the sandbox, from a
5219 // modeline or in secure mode, then deal with side
5220 // effects in secure mode. Also when the value was
5221 // set with the P_INSECURE flag and is not
5222 // completely replaced.
5223 if (secure
5224#ifdef HAVE_SANDBOX
5225 || sandbox != 0
5226#endif
5227 || (opt_flags & OPT_MODELINE)
5228 || (!value_is_replaced && (*p & P_INSECURE)))
5229 {
5230 did_inc_secure = TRUE;
5231 ++secure;
5232 }
5233
5234 // Handle side effects, and set the global value for
5235 // ":set" on local options. Note: when setting 'syntax'
5236 // or 'filetype' autocommands may be triggered that can
5237 // cause havoc.
5238 errmsg = did_set_string_option(opt_idx, (char_u **)varp,
5239 new_value_alloced, oldval, errbuf, opt_flags);
5240
5241 if (did_inc_secure)
5242 --secure;
5243 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005244
Bram Moolenaarf2bd8ef2018-03-04 18:08:14 +01005245#if defined(FEAT_EVAL)
Bram Moolenaar8efa0262017-08-20 15:47:20 +02005246 if (errmsg == NULL)
5247 trigger_optionsset_string(opt_idx, opt_flags,
5248 saved_origval, saved_newval);
5249 vim_free(saved_origval);
5250 vim_free(saved_newval);
5251#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005252 /* If error detected, print the error message. */
5253 if (errmsg != NULL)
5254 goto skip;
5255 }
5256 else /* key code option */
5257 {
5258 char_u *p;
5259
5260 if (nextchar == '&')
5261 {
5262 if (add_termcap_entry(key_name, TRUE) == FAIL)
5263 errmsg = (char_u *)N_("E522: Not found in termcap");
5264 }
5265 else
5266 {
5267 ++arg; /* jump to after the '=' or ':' */
Bram Moolenaar1c465442017-03-12 20:10:05 +01005268 for (p = arg; *p && !VIM_ISWHITE(*p); ++p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005269 if (*p == '\\' && p[1] != NUL)
5270 ++p;
5271 nextchar = *p;
5272 *p = NUL;
5273 add_termcode(key_name, arg, FALSE);
5274 *p = nextchar;
5275 }
5276 if (full_screen)
5277 ttest(FALSE);
5278 redraw_all_later(CLEAR);
5279 }
5280 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005281
Bram Moolenaar071d4272004-06-13 20:20:40 +00005282 if (opt_idx >= 0)
Bram Moolenaar247bb7e2018-11-20 14:27:07 +01005283 did_set_option(opt_idx, opt_flags, value_is_replaced);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005284 }
5285
5286skip:
5287 /*
5288 * Advance to next argument.
5289 * - skip until a blank found, taking care of backslashes
5290 * - skip blanks
5291 * - skip one "=val" argument (for hidden options ":set gfn =xx")
5292 */
5293 for (i = 0; i < 2 ; ++i)
5294 {
Bram Moolenaar1c465442017-03-12 20:10:05 +01005295 while (*arg != NUL && !VIM_ISWHITE(*arg))
Bram Moolenaar071d4272004-06-13 20:20:40 +00005296 if (*arg++ == '\\' && *arg != NUL)
5297 ++arg;
5298 arg = skipwhite(arg);
5299 if (*arg != '=')
5300 break;
5301 }
5302 }
5303
5304 if (errmsg != NULL)
5305 {
Bram Moolenaarce0842a2005-07-18 21:58:11 +00005306 vim_strncpy(IObuff, (char_u *)_(errmsg), IOSIZE - 1);
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00005307 i = (int)STRLEN(IObuff) + 2;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005308 if (i + (arg - startarg) < IOSIZE)
5309 {
5310 /* append the argument with the error */
5311 STRCAT(IObuff, ": ");
5312 mch_memmove(IObuff + i, startarg, (arg - startarg));
5313 IObuff[i + (arg - startarg)] = NUL;
5314 }
5315 /* make sure all characters are printable */
5316 trans_characters(IObuff, IOSIZE);
5317
5318 ++no_wait_return; /* wait_return done later */
5319 emsg(IObuff); /* show error highlighted */
5320 --no_wait_return;
5321
5322 return FAIL;
5323 }
5324
5325 arg = skipwhite(arg);
5326 }
5327
Bram Moolenaar26a60b42005-02-22 08:49:11 +00005328theend:
5329 if (silent_mode && did_show)
5330 {
5331 /* After displaying option values in silent mode. */
5332 silent_mode = FALSE;
5333 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
5334 msg_putchar('\n');
5335 cursor_on(); /* msg_start() switches it off */
5336 out_flush();
5337 silent_mode = TRUE;
5338 info_message = FALSE; /* use mch_msg(), not mch_errmsg() */
5339 }
5340
Bram Moolenaar071d4272004-06-13 20:20:40 +00005341 return OK;
5342}
5343
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005344/*
5345 * Call this when an option has been given a new value through a user command.
5346 * Sets the P_WAS_SET flag and takes care of the P_INSECURE flag.
5347 */
5348 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005349did_set_option(
5350 int opt_idx,
5351 int opt_flags, /* possibly with OPT_MODELINE */
5352 int new_value) /* value was replaced completely */
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005353{
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005354 long_u *p;
5355
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005356 options[opt_idx].flags |= P_WAS_SET;
5357
5358 /* When an option is set in the sandbox, from a modeline or in secure mode
5359 * set the P_INSECURE flag. Otherwise, if a new value is stored reset the
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005360 * flag. */
5361 p = insecure_flag(opt_idx, opt_flags);
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005362 if (secure
5363#ifdef HAVE_SANDBOX
5364 || sandbox != 0
5365#endif
5366 || (opt_flags & OPT_MODELINE))
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005367 *p = *p | P_INSECURE;
5368 else if (new_value)
5369 *p = *p & ~P_INSECURE;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005370}
5371
Bram Moolenaar071d4272004-06-13 20:20:40 +00005372 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005373illegal_char(char_u *errbuf, int c)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005374{
5375 if (errbuf == NULL)
5376 return (char_u *)"";
5377 sprintf((char *)errbuf, _("E539: Illegal character <%s>"),
Bram Moolenaar555b2802005-05-19 21:08:39 +00005378 (char *)transchar(c));
Bram Moolenaar071d4272004-06-13 20:20:40 +00005379 return errbuf;
5380}
5381
5382/*
5383 * Convert a key name or string into a key value.
5384 * Used for 'wildchar' and 'cedit' options.
Bram Moolenaardbe948d2017-07-23 22:50:51 +02005385 * When "multi_byte" is TRUE allow for multi-byte characters.
Bram Moolenaar071d4272004-06-13 20:20:40 +00005386 */
Bram Moolenaardbe948d2017-07-23 22:50:51 +02005387 int
5388string_to_key(char_u *arg, int multi_byte)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005389{
5390 if (*arg == '<')
Bram Moolenaar9cf4b502018-07-23 04:12:03 +02005391 return find_key_option(arg + 1, TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005392 if (*arg == '^')
5393 return Ctrl_chr(arg[1]);
Bram Moolenaardbe948d2017-07-23 22:50:51 +02005394 if (multi_byte)
5395 return PTR2CHAR(arg);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005396 return *arg;
5397}
5398
5399#ifdef FEAT_CMDWIN
5400/*
5401 * Check value of 'cedit' and set cedit_key.
5402 * Returns NULL if value is OK, error message otherwise.
5403 */
5404 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005405check_cedit(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005406{
5407 int n;
5408
5409 if (*p_cedit == NUL)
5410 cedit_key = -1;
5411 else
5412 {
Bram Moolenaardbe948d2017-07-23 22:50:51 +02005413 n = string_to_key(p_cedit, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005414 if (vim_isprintc(n))
5415 return e_invarg;
5416 cedit_key = n;
5417 }
5418 return NULL;
5419}
5420#endif
5421
5422#ifdef FEAT_TITLE
5423/*
5424 * When changing 'title', 'titlestring', 'icon' or 'iconstring', call
5425 * maketitle() to create and display it.
5426 * When switching the title or icon off, call mch_restore_title() to get
5427 * the old value back.
5428 */
5429 static void
Bram Moolenaar84a93082018-06-16 22:58:15 +02005430did_set_title(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005431{
5432 if (starting != NO_SCREEN
5433#ifdef FEAT_GUI
5434 && !gui.starting
5435#endif
5436 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00005437 maketitle();
Bram Moolenaar071d4272004-06-13 20:20:40 +00005438}
5439#endif
5440
5441/*
5442 * set_options_bin - called when 'bin' changes value.
5443 */
5444 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005445set_options_bin(
5446 int oldval,
5447 int newval,
5448 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005449{
5450 /*
5451 * The option values that are changed when 'bin' changes are
5452 * copied when 'bin is set and restored when 'bin' is reset.
5453 */
5454 if (newval)
5455 {
5456 if (!oldval) /* switched on */
5457 {
5458 if (!(opt_flags & OPT_GLOBAL))
5459 {
5460 curbuf->b_p_tw_nobin = curbuf->b_p_tw;
5461 curbuf->b_p_wm_nobin = curbuf->b_p_wm;
5462 curbuf->b_p_ml_nobin = curbuf->b_p_ml;
5463 curbuf->b_p_et_nobin = curbuf->b_p_et;
5464 }
5465 if (!(opt_flags & OPT_LOCAL))
5466 {
5467 p_tw_nobin = p_tw;
5468 p_wm_nobin = p_wm;
5469 p_ml_nobin = p_ml;
5470 p_et_nobin = p_et;
5471 }
5472 }
5473
5474 if (!(opt_flags & OPT_GLOBAL))
5475 {
5476 curbuf->b_p_tw = 0; /* no automatic line wrap */
5477 curbuf->b_p_wm = 0; /* no automatic line wrap */
5478 curbuf->b_p_ml = 0; /* no modelines */
5479 curbuf->b_p_et = 0; /* no expandtab */
5480 }
5481 if (!(opt_flags & OPT_LOCAL))
5482 {
5483 p_tw = 0;
5484 p_wm = 0;
5485 p_ml = FALSE;
5486 p_et = FALSE;
5487 p_bin = TRUE; /* needed when called for the "-b" argument */
5488 }
5489 }
5490 else if (oldval) /* switched off */
5491 {
5492 if (!(opt_flags & OPT_GLOBAL))
5493 {
5494 curbuf->b_p_tw = curbuf->b_p_tw_nobin;
5495 curbuf->b_p_wm = curbuf->b_p_wm_nobin;
5496 curbuf->b_p_ml = curbuf->b_p_ml_nobin;
5497 curbuf->b_p_et = curbuf->b_p_et_nobin;
5498 }
5499 if (!(opt_flags & OPT_LOCAL))
5500 {
5501 p_tw = p_tw_nobin;
5502 p_wm = p_wm_nobin;
5503 p_ml = p_ml_nobin;
5504 p_et = p_et_nobin;
5505 }
5506 }
5507}
5508
5509#ifdef FEAT_VIMINFO
5510/*
5511 * Find the parameter represented by the given character (eg ', :, ", or /),
5512 * and return its associated value in the 'viminfo' string.
5513 * Only works for number parameters, not for 'r' or 'n'.
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +00005514 * If the parameter is not specified in the string or there is no following
5515 * number, return -1.
Bram Moolenaar071d4272004-06-13 20:20:40 +00005516 */
5517 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01005518get_viminfo_parameter(int type)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005519{
5520 char_u *p;
5521
5522 p = find_viminfo_parameter(type);
5523 if (p != NULL && VIM_ISDIGIT(*p))
5524 return atoi((char *)p);
5525 return -1;
5526}
5527
5528/*
5529 * Find the parameter represented by the given character (eg ''', ':', '"', or
5530 * '/') in the 'viminfo' option and return a pointer to the string after it.
5531 * Return NULL if the parameter is not specified in the string.
5532 */
5533 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005534find_viminfo_parameter(int type)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005535{
5536 char_u *p;
5537
5538 for (p = p_viminfo; *p; ++p)
5539 {
5540 if (*p == type)
5541 return p + 1;
5542 if (*p == 'n') /* 'n' is always the last one */
5543 break;
5544 p = vim_strchr(p, ','); /* skip until next ',' */
5545 if (p == NULL) /* hit the end without finding parameter */
5546 break;
5547 }
5548 return NULL;
5549}
5550#endif
5551
5552/*
5553 * Expand environment variables for some string options.
5554 * These string options cannot be indirect!
5555 * If "val" is NULL expand the current value of the option.
5556 * Return pointer to NameBuff, or NULL when not expanded.
5557 */
5558 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005559option_expand(int opt_idx, char_u *val)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005560{
5561 /* if option doesn't need expansion nothing to do */
5562 if (!(options[opt_idx].flags & P_EXPAND) || options[opt_idx].var == NULL)
5563 return NULL;
5564
5565 /* If val is longer than MAXPATHL no meaningful expansion can be done,
5566 * expand_env() would truncate the string. */
5567 if (val != NULL && STRLEN(val) > MAXPATHL)
5568 return NULL;
5569
5570 if (val == NULL)
5571 val = *(char_u **)options[opt_idx].var;
5572
5573 /*
5574 * Expanding this with NameBuff, expand_env() must not be passed IObuff.
5575 * Escape spaces when expanding 'tags', they are used to separate file
5576 * names.
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005577 * For 'spellsuggest' expand after "file:".
Bram Moolenaar071d4272004-06-13 20:20:40 +00005578 */
5579 expand_env_esc(val, NameBuff, MAXPATHL,
Bram Moolenaar9f0545d2007-09-26 20:36:32 +00005580 (char_u **)options[opt_idx].var == &p_tags, FALSE,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005581#ifdef FEAT_SPELL
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005582 (char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" :
5583#endif
5584 NULL);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005585 if (STRCMP(NameBuff, val) == 0) /* they are the same */
5586 return NULL;
5587
5588 return NameBuff;
5589}
5590
5591/*
5592 * After setting various option values: recompute variables that depend on
5593 * option values.
5594 */
5595 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005596didset_options(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005597{
5598 /* initialize the table for 'iskeyword' et.al. */
5599 (void)init_chartab();
5600
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00005601#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +00005602 (void)opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE);
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00005603#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005604 (void)opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, TRUE);
Bram Moolenaar165bc692015-07-21 17:53:25 +02005605 (void)opt_strings_flags(p_bo, p_bo_values, &bo_flags, TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005606#ifdef FEAT_SESSION
5607 (void)opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE);
5608 (void)opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE);
5609#endif
5610#ifdef FEAT_FOLDING
5611 (void)opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE);
5612#endif
5613 (void)opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE);
Bram Moolenaar0f6562e2015-11-24 18:48:14 +01005614 (void)opt_strings_flags(p_tc, p_tc_values, &tc_flags, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005615#ifdef FEAT_VIRTUALEDIT
5616 (void)opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE);
5617#endif
5618#if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
5619 (void)opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE);
5620#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005621#ifdef FEAT_SPELL
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00005622 (void)spell_check_msm();
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005623 (void)spell_check_sps();
Bram Moolenaar860cae12010-06-05 23:22:07 +02005624 (void)compile_cap_prog(curwin->w_s);
Bram Moolenaare68c25c2015-08-25 15:39:55 +02005625 (void)did_set_spell_option(TRUE);
Bram Moolenaard857f0e2005-06-21 22:37:39 +00005626#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005627#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
5628 (void)opt_strings_flags(p_toolbar, p_toolbar_values, &toolbar_flags, TRUE);
5629#endif
Bram Moolenaar182c5be2010-06-25 05:37:59 +02005630#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005631 (void)opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE);
5632#endif
5633#ifdef FEAT_CMDWIN
5634 /* set cedit_key */
5635 (void)check_cedit();
5636#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +02005637#ifdef FEAT_LINEBREAK
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02005638 briopt_check(curwin);
Bram Moolenaar597a4222014-06-25 14:39:50 +02005639#endif
Bram Moolenaare68c25c2015-08-25 15:39:55 +02005640#ifdef FEAT_LINEBREAK
5641 /* initialize the table for 'breakat'. */
5642 fill_breakat_flags();
5643#endif
5644
5645}
5646
5647/*
5648 * More side effects of setting options.
5649 */
5650 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005651didset_options2(void)
Bram Moolenaare68c25c2015-08-25 15:39:55 +02005652{
5653 /* Initialize the highlight_attr[] table. */
5654 (void)highlight_changed();
5655
5656 /* Parse default for 'wildmode' */
5657 check_opt_wim();
5658
5659 (void)set_chars_option(&p_lcs);
Bram Moolenaare68c25c2015-08-25 15:39:55 +02005660 /* Parse default for 'fillchars'. */
5661 (void)set_chars_option(&p_fcs);
Bram Moolenaare68c25c2015-08-25 15:39:55 +02005662
5663#ifdef FEAT_CLIPBOARD
5664 /* Parse default for 'clipboard' */
5665 (void)check_clipboard_option();
5666#endif
Bram Moolenaar04958cb2018-06-23 19:23:02 +02005667#ifdef FEAT_VARTABS
5668 tabstop_set(curbuf->b_p_vsts, &curbuf->b_p_vsts_array);
5669 tabstop_set(curbuf->b_p_vts, &curbuf->b_p_vts_array);
5670#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005671}
5672
5673/*
5674 * Check for string options that are NULL (normally only termcap options).
5675 */
5676 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005677check_options(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005678{
5679 int opt_idx;
5680
5681 for (opt_idx = 0; options[opt_idx].fullname != NULL; opt_idx++)
5682 if ((options[opt_idx].flags & P_STRING) && options[opt_idx].var != NULL)
5683 check_string_option((char_u **)get_varp(&(options[opt_idx])));
5684}
5685
5686/*
5687 * Check string options in a buffer for NULL value.
5688 */
5689 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005690check_buf_options(buf_T *buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005691{
Bram Moolenaar071d4272004-06-13 20:20:40 +00005692 check_string_option(&buf->b_p_bh);
5693 check_string_option(&buf->b_p_bt);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005694#ifdef FEAT_MBYTE
5695 check_string_option(&buf->b_p_fenc);
5696#endif
5697 check_string_option(&buf->b_p_ff);
5698#ifdef FEAT_FIND_ID
5699 check_string_option(&buf->b_p_def);
5700 check_string_option(&buf->b_p_inc);
5701# ifdef FEAT_EVAL
5702 check_string_option(&buf->b_p_inex);
5703# endif
5704#endif
5705#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
5706 check_string_option(&buf->b_p_inde);
5707 check_string_option(&buf->b_p_indk);
5708#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00005709#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
5710 check_string_option(&buf->b_p_bexpr);
5711#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +02005712#if defined(FEAT_CRYPT)
5713 check_string_option(&buf->b_p_cm);
5714#endif
Bram Moolenaar9be7c042017-01-14 14:28:30 +01005715 check_string_option(&buf->b_p_fp);
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00005716#if defined(FEAT_EVAL)
5717 check_string_option(&buf->b_p_fex);
5718#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005719#ifdef FEAT_CRYPT
5720 check_string_option(&buf->b_p_key);
5721#endif
5722 check_string_option(&buf->b_p_kp);
5723 check_string_option(&buf->b_p_mps);
5724 check_string_option(&buf->b_p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +00005725 check_string_option(&buf->b_p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005726 check_string_option(&buf->b_p_isk);
5727#ifdef FEAT_COMMENTS
5728 check_string_option(&buf->b_p_com);
5729#endif
5730#ifdef FEAT_FOLDING
5731 check_string_option(&buf->b_p_cms);
5732#endif
5733 check_string_option(&buf->b_p_nf);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005734#ifdef FEAT_TEXTOBJ
5735 check_string_option(&buf->b_p_qe);
5736#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005737#ifdef FEAT_SYN_HL
5738 check_string_option(&buf->b_p_syn);
Bram Moolenaarb8060fe2016-01-19 22:29:28 +01005739 check_string_option(&buf->b_s.b_syn_isk);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005740#endif
5741#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02005742 check_string_option(&buf->b_s.b_p_spc);
5743 check_string_option(&buf->b_s.b_p_spf);
5744 check_string_option(&buf->b_s.b_p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005745#endif
5746#ifdef FEAT_SEARCHPATH
5747 check_string_option(&buf->b_p_sua);
5748#endif
5749#ifdef FEAT_CINDENT
5750 check_string_option(&buf->b_p_cink);
5751 check_string_option(&buf->b_p_cino);
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01005752 parse_cino(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005753#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005754 check_string_option(&buf->b_p_ft);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005755#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
5756 check_string_option(&buf->b_p_cinw);
5757#endif
5758#ifdef FEAT_INS_EXPAND
5759 check_string_option(&buf->b_p_cpt);
5760#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005761#ifdef FEAT_COMPL_FUNC
5762 check_string_option(&buf->b_p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +00005763 check_string_option(&buf->b_p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005764#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005765#ifdef FEAT_KEYMAP
5766 check_string_option(&buf->b_p_keymap);
5767#endif
5768#ifdef FEAT_QUICKFIX
5769 check_string_option(&buf->b_p_gp);
5770 check_string_option(&buf->b_p_mp);
5771 check_string_option(&buf->b_p_efm);
5772#endif
5773 check_string_option(&buf->b_p_ep);
5774 check_string_option(&buf->b_p_path);
5775 check_string_option(&buf->b_p_tags);
Bram Moolenaar0f6562e2015-11-24 18:48:14 +01005776 check_string_option(&buf->b_p_tc);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005777#ifdef FEAT_INS_EXPAND
5778 check_string_option(&buf->b_p_dict);
5779 check_string_option(&buf->b_p_tsr);
5780#endif
Bram Moolenaaraf6c1312014-03-12 18:55:58 +01005781#ifdef FEAT_LISP
5782 check_string_option(&buf->b_p_lw);
5783#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02005784 check_string_option(&buf->b_p_bkc);
Bram Moolenaar2c7292d2017-03-05 17:43:31 +01005785#ifdef FEAT_MBYTE
5786 check_string_option(&buf->b_p_menc);
5787#endif
Bram Moolenaar04958cb2018-06-23 19:23:02 +02005788#ifdef FEAT_VARTABS
5789 check_string_option(&buf->b_p_vsts);
5790 check_string_option(&buf->b_p_vts);
5791#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005792}
5793
5794/*
5795 * Free the string allocated for an option.
5796 * Checks for the string being empty_option. This may happen if we're out of
5797 * memory, vim_strsave() returned NULL, which was replaced by empty_option by
5798 * check_options().
5799 * Does NOT check for P_ALLOCED flag!
5800 */
5801 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005802free_string_option(char_u *p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005803{
5804 if (p != empty_option)
5805 vim_free(p);
5806}
5807
5808 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005809clear_string_option(char_u **pp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005810{
5811 if (*pp != empty_option)
5812 vim_free(*pp);
5813 *pp = empty_option;
5814}
5815
5816 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005817check_string_option(char_u **pp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005818{
5819 if (*pp == NULL)
5820 *pp = empty_option;
5821}
5822
5823/*
Bram Moolenaar35bc7d62018-10-02 14:45:10 +02005824 * Return the option index found by a pointer into term_strings[].
5825 * Return -1 if not found.
Bram Moolenaar071d4272004-06-13 20:20:40 +00005826 */
Bram Moolenaar35bc7d62018-10-02 14:45:10 +02005827 int
5828get_term_opt_idx(char_u **p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005829{
Bram Moolenaar35bc7d62018-10-02 14:45:10 +02005830 int opt_idx;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005831
5832 for (opt_idx = 1; options[opt_idx].fullname != NULL; opt_idx++)
5833 if (options[opt_idx].var == (char_u *)p)
Bram Moolenaar35bc7d62018-10-02 14:45:10 +02005834 return opt_idx;
5835 return -1; // cannot happen: didn't find it!
5836}
5837
5838/*
5839 * Mark a terminal option as allocated, found by a pointer into term_strings[].
5840 * Return the option index or -1 if not found.
5841 */
5842 int
5843set_term_option_alloced(char_u **p)
5844{
5845 int opt_idx = get_term_opt_idx(p);
5846
5847 if (opt_idx >= 0)
5848 options[opt_idx].flags |= P_ALLOCED;
5849 return opt_idx;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005850}
5851
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005852#if defined(FEAT_EVAL) || defined(PROTO)
5853/*
5854 * Return TRUE when option "opt" was set from a modeline or in secure mode.
5855 * Return FALSE when it wasn't.
5856 * Return -1 for an unknown option.
5857 */
5858 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01005859was_set_insecurely(char_u *opt, int opt_flags)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005860{
5861 int idx = findoption(opt);
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005862 long_u *flagp;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005863
5864 if (idx >= 0)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005865 {
5866 flagp = insecure_flag(idx, opt_flags);
5867 return (*flagp & P_INSECURE) != 0;
5868 }
Bram Moolenaar95f09602016-11-10 20:01:45 +01005869 internal_error("was_set_insecurely()");
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005870 return -1;
5871}
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005872
5873/*
5874 * Get a pointer to the flags used for the P_INSECURE flag of option
5875 * "opt_idx". For some local options a local flags field is used.
5876 */
5877 static long_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005878insecure_flag(int opt_idx, int opt_flags)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005879{
5880 if (opt_flags & OPT_LOCAL)
5881 switch ((int)options[opt_idx].indir)
5882 {
5883#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005884 case PV_STL: return &curwin->w_p_stl_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005885#endif
5886#ifdef FEAT_EVAL
Bram Moolenaar2e978902006-05-13 12:37:50 +00005887# ifdef FEAT_FOLDING
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005888 case PV_FDE: return &curwin->w_p_fde_flags;
5889 case PV_FDT: return &curwin->w_p_fdt_flags;
Bram Moolenaar2e978902006-05-13 12:37:50 +00005890# endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00005891# ifdef FEAT_BEVAL
5892 case PV_BEXPR: return &curbuf->b_p_bexpr_flags;
5893# endif
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005894# if defined(FEAT_CINDENT)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005895 case PV_INDE: return &curbuf->b_p_inde_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005896# endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005897 case PV_FEX: return &curbuf->b_p_fex_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005898# ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005899 case PV_INEX: return &curbuf->b_p_inex_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005900# endif
5901#endif
5902 }
5903
5904 /* Nothing special, return global flags field. */
5905 return &options[opt_idx].flags;
5906}
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005907#endif
5908
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005909#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005910/*
5911 * Redraw the window title and/or tab page text later.
5912 */
Bram Moolenaar9b578142016-01-30 19:39:49 +01005913static void redraw_titles(void)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005914{
5915 need_maketitle = TRUE;
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005916 redraw_tabline = TRUE;
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005917}
5918#endif
5919
Bram Moolenaar071d4272004-06-13 20:20:40 +00005920/*
5921 * Set a string option to a new value (without checking the effect).
5922 * The string is copied into allocated memory.
5923 * if ("opt_idx" == -1) "name" is used, otherwise "opt_idx" is used.
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02005924 * When "set_sid" is zero set the scriptID to current_sctx.sc_sid. When
5925 * "set_sid" is SID_NONE don't set the scriptID. Otherwise set the scriptID to
5926 * "set_sid".
Bram Moolenaar071d4272004-06-13 20:20:40 +00005927 */
5928 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005929set_string_option_direct(
5930 char_u *name,
5931 int opt_idx,
5932 char_u *val,
5933 int opt_flags, /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
5934 int set_sid UNUSED)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005935{
5936 char_u *s;
5937 char_u **varp;
5938 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
Bram Moolenaar89d40322006-08-29 15:30:07 +00005939 int idx = opt_idx;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005940
Bram Moolenaar89d40322006-08-29 15:30:07 +00005941 if (idx == -1) /* use name */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005942 {
Bram Moolenaar89d40322006-08-29 15:30:07 +00005943 idx = findoption(name);
5944 if (idx < 0) /* not found (should not happen) */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005945 {
5946 EMSG2(_(e_intern2), "set_string_option_direct()");
Bram Moolenaar95f09602016-11-10 20:01:45 +01005947 IEMSG2(_("For option %s"), name);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005948 return;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005949 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005950 }
5951
Bram Moolenaar89d40322006-08-29 15:30:07 +00005952 if (options[idx].var == NULL) /* can't set hidden option */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005953 return;
5954
5955 s = vim_strsave(val);
5956 if (s != NULL)
5957 {
Bram Moolenaar89d40322006-08-29 15:30:07 +00005958 varp = (char_u **)get_varp_scope(&(options[idx]),
Bram Moolenaar071d4272004-06-13 20:20:40 +00005959 both ? OPT_LOCAL : opt_flags);
Bram Moolenaar89d40322006-08-29 15:30:07 +00005960 if ((opt_flags & OPT_FREE) && (options[idx].flags & P_ALLOCED))
Bram Moolenaar071d4272004-06-13 20:20:40 +00005961 free_string_option(*varp);
5962 *varp = s;
5963
5964 /* For buffer/window local option may also set the global value. */
5965 if (both)
Bram Moolenaar89d40322006-08-29 15:30:07 +00005966 set_string_option_global(idx, varp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005967
Bram Moolenaar89d40322006-08-29 15:30:07 +00005968 options[idx].flags |= P_ALLOCED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005969
5970 /* When setting both values of a global option with a local value,
5971 * make the local value empty, so that the global value is used. */
Bram Moolenaar89d40322006-08-29 15:30:07 +00005972 if (((int)options[idx].indir & PV_BOTH) && both)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005973 {
5974 free_string_option(*varp);
5975 *varp = empty_option;
5976 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005977# ifdef FEAT_EVAL
5978 if (set_sid != SID_NONE)
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02005979 {
5980 sctx_T script_ctx;
5981
5982 if (set_sid == 0)
5983 script_ctx = current_sctx;
5984 else
5985 {
5986 script_ctx.sc_sid = set_sid;
Bram Moolenaarded5f1b2018-11-10 17:33:29 +01005987 script_ctx.sc_seq = 0;
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02005988 script_ctx.sc_lnum = 0;
5989 }
5990 set_option_sctx_idx(idx, opt_flags, script_ctx);
5991 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005992# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005993 }
5994}
5995
5996/*
5997 * Set global value for string option when it's a local option.
5998 */
5999 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01006000set_string_option_global(
6001 int opt_idx, /* option index */
6002 char_u **varp) /* pointer to option variable */
Bram Moolenaar071d4272004-06-13 20:20:40 +00006003{
6004 char_u **p, *s;
6005
6006 /* the global value is always allocated */
6007 if (options[opt_idx].var == VAR_WIN)
6008 p = (char_u **)GLOBAL_WO(varp);
6009 else
6010 p = (char_u **)options[opt_idx].var;
6011 if (options[opt_idx].indir != PV_NONE
6012 && p != varp
6013 && (s = vim_strsave(*varp)) != NULL)
6014 {
6015 free_string_option(*p);
6016 *p = s;
6017 }
6018}
6019
6020/*
6021 * Set a string option to a new value, and handle the effects.
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02006022 *
6023 * Returns NULL on success or error message on error.
Bram Moolenaar071d4272004-06-13 20:20:40 +00006024 */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02006025 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01006026set_string_option(
6027 int opt_idx,
6028 char_u *value,
6029 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00006030{
6031 char_u *s;
6032 char_u **varp;
6033 char_u *oldval;
Bram Moolenaarf2bd8ef2018-03-04 18:08:14 +01006034#if defined(FEAT_EVAL)
Bram Moolenaar53744302015-07-17 17:38:22 +02006035 char_u *saved_oldval = NULL;
Bram Moolenaar182a17b2017-06-25 20:57:18 +02006036 char_u *saved_newval = NULL;
Bram Moolenaar53744302015-07-17 17:38:22 +02006037#endif
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02006038 char_u *r = NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006039
6040 if (options[opt_idx].var == NULL) /* don't set hidden option */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02006041 return NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006042
6043 s = vim_strsave(value);
6044 if (s != NULL)
6045 {
6046 varp = (char_u **)get_varp_scope(&(options[opt_idx]),
6047 (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00006048 ? (((int)options[opt_idx].indir & PV_BOTH)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006049 ? OPT_GLOBAL : OPT_LOCAL)
6050 : opt_flags);
6051 oldval = *varp;
6052 *varp = s;
Bram Moolenaar53744302015-07-17 17:38:22 +02006053
Bram Moolenaarf2bd8ef2018-03-04 18:08:14 +01006054#if defined(FEAT_EVAL)
Bram Moolenaar5cbb8db2015-07-17 23:08:29 +02006055 if (!starting
6056# ifdef FEAT_CRYPT
6057 && options[opt_idx].indir != PV_KEY
6058# endif
6059 )
Bram Moolenaar182a17b2017-06-25 20:57:18 +02006060 {
Bram Moolenaar53744302015-07-17 17:38:22 +02006061 saved_oldval = vim_strsave(oldval);
Bram Moolenaar182a17b2017-06-25 20:57:18 +02006062 saved_newval = vim_strsave(s);
6063 }
Bram Moolenaar53744302015-07-17 17:38:22 +02006064#endif
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02006065 if ((r = did_set_string_option(opt_idx, varp, TRUE, oldval, NULL,
6066 opt_flags)) == NULL)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00006067 did_set_option(opt_idx, opt_flags, TRUE);
Bram Moolenaar53744302015-07-17 17:38:22 +02006068
Bram Moolenaarf2bd8ef2018-03-04 18:08:14 +01006069#if defined(FEAT_EVAL)
Bram Moolenaar182a17b2017-06-25 20:57:18 +02006070 /* call autocommand after handling side effects */
Bram Moolenaar8efa0262017-08-20 15:47:20 +02006071 if (r == NULL)
6072 trigger_optionsset_string(opt_idx, opt_flags,
Bram Moolenaar182a17b2017-06-25 20:57:18 +02006073 saved_oldval, saved_newval);
Bram Moolenaar8efa0262017-08-20 15:47:20 +02006074 vim_free(saved_oldval);
6075 vim_free(saved_newval);
Bram Moolenaar53744302015-07-17 17:38:22 +02006076#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006077 }
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02006078 return r;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006079}
6080
6081/*
Bram Moolenaard0b51382016-11-04 15:23:45 +01006082 * Return TRUE if "val" is a valid 'filetype' name.
6083 * Also used for 'syntax' and 'keymap'.
6084 */
6085 static int
6086valid_filetype(char_u *val)
6087{
6088 char_u *s;
6089
6090 for (s = val; *s != NUL; ++s)
6091 if (!ASCII_ISALNUM(*s) && vim_strchr((char_u *)".-_", *s) == NULL)
6092 return FALSE;
6093 return TRUE;
6094}
6095
6096/*
Bram Moolenaar071d4272004-06-13 20:20:40 +00006097 * Handle string options that need some action to perform when changed.
6098 * Returns NULL for success, or an error message for an error.
6099 */
6100 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01006101did_set_string_option(
6102 int opt_idx, /* index in options[] table */
6103 char_u **varp, /* pointer to the option variable */
6104 int new_value_alloced, /* new value was allocated */
6105 char_u *oldval, /* previous value of the option */
6106 char_u *errbuf, /* buffer for errors, or NULL */
6107 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00006108{
6109 char_u *errmsg = NULL;
6110 char_u *s, *p;
6111 int did_chartab = FALSE;
6112 char_u **gvarp;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00006113 long_u free_oldval = (options[opt_idx].flags & P_ALLOCED);
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006114#ifdef FEAT_GUI
6115 /* set when changing an option that only requires a redraw in the GUI */
6116 int redraw_gui_only = FALSE;
6117#endif
Bram Moolenaarc3ffc9b2018-06-17 17:32:58 +02006118 int value_changed = FALSE;
Bram Moolenaarc5cd8852018-05-01 15:47:38 +02006119#if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS)
6120 int did_swaptcap = FALSE;
6121#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006122
6123 /* Get the global option to compare with, otherwise we would have to check
6124 * two values for all local options. */
6125 gvarp = (char_u **)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL);
6126
6127 /* Disallow changing some options from secure mode */
6128 if ((secure
6129#ifdef HAVE_SANDBOX
6130 || sandbox != 0
6131#endif
6132 ) && (options[opt_idx].flags & P_SECURE))
6133 {
6134 errmsg = e_secure;
6135 }
6136
Bram Moolenaar7554da42016-11-25 22:04:13 +01006137 /* Check for a "normal" directory or file name in some options. Disallow a
6138 * path separator (slash and/or backslash), wildcards and characters that
Bram Moolenaar0945eaf2016-11-29 22:10:48 +01006139 * are often illegal in a file name. Be more permissive if "secure" is off.
6140 */
Bram Moolenaar7554da42016-11-25 22:04:13 +01006141 else if (((options[opt_idx].flags & P_NFNAME)
Bram Moolenaar0945eaf2016-11-29 22:10:48 +01006142 && vim_strpbrk(*varp, (char_u *)(secure
6143 ? "/\\*?[|;&<>\r\n" : "/\\*?[<>\r\n")) != NULL)
Bram Moolenaar7554da42016-11-25 22:04:13 +01006144 || ((options[opt_idx].flags & P_NDNAME)
6145 && vim_strpbrk(*varp, (char_u *)"*?[|;&<>\r\n") != NULL))
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00006146 {
6147 errmsg = e_invarg;
6148 }
6149
Bram Moolenaar071d4272004-06-13 20:20:40 +00006150 /* 'term' */
6151 else if (varp == &T_NAME)
6152 {
6153 if (T_NAME[0] == NUL)
6154 errmsg = (char_u *)N_("E529: Cannot set 'term' to empty string");
6155#ifdef FEAT_GUI
6156 if (gui.in_use)
6157 errmsg = (char_u *)N_("E530: Cannot change term in GUI");
6158 else if (term_is_gui(T_NAME))
6159 errmsg = (char_u *)N_("E531: Use \":gui\" to start the GUI");
6160#endif
6161 else if (set_termname(T_NAME) == FAIL)
6162 errmsg = (char_u *)N_("E522: Not found in termcap");
6163 else
Bram Moolenaar67391142017-02-19 21:07:04 +01006164 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00006165 /* Screen colors may have changed. */
6166 redraw_later_clear();
Bram Moolenaar67391142017-02-19 21:07:04 +01006167
6168 /* Both 'term' and 'ttytype' point to T_NAME, only set the
6169 * P_ALLOCED flag on 'term'. */
6170 opt_idx = findoption((char_u *)"term");
Bram Moolenaar354796c2017-02-23 17:18:37 +01006171 free_oldval = (options[opt_idx].flags & P_ALLOCED);
Bram Moolenaar67391142017-02-19 21:07:04 +01006172 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006173 }
6174
6175 /* 'backupcopy' */
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02006176 else if (gvarp == &p_bkc)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006177 {
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02006178 char_u *bkc = p_bkc;
6179 unsigned int *flags = &bkc_flags;
6180
6181 if (opt_flags & OPT_LOCAL)
6182 {
6183 bkc = curbuf->b_p_bkc;
6184 flags = &curbuf->b_bkc_flags;
6185 }
6186
Bram Moolenaar84d17a62014-09-29 17:15:18 +02006187 if ((opt_flags & OPT_LOCAL) && *bkc == NUL)
6188 /* make the local value empty: use the global value */
6189 *flags = 0;
6190 else
Bram Moolenaar071d4272004-06-13 20:20:40 +00006191 {
Bram Moolenaar84d17a62014-09-29 17:15:18 +02006192 if (opt_strings_flags(bkc, p_bkc_values, flags, TRUE) != OK)
6193 errmsg = e_invarg;
6194 if ((((int)*flags & BKC_AUTO) != 0)
6195 + (((int)*flags & BKC_YES) != 0)
6196 + (((int)*flags & BKC_NO) != 0) != 1)
6197 {
6198 /* Must have exactly one of "auto", "yes" and "no". */
6199 (void)opt_strings_flags(oldval, p_bkc_values, flags, TRUE);
6200 errmsg = e_invarg;
6201 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006202 }
6203 }
6204
6205 /* 'backupext' and 'patchmode' */
6206 else if (varp == &p_bex || varp == &p_pm)
6207 {
6208 if (STRCMP(*p_bex == '.' ? p_bex + 1 : p_bex,
6209 *p_pm == '.' ? p_pm + 1 : p_pm) == 0)
6210 errmsg = (char_u *)N_("E589: 'backupext' and 'patchmode' are equal");
6211 }
Bram Moolenaar597a4222014-06-25 14:39:50 +02006212#ifdef FEAT_LINEBREAK
6213 /* 'breakindentopt' */
6214 else if (varp == &curwin->w_p_briopt)
6215 {
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02006216 if (briopt_check(curwin) == FAIL)
Bram Moolenaar597a4222014-06-25 14:39:50 +02006217 errmsg = e_invarg;
6218 }
6219#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006220
6221 /*
Bram Moolenaar88e8f9f2016-01-20 22:48:02 +01006222 * 'isident', 'iskeyword', 'isprint or 'isfname' option: refill g_chartab[]
Bram Moolenaar071d4272004-06-13 20:20:40 +00006223 * If the new option is invalid, use old value. 'lisp' option: refill
Bram Moolenaar88e8f9f2016-01-20 22:48:02 +01006224 * g_chartab[] for '-' char
Bram Moolenaar071d4272004-06-13 20:20:40 +00006225 */
6226 else if ( varp == &p_isi
6227 || varp == &(curbuf->b_p_isk)
6228 || varp == &p_isp
6229 || varp == &p_isf)
6230 {
6231 if (init_chartab() == FAIL)
6232 {
6233 did_chartab = TRUE; /* need to restore it below */
6234 errmsg = e_invarg; /* error in value */
6235 }
6236 }
6237
6238 /* 'helpfile' */
6239 else if (varp == &p_hf)
6240 {
6241 /* May compute new values for $VIM and $VIMRUNTIME */
6242 if (didset_vim)
6243 {
6244 vim_setenv((char_u *)"VIM", (char_u *)"");
6245 didset_vim = FALSE;
6246 }
6247 if (didset_vimruntime)
6248 {
6249 vim_setenv((char_u *)"VIMRUNTIME", (char_u *)"");
6250 didset_vimruntime = FALSE;
6251 }
6252 }
6253
Bram Moolenaar1a384422010-07-14 19:53:30 +02006254#ifdef FEAT_SYN_HL
6255 /* 'colorcolumn' */
6256 else if (varp == &curwin->w_p_cc)
6257 errmsg = check_colorcolumn(curwin);
6258#endif
6259
Bram Moolenaar071d4272004-06-13 20:20:40 +00006260#ifdef FEAT_MULTI_LANG
6261 /* 'helplang' */
6262 else if (varp == &p_hlg)
6263 {
6264 /* Check for "", "ab", "ab,cd", etc. */
6265 for (s = p_hlg; *s != NUL; s += 3)
6266 {
6267 if (s[1] == NUL || ((s[2] != ',' || s[3] == NUL) && s[2] != NUL))
6268 {
6269 errmsg = e_invarg;
6270 break;
6271 }
6272 if (s[2] == NUL)
6273 break;
6274 }
6275 }
6276#endif
6277
6278 /* 'highlight' */
6279 else if (varp == &p_hl)
6280 {
6281 if (highlight_changed() == FAIL)
6282 errmsg = e_invarg; /* invalid flags */
6283 }
6284
6285 /* 'nrformats' */
6286 else if (gvarp == &p_nf)
6287 {
6288 if (check_opt_strings(*varp, p_nf_values, TRUE) != OK)
6289 errmsg = e_invarg;
6290 }
6291
6292#ifdef FEAT_SESSION
6293 /* 'sessionoptions' */
6294 else if (varp == &p_ssop)
6295 {
6296 if (opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE) != OK)
6297 errmsg = e_invarg;
6298 if ((ssop_flags & SSOP_CURDIR) && (ssop_flags & SSOP_SESDIR))
6299 {
6300 /* Don't allow both "sesdir" and "curdir". */
6301 (void)opt_strings_flags(oldval, p_ssop_values, &ssop_flags, TRUE);
6302 errmsg = e_invarg;
6303 }
6304 }
6305 /* 'viewoptions' */
6306 else if (varp == &p_vop)
6307 {
6308 if (opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE) != OK)
6309 errmsg = e_invarg;
6310 }
6311#endif
6312
6313 /* 'scrollopt' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00006314 else if (varp == &p_sbo)
6315 {
6316 if (check_opt_strings(p_sbo, p_scbopt_values, TRUE) != OK)
6317 errmsg = e_invarg;
6318 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006319
6320 /* 'ambiwidth' */
6321#ifdef FEAT_MBYTE
Bram Moolenaar3848e002016-03-19 18:42:29 +01006322 else if (varp == &p_ambw || varp == &p_emoji)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006323 {
6324 if (check_opt_strings(p_ambw, p_ambw_values, FALSE) != OK)
6325 errmsg = e_invarg;
Bram Moolenaar5c3bd0a2010-08-04 20:55:44 +02006326 else if (set_chars_option(&p_lcs) != NULL)
6327 errmsg = (char_u *)_("E834: Conflicts with value of 'listchars'");
Bram Moolenaar5c3bd0a2010-08-04 20:55:44 +02006328 else if (set_chars_option(&p_fcs) != NULL)
6329 errmsg = (char_u *)_("E835: Conflicts with value of 'fillchars'");
Bram Moolenaar071d4272004-06-13 20:20:40 +00006330 }
6331#endif
6332
6333 /* 'background' */
6334 else if (varp == &p_bg)
6335 {
6336 if (check_opt_strings(p_bg, p_bg_values, FALSE) == OK)
6337 {
6338#ifdef FEAT_EVAL
6339 int dark = (*p_bg == 'd');
6340#endif
6341
6342 init_highlight(FALSE, FALSE);
6343
6344#ifdef FEAT_EVAL
6345 if (dark != (*p_bg == 'd')
6346 && get_var_value((char_u *)"g:colors_name") != NULL)
6347 {
6348 /* The color scheme must have set 'background' back to another
6349 * value, that's not what we want here. Disable the color
6350 * scheme and set the colors again. */
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00006351 do_unlet((char_u *)"g:colors_name", TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006352 free_string_option(p_bg);
6353 p_bg = vim_strsave((char_u *)(dark ? "dark" : "light"));
6354 check_string_option(&p_bg);
6355 init_highlight(FALSE, FALSE);
6356 }
6357#endif
6358 }
6359 else
6360 errmsg = e_invarg;
6361 }
6362
6363 /* 'wildmode' */
6364 else if (varp == &p_wim)
6365 {
6366 if (check_opt_wim() == FAIL)
6367 errmsg = e_invarg;
6368 }
6369
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00006370#ifdef FEAT_CMDL_COMPL
6371 /* 'wildoptions' */
6372 else if (varp == &p_wop)
6373 {
6374 if (check_opt_strings(p_wop, p_wop_values, TRUE) != OK)
6375 errmsg = e_invarg;
6376 }
6377#endif
6378
Bram Moolenaar071d4272004-06-13 20:20:40 +00006379#ifdef FEAT_WAK
6380 /* 'winaltkeys' */
6381 else if (varp == &p_wak)
6382 {
6383 if (*p_wak == NUL
6384 || check_opt_strings(p_wak, p_wak_values, FALSE) != OK)
6385 errmsg = e_invarg;
6386# ifdef FEAT_MENU
6387# ifdef FEAT_GUI_MOTIF
6388 else if (gui.in_use)
6389 gui_motif_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
6390# else
6391# ifdef FEAT_GUI_GTK
6392 else if (gui.in_use)
6393 gui_gtk_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
6394# endif
6395# endif
6396# endif
6397 }
6398#endif
6399
Bram Moolenaar071d4272004-06-13 20:20:40 +00006400 /* 'eventignore' */
6401 else if (varp == &p_ei)
6402 {
6403 if (check_ei() == FAIL)
6404 errmsg = e_invarg;
6405 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006406
6407#ifdef FEAT_MBYTE
Bram Moolenaar2c7292d2017-03-05 17:43:31 +01006408 /* 'encoding', 'fileencoding', 'termencoding' and 'makeencoding' */
6409 else if (varp == &p_enc || gvarp == &p_fenc || varp == &p_tenc
6410 || gvarp == &p_menc)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006411 {
6412 if (gvarp == &p_fenc)
6413 {
Bram Moolenaarf2f70252008-02-13 17:36:06 +00006414 if (!curbuf->b_p_ma && opt_flags != OPT_GLOBAL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006415 errmsg = e_modifiable;
6416 else if (vim_strchr(*varp, ',') != NULL)
6417 /* No comma allowed in 'fileencoding'; catches confusing it
6418 * with 'fileencodings'. */
6419 errmsg = e_invarg;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006420 else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006421 {
6422# ifdef FEAT_TITLE
Bram Moolenaar071d4272004-06-13 20:20:40 +00006423 /* May show a "+" in the title now. */
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006424 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006425# endif
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006426 /* Add 'fileencoding' to the swap file. */
6427 ml_setflags(curbuf);
6428 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006429 }
6430 if (errmsg == NULL)
6431 {
6432 /* canonize the value, so that STRCMP() can be used on it */
6433 p = enc_canonize(*varp);
6434 if (p != NULL)
6435 {
6436 vim_free(*varp);
6437 *varp = p;
6438 }
6439 if (varp == &p_enc)
6440 {
6441 errmsg = mb_init();
6442# ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006443 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006444# endif
6445 }
6446 }
6447
Bram Moolenaar182c5be2010-06-25 05:37:59 +02006448# if defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006449 if (errmsg == NULL && varp == &p_tenc && gui.in_use)
6450 {
6451 /* GTK+ 2 uses only a single encoding, and that is UTF-8. */
6452 if (STRCMP(p_tenc, "utf-8") != 0)
6453 errmsg = (char_u *)N_("E617: Cannot be changed in the GTK+ 2 GUI");
6454 }
6455# endif
6456
6457 if (errmsg == NULL)
6458 {
6459# ifdef FEAT_KEYMAP
6460 /* When 'keymap' is used and 'encoding' changes, reload the keymap
6461 * (with another encoding). */
6462 if (varp == &p_enc && *curbuf->b_p_keymap != NUL)
6463 (void)keymap_init();
6464# endif
6465
6466 /* When 'termencoding' is not empty and 'encoding' changes or when
6467 * 'termencoding' changes, need to setup for keyboard input and
6468 * display output conversion. */
6469 if (((varp == &p_enc && *p_tenc != NUL) || varp == &p_tenc))
6470 {
Bram Moolenaar17471e82017-11-26 23:47:18 +01006471 if (convert_setup(&input_conv, p_tenc, p_enc) == FAIL
6472 || convert_setup(&output_conv, p_enc, p_tenc) == FAIL)
6473 {
6474 EMSG3(_("E950: Cannot convert between %s and %s"),
6475 p_tenc, p_enc);
6476 errmsg = e_invarg;
6477 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006478 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00006479
6480# if defined(WIN3264) && defined(FEAT_MBYTE)
6481 /* $HOME may have characters in active code page. */
6482 if (varp == &p_enc)
6483 init_homedir();
6484# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006485 }
6486 }
6487#endif
6488
6489#if defined(FEAT_POSTSCRIPT)
6490 else if (varp == &p_penc)
6491 {
6492 /* Canonize printencoding if VIM standard one */
6493 p = enc_canonize(p_penc);
6494 if (p != NULL)
6495 {
6496 vim_free(p_penc);
6497 p_penc = p;
6498 }
6499 else
6500 {
6501 /* Ensure lower case and '-' for '_' */
6502 for (s = p_penc; *s != NUL; s++)
6503 {
6504 if (*s == '_')
6505 *s = '-';
6506 else
6507 *s = TOLOWER_ASC(*s);
6508 }
6509 }
6510 }
6511#endif
6512
Bram Moolenaar9372a112005-12-06 19:59:18 +00006513#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006514 else if (varp == &p_imak)
6515 {
Bram Moolenaar86e57922017-04-23 18:44:26 +02006516 if (!im_xim_isvalid_imactivate())
Bram Moolenaar071d4272004-06-13 20:20:40 +00006517 errmsg = e_invarg;
6518 }
6519#endif
6520
6521#ifdef FEAT_KEYMAP
6522 else if (varp == &curbuf->b_p_keymap)
6523 {
Bram Moolenaard0b51382016-11-04 15:23:45 +01006524 if (!valid_filetype(*varp))
6525 errmsg = e_invarg;
6526 else
6527 /* load or unload key mapping tables */
6528 errmsg = keymap_init();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006529
Bram Moolenaarfab06232009-03-04 03:13:35 +00006530 if (errmsg == NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006531 {
Bram Moolenaarfab06232009-03-04 03:13:35 +00006532 if (*curbuf->b_p_keymap != NUL)
6533 {
6534 /* Installed a new keymap, switch on using it. */
6535 curbuf->b_p_iminsert = B_IMODE_LMAP;
6536 if (curbuf->b_p_imsearch != B_IMODE_USE_INSERT)
6537 curbuf->b_p_imsearch = B_IMODE_LMAP;
6538 }
6539 else
6540 {
6541 /* Cleared the keymap, may reset 'iminsert' and 'imsearch'. */
6542 if (curbuf->b_p_iminsert == B_IMODE_LMAP)
6543 curbuf->b_p_iminsert = B_IMODE_NONE;
6544 if (curbuf->b_p_imsearch == B_IMODE_LMAP)
6545 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
6546 }
6547 if ((opt_flags & OPT_LOCAL) == 0)
6548 {
6549 set_iminsert_global();
6550 set_imsearch_global();
6551 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006552 status_redraw_curbuf();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006553 }
6554 }
6555#endif
6556
6557 /* 'fileformat' */
6558 else if (gvarp == &p_ff)
6559 {
6560 if (!curbuf->b_p_ma && !(opt_flags & OPT_GLOBAL))
6561 errmsg = e_modifiable;
6562 else if (check_opt_strings(*varp, p_ff_values, FALSE) != OK)
6563 errmsg = e_invarg;
6564 else
6565 {
6566 /* may also change 'textmode' */
6567 if (get_fileformat(curbuf) == EOL_DOS)
6568 curbuf->b_p_tx = TRUE;
6569 else
6570 curbuf->b_p_tx = FALSE;
6571#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006572 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006573#endif
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006574 /* update flag in swap file */
6575 ml_setflags(curbuf);
Bram Moolenaar0413d482010-02-11 17:02:11 +01006576 /* Redraw needed when switching to/from "mac": a CR in the text
6577 * will be displayed differently. */
6578 if (get_fileformat(curbuf) == EOL_MAC || *oldval == 'm')
6579 redraw_curbuf_later(NOT_VALID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006580 }
6581 }
6582
6583 /* 'fileformats' */
6584 else if (varp == &p_ffs)
6585 {
6586 if (check_opt_strings(p_ffs, p_ff_values, TRUE) != OK)
6587 errmsg = e_invarg;
6588 else
6589 {
6590 /* also change 'textauto' */
6591 if (*p_ffs == NUL)
6592 p_ta = FALSE;
6593 else
6594 p_ta = TRUE;
6595 }
6596 }
6597
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006598#if defined(FEAT_CRYPT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006599 /* 'cryptkey' */
6600 else if (gvarp == &p_key)
6601 {
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006602# if defined(FEAT_CMDHIST)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006603 /* Make sure the ":set" command doesn't show the new value in the
6604 * history. */
6605 remove_key_from_history();
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006606# endif
6607 if (STRCMP(curbuf->b_p_key, oldval) != 0)
6608 /* Need to update the swapfile. */
Bram Moolenaarbc563362015-06-09 18:35:25 +02006609 ml_set_crypt_key(curbuf, oldval,
6610 *curbuf->b_p_cm == NUL ? p_cm : curbuf->b_p_cm);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006611 }
6612
6613 else if (gvarp == &p_cm)
6614 {
6615 if (opt_flags & OPT_LOCAL)
6616 p = curbuf->b_p_cm;
6617 else
6618 p = p_cm;
6619 if (check_opt_strings(p, p_cm_values, TRUE) != OK)
6620 errmsg = e_invarg;
Bram Moolenaar8f4ac012014-08-10 13:38:34 +02006621 else if (crypt_self_test() == FAIL)
Bram Moolenaar49771f42010-07-20 17:32:38 +02006622 errmsg = e_invarg;
6623 else
6624 {
6625 /* When setting the global value to empty, make it "zip". */
6626 if (*p_cm == NUL)
6627 {
6628 if (new_value_alloced)
6629 free_string_option(p_cm);
6630 p_cm = vim_strsave((char_u *)"zip");
6631 new_value_alloced = TRUE;
6632 }
Bram Moolenaar2be79502014-08-13 21:58:28 +02006633 /* When using ":set cm=name" the local value is going to be empty.
6634 * Do that here, otherwise the crypt functions will still use the
6635 * local value. */
6636 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
6637 {
6638 free_string_option(curbuf->b_p_cm);
6639 curbuf->b_p_cm = empty_option;
6640 }
Bram Moolenaar49771f42010-07-20 17:32:38 +02006641
6642 /* Need to update the swapfile when the effective method changed.
6643 * Set "s" to the effective old value, "p" to the effective new
6644 * method and compare. */
6645 if ((opt_flags & OPT_LOCAL) && *oldval == NUL)
6646 s = p_cm; /* was previously using the global value */
6647 else
6648 s = oldval;
6649 if (*curbuf->b_p_cm == NUL)
6650 p = p_cm; /* is now using the global value */
6651 else
6652 p = curbuf->b_p_cm;
6653 if (STRCMP(s, p) != 0)
Bram Moolenaarbc563362015-06-09 18:35:25 +02006654 ml_set_crypt_key(curbuf, curbuf->b_p_key, s);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006655
6656 /* If the global value changes need to update the swapfile for all
6657 * buffers using that value. */
6658 if ((opt_flags & OPT_GLOBAL) && STRCMP(p_cm, oldval) != 0)
6659 {
6660 buf_T *buf;
6661
Bram Moolenaar29323592016-07-24 22:04:11 +02006662 FOR_ALL_BUFFERS(buf)
Bram Moolenaar49771f42010-07-20 17:32:38 +02006663 if (buf != curbuf && *buf->b_p_cm == NUL)
Bram Moolenaarbc563362015-06-09 18:35:25 +02006664 ml_set_crypt_key(buf, buf->b_p_key, oldval);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006665 }
6666 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006667 }
6668#endif
6669
6670 /* 'matchpairs' */
6671 else if (gvarp == &p_mps)
6672 {
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006673#ifdef FEAT_MBYTE
6674 if (has_mbyte)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006675 {
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006676 for (p = *varp; *p != NUL; ++p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006677 {
Bram Moolenaar09365022013-01-17 17:37:35 +01006678 int x2 = -1;
6679 int x3 = -1;
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006680
6681 if (*p != NUL)
6682 p += mb_ptr2len(p);
6683 if (*p != NUL)
6684 x2 = *p++;
6685 if (*p != NUL)
6686 {
6687 x3 = mb_ptr2char(p);
6688 p += mb_ptr2len(p);
6689 }
Bram Moolenaar09365022013-01-17 17:37:35 +01006690 if (x2 != ':' || x3 == -1 || (*p != NUL && *p != ','))
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006691 {
6692 errmsg = e_invarg;
6693 break;
6694 }
6695 if (*p == NUL)
6696 break;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006697 }
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006698 }
6699 else
6700#endif
6701 {
6702 /* Check for "x:y,x:y" */
6703 for (p = *varp; *p != NUL; p += 4)
6704 {
6705 if (p[1] != ':' || p[2] == NUL || (p[3] != NUL && p[3] != ','))
6706 {
6707 errmsg = e_invarg;
6708 break;
6709 }
6710 if (p[3] == NUL)
6711 break;
6712 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006713 }
6714 }
6715
6716#ifdef FEAT_COMMENTS
6717 /* 'comments' */
6718 else if (gvarp == &p_com)
6719 {
6720 for (s = *varp; *s; )
6721 {
6722 while (*s && *s != ':')
6723 {
6724 if (vim_strchr((char_u *)COM_ALL, *s) == NULL
6725 && !VIM_ISDIGIT(*s) && *s != '-')
6726 {
6727 errmsg = illegal_char(errbuf, *s);
6728 break;
6729 }
6730 ++s;
6731 }
6732 if (*s++ == NUL)
6733 errmsg = (char_u *)N_("E524: Missing colon");
6734 else if (*s == ',' || *s == NUL)
6735 errmsg = (char_u *)N_("E525: Zero length string");
6736 if (errmsg != NULL)
6737 break;
6738 while (*s && *s != ',')
6739 {
6740 if (*s == '\\' && s[1] != NUL)
6741 ++s;
6742 ++s;
6743 }
6744 s = skip_to_option_part(s);
6745 }
6746 }
6747#endif
6748
6749 /* 'listchars' */
6750 else if (varp == &p_lcs)
6751 {
6752 errmsg = set_chars_option(varp);
6753 }
6754
Bram Moolenaar071d4272004-06-13 20:20:40 +00006755 /* 'fillchars' */
6756 else if (varp == &p_fcs)
6757 {
6758 errmsg = set_chars_option(varp);
6759 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006760
6761#ifdef FEAT_CMDWIN
6762 /* 'cedit' */
6763 else if (varp == &p_cedit)
6764 {
6765 errmsg = check_cedit();
6766 }
6767#endif
6768
Bram Moolenaar54ee7752005-05-31 22:22:17 +00006769 /* 'verbosefile' */
6770 else if (varp == &p_vfile)
6771 {
6772 verbose_stop();
6773 if (*p_vfile != NUL && verbose_open() == FAIL)
6774 errmsg = e_invarg;
6775 }
6776
Bram Moolenaar071d4272004-06-13 20:20:40 +00006777#ifdef FEAT_VIMINFO
6778 /* 'viminfo' */
6779 else if (varp == &p_viminfo)
6780 {
6781 for (s = p_viminfo; *s;)
6782 {
6783 /* Check it's a valid character */
6784 if (vim_strchr((char_u *)"!\"%'/:<@cfhnrs", *s) == NULL)
6785 {
6786 errmsg = illegal_char(errbuf, *s);
6787 break;
6788 }
6789 if (*s == 'n') /* name is always last one */
6790 {
6791 break;
6792 }
6793 else if (*s == 'r') /* skip until next ',' */
6794 {
6795 while (*++s && *s != ',')
6796 ;
6797 }
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +00006798 else if (*s == '%')
6799 {
6800 /* optional number */
6801 while (vim_isdigit(*++s))
6802 ;
6803 }
6804 else if (*s == '!' || *s == 'h' || *s == 'c')
Bram Moolenaar071d4272004-06-13 20:20:40 +00006805 ++s; /* no extra chars */
6806 else /* must have a number */
6807 {
6808 while (vim_isdigit(*++s))
6809 ;
6810
6811 if (!VIM_ISDIGIT(*(s - 1)))
6812 {
6813 if (errbuf != NULL)
6814 {
Bram Moolenaar8f999f12005-01-25 22:12:55 +00006815 sprintf((char *)errbuf,
6816 _("E526: Missing number after <%s>"),
Bram Moolenaar071d4272004-06-13 20:20:40 +00006817 transchar_byte(*(s - 1)));
6818 errmsg = errbuf;
6819 }
6820 else
6821 errmsg = (char_u *)"";
6822 break;
6823 }
6824 }
6825 if (*s == ',')
6826 ++s;
6827 else if (*s)
6828 {
6829 if (errbuf != NULL)
6830 errmsg = (char_u *)N_("E527: Missing comma");
6831 else
6832 errmsg = (char_u *)"";
6833 break;
6834 }
6835 }
6836 if (*p_viminfo && errmsg == NULL && get_viminfo_parameter('\'') < 0)
6837 errmsg = (char_u *)N_("E528: Must specify a ' value");
6838 }
6839#endif /* FEAT_VIMINFO */
6840
6841 /* terminal options */
6842 else if (istermoption(&options[opt_idx]) && full_screen)
6843 {
6844 /* ":set t_Co=0" and ":set t_Co=1" do ":set t_Co=" */
6845 if (varp == &T_CCO)
6846 {
Bram Moolenaarc84e8952009-03-18 13:21:18 +00006847 int colors = atoi((char *)T_CCO);
6848
6849 /* Only reinitialize colors if t_Co value has really changed to
6850 * avoid expensive reload of colorscheme if t_Co is set to the
6851 * same value multiple times. */
6852 if (colors != t_colors)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006853 {
Bram Moolenaarc84e8952009-03-18 13:21:18 +00006854 t_colors = colors;
6855 if (t_colors <= 1)
6856 {
6857 if (new_value_alloced)
6858 vim_free(T_CCO);
6859 T_CCO = empty_option;
6860 }
Bram Moolenaarc5cd8852018-05-01 15:47:38 +02006861#if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS)
6862 if (is_term_win32())
6863 {
6864 swap_tcap();
6865 did_swaptcap = TRUE;
6866 }
6867#endif
Bram Moolenaarc84e8952009-03-18 13:21:18 +00006868 /* We now have a different color setup, initialize it again. */
6869 init_highlight(TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006870 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006871 }
6872 ttest(FALSE);
6873 if (varp == &T_ME)
6874 {
6875 out_str(T_ME);
6876 redraw_later(CLEAR);
Bram Moolenaar48e330a2016-02-23 14:53:34 +01006877#if defined(WIN3264) && !defined(FEAT_GUI_W32)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006878 /* Since t_me has been set, this probably means that the user
6879 * wants to use this as default colors. Need to reset default
6880 * background/foreground colors. */
6881 mch_set_normal_colors();
6882#endif
6883 }
Bram Moolenaard9c60642017-01-27 20:03:18 +01006884 if (varp == &T_BE && termcap_active)
6885 {
6886 if (*T_BE == NUL)
6887 /* When clearing t_BE we assume the user no longer wants
6888 * bracketed paste, thus disable it by writing t_BD. */
6889 out_str(T_BD);
6890 else
6891 out_str(T_BE);
6892 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006893 }
6894
6895#ifdef FEAT_LINEBREAK
6896 /* 'showbreak' */
6897 else if (varp == &p_sbr)
6898 {
6899 for (s = p_sbr; *s; )
6900 {
6901 if (ptr2cells(s) != 1)
6902 errmsg = (char_u *)N_("E595: contains unprintable or wide character");
Bram Moolenaar91acfff2017-03-12 19:22:36 +01006903 MB_PTR_ADV(s);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006904 }
6905 }
6906#endif
6907
6908#ifdef FEAT_GUI
6909 /* 'guifont' */
6910 else if (varp == &p_guifont)
6911 {
6912 if (gui.in_use)
6913 {
6914 p = p_guifont;
Bram Moolenaar9372a112005-12-06 19:59:18 +00006915# if defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006916 /*
6917 * Put up a font dialog and let the user select a new value.
6918 * If this is cancelled go back to the old value but don't
6919 * give an error message.
6920 */
6921 if (STRCMP(p, "*") == 0)
6922 {
6923 p = gui_mch_font_dialog(oldval);
6924
6925 if (new_value_alloced)
6926 free_string_option(p_guifont);
6927
6928 p_guifont = (p != NULL) ? p : vim_strsave(oldval);
6929 new_value_alloced = TRUE;
6930 }
6931# endif
6932 if (p != NULL && gui_init_font(p_guifont, FALSE) != OK)
6933 {
6934# if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_PHOTON)
6935 if (STRCMP(p_guifont, "*") == 0)
6936 {
6937 /* Dialog was cancelled: Keep the old value without giving
6938 * an error message. */
6939 if (new_value_alloced)
6940 free_string_option(p_guifont);
6941 p_guifont = vim_strsave(oldval);
6942 new_value_alloced = TRUE;
6943 }
6944 else
6945# endif
6946 errmsg = (char_u *)N_("E596: Invalid font(s)");
6947 }
6948 }
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006949 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006950 }
6951# ifdef FEAT_XFONTSET
6952 else if (varp == &p_guifontset)
6953 {
6954 if (STRCMP(p_guifontset, "*") == 0)
6955 errmsg = (char_u *)N_("E597: can't select fontset");
6956 else if (gui.in_use && gui_init_font(p_guifontset, TRUE) != OK)
6957 errmsg = (char_u *)N_("E598: Invalid fontset");
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006958 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006959 }
6960# endif
6961# ifdef FEAT_MBYTE
6962 else if (varp == &p_guifontwide)
6963 {
6964 if (STRCMP(p_guifontwide, "*") == 0)
6965 errmsg = (char_u *)N_("E533: can't select wide font");
6966 else if (gui_get_wide_font() == FAIL)
6967 errmsg = (char_u *)N_("E534: Invalid wide font");
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006968 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006969 }
6970# endif
6971#endif
6972
6973#ifdef CURSOR_SHAPE
6974 /* 'guicursor' */
6975 else if (varp == &p_guicursor)
6976 errmsg = parse_shape_opt(SHAPE_CURSOR);
6977#endif
6978
6979#ifdef FEAT_MOUSESHAPE
6980 /* 'mouseshape' */
6981 else if (varp == &p_mouseshape)
6982 {
6983 errmsg = parse_shape_opt(SHAPE_MOUSE);
6984 update_mouseshape(-1);
6985 }
6986#endif
6987
6988#ifdef FEAT_PRINTER
6989 else if (varp == &p_popt)
Bram Moolenaar58d98232005-07-23 22:25:46 +00006990 errmsg = parse_printoptions();
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00006991# if defined(FEAT_MBYTE) && defined(FEAT_POSTSCRIPT)
Bram Moolenaar8299df92004-07-10 09:47:34 +00006992 else if (varp == &p_pmfn)
Bram Moolenaar58d98232005-07-23 22:25:46 +00006993 errmsg = parse_printmbfont();
Bram Moolenaar8299df92004-07-10 09:47:34 +00006994# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006995#endif
6996
6997#ifdef FEAT_LANGMAP
6998 /* 'langmap' */
6999 else if (varp == &p_langmap)
7000 langmap_set();
7001#endif
7002
7003#ifdef FEAT_LINEBREAK
7004 /* 'breakat' */
7005 else if (varp == &p_breakat)
7006 fill_breakat_flags();
7007#endif
7008
7009#ifdef FEAT_TITLE
7010 /* 'titlestring' and 'iconstring' */
7011 else if (varp == &p_titlestring || varp == &p_iconstring)
7012 {
7013# ifdef FEAT_STL_OPT
7014 int flagval = (varp == &p_titlestring) ? STL_IN_TITLE : STL_IN_ICON;
7015
7016 /* NULL => statusline syntax */
7017 if (vim_strchr(*varp, '%') && check_stl_option(*varp) == NULL)
7018 stl_syntax |= flagval;
7019 else
7020 stl_syntax &= ~flagval;
7021# endif
Bram Moolenaar84a93082018-06-16 22:58:15 +02007022 did_set_title();
Bram Moolenaar071d4272004-06-13 20:20:40 +00007023 }
7024#endif
7025
7026#ifdef FEAT_GUI
7027 /* 'guioptions' */
7028 else if (varp == &p_go)
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00007029 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00007030 gui_init_which_components(oldval);
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00007031 redraw_gui_only = TRUE;
7032 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007033#endif
7034
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00007035#if defined(FEAT_GUI_TABLINE)
7036 /* 'guitablabel' */
7037 else if (varp == &p_gtl)
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00007038 {
Bram Moolenaar18144c82006-04-12 21:52:12 +00007039 redraw_tabline = TRUE;
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00007040 redraw_gui_only = TRUE;
7041 }
7042 /* 'guitabtooltip' */
7043 else if (varp == &p_gtt)
7044 {
7045 redraw_gui_only = TRUE;
7046 }
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00007047#endif
7048
Bram Moolenaar071d4272004-06-13 20:20:40 +00007049#if defined(FEAT_MOUSE_TTY) && (defined(UNIX) || defined(VMS))
7050 /* 'ttymouse' */
7051 else if (varp == &p_ttym)
7052 {
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00007053 /* Switch the mouse off before changing the escape sequences used for
7054 * that. */
7055 mch_setmouse(FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007056 if (opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE) != OK)
7057 errmsg = e_invarg;
7058 else
7059 check_mouse_termcode();
Bram Moolenaar6bb68362005-03-22 23:03:44 +00007060 if (termcap_active)
7061 setmouse(); /* may switch it on again */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007062 }
7063#endif
7064
Bram Moolenaar071d4272004-06-13 20:20:40 +00007065 /* 'selection' */
7066 else if (varp == &p_sel)
7067 {
7068 if (*p_sel == NUL
7069 || check_opt_strings(p_sel, p_sel_values, FALSE) != OK)
7070 errmsg = e_invarg;
7071 }
7072
7073 /* 'selectmode' */
7074 else if (varp == &p_slm)
7075 {
7076 if (check_opt_strings(p_slm, p_slm_values, TRUE) != OK)
7077 errmsg = e_invarg;
7078 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007079
7080#ifdef FEAT_BROWSE
7081 /* 'browsedir' */
7082 else if (varp == &p_bsdir)
7083 {
7084 if (check_opt_strings(p_bsdir, p_bsdir_values, FALSE) != OK
7085 && !mch_isdir(p_bsdir))
7086 errmsg = e_invarg;
7087 }
7088#endif
7089
Bram Moolenaar071d4272004-06-13 20:20:40 +00007090 /* 'keymodel' */
7091 else if (varp == &p_km)
7092 {
7093 if (check_opt_strings(p_km, p_km_values, TRUE) != OK)
7094 errmsg = e_invarg;
7095 else
7096 {
7097 km_stopsel = (vim_strchr(p_km, 'o') != NULL);
7098 km_startsel = (vim_strchr(p_km, 'a') != NULL);
7099 }
7100 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007101
7102 /* 'mousemodel' */
7103 else if (varp == &p_mousem)
7104 {
7105 if (check_opt_strings(p_mousem, p_mousem_values, FALSE) != OK)
7106 errmsg = e_invarg;
7107#if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU) && (XmVersion <= 1002)
7108 else if (*p_mousem != *oldval)
7109 /* Changed from "extend" to "popup" or "popup_setpos" or vv: need
7110 * to create or delete the popup menus. */
7111 gui_motif_update_mousemodel(root_menu);
7112#endif
7113 }
7114
7115 /* 'switchbuf' */
7116 else if (varp == &p_swb)
7117 {
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00007118 if (opt_strings_flags(p_swb, p_swb_values, &swb_flags, TRUE) != OK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007119 errmsg = e_invarg;
7120 }
7121
7122 /* 'debug' */
7123 else if (varp == &p_debug)
7124 {
Bram Moolenaar57657d82006-04-21 22:12:41 +00007125 if (check_opt_strings(p_debug, p_debug_values, TRUE) != OK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007126 errmsg = e_invarg;
7127 }
7128
7129 /* 'display' */
7130 else if (varp == &p_dy)
7131 {
7132 if (opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE) != OK)
7133 errmsg = e_invarg;
7134 else
7135 (void)init_chartab();
7136
7137 }
7138
Bram Moolenaar071d4272004-06-13 20:20:40 +00007139 /* 'eadirection' */
7140 else if (varp == &p_ead)
7141 {
7142 if (check_opt_strings(p_ead, p_ead_values, FALSE) != OK)
7143 errmsg = e_invarg;
7144 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007145
7146#ifdef FEAT_CLIPBOARD
7147 /* 'clipboard' */
7148 else if (varp == &p_cb)
7149 errmsg = check_clipboard_option();
7150#endif
7151
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007152#ifdef FEAT_SPELL
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00007153 /* When 'spelllang' or 'spellfile' is set and there is a window for this
7154 * buffer in which 'spell' is set load the wordlists. */
Bram Moolenaar2683c8e2014-11-19 19:33:16 +01007155 else if (varp == &(curwin->w_s->b_p_spl)
7156 || varp == &(curwin->w_s->b_p_spf))
Bram Moolenaar217ad922005-03-20 22:37:15 +00007157 {
Bram Moolenaare68c25c2015-08-25 15:39:55 +02007158 errmsg = did_set_spell_option(varp == &(curwin->w_s->b_p_spf));
Bram Moolenaar217ad922005-03-20 22:37:15 +00007159 }
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007160 /* When 'spellcapcheck' is set compile the regexp program. */
Bram Moolenaar860cae12010-06-05 23:22:07 +02007161 else if (varp == &(curwin->w_s->b_p_spc))
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007162 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007163 errmsg = compile_cap_prog(curwin->w_s);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007164 }
Bram Moolenaard857f0e2005-06-21 22:37:39 +00007165 /* 'spellsuggest' */
7166 else if (varp == &p_sps)
7167 {
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00007168 if (spell_check_sps() != OK)
Bram Moolenaard857f0e2005-06-21 22:37:39 +00007169 errmsg = e_invarg;
7170 }
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00007171 /* 'mkspellmem' */
7172 else if (varp == &p_msm)
7173 {
7174 if (spell_check_msm() != OK)
7175 errmsg = e_invarg;
7176 }
Bram Moolenaar217ad922005-03-20 22:37:15 +00007177#endif
7178
Bram Moolenaar071d4272004-06-13 20:20:40 +00007179 /* When 'bufhidden' is set, check for valid value. */
7180 else if (gvarp == &p_bh)
7181 {
7182 if (check_opt_strings(curbuf->b_p_bh, p_bufhidden_values, FALSE) != OK)
7183 errmsg = e_invarg;
7184 }
7185
7186 /* When 'buftype' is set, check for valid value. */
7187 else if (gvarp == &p_bt)
7188 {
7189 if (check_opt_strings(curbuf->b_p_bt, p_buftype_values, FALSE) != OK)
7190 errmsg = e_invarg;
7191 else
7192 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00007193 if (curwin->w_status_height)
7194 {
7195 curwin->w_redr_status = TRUE;
7196 redraw_later(VALID);
7197 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007198 curbuf->b_help = (curbuf->b_p_bt[0] == 'h');
Bram Moolenaar1f2903c2017-07-23 19:51:01 +02007199#ifdef FEAT_TITLE
Bram Moolenaar5075aad2010-01-27 15:58:13 +01007200 redraw_titles();
Bram Moolenaar1f2903c2017-07-23 19:51:01 +02007201#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007202 }
7203 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007204
7205#ifdef FEAT_STL_OPT
7206 /* 'statusline' or 'rulerformat' */
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00007207 else if (gvarp == &p_stl || varp == &p_ruf)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007208 {
7209 int wid;
7210
7211 if (varp == &p_ruf) /* reset ru_wid first */
7212 ru_wid = 0;
7213 s = *varp;
7214 if (varp == &p_ruf && *s == '%')
7215 {
7216 /* set ru_wid if 'ruf' starts with "%99(" */
7217 if (*++s == '-') /* ignore a '-' */
7218 s++;
7219 wid = getdigits(&s);
7220 if (wid && *s == '(' && (errmsg = check_stl_option(p_ruf)) == NULL)
7221 ru_wid = wid;
7222 else
7223 errmsg = check_stl_option(p_ruf);
7224 }
Bram Moolenaar3709e7c2006-08-08 14:29:16 +00007225 /* check 'statusline' only if it doesn't start with "%!" */
Bram Moolenaar177d8c62007-09-06 11:33:37 +00007226 else if (varp == &p_ruf || s[0] != '%' || s[1] != '!')
Bram Moolenaar071d4272004-06-13 20:20:40 +00007227 errmsg = check_stl_option(s);
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00007228 if (varp == &p_ruf && errmsg == NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007229 comp_col();
7230 }
7231#endif
7232
7233#ifdef FEAT_INS_EXPAND
7234 /* check if it is a valid value for 'complete' -- Acevedo */
7235 else if (gvarp == &p_cpt)
7236 {
7237 for (s = *varp; *s;)
7238 {
Bram Moolenaar11b73d62012-06-29 15:51:30 +02007239 while (*s == ',' || *s == ' ')
Bram Moolenaar071d4272004-06-13 20:20:40 +00007240 s++;
7241 if (!*s)
7242 break;
7243 if (vim_strchr((char_u *)".wbuksid]tU", *s) == NULL)
7244 {
7245 errmsg = illegal_char(errbuf, *s);
7246 break;
7247 }
7248 if (*++s != NUL && *s != ',' && *s != ' ')
7249 {
7250 if (s[-1] == 'k' || s[-1] == 's')
7251 {
7252 /* skip optional filename after 'k' and 's' */
7253 while (*s && *s != ',' && *s != ' ')
7254 {
Bram Moolenaar226c5342017-02-17 14:53:15 +01007255 if (*s == '\\' && s[1] != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007256 ++s;
7257 ++s;
7258 }
7259 }
7260 else
7261 {
7262 if (errbuf != NULL)
7263 {
7264 sprintf((char *)errbuf,
7265 _("E535: Illegal character after <%c>"),
7266 *--s);
7267 errmsg = errbuf;
7268 }
7269 else
7270 errmsg = (char_u *)"";
7271 break;
7272 }
7273 }
7274 }
7275 }
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00007276
7277 /* 'completeopt' */
7278 else if (varp == &p_cot)
7279 {
7280 if (check_opt_strings(p_cot, p_cot_values, TRUE) != OK)
7281 errmsg = e_invarg;
Bram Moolenaarc0200422016-04-20 12:02:02 +02007282 else
7283 completeopt_was_set();
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00007284 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007285#endif /* FEAT_INS_EXPAND */
7286
Bram Moolenaar95ec9d62016-08-12 18:29:59 +02007287#ifdef FEAT_SIGNS
7288 /* 'signcolumn' */
7289 else if (varp == &curwin->w_p_scl)
7290 {
7291 if (check_opt_strings(*varp, p_scl_values, FALSE) != OK)
7292 errmsg = e_invarg;
7293 }
7294#endif
7295
Bram Moolenaar071d4272004-06-13 20:20:40 +00007296
7297#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
Bram Moolenaar031cb742016-11-24 21:46:19 +01007298 /* 'toolbar' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007299 else if (varp == &p_toolbar)
7300 {
7301 if (opt_strings_flags(p_toolbar, p_toolbar_values,
7302 &toolbar_flags, TRUE) != OK)
7303 errmsg = e_invarg;
7304 else
7305 {
7306 out_flush();
7307 gui_mch_show_toolbar((toolbar_flags &
7308 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
7309 }
7310 }
7311#endif
7312
Bram Moolenaar182c5be2010-06-25 05:37:59 +02007313#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007314 /* 'toolbariconsize': GTK+ 2 only */
7315 else if (varp == &p_tbis)
7316 {
7317 if (opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE) != OK)
7318 errmsg = e_invarg;
7319 else
7320 {
7321 out_flush();
7322 gui_mch_show_toolbar((toolbar_flags &
7323 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
7324 }
7325 }
7326#endif
7327
7328 /* 'pastetoggle': translate key codes like in a mapping */
7329 else if (varp == &p_pt)
7330 {
7331 if (*p_pt)
7332 {
Bram Moolenaar9c102382006-05-03 21:26:49 +00007333 (void)replace_termcodes(p_pt, &p, TRUE, TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007334 if (p != NULL)
7335 {
7336 if (new_value_alloced)
7337 free_string_option(p_pt);
7338 p_pt = p;
7339 new_value_alloced = TRUE;
7340 }
7341 }
7342 }
7343
7344 /* 'backspace' */
7345 else if (varp == &p_bs)
7346 {
7347 if (VIM_ISDIGIT(*p_bs))
7348 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01007349 if (*p_bs > '2' || p_bs[1] != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007350 errmsg = e_invarg;
7351 }
7352 else if (check_opt_strings(p_bs, p_bs_values, TRUE) != OK)
7353 errmsg = e_invarg;
7354 }
Bram Moolenaar165bc692015-07-21 17:53:25 +02007355 else if (varp == &p_bo)
7356 {
7357 if (opt_strings_flags(p_bo, p_bo_values, &bo_flags, TRUE) != OK)
7358 errmsg = e_invarg;
7359 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007360
Bram Moolenaar0f6562e2015-11-24 18:48:14 +01007361 /* 'tagcase' */
7362 else if (gvarp == &p_tc)
7363 {
7364 unsigned int *flags;
7365
7366 if (opt_flags & OPT_LOCAL)
7367 {
7368 p = curbuf->b_p_tc;
7369 flags = &curbuf->b_tc_flags;
7370 }
7371 else
7372 {
7373 p = p_tc;
7374 flags = &tc_flags;
7375 }
7376
7377 if ((opt_flags & OPT_LOCAL) && *p == NUL)
7378 /* make the local value empty: use the global value */
7379 *flags = 0;
7380 else if (*p == NUL
7381 || opt_strings_flags(p, p_tc_values, flags, FALSE) != OK)
7382 errmsg = e_invarg;
7383 }
7384
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00007385#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +00007386 /* 'casemap' */
7387 else if (varp == &p_cmp)
7388 {
7389 if (opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE) != OK)
7390 errmsg = e_invarg;
7391 }
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00007392#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007393
7394#ifdef FEAT_DIFF
7395 /* 'diffopt' */
7396 else if (varp == &p_dip)
7397 {
7398 if (diffopt_changed() == FAIL)
7399 errmsg = e_invarg;
7400 }
7401#endif
7402
7403#ifdef FEAT_FOLDING
7404 /* 'foldmethod' */
7405 else if (gvarp == &curwin->w_allbuf_opt.wo_fdm)
7406 {
7407 if (check_opt_strings(*varp, p_fdm_values, FALSE) != OK
7408 || *curwin->w_p_fdm == NUL)
7409 errmsg = e_invarg;
7410 else
Bram Moolenaarf4d7f942010-02-24 14:34:19 +01007411 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00007412 foldUpdateAll(curwin);
Bram Moolenaarf4d7f942010-02-24 14:34:19 +01007413 if (foldmethodIsDiff(curwin))
7414 newFoldLevel();
7415 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007416 }
7417# ifdef FEAT_EVAL
7418 /* 'foldexpr' */
7419 else if (varp == &curwin->w_p_fde)
7420 {
7421 if (foldmethodIsExpr(curwin))
7422 foldUpdateAll(curwin);
7423 }
7424# endif
7425 /* 'foldmarker' */
7426 else if (gvarp == &curwin->w_allbuf_opt.wo_fmr)
7427 {
7428 p = vim_strchr(*varp, ',');
7429 if (p == NULL)
7430 errmsg = (char_u *)N_("E536: comma required");
7431 else if (p == *varp || p[1] == NUL)
7432 errmsg = e_invarg;
7433 else if (foldmethodIsMarker(curwin))
7434 foldUpdateAll(curwin);
7435 }
7436 /* 'commentstring' */
7437 else if (gvarp == &p_cms)
7438 {
7439 if (**varp != NUL && strstr((char *)*varp, "%s") == NULL)
7440 errmsg = (char_u *)N_("E537: 'commentstring' must be empty or contain %s");
7441 }
7442 /* 'foldopen' */
7443 else if (varp == &p_fdo)
7444 {
7445 if (opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE) != OK)
7446 errmsg = e_invarg;
7447 }
7448 /* 'foldclose' */
7449 else if (varp == &p_fcl)
7450 {
7451 if (check_opt_strings(p_fcl, p_fcl_values, TRUE) != OK)
7452 errmsg = e_invarg;
7453 }
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00007454 /* 'foldignore' */
7455 else if (gvarp == &curwin->w_allbuf_opt.wo_fdi)
7456 {
7457 if (foldmethodIsIndent(curwin))
7458 foldUpdateAll(curwin);
7459 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007460#endif
7461
7462#ifdef FEAT_VIRTUALEDIT
7463 /* 'virtualedit' */
7464 else if (varp == &p_ve)
7465 {
7466 if (opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE) != OK)
7467 errmsg = e_invarg;
7468 else if (STRCMP(p_ve, oldval) != 0)
7469 {
7470 /* Recompute cursor position in case the new 've' setting
7471 * changes something. */
7472 validate_virtcol();
7473 coladvance(curwin->w_virtcol);
7474 }
7475 }
7476#endif
7477
7478#if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX)
7479 else if (varp == &p_csqf)
7480 {
7481 if (p_csqf != NULL)
7482 {
7483 p = p_csqf;
7484 while (*p != NUL)
7485 {
7486 if (vim_strchr((char_u *)CSQF_CMDS, *p) == NULL
7487 || p[1] == NUL
7488 || vim_strchr((char_u *)CSQF_FLAGS, p[1]) == NULL
7489 || (p[2] != NUL && p[2] != ','))
7490 {
7491 errmsg = e_invarg;
7492 break;
7493 }
7494 else if (p[2] == NUL)
7495 break;
7496 else
7497 p += 3;
7498 }
7499 }
7500 }
7501#endif
7502
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01007503#ifdef FEAT_CINDENT
7504 /* 'cinoptions' */
7505 else if (gvarp == &p_cino)
7506 {
7507 /* TODO: recognize errors */
7508 parse_cino(curbuf);
7509 }
7510#endif
7511
Bram Moolenaarb5a7a8b2014-08-06 14:52:30 +02007512#if defined(FEAT_RENDER_OPTIONS)
Bram Moolenaar031cb742016-11-24 21:46:19 +01007513 /* 'renderoptions' */
Bram Moolenaar3767c6e2017-12-05 16:57:56 +01007514 else if (varp == &p_rop)
Bram Moolenaarb5a7a8b2014-08-06 14:52:30 +02007515 {
7516 if (!gui_mch_set_rendering_options(p_rop))
7517 errmsg = e_invarg;
7518 }
7519#endif
7520
Bram Moolenaard0b51382016-11-04 15:23:45 +01007521 else if (gvarp == &p_ft)
7522 {
7523 if (!valid_filetype(*varp))
7524 errmsg = e_invarg;
Bram Moolenaar90492982017-06-22 14:16:31 +02007525 else
Bram Moolenaarc3ffc9b2018-06-17 17:32:58 +02007526 value_changed = STRCMP(oldval, *varp) != 0;
Bram Moolenaard0b51382016-11-04 15:23:45 +01007527 }
Bram Moolenaard0b51382016-11-04 15:23:45 +01007528
7529#ifdef FEAT_SYN_HL
7530 else if (gvarp == &p_syn)
7531 {
7532 if (!valid_filetype(*varp))
7533 errmsg = e_invarg;
Bram Moolenaarc3ffc9b2018-06-17 17:32:58 +02007534 else
7535 value_changed = STRCMP(oldval, *varp) != 0;
Bram Moolenaard0b51382016-11-04 15:23:45 +01007536 }
7537#endif
7538
Bram Moolenaar825680f2017-07-22 17:04:02 +02007539#ifdef FEAT_TERMINAL
Bram Moolenaar6d150f72018-04-21 20:03:20 +02007540 /* 'termwinkey' */
7541 else if (varp == &curwin->w_p_twk)
Bram Moolenaardbe948d2017-07-23 22:50:51 +02007542 {
Bram Moolenaar6d150f72018-04-21 20:03:20 +02007543 if (*curwin->w_p_twk != NUL
7544 && string_to_key(curwin->w_p_twk, TRUE) == 0)
Bram Moolenaardbe948d2017-07-23 22:50:51 +02007545 errmsg = e_invarg;
7546 }
Bram Moolenaar6d150f72018-04-21 20:03:20 +02007547 /* 'termwinsize' */
7548 else if (varp == &curwin->w_p_tws)
Bram Moolenaar825680f2017-07-22 17:04:02 +02007549 {
Bram Moolenaar6d150f72018-04-21 20:03:20 +02007550 if (*curwin->w_p_tws != NUL)
Bram Moolenaar825680f2017-07-22 17:04:02 +02007551 {
Bram Moolenaar6d150f72018-04-21 20:03:20 +02007552 p = skipdigits(curwin->w_p_tws);
7553 if (p == curwin->w_p_tws
Bram Moolenaar498c2562018-04-15 23:45:15 +02007554 || (*p != 'x' && *p != '*')
7555 || *skipdigits(p + 1) != NUL)
Bram Moolenaar825680f2017-07-22 17:04:02 +02007556 errmsg = e_invarg;
7557 }
7558 }
7559#endif
7560
Bram Moolenaar04958cb2018-06-23 19:23:02 +02007561#ifdef FEAT_VARTABS
7562 /* 'varsofttabstop' */
7563 else if (varp == &(curbuf->b_p_vsts))
7564 {
7565 char_u *cp;
7566
7567 if (!(*varp)[0] || ((*varp)[0] == '0' && !(*varp)[1]))
7568 {
7569 if (curbuf->b_p_vsts_array)
7570 {
7571 vim_free(curbuf->b_p_vsts_array);
7572 curbuf->b_p_vsts_array = 0;
7573 }
7574 }
7575 else
7576 {
7577 for (cp = *varp; *cp; ++cp)
7578 {
7579 if (vim_isdigit(*cp))
7580 continue;
7581 if (*cp == ',' && cp > *varp && *(cp-1) != ',')
7582 continue;
7583 errmsg = e_invarg;
7584 break;
7585 }
7586 if (errmsg == NULL)
7587 {
7588 int *oldarray = curbuf->b_p_vsts_array;
7589 if (tabstop_set(*varp, &(curbuf->b_p_vsts_array)))
7590 {
7591 if (oldarray)
7592 vim_free(oldarray);
7593 }
7594 else
7595 errmsg = e_invarg;
7596 }
7597 }
7598 }
7599
7600 /* 'vartabstop' */
7601 else if (varp == &(curbuf->b_p_vts))
7602 {
7603 char_u *cp;
7604
7605 if (!(*varp)[0] || ((*varp)[0] == '0' && !(*varp)[1]))
7606 {
7607 if (curbuf->b_p_vts_array)
7608 {
7609 vim_free(curbuf->b_p_vts_array);
7610 curbuf->b_p_vts_array = NULL;
7611 }
7612 }
7613 else
7614 {
7615 for (cp = *varp; *cp; ++cp)
7616 {
7617 if (vim_isdigit(*cp))
7618 continue;
7619 if (*cp == ',' && cp > *varp && *(cp-1) != ',')
7620 continue;
7621 errmsg = e_invarg;
7622 break;
7623 }
7624 if (errmsg == NULL)
7625 {
7626 int *oldarray = curbuf->b_p_vts_array;
7627 if (tabstop_set(*varp, &(curbuf->b_p_vts_array)))
7628 {
7629 if (oldarray)
7630 vim_free(oldarray);
7631#ifdef FEAT_FOLDING
7632 if (foldmethodIsIndent(curwin))
7633 foldUpdateAll(curwin);
7634#endif /* FEAT_FOLDING */
7635 }
7636 else
7637 errmsg = e_invarg;
7638 }
7639 }
7640 }
7641#endif
7642
Bram Moolenaar071d4272004-06-13 20:20:40 +00007643 /* Options that are a list of flags. */
7644 else
7645 {
7646 p = NULL;
Bram Moolenaar031cb742016-11-24 21:46:19 +01007647 if (varp == &p_ww) /* 'whichwrap' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007648 p = (char_u *)WW_ALL;
Bram Moolenaar031cb742016-11-24 21:46:19 +01007649 if (varp == &p_shm) /* 'shortmess' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007650 p = (char_u *)SHM_ALL;
Bram Moolenaar031cb742016-11-24 21:46:19 +01007651 else if (varp == &(p_cpo)) /* 'cpoptions' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007652 p = (char_u *)CPO_ALL;
Bram Moolenaar031cb742016-11-24 21:46:19 +01007653 else if (varp == &(curbuf->b_p_fo)) /* 'formatoptions' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007654 p = (char_u *)FO_ALL;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02007655#ifdef FEAT_CONCEAL
Bram Moolenaar031cb742016-11-24 21:46:19 +01007656 else if (varp == &curwin->w_p_cocu) /* 'concealcursor' */
Bram Moolenaarf5963f72010-07-23 22:10:27 +02007657 p = (char_u *)COCU_ALL;
7658#endif
Bram Moolenaar031cb742016-11-24 21:46:19 +01007659 else if (varp == &p_mouse) /* 'mouse' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007660 {
7661#ifdef FEAT_MOUSE
7662 p = (char_u *)MOUSE_ALL;
7663#else
7664 if (*p_mouse != NUL)
7665 errmsg = (char_u *)N_("E538: No mouse support");
7666#endif
7667 }
7668#if defined(FEAT_GUI)
Bram Moolenaar031cb742016-11-24 21:46:19 +01007669 else if (varp == &p_go) /* 'guioptions' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007670 p = (char_u *)GO_ALL;
7671#endif
7672 if (p != NULL)
7673 {
7674 for (s = *varp; *s; ++s)
7675 if (vim_strchr(p, *s) == NULL)
7676 {
7677 errmsg = illegal_char(errbuf, *s);
7678 break;
7679 }
7680 }
7681 }
7682
7683 /*
7684 * If error detected, restore the previous value.
7685 */
7686 if (errmsg != NULL)
7687 {
7688 if (new_value_alloced)
7689 free_string_option(*varp);
7690 *varp = oldval;
7691 /*
7692 * When resetting some values, need to act on it.
7693 */
7694 if (did_chartab)
7695 (void)init_chartab();
7696 if (varp == &p_hl)
7697 (void)highlight_changed();
7698 }
7699 else
7700 {
7701#ifdef FEAT_EVAL
7702 /* Remember where the option was set. */
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02007703 set_option_sctx_idx(opt_idx, opt_flags, current_sctx);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007704#endif
7705 /*
7706 * Free string options that are in allocated memory.
Bram Moolenaarc0197e22004-09-13 20:26:32 +00007707 * Use "free_oldval", because recursiveness may change the flags under
7708 * our fingers (esp. init_highlight()).
Bram Moolenaar071d4272004-06-13 20:20:40 +00007709 */
Bram Moolenaarc0197e22004-09-13 20:26:32 +00007710 if (free_oldval)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007711 free_string_option(oldval);
7712 if (new_value_alloced)
7713 options[opt_idx].flags |= P_ALLOCED;
7714 else
7715 options[opt_idx].flags &= ~P_ALLOCED;
7716
7717 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00007718 && ((int)options[opt_idx].indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007719 {
7720 /* global option with local value set to use global value; free
7721 * the local value and make it empty */
7722 p = get_varp_scope(&(options[opt_idx]), OPT_LOCAL);
7723 free_string_option(*(char_u **)p);
7724 *(char_u **)p = empty_option;
7725 }
7726
7727 /* May set global value for local option. */
7728 else if (!(opt_flags & OPT_LOCAL) && opt_flags != OPT_GLOBAL)
7729 set_string_option_global(opt_idx, varp);
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007730
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007731 /*
7732 * Trigger the autocommand only after setting the flags.
7733 */
Bram Moolenaarf2bd8ef2018-03-04 18:08:14 +01007734#ifdef FEAT_SYN_HL
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007735 /* When 'syntax' is set, load the syntax of that name */
7736 if (varp == &(curbuf->b_p_syn))
7737 {
Bram Moolenaara5616b02018-06-17 19:08:30 +02007738 static int syn_recursive = 0;
7739
7740 ++syn_recursive;
7741 // Only pass TRUE for "force" when the value changed or not used
7742 // recursively, to avoid endless recurrence.
7743 apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn, curbuf->b_fname,
7744 value_changed || syn_recursive == 1, curbuf);
7745 --syn_recursive;
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007746 }
Bram Moolenaarf2bd8ef2018-03-04 18:08:14 +01007747#endif
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007748 else if (varp == &(curbuf->b_p_ft))
7749 {
Bram Moolenaar90492982017-06-22 14:16:31 +02007750 /* 'filetype' is set, trigger the FileType autocommand.
7751 * Skip this when called from a modeline and the filetype was
Bram Moolenaara5616b02018-06-17 19:08:30 +02007752 * already set to this value. */
Bram Moolenaarc3ffc9b2018-06-17 17:32:58 +02007753 if (!(opt_flags & OPT_MODELINE) || value_changed)
Bram Moolenaar90492982017-06-22 14:16:31 +02007754 {
Bram Moolenaara5616b02018-06-17 19:08:30 +02007755 static int ft_recursive = 0;
7756
7757 ++ft_recursive;
Bram Moolenaar90492982017-06-22 14:16:31 +02007758 did_filetype = TRUE;
Bram Moolenaara5616b02018-06-17 19:08:30 +02007759 // Only pass TRUE for "force" when the value changed or not
7760 // used recursively, to avoid endless recurrence.
7761 apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft, curbuf->b_fname,
7762 value_changed || ft_recursive == 1, curbuf);
7763 --ft_recursive;
Bram Moolenaar163095f2017-07-09 15:41:53 +02007764 /* Just in case the old "curbuf" is now invalid. */
7765 if (varp != &(curbuf->b_p_ft))
7766 varp = NULL;
Bram Moolenaar90492982017-06-22 14:16:31 +02007767 }
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007768 }
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007769#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02007770 if (varp == &(curwin->w_s->b_p_spl))
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007771 {
7772 char_u fname[200];
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007773 char_u *q = curwin->w_s->b_p_spl;
7774
7775 /* Skip the first name if it is "cjk". */
7776 if (STRNCMP(q, "cjk,", 4) == 0)
7777 q += 4;
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007778
7779 /*
7780 * Source the spell/LANG.vim in 'runtimepath'.
7781 * They could set 'spellcapcheck' depending on the language.
7782 * Use the first name in 'spelllang' up to '_region' or
7783 * '.encoding'.
7784 */
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007785 for (p = q; *p != NUL; ++p)
Bram Moolenaar247bb7e2018-11-20 14:27:07 +01007786 if (!ASCII_ISALNUM(*p) && *p != '-')
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007787 break;
Bram Moolenaar82e8c922018-11-20 13:32:36 +01007788 if (p > q)
7789 {
7790 vim_snprintf((char *)fname, 200, "spell/%.*s.vim", (int)(p - q), q);
7791 source_runtime(fname, DIP_ALL);
7792 }
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007793 }
7794#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007795 }
7796
7797#ifdef FEAT_MOUSE
7798 if (varp == &p_mouse)
7799 {
7800# ifdef FEAT_MOUSE_TTY
7801 if (*p_mouse == NUL)
7802 mch_setmouse(FALSE); /* switch mouse off */
7803 else
7804# endif
7805 setmouse(); /* in case 'mouse' changed */
7806 }
7807#endif
7808
Bram Moolenaar913077c2012-03-28 19:59:04 +02007809 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01007810 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02007811 curwin->w_set_curswant = TRUE;
7812
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00007813#ifdef FEAT_GUI
7814 /* check redraw when it's not a GUI option or the GUI is active. */
7815 if (!redraw_gui_only || gui.in_use)
7816#endif
7817 check_redraw(options[opt_idx].flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007818
Bram Moolenaarc5cd8852018-05-01 15:47:38 +02007819#if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS)
7820 if (did_swaptcap)
7821 {
Bram Moolenaarc5cd8852018-05-01 15:47:38 +02007822 set_termname((char_u *)"win32");
7823 init_highlight(TRUE, FALSE);
7824 }
7825#endif
7826
Bram Moolenaar071d4272004-06-13 20:20:40 +00007827 return errmsg;
7828}
7829
Bram Moolenaarf4e5e862013-02-13 15:44:26 +01007830#if defined(FEAT_SYN_HL) || defined(PROTO)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007831/*
7832 * Simple int comparison function for use with qsort()
7833 */
7834 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01007835int_cmp(const void *a, const void *b)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007836{
7837 return *(const int *)a - *(const int *)b;
7838}
7839
7840/*
7841 * Handle setting 'colorcolumn' or 'textwidth' in window "wp".
7842 * Returns error message, NULL if it's OK.
7843 */
7844 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007845check_colorcolumn(win_T *wp)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007846{
7847 char_u *s;
7848 int col;
7849 int count = 0;
7850 int color_cols[256];
7851 int i;
7852 int j = 0;
7853
Bram Moolenaar50f834d2011-09-21 13:40:17 +02007854 if (wp->w_buffer == NULL)
7855 return NULL; /* buffer was closed */
7856
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007857 for (s = wp->w_p_cc; *s != NUL && count < 255;)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007858 {
7859 if (*s == '-' || *s == '+')
7860 {
7861 /* -N and +N: add to 'textwidth' */
7862 col = (*s == '-') ? -1 : 1;
7863 ++s;
7864 if (!VIM_ISDIGIT(*s))
7865 return e_invarg;
7866 col = col * getdigits(&s);
7867 if (wp->w_buffer->b_p_tw == 0)
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007868 goto skip; /* 'textwidth' not set, skip this item */
Bram Moolenaar1a384422010-07-14 19:53:30 +02007869 col += wp->w_buffer->b_p_tw;
7870 if (col < 0)
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007871 goto skip;
Bram Moolenaar1a384422010-07-14 19:53:30 +02007872 }
7873 else if (VIM_ISDIGIT(*s))
7874 col = getdigits(&s);
7875 else
7876 return e_invarg;
7877 color_cols[count++] = col - 1; /* 1-based to 0-based */
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007878skip:
Bram Moolenaar1a384422010-07-14 19:53:30 +02007879 if (*s == NUL)
7880 break;
7881 if (*s != ',')
7882 return e_invarg;
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007883 if (*++s == NUL)
7884 return e_invarg; /* illegal trailing comma as in "set cc=80," */
Bram Moolenaar1a384422010-07-14 19:53:30 +02007885 }
7886
7887 vim_free(wp->w_p_cc_cols);
7888 if (count == 0)
7889 wp->w_p_cc_cols = NULL;
7890 else
7891 {
7892 wp->w_p_cc_cols = (int *)alloc((unsigned)sizeof(int) * (count + 1));
7893 if (wp->w_p_cc_cols != NULL)
7894 {
7895 /* sort the columns for faster usage on screen redraw inside
7896 * win_line() */
7897 qsort(color_cols, count, sizeof(int), int_cmp);
7898
7899 for (i = 0; i < count; ++i)
7900 /* skip duplicates */
7901 if (j == 0 || wp->w_p_cc_cols[j - 1] != color_cols[i])
7902 wp->w_p_cc_cols[j++] = color_cols[i];
7903 wp->w_p_cc_cols[j] = -1; /* end marker */
7904 }
7905 }
7906
7907 return NULL; /* no error */
7908}
7909#endif
7910
Bram Moolenaar071d4272004-06-13 20:20:40 +00007911/*
7912 * Handle setting 'listchars' or 'fillchars'.
7913 * Returns error message, NULL if it's OK.
7914 */
7915 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007916set_chars_option(char_u **varp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007917{
7918 int round, i, len, entries;
7919 char_u *p, *s;
7920 int c1, c2 = 0;
7921 struct charstab
7922 {
7923 int *cp;
7924 char *name;
7925 };
Bram Moolenaar071d4272004-06-13 20:20:40 +00007926 static struct charstab filltab[] =
7927 {
7928 {&fill_stl, "stl"},
7929 {&fill_stlnc, "stlnc"},
7930 {&fill_vert, "vert"},
7931 {&fill_fold, "fold"},
7932 {&fill_diff, "diff"},
7933 };
Bram Moolenaar071d4272004-06-13 20:20:40 +00007934 static struct charstab lcstab[] =
7935 {
7936 {&lcs_eol, "eol"},
7937 {&lcs_ext, "extends"},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00007938 {&lcs_nbsp, "nbsp"},
Bram Moolenaar071d4272004-06-13 20:20:40 +00007939 {&lcs_prec, "precedes"},
Bram Moolenaar4c6b3b22015-04-21 19:10:48 +02007940 {&lcs_space, "space"},
Bram Moolenaar071d4272004-06-13 20:20:40 +00007941 {&lcs_tab2, "tab"},
7942 {&lcs_trail, "trail"},
Bram Moolenaar860cae12010-06-05 23:22:07 +02007943#ifdef FEAT_CONCEAL
7944 {&lcs_conceal, "conceal"},
7945#else
7946 {NULL, "conceal"},
7947#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007948 };
7949 struct charstab *tab;
7950
Bram Moolenaar071d4272004-06-13 20:20:40 +00007951 if (varp == &p_lcs)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007952 {
7953 tab = lcstab;
7954 entries = sizeof(lcstab) / sizeof(struct charstab);
7955 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007956 else
7957 {
7958 tab = filltab;
7959 entries = sizeof(filltab) / sizeof(struct charstab);
7960 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007961
7962 /* first round: check for valid value, second round: assign values */
7963 for (round = 0; round <= 1; ++round)
7964 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007965 if (round > 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007966 {
7967 /* After checking that the value is valid: set defaults: space for
7968 * 'fillchars', NUL for 'listchars' */
7969 for (i = 0; i < entries; ++i)
Bram Moolenaar860cae12010-06-05 23:22:07 +02007970 if (tab[i].cp != NULL)
7971 *(tab[i].cp) = (varp == &p_lcs ? NUL : ' ');
Bram Moolenaar071d4272004-06-13 20:20:40 +00007972 if (varp == &p_lcs)
7973 lcs_tab1 = NUL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007974 else
7975 fill_diff = '-';
Bram Moolenaar071d4272004-06-13 20:20:40 +00007976 }
7977 p = *varp;
7978 while (*p)
7979 {
7980 for (i = 0; i < entries; ++i)
7981 {
7982 len = (int)STRLEN(tab[i].name);
7983 if (STRNCMP(p, tab[i].name, len) == 0
7984 && p[len] == ':'
7985 && p[len + 1] != NUL)
7986 {
7987 s = p + len + 1;
7988#ifdef FEAT_MBYTE
7989 c1 = mb_ptr2char_adv(&s);
Bram Moolenaar910f66f2006-04-05 20:41:53 +00007990 if (mb_char2cells(c1) > 1)
7991 continue;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007992#else
7993 c1 = *s++;
7994#endif
7995 if (tab[i].cp == &lcs_tab2)
7996 {
7997 if (*s == NUL)
7998 continue;
7999#ifdef FEAT_MBYTE
8000 c2 = mb_ptr2char_adv(&s);
Bram Moolenaar910f66f2006-04-05 20:41:53 +00008001 if (mb_char2cells(c2) > 1)
8002 continue;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008003#else
8004 c2 = *s++;
8005#endif
8006 }
8007 if (*s == ',' || *s == NUL)
8008 {
8009 if (round)
8010 {
8011 if (tab[i].cp == &lcs_tab2)
8012 {
8013 lcs_tab1 = c1;
8014 lcs_tab2 = c2;
8015 }
Bram Moolenaar860cae12010-06-05 23:22:07 +02008016 else if (tab[i].cp != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008017 *(tab[i].cp) = c1;
8018
8019 }
8020 p = s;
8021 break;
8022 }
8023 }
8024 }
8025
8026 if (i == entries)
8027 return e_invarg;
8028 if (*p == ',')
8029 ++p;
8030 }
8031 }
8032
8033 return NULL; /* no error */
8034}
8035
8036#ifdef FEAT_STL_OPT
8037/*
8038 * Check validity of options with the 'statusline' format.
8039 * Return error message or NULL.
8040 */
8041 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01008042check_stl_option(char_u *s)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008043{
8044 int itemcnt = 0;
8045 int groupdepth = 0;
8046 static char_u errbuf[80];
8047
8048 while (*s && itemcnt < STL_MAX_ITEM)
8049 {
8050 /* Check for valid keys after % sequences */
8051 while (*s && *s != '%')
8052 s++;
8053 if (!*s)
8054 break;
8055 s++;
8056 if (*s != '%' && *s != ')')
8057 ++itemcnt;
8058 if (*s == '%' || *s == STL_TRUNCMARK || *s == STL_MIDDLEMARK)
8059 {
8060 s++;
8061 continue;
8062 }
8063 if (*s == ')')
8064 {
8065 s++;
8066 if (--groupdepth < 0)
8067 break;
8068 continue;
8069 }
8070 if (*s == '-')
8071 s++;
8072 while (VIM_ISDIGIT(*s))
8073 s++;
Bram Moolenaar238a5642006-02-21 22:12:05 +00008074 if (*s == STL_USER_HL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008075 continue;
8076 if (*s == '.')
8077 {
8078 s++;
8079 while (*s && VIM_ISDIGIT(*s))
8080 s++;
8081 }
8082 if (*s == '(')
8083 {
8084 groupdepth++;
8085 continue;
8086 }
8087 if (vim_strchr(STL_ALL, *s) == NULL)
8088 {
8089 return illegal_char(errbuf, *s);
8090 }
8091 if (*s == '{')
8092 {
8093 s++;
8094 while (*s != '}' && *s)
8095 s++;
8096 if (*s != '}')
8097 return (char_u *)N_("E540: Unclosed expression sequence");
8098 }
8099 }
8100 if (itemcnt >= STL_MAX_ITEM)
8101 return (char_u *)N_("E541: too many items");
8102 if (groupdepth != 0)
8103 return (char_u *)N_("E542: unbalanced groups");
8104 return NULL;
8105}
8106#endif
8107
8108#ifdef FEAT_CLIPBOARD
8109/*
8110 * Extract the items in the 'clipboard' option and set global values.
8111 */
8112 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01008113check_clipboard_option(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008114{
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01008115 int new_unnamed = 0;
Bram Moolenaar89af4392012-07-10 18:31:54 +02008116 int new_autoselect_star = FALSE;
8117 int new_autoselect_plus = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008118 int new_autoselectml = FALSE;
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00008119 int new_html = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008120 regprog_T *new_exclude_prog = NULL;
8121 char_u *errmsg = NULL;
8122 char_u *p;
8123
8124 for (p = p_cb; *p != NUL; )
8125 {
8126 if (STRNCMP(p, "unnamed", 7) == 0 && (p[7] == ',' || p[7] == NUL))
8127 {
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01008128 new_unnamed |= CLIP_UNNAMED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008129 p += 7;
8130 }
Bram Moolenaar11b73d62012-06-29 15:51:30 +02008131 else if (STRNCMP(p, "unnamedplus", 11) == 0
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01008132 && (p[11] == ',' || p[11] == NUL))
8133 {
8134 new_unnamed |= CLIP_UNNAMED_PLUS;
8135 p += 11;
8136 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008137 else if (STRNCMP(p, "autoselect", 10) == 0
Bram Moolenaar89af4392012-07-10 18:31:54 +02008138 && (p[10] == ',' || p[10] == NUL))
Bram Moolenaar071d4272004-06-13 20:20:40 +00008139 {
Bram Moolenaar89af4392012-07-10 18:31:54 +02008140 new_autoselect_star = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008141 p += 10;
8142 }
Bram Moolenaar89af4392012-07-10 18:31:54 +02008143 else if (STRNCMP(p, "autoselectplus", 14) == 0
8144 && (p[14] == ',' || p[14] == NUL))
8145 {
8146 new_autoselect_plus = TRUE;
8147 p += 14;
8148 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008149 else if (STRNCMP(p, "autoselectml", 12) == 0
Bram Moolenaar89af4392012-07-10 18:31:54 +02008150 && (p[12] == ',' || p[12] == NUL))
Bram Moolenaar071d4272004-06-13 20:20:40 +00008151 {
8152 new_autoselectml = TRUE;
8153 p += 12;
8154 }
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00008155 else if (STRNCMP(p, "html", 4) == 0 && (p[4] == ',' || p[4] == NUL))
8156 {
8157 new_html = TRUE;
8158 p += 4;
8159 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008160 else if (STRNCMP(p, "exclude:", 8) == 0 && new_exclude_prog == NULL)
8161 {
8162 p += 8;
8163 new_exclude_prog = vim_regcomp(p, RE_MAGIC);
8164 if (new_exclude_prog == NULL)
8165 errmsg = e_invarg;
8166 break;
8167 }
8168 else
8169 {
8170 errmsg = e_invarg;
8171 break;
8172 }
8173 if (*p == ',')
8174 ++p;
8175 }
8176 if (errmsg == NULL)
8177 {
8178 clip_unnamed = new_unnamed;
Bram Moolenaar89af4392012-07-10 18:31:54 +02008179 clip_autoselect_star = new_autoselect_star;
8180 clip_autoselect_plus = new_autoselect_plus;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008181 clip_autoselectml = new_autoselectml;
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00008182 clip_html = new_html;
Bram Moolenaar473de612013-06-08 18:19:48 +02008183 vim_regfree(clip_exclude_prog);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008184 clip_exclude_prog = new_exclude_prog;
Bram Moolenaara76638f2010-06-05 12:49:46 +02008185#ifdef FEAT_GUI_GTK
8186 if (gui.in_use)
8187 {
8188 gui_gtk_set_selection_targets();
8189 gui_gtk_set_dnd_targets();
8190 }
8191#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008192 }
8193 else
Bram Moolenaar473de612013-06-08 18:19:48 +02008194 vim_regfree(new_exclude_prog);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008195
8196 return errmsg;
8197}
8198#endif
8199
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00008200#ifdef FEAT_SPELL
Bram Moolenaare68c25c2015-08-25 15:39:55 +02008201 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01008202did_set_spell_option(int is_spellfile)
Bram Moolenaare68c25c2015-08-25 15:39:55 +02008203{
8204 char_u *errmsg = NULL;
8205 win_T *wp;
8206 int l;
8207
8208 if (is_spellfile)
8209 {
8210 l = (int)STRLEN(curwin->w_s->b_p_spf);
8211 if (l > 0 && (l < 4
8212 || STRCMP(curwin->w_s->b_p_spf + l - 4, ".add") != 0))
8213 errmsg = e_invarg;
8214 }
8215
8216 if (errmsg == NULL)
8217 {
8218 FOR_ALL_WINDOWS(wp)
8219 if (wp->w_buffer == curbuf && wp->w_p_spell)
8220 {
8221 errmsg = did_set_spelllang(wp);
Bram Moolenaare68c25c2015-08-25 15:39:55 +02008222 break;
Bram Moolenaare68c25c2015-08-25 15:39:55 +02008223 }
8224 }
8225 return errmsg;
8226}
8227
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00008228/*
8229 * Set curbuf->b_cap_prog to the regexp program for 'spellcapcheck'.
8230 * Return error message when failed, NULL when OK.
8231 */
8232 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01008233compile_cap_prog(synblock_T *synblock)
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00008234{
Bram Moolenaar860cae12010-06-05 23:22:07 +02008235 regprog_T *rp = synblock->b_cap_prog;
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008236 char_u *re;
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00008237
Bram Moolenaar860cae12010-06-05 23:22:07 +02008238 if (*synblock->b_p_spc == NUL)
8239 synblock->b_cap_prog = NULL;
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008240 else
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00008241 {
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008242 /* Prepend a ^ so that we only match at one column */
Bram Moolenaar860cae12010-06-05 23:22:07 +02008243 re = concat_str((char_u *)"^", synblock->b_p_spc);
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008244 if (re != NULL)
8245 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02008246 synblock->b_cap_prog = vim_regcomp(re, RE_MAGIC);
Bram Moolenaar473de612013-06-08 18:19:48 +02008247 vim_free(re);
Bram Moolenaar860cae12010-06-05 23:22:07 +02008248 if (synblock->b_cap_prog == NULL)
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008249 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02008250 synblock->b_cap_prog = rp; /* restore the previous program */
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008251 return e_invarg;
8252 }
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008253 }
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00008254 }
8255
Bram Moolenaar473de612013-06-08 18:19:48 +02008256 vim_regfree(rp);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00008257 return NULL;
8258}
8259#endif
8260
Bram Moolenaard1f56e62006-02-22 21:25:37 +00008261#if defined(FEAT_EVAL) || defined(PROTO)
8262/*
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02008263 * Set the script_ctx for an option, taking care of setting the buffer- or
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008264 * window-local value.
Bram Moolenaard1f56e62006-02-22 21:25:37 +00008265 */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008266 static void
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02008267set_option_sctx_idx(int opt_idx, int opt_flags, sctx_T script_ctx)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00008268{
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008269 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
8270 int indir = (int)options[opt_idx].indir;
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02008271 sctx_T new_script_ctx = script_ctx;
8272
8273 new_script_ctx.sc_lnum += sourcing_lnum;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00008274
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008275 /* Remember where the option was set. For local options need to do that
8276 * in the buffer or window structure. */
8277 if (both || (opt_flags & OPT_GLOBAL) || (indir & (PV_BUF|PV_WIN)) == 0)
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02008278 options[opt_idx].script_ctx = new_script_ctx;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008279 if (both || (opt_flags & OPT_LOCAL))
8280 {
8281 if (indir & PV_BUF)
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02008282 curbuf->b_p_script_ctx[indir & PV_MASK] = new_script_ctx;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008283 else if (indir & PV_WIN)
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02008284 curwin->w_p_script_ctx[indir & PV_MASK] = new_script_ctx;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008285 }
Bram Moolenaard1f56e62006-02-22 21:25:37 +00008286}
Bram Moolenaar35bc7d62018-10-02 14:45:10 +02008287
8288/*
8289 * Set the script_ctx for a termcap option.
8290 * "name" must be the two character code, e.g. "RV".
8291 * When "name" is NULL use "opt_idx".
8292 */
8293 void
8294set_term_option_sctx_idx(char *name, int opt_idx)
8295{
8296 char_u buf[5];
8297 int idx;
8298
8299 if (name == NULL)
8300 idx = opt_idx;
8301 else
8302 {
8303 buf[0] = 't';
8304 buf[1] = '_';
8305 buf[2] = name[0];
8306 buf[3] = name[1];
8307 buf[4] = 0;
8308 idx = findoption(buf);
8309 }
8310 if (idx >= 0)
8311 set_option_sctx_idx(idx, OPT_GLOBAL, current_sctx);
8312}
Bram Moolenaard1f56e62006-02-22 21:25:37 +00008313#endif
8314
Bram Moolenaar071d4272004-06-13 20:20:40 +00008315/*
8316 * Set the value of a boolean option, and take care of side effects.
8317 * Returns NULL for success, or an error message for an error.
8318 */
8319 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01008320set_bool_option(
8321 int opt_idx, /* index in options[] table */
8322 char_u *varp, /* pointer to the option variable */
8323 int value, /* new value */
8324 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008325{
8326 int old_value = *(int *)varp;
8327
Bram Moolenaar071d4272004-06-13 20:20:40 +00008328 /* Disallow changing some options from secure mode */
8329 if ((secure
8330#ifdef HAVE_SANDBOX
8331 || sandbox != 0
8332#endif
8333 ) && (options[opt_idx].flags & P_SECURE))
8334 return e_secure;
8335
8336 *(int *)varp = value; /* set the new value */
8337#ifdef FEAT_EVAL
8338 /* Remember where the option was set. */
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02008339 set_option_sctx_idx(opt_idx, opt_flags, current_sctx);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008340#endif
8341
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008342#ifdef FEAT_GUI
8343 need_mouse_correct = TRUE;
8344#endif
8345
Bram Moolenaar071d4272004-06-13 20:20:40 +00008346 /* May set global value for local option. */
8347 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
8348 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = value;
8349
8350 /*
8351 * Handle side effects of changing a bool option.
8352 */
8353
8354 /* 'compatible' */
8355 if ((int *)varp == &p_cp)
8356 {
8357 compatible_set();
8358 }
8359
Bram Moolenaar920694c2016-08-21 17:45:02 +02008360#ifdef FEAT_LANGMAP
8361 if ((int *)varp == &p_lrm)
8362 /* 'langremap' -> !'langnoremap' */
8363 p_lnr = !p_lrm;
8364 else if ((int *)varp == &p_lnr)
8365 /* 'langnoremap' -> !'langremap' */
8366 p_lrm = !p_lnr;
8367#endif
8368
Bram Moolenaar8c63e0e2018-09-25 22:17:54 +02008369#ifdef FEAT_SYN_HL
8370 else if ((int *)varp == &curwin->w_p_cul && !value && old_value)
8371 reset_cursorline();
8372#endif
8373
Bram Moolenaar374d32d2012-01-04 19:34:37 +01008374#ifdef FEAT_PERSISTENT_UNDO
8375 /* 'undofile' */
8376 else if ((int *)varp == &curbuf->b_p_udf || (int *)varp == &p_udf)
8377 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02008378 /* Only take action when the option was set. When reset we do not
8379 * delete the undo file, the option may be set again without making
8380 * any changes in between. */
8381 if (curbuf->b_p_udf || p_udf)
Bram Moolenaar374d32d2012-01-04 19:34:37 +01008382 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02008383 char_u hash[UNDO_HASH_SIZE];
8384 buf_T *save_curbuf = curbuf;
8385
Bram Moolenaar29323592016-07-24 22:04:11 +02008386 FOR_ALL_BUFFERS(curbuf)
Bram Moolenaar374d32d2012-01-04 19:34:37 +01008387 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02008388 /* When 'undofile' is set globally: for every buffer, otherwise
8389 * only for the current buffer: Try to read in the undofile,
8390 * if one exists, the buffer wasn't changed and the buffer was
8391 * loaded */
8392 if ((curbuf == save_curbuf
8393 || (opt_flags & OPT_GLOBAL) || opt_flags == 0)
8394 && !curbufIsChanged() && curbuf->b_ml.ml_mfp != NULL)
8395 {
8396 u_compute_hash(hash);
8397 u_read_undo(NULL, hash, curbuf->b_fname);
8398 }
Bram Moolenaar374d32d2012-01-04 19:34:37 +01008399 }
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02008400 curbuf = save_curbuf;
Bram Moolenaar374d32d2012-01-04 19:34:37 +01008401 }
Bram Moolenaar374d32d2012-01-04 19:34:37 +01008402 }
8403#endif
8404
Bram Moolenaar071d4272004-06-13 20:20:40 +00008405 else if ((int *)varp == &curbuf->b_p_ro)
8406 {
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00008407 /* when 'readonly' is reset globally, also reset readonlymode */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008408 if (!curbuf->b_p_ro && (opt_flags & OPT_LOCAL) == 0)
8409 readonlymode = FALSE;
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00008410
8411 /* when 'readonly' is set may give W10 again */
8412 if (curbuf->b_p_ro)
8413 curbuf->b_did_warn = FALSE;
8414
Bram Moolenaar071d4272004-06-13 20:20:40 +00008415#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008416 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008417#endif
8418 }
8419
Bram Moolenaar9c449722010-07-20 18:44:27 +02008420#ifdef FEAT_GUI
8421 else if ((int *)varp == &p_mh)
8422 {
8423 if (!p_mh)
8424 gui_mch_mousehide(FALSE);
8425 }
8426#endif
8427
Bram Moolenaara539df02010-08-01 14:35:05 +02008428 /* when 'modifiable' is changed, redraw the window title */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008429 else if ((int *)varp == &curbuf->b_p_ma)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008430 {
Bram Moolenaar423802d2017-07-30 16:52:24 +02008431# ifdef FEAT_TERMINAL
8432 /* Cannot set 'modifiable' when in Terminal mode. */
Bram Moolenaard7db27b2018-03-07 23:02:33 +01008433 if (curbuf->b_p_ma && (term_in_normal_mode() || (bt_terminal(curbuf)
8434 && curbuf->b_term != NULL && !term_is_finished(curbuf))))
Bram Moolenaar423802d2017-07-30 16:52:24 +02008435 {
8436 curbuf->b_p_ma = FALSE;
8437 return (char_u *)N_("E946: Cannot make a terminal with running job modifiable");
8438 }
8439# endif
8440# ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008441 redraw_titles();
Bram Moolenaar423802d2017-07-30 16:52:24 +02008442# endif
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008443 }
Bram Moolenaar423802d2017-07-30 16:52:24 +02008444#ifdef FEAT_TITLE
Bram Moolenaar071d4272004-06-13 20:20:40 +00008445 /* when 'endofline' is changed, redraw the window title */
8446 else if ((int *)varp == &curbuf->b_p_eol)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008447 {
8448 redraw_titles();
8449 }
Bram Moolenaar34d72d42015-07-17 14:18:08 +02008450 /* when 'fixeol' is changed, redraw the window title */
8451 else if ((int *)varp == &curbuf->b_p_fixeol)
8452 {
8453 redraw_titles();
8454 }
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008455# ifdef FEAT_MBYTE
8456 /* when 'bomb' is changed, redraw the window title and tab page text */
Bram Moolenaar83eb8852007-08-12 13:51:26 +00008457 else if ((int *)varp == &curbuf->b_p_bomb)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008458 {
8459 redraw_titles();
8460 }
8461# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008462#endif
8463
8464 /* when 'bin' is set also set some other options */
8465 else if ((int *)varp == &curbuf->b_p_bin)
8466 {
8467 set_options_bin(old_value, curbuf->b_p_bin, opt_flags);
8468#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008469 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008470#endif
8471 }
8472
Bram Moolenaar071d4272004-06-13 20:20:40 +00008473 /* when 'buflisted' changes, trigger autocommands */
8474 else if ((int *)varp == &curbuf->b_p_bl && old_value != curbuf->b_p_bl)
8475 {
8476 apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE,
8477 NULL, NULL, TRUE, curbuf);
8478 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008479
8480 /* when 'swf' is set, create swapfile, when reset remove swapfile */
8481 else if ((int *)varp == &curbuf->b_p_swf)
8482 {
8483 if (curbuf->b_p_swf && p_uc)
8484 ml_open_file(curbuf); /* create the swap file */
8485 else
Bram Moolenaard55de222007-05-06 13:38:48 +00008486 /* no need to reset curbuf->b_may_swap, ml_open_file() will check
8487 * buf->b_p_swf */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008488 mf_close_file(curbuf, TRUE); /* remove the swap file */
8489 }
8490
8491 /* when 'terse' is set change 'shortmess' */
8492 else if ((int *)varp == &p_terse)
8493 {
8494 char_u *p;
8495
8496 p = vim_strchr(p_shm, SHM_SEARCH);
8497
8498 /* insert 's' in p_shm */
8499 if (p_terse && p == NULL)
8500 {
8501 STRCPY(IObuff, p_shm);
8502 STRCAT(IObuff, "s");
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008503 set_string_option_direct((char_u *)"shm", -1, IObuff, OPT_FREE, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008504 }
8505 /* remove 's' from p_shm */
8506 else if (!p_terse && p != NULL)
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00008507 STRMOVE(p, p + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008508 }
8509
8510 /* when 'paste' is set or reset also change other options */
8511 else if ((int *)varp == &p_paste)
8512 {
8513 paste_option_changed();
8514 }
8515
8516 /* when 'insertmode' is set from an autocommand need to do work here */
8517 else if ((int *)varp == &p_im)
8518 {
8519 if (p_im)
8520 {
8521 if ((State & INSERT) == 0)
8522 need_start_insertmode = TRUE;
8523 stop_insert_mode = FALSE;
8524 }
Bram Moolenaar00672e12016-06-26 18:38:13 +02008525 /* only reset if it was set previously */
8526 else if (old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008527 {
8528 need_start_insertmode = FALSE;
8529 stop_insert_mode = TRUE;
Bram Moolenaard12f5c12006-01-25 22:10:52 +00008530 if (restart_edit != 0 && mode_displayed)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008531 clear_cmdline = TRUE; /* remove "(insert)" */
8532 restart_edit = 0;
8533 }
8534 }
8535
8536 /* when 'ignorecase' is set or reset and 'hlsearch' is set, redraw */
8537 else if ((int *)varp == &p_ic && p_hls)
8538 {
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00008539 redraw_all_later(SOME_VALID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008540 }
8541
8542#ifdef FEAT_SEARCH_EXTRA
8543 /* when 'hlsearch' is set or reset: reset no_hlsearch */
8544 else if ((int *)varp == &p_hls)
8545 {
Bram Moolenaar451fc7b2018-04-27 22:53:07 +02008546 set_no_hlsearch(FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008547 }
8548#endif
8549
Bram Moolenaar071d4272004-06-13 20:20:40 +00008550 /* when 'scrollbind' is set: snapshot the current position to avoid a jump
8551 * at the end of normal_cmd() */
8552 else if ((int *)varp == &curwin->w_p_scb)
8553 {
8554 if (curwin->w_p_scb)
Bram Moolenaar04c5c9e2013-07-09 13:44:59 +02008555 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00008556 do_check_scrollbind(FALSE);
Bram Moolenaar04c5c9e2013-07-09 13:44:59 +02008557 curwin->w_scbind_pos = curwin->w_topline;
8558 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008559 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008560
Bram Moolenaar4033c552017-09-16 20:54:51 +02008561#if defined(FEAT_QUICKFIX)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008562 /* There can be only one window with 'previewwindow' set. */
8563 else if ((int *)varp == &curwin->w_p_pvw)
8564 {
8565 if (curwin->w_p_pvw)
8566 {
8567 win_T *win;
8568
Bram Moolenaar29323592016-07-24 22:04:11 +02008569 FOR_ALL_WINDOWS(win)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008570 if (win->w_p_pvw && win != curwin)
8571 {
8572 curwin->w_p_pvw = FALSE;
8573 return (char_u *)N_("E590: A preview window already exists");
8574 }
8575 }
8576 }
8577#endif
8578
8579 /* when 'textmode' is set or reset also change 'fileformat' */
8580 else if ((int *)varp == &curbuf->b_p_tx)
8581 {
8582 set_fileformat(curbuf->b_p_tx ? EOL_DOS : EOL_UNIX, opt_flags);
8583 }
8584
8585 /* when 'textauto' is set or reset also change 'fileformats' */
8586 else if ((int *)varp == &p_ta)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008587 set_string_option_direct((char_u *)"ffs", -1,
8588 p_ta ? (char_u *)DFLT_FFS_VIM : (char_u *)"",
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008589 OPT_FREE | opt_flags, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008590
8591 /*
8592 * When 'lisp' option changes include/exclude '-' in
8593 * keyword characters.
8594 */
8595#ifdef FEAT_LISP
8596 else if (varp == (char_u *)&(curbuf->b_p_lisp))
8597 {
8598 (void)buf_init_chartab(curbuf, FALSE); /* ignore errors */
8599 }
8600#endif
8601
8602#ifdef FEAT_TITLE
8603 /* when 'title' changed, may need to change the title; same for 'icon' */
Bram Moolenaar84a93082018-06-16 22:58:15 +02008604 else if ((int *)varp == &p_title || (int *)varp == &p_icon)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008605 {
Bram Moolenaar84a93082018-06-16 22:58:15 +02008606 did_set_title();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008607 }
8608#endif
8609
8610 else if ((int *)varp == &curbuf->b_changed)
8611 {
8612 if (!value)
8613 save_file_ff(curbuf); /* Buffer is unchanged */
8614#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008615 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008616#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008617 modified_was_set = value;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008618 }
8619
8620#ifdef BACKSLASH_IN_FILENAME
8621 else if ((int *)varp == &p_ssl)
8622 {
8623 if (p_ssl)
8624 {
8625 psepc = '/';
8626 psepcN = '\\';
8627 pseps[0] = '/';
Bram Moolenaar071d4272004-06-13 20:20:40 +00008628 }
8629 else
8630 {
8631 psepc = '\\';
8632 psepcN = '/';
8633 pseps[0] = '\\';
Bram Moolenaar071d4272004-06-13 20:20:40 +00008634 }
8635
8636 /* need to adjust the file name arguments and buffer names. */
8637 buflist_slash_adjust();
8638 alist_slash_adjust();
8639# ifdef FEAT_EVAL
8640 scriptnames_slash_adjust();
8641# endif
8642 }
8643#endif
8644
8645 /* If 'wrap' is set, set w_leftcol to zero. */
8646 else if ((int *)varp == &curwin->w_p_wrap)
8647 {
8648 if (curwin->w_p_wrap)
8649 curwin->w_leftcol = 0;
8650 }
8651
Bram Moolenaar071d4272004-06-13 20:20:40 +00008652 else if ((int *)varp == &p_ea)
8653 {
8654 if (p_ea && !old_value)
8655 win_equal(curwin, FALSE, 0);
8656 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008657
8658 else if ((int *)varp == &p_wiv)
8659 {
8660 /*
8661 * When 'weirdinvert' changed, set/reset 't_xs'.
8662 * Then set 'weirdinvert' according to value of 't_xs'.
8663 */
8664 if (p_wiv && !old_value)
8665 T_XS = (char_u *)"y";
8666 else if (!p_wiv && old_value)
8667 T_XS = empty_option;
8668 p_wiv = (*T_XS != NUL);
8669 }
8670
Bram Moolenaarc3719bd2017-11-18 22:13:31 +01008671#ifdef FEAT_BEVAL_GUI
Bram Moolenaar071d4272004-06-13 20:20:40 +00008672 else if ((int *)varp == &p_beval)
8673 {
Bram Moolenaar51b0f372017-11-18 18:52:04 +01008674 if (!balloonEvalForTerm)
8675 {
8676 if (p_beval && !old_value)
8677 gui_mch_enable_beval_area(balloonEval);
8678 else if (!p_beval && old_value)
8679 gui_mch_disable_beval_area(balloonEval);
8680 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008681 }
Bram Moolenaar8dff8182006-04-06 20:18:50 +00008682#endif
Bram Moolenaarc3719bd2017-11-18 22:13:31 +01008683#ifdef FEAT_BEVAL_TERM
Bram Moolenaar51b0f372017-11-18 18:52:04 +01008684 else if ((int *)varp == &p_bevalterm)
8685 {
8686 mch_bevalterm_changed();
8687 }
Bram Moolenaarc3719bd2017-11-18 22:13:31 +01008688#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008689
Bram Moolenaar8dff8182006-04-06 20:18:50 +00008690#ifdef FEAT_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +00008691 else if ((int *)varp == &p_acd)
8692 {
Bram Moolenaar498efdb2006-09-05 14:31:54 +00008693 /* Change directories when the 'acd' option is set now. */
Bram Moolenaar6f470022018-04-10 18:47:20 +02008694 DO_AUTOCHDIR;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008695 }
8696#endif
8697
8698#ifdef FEAT_DIFF
8699 /* 'diff' */
8700 else if ((int *)varp == &curwin->w_p_diff)
8701 {
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008702 /* May add or remove the buffer from the list of diff buffers. */
8703 diff_buf_adjust(curwin);
8704# ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00008705 if (foldmethodIsDiff(curwin))
8706 foldUpdateAll(curwin);
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008707# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008708 }
8709#endif
8710
Bram Moolenaarf2bd8ef2018-03-04 18:08:14 +01008711#ifdef HAVE_INPUT_METHOD
Bram Moolenaar071d4272004-06-13 20:20:40 +00008712 /* 'imdisable' */
8713 else if ((int *)varp == &p_imdisable)
8714 {
8715 /* Only de-activate it here, it will be enabled when changing mode. */
8716 if (p_imdisable)
8717 im_set_active(FALSE);
Bram Moolenaar725a9622011-10-12 16:57:13 +02008718 else if (State & INSERT)
8719 /* When the option is set from an autocommand, it may need to take
8720 * effect right away. */
8721 im_set_active(curbuf->b_p_iminsert == B_IMODE_IM);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008722 }
8723#endif
8724
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00008725#ifdef FEAT_SPELL
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00008726 /* 'spell' */
8727 else if ((int *)varp == &curwin->w_p_spell)
8728 {
8729 if (curwin->w_p_spell)
8730 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02008731 char_u *errmsg = did_set_spelllang(curwin);
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00008732 if (errmsg != NULL)
8733 EMSG(_(errmsg));
8734 }
8735 }
8736#endif
8737
Bram Moolenaar071d4272004-06-13 20:20:40 +00008738#ifdef FEAT_FKMAP
8739 else if ((int *)varp == &p_altkeymap)
8740 {
8741 if (old_value != p_altkeymap)
8742 {
8743 if (!p_altkeymap)
8744 {
8745 p_hkmap = p_fkmap;
8746 p_fkmap = 0;
8747 }
8748 else
8749 {
8750 p_fkmap = p_hkmap;
8751 p_hkmap = 0;
8752 }
8753 (void)init_chartab();
8754 }
8755 }
8756
8757 /*
8758 * In case some second language keymapping options have changed, check
8759 * and correct the setting in a consistent way.
8760 */
8761
8762 /*
8763 * If hkmap or fkmap are set, reset Arabic keymapping.
8764 */
8765 if ((p_hkmap || p_fkmap) && p_altkeymap)
8766 {
8767 p_altkeymap = p_fkmap;
8768# ifdef FEAT_ARABIC
8769 curwin->w_p_arab = FALSE;
8770# endif
8771 (void)init_chartab();
8772 }
8773
8774 /*
8775 * If hkmap set, reset Farsi keymapping.
8776 */
8777 if (p_hkmap && p_altkeymap)
8778 {
8779 p_altkeymap = 0;
8780 p_fkmap = 0;
8781# ifdef FEAT_ARABIC
8782 curwin->w_p_arab = FALSE;
8783# endif
8784 (void)init_chartab();
8785 }
8786
8787 /*
8788 * If fkmap set, reset Hebrew keymapping.
8789 */
8790 if (p_fkmap && !p_altkeymap)
8791 {
8792 p_altkeymap = 1;
8793 p_hkmap = 0;
8794# ifdef FEAT_ARABIC
8795 curwin->w_p_arab = FALSE;
8796# endif
8797 (void)init_chartab();
8798 }
8799#endif
8800
8801#ifdef FEAT_ARABIC
8802 if ((int *)varp == &curwin->w_p_arab)
8803 {
8804 if (curwin->w_p_arab)
8805 {
8806 /*
8807 * 'arabic' is set, handle various sub-settings.
8808 */
8809 if (!p_tbidi)
8810 {
8811 /* set rightleft mode */
8812 if (!curwin->w_p_rl)
8813 {
8814 curwin->w_p_rl = TRUE;
8815 changed_window_setting();
8816 }
8817
8818 /* Enable Arabic shaping (major part of what Arabic requires) */
8819 if (!p_arshape)
8820 {
8821 p_arshape = TRUE;
8822 redraw_later_clear();
8823 }
8824 }
8825
8826 /* Arabic requires a utf-8 encoding, inform the user if its not
8827 * set. */
8828 if (STRCMP(p_enc, "utf-8") != 0)
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008829 {
Bram Moolenaar496c5262009-03-18 14:42:00 +00008830 static char *w_arabic = N_("W17: Arabic requires UTF-8, do ':set encoding=utf-8'");
8831
Bram Moolenaar8820b482017-03-16 17:23:31 +01008832 msg_source(HL_ATTR(HLF_W));
8833 MSG_ATTR(_(w_arabic), HL_ATTR(HLF_W));
Bram Moolenaar496c5262009-03-18 14:42:00 +00008834#ifdef FEAT_EVAL
8835 set_vim_var_string(VV_WARNINGMSG, (char_u *)_(w_arabic), -1);
8836#endif
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008837 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008838
8839# ifdef FEAT_MBYTE
8840 /* set 'delcombine' */
8841 p_deco = TRUE;
8842# endif
8843
8844# ifdef FEAT_KEYMAP
8845 /* Force-set the necessary keymap for arabic */
8846 set_option_value((char_u *)"keymap", 0L, (char_u *)"arabic",
8847 OPT_LOCAL);
8848# endif
8849# ifdef FEAT_FKMAP
8850 p_altkeymap = 0;
8851 p_hkmap = 0;
8852 p_fkmap = 0;
8853 (void)init_chartab();
8854# endif
8855 }
8856 else
8857 {
8858 /*
8859 * 'arabic' is reset, handle various sub-settings.
8860 */
8861 if (!p_tbidi)
8862 {
8863 /* reset rightleft mode */
8864 if (curwin->w_p_rl)
8865 {
8866 curwin->w_p_rl = FALSE;
8867 changed_window_setting();
8868 }
8869
8870 /* 'arabicshape' isn't reset, it is a global option and
8871 * another window may still need it "on". */
8872 }
8873
8874 /* 'delcombine' isn't reset, it is a global option and another
8875 * window may still want it "on". */
8876
8877# ifdef FEAT_KEYMAP
8878 /* Revert to the default keymap */
8879 curbuf->b_p_iminsert = B_IMODE_NONE;
8880 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
8881# endif
8882 }
Bram Moolenaar801f8b82009-07-29 13:42:05 +00008883 }
8884
Bram Moolenaar319bdbd2009-09-11 13:20:33 +00008885#endif
8886
Bram Moolenaar61be73b2016-04-29 22:59:22 +02008887#ifdef FEAT_TERMGUICOLORS
8888 /* 'termguicolors' */
8889 else if ((int *)varp == &p_tgc)
Bram Moolenaar8a633e32016-04-21 21:10:14 +02008890 {
Bram Moolenaarcafafb32018-02-22 21:07:09 +01008891# ifdef FEAT_VTP
8892 /* Do not turn on 'tgc' when 24-bit colors are not supported. */
8893 if (!has_vtp_working())
8894 {
8895 p_tgc = 0;
8896 return (char_u*)N_("E954: 24-bit colors are not supported on this environment");
8897 }
Bram Moolenaarc5cd8852018-05-01 15:47:38 +02008898 if (is_term_win32())
8899 swap_tcap();
Bram Moolenaarcafafb32018-02-22 21:07:09 +01008900# endif
Bram Moolenaar8a633e32016-04-21 21:10:14 +02008901# ifdef FEAT_GUI
8902 if (!gui.in_use && !gui.starting)
8903# endif
8904 highlight_gui_started();
Bram Moolenaarcafafb32018-02-22 21:07:09 +01008905# ifdef FEAT_VTP
Bram Moolenaarcafafb32018-02-22 21:07:09 +01008906 /* reset t_Co */
Bram Moolenaarc5cd8852018-05-01 15:47:38 +02008907 if (is_term_win32())
Bram Moolenaarb0eb14f2018-06-28 15:29:52 +02008908 {
8909 control_console_color_rgb();
Bram Moolenaarcafafb32018-02-22 21:07:09 +01008910 set_termname(T_NAME);
Bram Moolenaarb0eb14f2018-06-28 15:29:52 +02008911 init_highlight(TRUE, FALSE);
8912 }
Bram Moolenaarcafafb32018-02-22 21:07:09 +01008913# endif
Bram Moolenaar8a633e32016-04-21 21:10:14 +02008914 }
8915#endif
8916
Bram Moolenaar071d4272004-06-13 20:20:40 +00008917 /*
8918 * End of handling side effects for bool options.
8919 */
8920
Bram Moolenaar53744302015-07-17 17:38:22 +02008921 /* after handling side effects, call autocommand */
8922
Bram Moolenaar071d4272004-06-13 20:20:40 +00008923 options[opt_idx].flags |= P_WAS_SET;
8924
Bram Moolenaarf2bd8ef2018-03-04 18:08:14 +01008925#if defined(FEAT_EVAL)
Bram Moolenaar3f3fb0b2018-09-21 11:59:32 +02008926 // Don't do this while starting up or recursively.
8927 if (!starting && *get_vim_var_str(VV_OPTION_TYPE) == NUL)
Bram Moolenaar53744302015-07-17 17:38:22 +02008928 {
8929 char_u buf_old[2], buf_new[2], buf_type[7];
Bram Moolenaar3f3fb0b2018-09-21 11:59:32 +02008930
Bram Moolenaarfb9bc482015-07-17 22:04:48 +02008931 vim_snprintf((char *)buf_old, 2, "%d", old_value ? TRUE: FALSE);
8932 vim_snprintf((char *)buf_new, 2, "%d", value ? TRUE: FALSE);
8933 vim_snprintf((char *)buf_type, 7, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar53744302015-07-17 17:38:22 +02008934 set_vim_var_string(VV_OPTION_NEW, buf_new, -1);
8935 set_vim_var_string(VV_OPTION_OLD, buf_old, -1);
8936 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
8937 apply_autocmds(EVENT_OPTIONSET, (char_u *) options[opt_idx].fullname, NULL, FALSE, NULL);
8938 reset_v_option_vars();
8939 }
8940#endif
8941
Bram Moolenaar071d4272004-06-13 20:20:40 +00008942 comp_col(); /* in case 'ruler' or 'showcmd' changed */
Bram Moolenaar913077c2012-03-28 19:59:04 +02008943 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01008944 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02008945 curwin->w_set_curswant = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008946 check_redraw(options[opt_idx].flags);
8947
8948 return NULL;
8949}
8950
8951/*
8952 * Set the value of a number option, and take care of side effects.
8953 * Returns NULL for success, or an error message for an error.
8954 */
8955 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01008956set_num_option(
8957 int opt_idx, /* index in options[] table */
8958 char_u *varp, /* pointer to the option variable */
8959 long value, /* new value */
8960 char_u *errbuf, /* buffer for error messages */
8961 size_t errbuflen, /* length of "errbuf" */
8962 int opt_flags) /* OPT_LOCAL, OPT_GLOBAL and
Bram Moolenaar071d4272004-06-13 20:20:40 +00008963 OPT_MODELINE */
8964{
8965 char_u *errmsg = NULL;
8966 long old_value = *(long *)varp;
8967 long old_Rows = Rows; /* remember old Rows */
8968 long old_Columns = Columns; /* remember old Columns */
8969 long *pp = (long *)varp;
8970
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008971 /* Disallow changing some options from secure mode. */
8972 if ((secure
8973#ifdef HAVE_SANDBOX
8974 || sandbox != 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00008975#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008976 ) && (options[opt_idx].flags & P_SECURE))
8977 return e_secure;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008978
8979 *pp = value;
8980#ifdef FEAT_EVAL
8981 /* Remember where the option was set. */
Bram Moolenaarf29c1c62018-09-10 21:05:02 +02008982 set_option_sctx_idx(opt_idx, opt_flags, current_sctx);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008983#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008984#ifdef FEAT_GUI
8985 need_mouse_correct = TRUE;
8986#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008987
Bram Moolenaar14f24742012-08-08 18:01:05 +02008988 if (curbuf->b_p_sw < 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008989 {
8990 errmsg = e_positive;
Bram Moolenaar04958cb2018-06-23 19:23:02 +02008991#ifdef FEAT_VARTABS
8992 // Use the first 'vartabstop' value, or 'tabstop' if vts isn't in use.
8993 curbuf->b_p_sw = tabstop_count(curbuf->b_p_vts_array) > 0
8994 ? tabstop_first(curbuf->b_p_vts_array)
8995 : curbuf->b_p_ts;
8996#else
Bram Moolenaar071d4272004-06-13 20:20:40 +00008997 curbuf->b_p_sw = curbuf->b_p_ts;
Bram Moolenaar04958cb2018-06-23 19:23:02 +02008998#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008999 }
9000
9001 /*
9002 * Number options that need some action when changed
9003 */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009004 if (pp == &p_wh || pp == &p_hh)
9005 {
Bram Moolenaar1c3c1042018-06-12 16:49:30 +02009006 // 'winheight' and 'helpheight'
Bram Moolenaar071d4272004-06-13 20:20:40 +00009007 if (p_wh < 1)
9008 {
9009 errmsg = e_positive;
9010 p_wh = 1;
9011 }
9012 if (p_wmh > p_wh)
9013 {
9014 errmsg = e_winheight;
9015 p_wh = p_wmh;
9016 }
9017 if (p_hh < 0)
9018 {
9019 errmsg = e_positive;
9020 p_hh = 0;
9021 }
9022
9023 /* Change window height NOW */
Bram Moolenaar459ca562016-11-10 18:16:33 +01009024 if (!ONE_WINDOW)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009025 {
9026 if (pp == &p_wh && curwin->w_height < p_wh)
9027 win_setheight((int)p_wh);
9028 if (pp == &p_hh && curbuf->b_help && curwin->w_height < p_hh)
9029 win_setheight((int)p_hh);
9030 }
9031 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009032 else if (pp == &p_wmh)
9033 {
Bram Moolenaar1c3c1042018-06-12 16:49:30 +02009034 // 'winminheight'
Bram Moolenaar071d4272004-06-13 20:20:40 +00009035 if (p_wmh < 0)
9036 {
9037 errmsg = e_positive;
9038 p_wmh = 0;
9039 }
9040 if (p_wmh > p_wh)
9041 {
9042 errmsg = e_winheight;
9043 p_wmh = p_wh;
9044 }
9045 win_setminheight();
9046 }
Bram Moolenaar592e0a22004-07-03 16:05:59 +00009047 else if (pp == &p_wiw)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009048 {
Bram Moolenaar1c3c1042018-06-12 16:49:30 +02009049 // 'winwidth'
Bram Moolenaar071d4272004-06-13 20:20:40 +00009050 if (p_wiw < 1)
9051 {
9052 errmsg = e_positive;
9053 p_wiw = 1;
9054 }
9055 if (p_wmw > p_wiw)
9056 {
9057 errmsg = e_winwidth;
9058 p_wiw = p_wmw;
9059 }
9060
9061 /* Change window width NOW */
Bram Moolenaar459ca562016-11-10 18:16:33 +01009062 if (!ONE_WINDOW && curwin->w_width < p_wiw)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009063 win_setwidth((int)p_wiw);
9064 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009065 else if (pp == &p_wmw)
9066 {
Bram Moolenaar1c3c1042018-06-12 16:49:30 +02009067 // 'winminwidth'
Bram Moolenaar071d4272004-06-13 20:20:40 +00009068 if (p_wmw < 0)
9069 {
9070 errmsg = e_positive;
9071 p_wmw = 0;
9072 }
9073 if (p_wmw > p_wiw)
9074 {
9075 errmsg = e_winwidth;
9076 p_wmw = p_wiw;
9077 }
Bram Moolenaar1c3c1042018-06-12 16:49:30 +02009078 win_setminwidth();
Bram Moolenaar071d4272004-06-13 20:20:40 +00009079 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009080
Bram Moolenaar071d4272004-06-13 20:20:40 +00009081 /* (re)set last window status line */
9082 else if (pp == &p_ls)
9083 {
9084 last_status(FALSE);
9085 }
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00009086
9087 /* (re)set tab page line */
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00009088 else if (pp == &p_stal)
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00009089 {
9090 shell_new_rows(); /* recompute window positions and heights */
9091 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009092
9093#ifdef FEAT_GUI
9094 else if (pp == &p_linespace)
9095 {
Bram Moolenaar02743632005-07-25 20:42:36 +00009096 /* Recompute gui.char_height and resize the Vim window to keep the
9097 * same number of lines. */
9098 if (gui.in_use && gui_mch_adjust_charheight() == OK)
Bram Moolenaar3964b7e2006-03-27 20:59:33 +00009099 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009100 }
9101#endif
9102
9103#ifdef FEAT_FOLDING
9104 /* 'foldlevel' */
9105 else if (pp == &curwin->w_p_fdl)
9106 {
9107 if (curwin->w_p_fdl < 0)
9108 curwin->w_p_fdl = 0;
9109 newFoldLevel();
9110 }
9111
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00009112 /* 'foldminlines' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009113 else if (pp == &curwin->w_p_fml)
9114 {
9115 foldUpdateAll(curwin);
9116 }
9117
9118 /* 'foldnestmax' */
9119 else if (pp == &curwin->w_p_fdn)
9120 {
9121 if (foldmethodIsSyntax(curwin) || foldmethodIsIndent(curwin))
9122 foldUpdateAll(curwin);
9123 }
9124
9125 /* 'foldcolumn' */
9126 else if (pp == &curwin->w_p_fdc)
9127 {
9128 if (curwin->w_p_fdc < 0)
9129 {
9130 errmsg = e_positive;
9131 curwin->w_p_fdc = 0;
9132 }
9133 else if (curwin->w_p_fdc > 12)
9134 {
9135 errmsg = e_invarg;
9136 curwin->w_p_fdc = 12;
9137 }
9138 }
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01009139#endif /* FEAT_FOLDING */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009140
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01009141#if defined(FEAT_FOLDING) || defined(FEAT_CINDENT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009142 /* 'shiftwidth' or 'tabstop' */
9143 else if (pp == &curbuf->b_p_sw || pp == &curbuf->b_p_ts)
9144 {
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01009145# ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00009146 if (foldmethodIsIndent(curwin))
9147 foldUpdateAll(curwin);
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01009148# endif
9149# ifdef FEAT_CINDENT
9150 /* When 'shiftwidth' changes, or it's zero and 'tabstop' changes:
9151 * parse 'cinoptions'. */
9152 if (pp == &curbuf->b_p_sw || curbuf->b_p_sw == 0)
9153 parse_cino(curbuf);
9154# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009155 }
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01009156#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009157
Bram Moolenaar362e1a32006-03-06 23:29:24 +00009158#ifdef FEAT_MBYTE
9159 /* 'maxcombine' */
9160 else if (pp == &p_mco)
9161 {
9162 if (p_mco > MAX_MCO)
9163 p_mco = MAX_MCO;
9164 else if (p_mco < 0)
9165 p_mco = 0;
9166 screenclear(); /* will re-allocate the screen */
9167 }
9168#endif
9169
Bram Moolenaar071d4272004-06-13 20:20:40 +00009170 else if (pp == &curbuf->b_p_iminsert)
9171 {
9172 if (curbuf->b_p_iminsert < 0 || curbuf->b_p_iminsert > B_IMODE_LAST)
9173 {
9174 errmsg = e_invarg;
9175 curbuf->b_p_iminsert = B_IMODE_NONE;
9176 }
9177 p_iminsert = curbuf->b_p_iminsert;
9178 if (termcap_active) /* don't do this in the alternate screen */
9179 showmode();
Bram Moolenaar4033c552017-09-16 20:54:51 +02009180#if defined(FEAT_KEYMAP)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009181 /* Show/unshow value of 'keymap' in status lines. */
9182 status_redraw_curbuf();
9183#endif
9184 }
9185
Bram Moolenaar5c6dbcb2017-08-30 22:00:20 +02009186#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
9187 /* 'imstyle' */
9188 else if (pp == &p_imst)
9189 {
9190 if (p_imst != IM_ON_THE_SPOT && p_imst != IM_OVER_THE_SPOT)
9191 errmsg = e_invarg;
9192 }
9193#endif
9194
Bram Moolenaar4399ef42005-02-12 14:29:27 +00009195 else if (pp == &p_window)
9196 {
9197 if (p_window < 1)
9198 p_window = 1;
9199 else if (p_window >= Rows)
9200 p_window = Rows - 1;
9201 }
9202
Bram Moolenaar071d4272004-06-13 20:20:40 +00009203 else if (pp == &curbuf->b_p_imsearch)
9204 {
9205 if (curbuf->b_p_imsearch < -1 || curbuf->b_p_imsearch > B_IMODE_LAST)
9206 {
9207 errmsg = e_invarg;
9208 curbuf->b_p_imsearch = B_IMODE_NONE;
9209 }
9210 p_imsearch = curbuf->b_p_imsearch;
9211 }
9212
9213#ifdef FEAT_TITLE
9214 /* if 'titlelen' has changed, redraw the title */
9215 else if (pp == &p_titlelen)
9216 {
9217 if (p_titlelen < 0)
9218 {
9219 errmsg = e_positive;
9220 p_titlelen = 85;
9221 }
9222 if (starting != NO_SCREEN && old_value != p_titlelen)
9223 need_maketitle = TRUE;
9224 }
9225#endif
9226
9227 /* if p_ch changed value, change the command line height */
9228 else if (pp == &p_ch)
9229 {
9230 if (p_ch < 1)
9231 {
9232 errmsg = e_positive;
9233 p_ch = 1;
9234 }
Bram Moolenaar719939c2007-09-25 12:51:28 +00009235 if (p_ch > Rows - min_rows() + 1)
9236 p_ch = Rows - min_rows() + 1;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009237
9238 /* Only compute the new window layout when startup has been
9239 * completed. Otherwise the frame sizes may be wrong. */
9240 if (p_ch != old_value && full_screen
9241#ifdef FEAT_GUI
9242 && !gui.starting
9243#endif
9244 )
Bram Moolenaarc6fe9192006-04-09 21:54:49 +00009245 command_height();
Bram Moolenaar071d4272004-06-13 20:20:40 +00009246 }
9247
9248 /* when 'updatecount' changes from zero to non-zero, open swap files */
9249 else if (pp == &p_uc)
9250 {
9251 if (p_uc < 0)
9252 {
9253 errmsg = e_positive;
9254 p_uc = 100;
9255 }
9256 if (p_uc && !old_value)
9257 ml_open_files();
9258 }
Bram Moolenaar860cae12010-06-05 23:22:07 +02009259#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +02009260 else if (pp == &curwin->w_p_cole)
Bram Moolenaar860cae12010-06-05 23:22:07 +02009261 {
Bram Moolenaarf5963f72010-07-23 22:10:27 +02009262 if (curwin->w_p_cole < 0)
Bram Moolenaar860cae12010-06-05 23:22:07 +02009263 {
9264 errmsg = e_positive;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02009265 curwin->w_p_cole = 0;
Bram Moolenaar860cae12010-06-05 23:22:07 +02009266 }
Bram Moolenaarf5963f72010-07-23 22:10:27 +02009267 else if (curwin->w_p_cole > 3)
Bram Moolenaar860cae12010-06-05 23:22:07 +02009268 {
9269 errmsg = e_invarg;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02009270 curwin->w_p_cole = 3;
Bram Moolenaar860cae12010-06-05 23:22:07 +02009271 }
9272 }
9273#endif
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00009274#ifdef MZSCHEME_GUI_THREADS
Bram Moolenaar325b7a22004-07-05 15:58:32 +00009275 else if (pp == &p_mzq)
9276 mzvim_reset_timer();
9277#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009278
Bram Moolenaarf42dd3c2017-01-28 16:06:38 +01009279#if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3)
9280 /* 'pyxversion' */
9281 else if (pp == &p_pyx)
9282 {
9283 if (p_pyx != 0 && p_pyx != 2 && p_pyx != 3)
9284 errmsg = e_invarg;
9285 }
9286#endif
9287
Bram Moolenaar071d4272004-06-13 20:20:40 +00009288 /* sync undo before 'undolevels' changes */
9289 else if (pp == &p_ul)
9290 {
9291 /* use the old value, otherwise u_sync() may not work properly */
9292 p_ul = old_value;
Bram Moolenaar779b74b2006-04-10 14:55:34 +00009293 u_sync(TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009294 p_ul = value;
9295 }
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01009296 else if (pp == &curbuf->b_p_ul)
9297 {
9298 /* use the old value, otherwise u_sync() may not work properly */
9299 curbuf->b_p_ul = old_value;
9300 u_sync(TRUE);
9301 curbuf->b_p_ul = value;
9302 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009303
Bram Moolenaar592e0a22004-07-03 16:05:59 +00009304#ifdef FEAT_LINEBREAK
9305 /* 'numberwidth' must be positive */
9306 else if (pp == &curwin->w_p_nuw)
9307 {
9308 if (curwin->w_p_nuw < 1)
9309 {
9310 errmsg = e_positive;
9311 curwin->w_p_nuw = 1;
9312 }
9313 if (curwin->w_p_nuw > 10)
9314 {
9315 errmsg = e_invarg;
9316 curwin->w_p_nuw = 10;
9317 }
Bram Moolenaar1e7813a2015-03-31 18:31:03 +02009318 curwin->w_nrwidth_line_count = 0; /* trigger a redraw */
Bram Moolenaar592e0a22004-07-03 16:05:59 +00009319 }
9320#endif
9321
Bram Moolenaar1a384422010-07-14 19:53:30 +02009322 else if (pp == &curbuf->b_p_tw)
9323 {
9324 if (curbuf->b_p_tw < 0)
9325 {
9326 errmsg = e_positive;
9327 curbuf->b_p_tw = 0;
9328 }
9329#ifdef FEAT_SYN_HL
Bram Moolenaar1a384422010-07-14 19:53:30 +02009330 {
9331 win_T *wp;
9332 tabpage_T *tp;
9333
9334 FOR_ALL_TAB_WINDOWS(tp, wp)
9335 check_colorcolumn(wp);
9336 }
Bram Moolenaar1a384422010-07-14 19:53:30 +02009337#endif
9338 }
9339
Bram Moolenaar071d4272004-06-13 20:20:40 +00009340 /*
9341 * Check the bounds for numeric options here
9342 */
9343 if (Rows < min_rows() && full_screen)
9344 {
9345 if (errbuf != NULL)
9346 {
Bram Moolenaar555b2802005-05-19 21:08:39 +00009347 vim_snprintf((char *)errbuf, errbuflen,
9348 _("E593: Need at least %d lines"), min_rows());
Bram Moolenaar071d4272004-06-13 20:20:40 +00009349 errmsg = errbuf;
9350 }
9351 Rows = min_rows();
9352 }
9353 if (Columns < MIN_COLUMNS && full_screen)
9354 {
9355 if (errbuf != NULL)
9356 {
Bram Moolenaar555b2802005-05-19 21:08:39 +00009357 vim_snprintf((char *)errbuf, errbuflen,
9358 _("E594: Need at least %d columns"), MIN_COLUMNS);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009359 errmsg = errbuf;
9360 }
9361 Columns = MIN_COLUMNS;
9362 }
Bram Moolenaare057d402013-06-30 17:51:51 +02009363 limit_screen_size();
Bram Moolenaar071d4272004-06-13 20:20:40 +00009364
Bram Moolenaar071d4272004-06-13 20:20:40 +00009365 /*
9366 * If the screen (shell) height has been changed, assume it is the
9367 * physical screenheight.
9368 */
9369 if (old_Rows != Rows || old_Columns != Columns)
9370 {
9371 /* Changing the screen size is not allowed while updating the screen. */
9372 if (updating_screen)
9373 *pp = old_value;
9374 else if (full_screen
9375#ifdef FEAT_GUI
9376 && !gui.starting
9377#endif
9378 )
9379 set_shellsize((int)Columns, (int)Rows, TRUE);
9380 else
9381 {
9382 /* Postpone the resizing; check the size and cmdline position for
9383 * messages. */
9384 check_shellsize();
9385 if (cmdline_row > Rows - p_ch && Rows > p_ch)
9386 cmdline_row = Rows - p_ch;
9387 }
Bram Moolenaard68071d2006-05-02 22:08:30 +00009388 if (p_window >= Rows || !option_was_set((char_u *)"window"))
Bram Moolenaar4399ef42005-02-12 14:29:27 +00009389 p_window = Rows - 1;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009390 }
9391
Bram Moolenaar071d4272004-06-13 20:20:40 +00009392 if (curbuf->b_p_ts <= 0)
9393 {
9394 errmsg = e_positive;
9395 curbuf->b_p_ts = 8;
9396 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009397 if (p_tm < 0)
9398 {
9399 errmsg = e_positive;
9400 p_tm = 0;
9401 }
9402 if ((curwin->w_p_scr <= 0
9403 || (curwin->w_p_scr > curwin->w_height
9404 && curwin->w_height > 0))
9405 && full_screen)
9406 {
9407 if (pp == &(curwin->w_p_scr))
9408 {
9409 if (curwin->w_p_scr != 0)
9410 errmsg = e_scroll;
9411 win_comp_scroll(curwin);
9412 }
9413 /* If 'scroll' became invalid because of a side effect silently adjust
9414 * it. */
9415 else if (curwin->w_p_scr <= 0)
9416 curwin->w_p_scr = 1;
9417 else /* curwin->w_p_scr > curwin->w_height */
9418 curwin->w_p_scr = curwin->w_height;
9419 }
Bram Moolenaar991e10f2008-10-02 20:48:41 +00009420 if (p_hi < 0)
9421 {
9422 errmsg = e_positive;
9423 p_hi = 0;
9424 }
Bram Moolenaar78159bb2014-06-25 11:48:54 +02009425 else if (p_hi > 10000)
9426 {
9427 errmsg = e_invarg;
9428 p_hi = 10000;
9429 }
Bram Moolenaarfbc0d2e2013-05-19 19:40:29 +02009430 if (p_re < 0 || p_re > 2)
9431 {
9432 errmsg = e_invarg;
9433 p_re = 0;
9434 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009435 if (p_report < 0)
9436 {
9437 errmsg = e_positive;
9438 p_report = 1;
9439 }
Bram Moolenaar1e015462005-09-25 22:16:38 +00009440 if ((p_sj < -100 || p_sj >= Rows) && full_screen)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009441 {
9442 if (Rows != old_Rows) /* Rows changed, just adjust p_sj */
9443 p_sj = Rows / 2;
9444 else
9445 {
9446 errmsg = e_scroll;
9447 p_sj = 1;
9448 }
9449 }
9450 if (p_so < 0 && full_screen)
9451 {
9452 errmsg = e_scroll;
9453 p_so = 0;
9454 }
9455 if (p_siso < 0 && full_screen)
9456 {
9457 errmsg = e_positive;
9458 p_siso = 0;
9459 }
9460#ifdef FEAT_CMDWIN
9461 if (p_cwh < 1)
9462 {
9463 errmsg = e_positive;
9464 p_cwh = 1;
9465 }
9466#endif
9467 if (p_ut < 0)
9468 {
9469 errmsg = e_positive;
9470 p_ut = 2000;
9471 }
9472 if (p_ss < 0)
9473 {
9474 errmsg = e_positive;
9475 p_ss = 0;
9476 }
9477
9478 /* May set global value for local option. */
9479 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
9480 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = *pp;
9481
9482 options[opt_idx].flags |= P_WAS_SET;
9483
Bram Moolenaarf2bd8ef2018-03-04 18:08:14 +01009484#if defined(FEAT_EVAL)
Bram Moolenaar3f3fb0b2018-09-21 11:59:32 +02009485 // Don't do this while starting up, failure or recursively.
9486 if (!starting && errmsg == NULL && *get_vim_var_str(VV_OPTION_TYPE) == NUL)
Bram Moolenaar53744302015-07-17 17:38:22 +02009487 {
9488 char_u buf_old[11], buf_new[11], buf_type[7];
Bram Moolenaarfb9bc482015-07-17 22:04:48 +02009489 vim_snprintf((char *)buf_old, 10, "%ld", old_value);
9490 vim_snprintf((char *)buf_new, 10, "%ld", value);
9491 vim_snprintf((char *)buf_type, 7, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar53744302015-07-17 17:38:22 +02009492 set_vim_var_string(VV_OPTION_NEW, buf_new, -1);
9493 set_vim_var_string(VV_OPTION_OLD, buf_old, -1);
9494 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
9495 apply_autocmds(EVENT_OPTIONSET, (char_u *) options[opt_idx].fullname, NULL, FALSE, NULL);
9496 reset_v_option_vars();
9497 }
9498#endif
9499
Bram Moolenaar071d4272004-06-13 20:20:40 +00009500 comp_col(); /* in case 'columns' or 'ls' changed */
Bram Moolenaar913077c2012-03-28 19:59:04 +02009501 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01009502 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02009503 curwin->w_set_curswant = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009504 check_redraw(options[opt_idx].flags);
9505
9506 return errmsg;
9507}
9508
9509/*
9510 * Called after an option changed: check if something needs to be redrawn.
9511 */
9512 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01009513check_redraw(long_u flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009514{
9515 /* Careful: P_RCLR and P_RALL are a combination of other P_ flags */
Bram Moolenaar70b2a562012-01-10 22:26:17 +01009516 int doclear = (flags & P_RCLR) == P_RCLR;
9517 int all = ((flags & P_RALL) == P_RALL || doclear);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009518
Bram Moolenaar071d4272004-06-13 20:20:40 +00009519 if ((flags & P_RSTAT) || all) /* mark all status lines dirty */
9520 status_redraw_all();
Bram Moolenaar071d4272004-06-13 20:20:40 +00009521
9522 if ((flags & P_RBUF) || (flags & P_RWIN) || all)
9523 changed_window_setting();
9524 if (flags & P_RBUF)
9525 redraw_curbuf_later(NOT_VALID);
Bram Moolenaara2477fd2016-12-03 15:13:20 +01009526 if (flags & P_RWINONLY)
9527 redraw_later(NOT_VALID);
Bram Moolenaar70b2a562012-01-10 22:26:17 +01009528 if (doclear)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009529 redraw_all_later(CLEAR);
9530 else if (all)
9531 redraw_all_later(NOT_VALID);
9532}
9533
9534/*
9535 * Find index for option 'arg'.
9536 * Return -1 if not found.
9537 */
9538 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009539findoption(char_u *arg)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009540{
9541 int opt_idx;
9542 char *s, *p;
9543 static short quick_tab[27] = {0, 0}; /* quick access table */
9544 int is_term_opt;
9545
9546 /*
9547 * For first call: Initialize the quick-access table.
9548 * It contains the index for the first option that starts with a certain
9549 * letter. There are 26 letters, plus the first "t_" option.
9550 */
9551 if (quick_tab[1] == 0)
9552 {
9553 p = options[0].fullname;
9554 for (opt_idx = 1; (s = options[opt_idx].fullname) != NULL; opt_idx++)
9555 {
9556 if (s[0] != p[0])
9557 {
9558 if (s[0] == 't' && s[1] == '_')
9559 quick_tab[26] = opt_idx;
9560 else
9561 quick_tab[CharOrdLow(s[0])] = opt_idx;
9562 }
9563 p = s;
9564 }
9565 }
9566
9567 /*
9568 * Check for name starting with an illegal character.
9569 */
9570#ifdef EBCDIC
9571 if (!islower(arg[0]))
9572#else
9573 if (arg[0] < 'a' || arg[0] > 'z')
9574#endif
9575 return -1;
9576
9577 is_term_opt = (arg[0] == 't' && arg[1] == '_');
9578 if (is_term_opt)
9579 opt_idx = quick_tab[26];
9580 else
9581 opt_idx = quick_tab[CharOrdLow(arg[0])];
9582 for ( ; (s = options[opt_idx].fullname) != NULL; opt_idx++)
9583 {
9584 if (STRCMP(arg, s) == 0) /* match full name */
9585 break;
9586 }
9587 if (s == NULL && !is_term_opt)
9588 {
9589 opt_idx = quick_tab[CharOrdLow(arg[0])];
9590 for ( ; options[opt_idx].fullname != NULL; opt_idx++)
9591 {
9592 s = options[opt_idx].shortname;
9593 if (s != NULL && STRCMP(arg, s) == 0) /* match short name */
9594 break;
9595 s = NULL;
9596 }
9597 }
9598 if (s == NULL)
9599 opt_idx = -1;
9600 return opt_idx;
9601}
9602
Bram Moolenaar325b7a22004-07-05 15:58:32 +00009603#if defined(FEAT_EVAL) || defined(FEAT_TCL) || defined(FEAT_MZSCHEME)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009604/*
9605 * Get the value for an option.
9606 *
9607 * Returns:
9608 * Number or Toggle option: 1, *numval gets value.
9609 * String option: 0, *stringval gets allocated string.
9610 * Hidden Number or Toggle option: -1.
9611 * hidden String option: -2.
9612 * unknown option: -3.
9613 */
9614 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009615get_option_value(
9616 char_u *name,
9617 long *numval,
9618 char_u **stringval, /* NULL when only checking existence */
9619 int opt_flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009620{
9621 int opt_idx;
9622 char_u *varp;
9623
9624 opt_idx = findoption(name);
9625 if (opt_idx < 0) /* unknown option */
Bram Moolenaare353c402017-02-04 19:49:16 +01009626 {
9627 int key;
9628
9629 if (STRLEN(name) == 4 && name[0] == 't' && name[1] == '_'
Bram Moolenaar9cf4b502018-07-23 04:12:03 +02009630 && (key = find_key_option(name, FALSE)) != 0)
Bram Moolenaare353c402017-02-04 19:49:16 +01009631 {
9632 char_u key_name[2];
9633 char_u *p;
9634
9635 if (key < 0)
9636 {
9637 key_name[0] = KEY2TERMCAP0(key);
9638 key_name[1] = KEY2TERMCAP1(key);
9639 }
9640 else
9641 {
9642 key_name[0] = KS_KEY;
9643 key_name[1] = (key & 0xff);
9644 }
9645 p = find_termcode(key_name);
9646 if (p != NULL)
9647 {
9648 if (stringval != NULL)
9649 *stringval = vim_strsave(p);
9650 return 0;
9651 }
9652 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009653 return -3;
Bram Moolenaare353c402017-02-04 19:49:16 +01009654 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009655
9656 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
9657
9658 if (options[opt_idx].flags & P_STRING)
9659 {
9660 if (varp == NULL) /* hidden option */
9661 return -2;
9662 if (stringval != NULL)
9663 {
9664#ifdef FEAT_CRYPT
9665 /* never return the value of the crypt key */
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00009666 if ((char_u **)varp == &curbuf->b_p_key
9667 && **(char_u **)(varp) != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009668 *stringval = vim_strsave((char_u *)"*****");
9669 else
9670#endif
9671 *stringval = vim_strsave(*(char_u **)(varp));
9672 }
9673 return 0;
9674 }
9675
9676 if (varp == NULL) /* hidden option */
9677 return -1;
9678 if (options[opt_idx].flags & P_NUM)
9679 *numval = *(long *)varp;
9680 else
9681 {
9682 /* Special case: 'modified' is b_changed, but we also want to consider
9683 * it set when 'ff' or 'fenc' changed. */
9684 if ((int *)varp == &curbuf->b_changed)
9685 *numval = curbufIsChanged();
9686 else
Bram Moolenaar2acfbed2016-07-01 23:14:02 +02009687 *numval = (long) *(int *)varp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009688 }
9689 return 1;
9690}
9691#endif
9692
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009693#if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009694/*
9695 * Returns the option attributes and its value. Unlike the above function it
9696 * will return either global value or local value of the option depending on
9697 * what was requested, but it will never return global value if it was
9698 * requested to return local one and vice versa. Neither it will return
9699 * buffer-local value if it was requested to return window-local one.
9700 *
9701 * Pretends that option is absent if it is not present in the requested scope
9702 * (i.e. has no global, window-local or buffer-local value depending on
9703 * opt_type). Uses
9704 *
9705 * Returned flags:
Bram Moolenaar75a8d742014-05-07 15:10:21 +02009706 * 0 hidden or unknown option, also option that does not have requested
9707 * type (see SREQ_* in vim.h)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009708 * see SOPT_* in vim.h for other flags
9709 *
9710 * Possible opt_type values: see SREQ_* in vim.h
9711 */
9712 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009713get_option_value_strict(
9714 char_u *name,
9715 long *numval,
9716 char_u **stringval, /* NULL when only obtaining attributes */
9717 int opt_type,
9718 void *from)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009719{
9720 int opt_idx;
Bram Moolenaar68001862013-05-11 13:45:05 +02009721 char_u *varp = NULL;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009722 struct vimoption *p;
9723 int r = 0;
9724
9725 opt_idx = findoption(name);
9726 if (opt_idx < 0)
9727 return 0;
9728
9729 p = &(options[opt_idx]);
9730
9731 /* Hidden option */
9732 if (p->var == NULL)
9733 return 0;
9734
9735 if (p->flags & P_BOOL)
9736 r |= SOPT_BOOL;
9737 else if (p->flags & P_NUM)
9738 r |= SOPT_NUM;
9739 else if (p->flags & P_STRING)
9740 r |= SOPT_STRING;
9741
9742 if (p->indir == PV_NONE)
9743 {
9744 if (opt_type == SREQ_GLOBAL)
9745 r |= SOPT_GLOBAL;
9746 else
9747 return 0; /* Did not request global-only option */
9748 }
9749 else
9750 {
9751 if (p->indir & PV_BOTH)
9752 r |= SOPT_GLOBAL;
9753 else if (opt_type == SREQ_GLOBAL)
9754 return 0; /* Requested global option */
9755
9756 if (p->indir & PV_WIN)
9757 {
9758 if (opt_type == SREQ_BUF)
9759 return 0; /* Did not request window-local option */
9760 else
9761 r |= SOPT_WIN;
9762 }
9763 else if (p->indir & PV_BUF)
9764 {
9765 if (opt_type == SREQ_WIN)
9766 return 0; /* Did not request buffer-local option */
9767 else
9768 r |= SOPT_BUF;
9769 }
9770 }
9771
9772 if (stringval == NULL)
9773 return r;
9774
9775 if (opt_type == SREQ_GLOBAL)
9776 varp = p->var;
9777 else
9778 {
9779 if (opt_type == SREQ_BUF)
9780 {
9781 /* Special case: 'modified' is b_changed, but we also want to
9782 * consider it set when 'ff' or 'fenc' changed. */
9783 if (p->indir == PV_MOD)
9784 {
Bram Moolenaardefe6422018-06-24 15:14:07 +02009785 *numval = bufIsChanged((buf_T *)from);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009786 varp = NULL;
9787 }
9788#ifdef FEAT_CRYPT
9789 else if (p->indir == PV_KEY)
9790 {
9791 /* never return the value of the crypt key */
9792 *stringval = NULL;
9793 varp = NULL;
9794 }
9795#endif
9796 else
9797 {
Bram Moolenaardefe6422018-06-24 15:14:07 +02009798 buf_T *save_curbuf = curbuf;
9799
9800 // only getting a pointer, no need to use aucmd_prepbuf()
9801 curbuf = (buf_T *)from;
9802 curwin->w_buffer = curbuf;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009803 varp = get_varp(p);
Bram Moolenaardefe6422018-06-24 15:14:07 +02009804 curbuf = save_curbuf;
9805 curwin->w_buffer = curbuf;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009806 }
9807 }
9808 else if (opt_type == SREQ_WIN)
9809 {
Bram Moolenaardefe6422018-06-24 15:14:07 +02009810 win_T *save_curwin = curwin;
9811
9812 curwin = (win_T *)from;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009813 curbuf = curwin->w_buffer;
9814 varp = get_varp(p);
9815 curwin = save_curwin;
9816 curbuf = curwin->w_buffer;
9817 }
9818 if (varp == p->var)
9819 return (r | SOPT_UNSET);
9820 }
9821
9822 if (varp != NULL)
9823 {
9824 if (p->flags & P_STRING)
9825 *stringval = vim_strsave(*(char_u **)(varp));
9826 else if (p->flags & P_NUM)
9827 *numval = *(long *) varp;
9828 else
9829 *numval = *(int *)varp;
9830 }
9831
9832 return r;
9833}
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009834
9835/*
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009836 * Iterate over options. First argument is a pointer to a pointer to a
9837 * structure inside options[] array, second is option type like in the above
9838 * function.
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009839 *
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009840 * If first argument points to NULL it is assumed that iteration just started
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009841 * and caller needs the very first value.
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009842 * If first argument points to the end marker function returns NULL and sets
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009843 * first argument to NULL.
9844 *
9845 * Returns full option name for current option on each call.
9846 */
9847 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009848option_iter_next(void **option, int opt_type)
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009849{
9850 struct vimoption *ret = NULL;
9851 do
9852 {
9853 if (*option == NULL)
9854 *option = (void *) options;
9855 else if (((struct vimoption *) (*option))->fullname == NULL)
9856 {
9857 *option = NULL;
9858 return NULL;
9859 }
9860 else
9861 *option = (void *) (((struct vimoption *) (*option)) + 1);
9862
9863 ret = ((struct vimoption *) (*option));
9864
9865 /* Hidden option */
9866 if (ret->var == NULL)
9867 {
9868 ret = NULL;
9869 continue;
9870 }
9871
9872 switch (opt_type)
9873 {
9874 case SREQ_GLOBAL:
9875 if (!(ret->indir == PV_NONE || ret->indir & PV_BOTH))
9876 ret = NULL;
9877 break;
9878 case SREQ_BUF:
9879 if (!(ret->indir & PV_BUF))
9880 ret = NULL;
9881 break;
9882 case SREQ_WIN:
9883 if (!(ret->indir & PV_WIN))
9884 ret = NULL;
9885 break;
9886 default:
Bram Moolenaar95f09602016-11-10 20:01:45 +01009887 internal_error("option_iter_next()");
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009888 return NULL;
9889 }
9890 }
9891 while (ret == NULL);
9892
9893 return (char_u *)ret->fullname;
9894}
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009895#endif
9896
Bram Moolenaar071d4272004-06-13 20:20:40 +00009897/*
9898 * Set the value of option "name".
9899 * Use "string" for string options, use "number" for other options.
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009900 *
9901 * Returns NULL on success or error message on error.
Bram Moolenaar071d4272004-06-13 20:20:40 +00009902 */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009903 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009904set_option_value(
9905 char_u *name,
9906 long number,
9907 char_u *string,
9908 int opt_flags) /* OPT_LOCAL or 0 (both) */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009909{
9910 int opt_idx;
9911 char_u *varp;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00009912 long_u flags;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009913
9914 opt_idx = findoption(name);
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00009915 if (opt_idx < 0)
Bram Moolenaare353c402017-02-04 19:49:16 +01009916 {
9917 int key;
9918
9919 if (STRLEN(name) == 4 && name[0] == 't' && name[1] == '_'
Bram Moolenaar9cf4b502018-07-23 04:12:03 +02009920 && (key = find_key_option(name, FALSE)) != 0)
Bram Moolenaare353c402017-02-04 19:49:16 +01009921 {
9922 char_u key_name[2];
9923
9924 if (key < 0)
9925 {
9926 key_name[0] = KEY2TERMCAP0(key);
9927 key_name[1] = KEY2TERMCAP1(key);
9928 }
9929 else
9930 {
9931 key_name[0] = KS_KEY;
9932 key_name[1] = (key & 0xff);
9933 }
9934 add_termcode(key_name, string, FALSE);
9935 if (full_screen)
9936 ttest(FALSE);
9937 redraw_all_later(CLEAR);
9938 return NULL;
9939 }
9940
Bram Moolenaar071d4272004-06-13 20:20:40 +00009941 EMSG2(_("E355: Unknown option: %s"), name);
Bram Moolenaare353c402017-02-04 19:49:16 +01009942 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009943 else
9944 {
9945 flags = options[opt_idx].flags;
9946#ifdef HAVE_SANDBOX
9947 /* Disallow changing some options in the sandbox */
9948 if (sandbox > 0 && (flags & P_SECURE))
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009949 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00009950 EMSG(_(e_sandbox));
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009951 return NULL;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009952 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009953#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009954 if (flags & P_STRING)
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009955 return set_string_option(opt_idx, string, opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009956 else
9957 {
Bram Moolenaarb3163762008-07-08 15:15:08 +00009958 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009959 if (varp != NULL) /* hidden option is not changed */
9960 {
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009961 if (number == 0 && string != NULL)
9962 {
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009963 int idx;
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009964
9965 /* Either we are given a string or we are setting option
9966 * to zero. */
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009967 for (idx = 0; string[idx] == '0'; ++idx)
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009968 ;
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009969 if (string[idx] != NUL || idx == 0)
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009970 {
9971 /* There's another character after zeros or the string
9972 * is empty. In both cases, we are trying to set a
9973 * num option using a string. */
9974 EMSG3(_("E521: Number required: &%s = '%s'"),
9975 name, string);
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009976 return NULL; /* do nothing as we hit an error */
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009977
9978 }
9979 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009980 if (flags & P_NUM)
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009981 return set_num_option(opt_idx, varp, number,
Bram Moolenaar555b2802005-05-19 21:08:39 +00009982 NULL, 0, opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009983 else
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009984 return set_bool_option(opt_idx, varp, (int)number,
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009985 opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009986 }
9987 }
9988 }
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009989 return NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009990}
9991
9992/*
9993 * Get the terminal code for a terminal option.
9994 * Returns NULL when not found.
9995 */
9996 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009997get_term_code(char_u *tname)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009998{
9999 int opt_idx;
10000 char_u *varp;
10001
10002 if (tname[0] != 't' || tname[1] != '_' ||
10003 tname[2] == NUL || tname[3] == NUL)
10004 return NULL;
10005 if ((opt_idx = findoption(tname)) >= 0)
10006 {
10007 varp = get_varp(&(options[opt_idx]));
10008 if (varp != NULL)
10009 varp = *(char_u **)(varp);
10010 return varp;
10011 }
10012 return find_termcode(tname + 2);
10013}
10014
10015 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +010010016get_highlight_default(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010017{
10018 int i;
10019
10020 i = findoption((char_u *)"hl");
10021 if (i >= 0)
10022 return options[i].def_val[VI_DEFAULT];
10023 return (char_u *)NULL;
10024}
10025
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000010026#if defined(FEAT_MBYTE) || defined(PROTO)
10027 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +010010028get_encoding_default(void)
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000010029{
10030 int i;
10031
10032 i = findoption((char_u *)"enc");
10033 if (i >= 0)
10034 return options[i].def_val[VI_DEFAULT];
10035 return (char_u *)NULL;
10036}
10037#endif
10038
Bram Moolenaar071d4272004-06-13 20:20:40 +000010039/*
10040 * Translate a string like "t_xx", "<t_xx>" or "<S-Tab>" to a key number.
Bram Moolenaar9cf4b502018-07-23 04:12:03 +020010041 * When "has_lt" is true there is a '<' before "*arg_arg".
10042 * Returns 0 when the key is not recognized.
Bram Moolenaar071d4272004-06-13 20:20:40 +000010043 */
10044 static int
Bram Moolenaar9cf4b502018-07-23 04:12:03 +020010045find_key_option(char_u *arg_arg, int has_lt)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010046{
Bram Moolenaar9cf4b502018-07-23 04:12:03 +020010047 int key = 0;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010048 int modifiers;
Bram Moolenaar9cf4b502018-07-23 04:12:03 +020010049 char_u *arg = arg_arg;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010050
10051 /*
10052 * Don't use get_special_key_code() for t_xx, we don't want it to call
10053 * add_termcap_entry().
10054 */
10055 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
10056 key = TERMCAP2KEY(arg[2], arg[3]);
Bram Moolenaar9cf4b502018-07-23 04:12:03 +020010057 else if (has_lt)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010058 {
10059 --arg; /* put arg at the '<' */
10060 modifiers = 0;
Bram Moolenaar35a4cfa2016-08-14 16:07:48 +020010061 key = find_special_key(&arg, &modifiers, TRUE, TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010062 if (modifiers) /* can't handle modifiers here */
10063 key = 0;
10064 }
10065 return key;
10066}
10067
10068/*
10069 * if 'all' == 0: show changed options
10070 * if 'all' == 1: show all normal options
10071 * if 'all' == 2: show all terminal options
10072 */
10073 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010074showoptions(
10075 int all,
10076 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +000010077{
10078 struct vimoption *p;
10079 int col;
10080 int isterm;
10081 char_u *varp;
10082 struct vimoption **items;
10083 int item_count;
10084 int run;
10085 int row, rows;
10086 int cols;
10087 int i;
10088 int len;
10089
10090#define INC 20
10091#define GAP 3
10092
10093 items = (struct vimoption **)alloc((unsigned)(sizeof(struct vimoption *) *
10094 PARAM_COUNT));
10095 if (items == NULL)
10096 return;
10097
10098 /* Highlight title */
10099 if (all == 2)
10100 MSG_PUTS_TITLE(_("\n--- Terminal codes ---"));
10101 else if (opt_flags & OPT_GLOBAL)
10102 MSG_PUTS_TITLE(_("\n--- Global option values ---"));
10103 else if (opt_flags & OPT_LOCAL)
10104 MSG_PUTS_TITLE(_("\n--- Local option values ---"));
10105 else
10106 MSG_PUTS_TITLE(_("\n--- Options ---"));
10107
10108 /*
10109 * do the loop two times:
10110 * 1. display the short items
10111 * 2. display the long items (only strings and numbers)
10112 */
10113 for (run = 1; run <= 2 && !got_int; ++run)
10114 {
10115 /*
10116 * collect the items in items[]
10117 */
10118 item_count = 0;
10119 for (p = &options[0]; p->fullname != NULL; p++)
10120 {
Bram Moolenaarf86db782018-10-25 13:31:37 +020010121 // apply :filter /pat/
10122 if (message_filtered((char_u *) p->fullname))
10123 continue;
10124
Bram Moolenaar071d4272004-06-13 20:20:40 +000010125 varp = NULL;
10126 isterm = istermoption(p);
10127 if (opt_flags != 0)
10128 {
10129 if (p->indir != PV_NONE && !isterm)
10130 varp = get_varp_scope(p, opt_flags);
10131 }
10132 else
10133 varp = get_varp(p);
10134 if (varp != NULL
10135 && ((all == 2 && isterm)
10136 || (all == 1 && !isterm)
10137 || (all == 0 && !optval_default(p, varp))))
10138 {
10139 if (p->flags & P_BOOL)
10140 len = 1; /* a toggle option fits always */
10141 else
10142 {
10143 option_value2string(p, opt_flags);
10144 len = (int)STRLEN(p->fullname) + vim_strsize(NameBuff) + 1;
10145 }
10146 if ((len <= INC - GAP && run == 1) ||
10147 (len > INC - GAP && run == 2))
10148 items[item_count++] = p;
10149 }
10150 }
10151
10152 /*
10153 * display the items
10154 */
10155 if (run == 1)
10156 {
10157 cols = (Columns + GAP - 3) / INC;
10158 if (cols == 0)
10159 cols = 1;
10160 rows = (item_count + cols - 1) / cols;
10161 }
10162 else /* run == 2 */
10163 rows = item_count;
10164 for (row = 0; row < rows && !got_int; ++row)
10165 {
10166 msg_putchar('\n'); /* go to next line */
10167 if (got_int) /* 'q' typed in more */
10168 break;
10169 col = 0;
10170 for (i = row; i < item_count; i += rows)
10171 {
10172 msg_col = col; /* make columns */
10173 showoneopt(items[i], opt_flags);
10174 col += INC;
10175 }
10176 out_flush();
10177 ui_breakcheck();
10178 }
10179 }
10180 vim_free(items);
10181}
10182
10183/*
10184 * Return TRUE if option "p" has its default value.
10185 */
10186 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010187optval_default(struct vimoption *p, char_u *varp)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010188{
10189 int dvi;
10190
10191 if (varp == NULL)
10192 return TRUE; /* hidden option is always at default */
10193 dvi = ((p->flags & P_VI_DEF) || p_cp) ? VI_DEFAULT : VIM_DEFAULT;
10194 if (p->flags & P_NUM)
Bram Moolenaareb3593b2006-04-22 22:33:57 +000010195 return (*(long *)varp == (long)(long_i)p->def_val[dvi]);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010196 if (p->flags & P_BOOL)
Bram Moolenaareb3593b2006-04-22 22:33:57 +000010197 /* the cast to long is required for Manx C, long_i is
10198 * needed for MSVC */
10199 return (*(int *)varp == (int)(long)(long_i)p->def_val[dvi]);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010200 /* P_STRING */
10201 return (STRCMP(*(char_u **)varp, p->def_val[dvi]) == 0);
10202}
10203
10204/*
10205 * showoneopt: show the value of one option
10206 * must not be called with a hidden option!
10207 */
10208 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010209showoneopt(
10210 struct vimoption *p,
10211 int opt_flags) /* OPT_LOCAL or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +000010212{
Bram Moolenaar26a60b42005-02-22 08:49:11 +000010213 char_u *varp;
10214 int save_silent = silent_mode;
10215
10216 silent_mode = FALSE;
10217 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
Bram Moolenaar071d4272004-06-13 20:20:40 +000010218
10219 varp = get_varp_scope(p, opt_flags);
10220
10221 /* for 'modified' we also need to check if 'ff' or 'fenc' changed. */
10222 if ((p->flags & P_BOOL) && ((int *)varp == &curbuf->b_changed
10223 ? !curbufIsChanged() : !*(int *)varp))
10224 MSG_PUTS("no");
10225 else if ((p->flags & P_BOOL) && *(int *)varp < 0)
10226 MSG_PUTS("--");
10227 else
10228 MSG_PUTS(" ");
10229 MSG_PUTS(p->fullname);
10230 if (!(p->flags & P_BOOL))
10231 {
10232 msg_putchar('=');
10233 /* put value string in NameBuff */
10234 option_value2string(p, opt_flags);
10235 msg_outtrans(NameBuff);
10236 }
Bram Moolenaar26a60b42005-02-22 08:49:11 +000010237
10238 silent_mode = save_silent;
10239 info_message = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010240}
10241
10242/*
10243 * Write modified options as ":set" commands to a file.
10244 *
10245 * There are three values for "opt_flags":
10246 * OPT_GLOBAL: Write global option values and fresh values of
10247 * buffer-local options (used for start of a session
10248 * file).
10249 * OPT_GLOBAL + OPT_LOCAL: Idem, add fresh values of window-local options for
10250 * curwin (used for a vimrc file).
10251 * OPT_LOCAL: Write buffer-local option values for curbuf, fresh
10252 * and local values for window-local options of
10253 * curwin. Local values are also written when at the
10254 * default value, because a modeline or autocommand
10255 * may have set them when doing ":edit file" and the
10256 * user has set them back at the default or fresh
10257 * value.
10258 * When "local_only" is TRUE, don't write fresh
10259 * values, only local values (for ":mkview").
10260 * (fresh value = value used for a new buffer or window for a local option).
10261 *
10262 * Return FAIL on error, OK otherwise.
10263 */
10264 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010265makeset(FILE *fd, int opt_flags, int local_only)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010266{
10267 struct vimoption *p;
10268 char_u *varp; /* currently used value */
10269 char_u *varp_fresh; /* local value */
10270 char_u *varp_local = NULL; /* fresh value */
10271 char *cmd;
10272 int round;
Bram Moolenaar7fd16022007-09-06 14:35:35 +000010273 int pri;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010274
10275 /*
10276 * The options that don't have a default (terminal name, columns, lines)
10277 * are never written. Terminal options are also not written.
Bram Moolenaar7fd16022007-09-06 14:35:35 +000010278 * Do the loop over "options[]" twice: once for options with the
10279 * P_PRI_MKRC flag and once without.
Bram Moolenaar071d4272004-06-13 20:20:40 +000010280 */
Bram Moolenaar7fd16022007-09-06 14:35:35 +000010281 for (pri = 1; pri >= 0; --pri)
10282 {
10283 for (p = &options[0]; !istermoption(p); p++)
10284 if (!(p->flags & P_NO_MKRC)
10285 && !istermoption(p)
10286 && ((pri == 1) == ((p->flags & P_PRI_MKRC) != 0)))
Bram Moolenaar071d4272004-06-13 20:20:40 +000010287 {
10288 /* skip global option when only doing locals */
10289 if (p->indir == PV_NONE && !(opt_flags & OPT_GLOBAL))
10290 continue;
10291
10292 /* Do not store options like 'bufhidden' and 'syntax' in a vimrc
10293 * file, they are always buffer-specific. */
10294 if ((opt_flags & OPT_GLOBAL) && (p->flags & P_NOGLOB))
10295 continue;
10296
10297 /* Global values are only written when not at the default value. */
10298 varp = get_varp_scope(p, opt_flags);
10299 if ((opt_flags & OPT_GLOBAL) && optval_default(p, varp))
10300 continue;
10301
10302 round = 2;
10303 if (p->indir != PV_NONE)
10304 {
10305 if (p->var == VAR_WIN)
10306 {
10307 /* skip window-local option when only doing globals */
10308 if (!(opt_flags & OPT_LOCAL))
10309 continue;
10310 /* When fresh value of window-local option is not at the
10311 * default, need to write it too. */
10312 if (!(opt_flags & OPT_GLOBAL) && !local_only)
10313 {
10314 varp_fresh = get_varp_scope(p, OPT_GLOBAL);
10315 if (!optval_default(p, varp_fresh))
10316 {
10317 round = 1;
10318 varp_local = varp;
10319 varp = varp_fresh;
10320 }
10321 }
10322 }
10323 }
10324
10325 /* Round 1: fresh value for window-local options.
10326 * Round 2: other values */
10327 for ( ; round <= 2; varp = varp_local, ++round)
10328 {
10329 if (round == 1 || (opt_flags & OPT_GLOBAL))
10330 cmd = "set";
10331 else
10332 cmd = "setlocal";
10333
10334 if (p->flags & P_BOOL)
10335 {
10336 if (put_setbool(fd, cmd, p->fullname, *(int *)varp) == FAIL)
10337 return FAIL;
10338 }
10339 else if (p->flags & P_NUM)
10340 {
10341 if (put_setnum(fd, cmd, p->fullname, (long *)varp) == FAIL)
10342 return FAIL;
10343 }
10344 else /* P_STRING */
10345 {
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010346 int do_endif = FALSE;
10347
Bram Moolenaar071d4272004-06-13 20:20:40 +000010348 /* Don't set 'syntax' and 'filetype' again if the value is
10349 * already right, avoids reloading the syntax file. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010350 if (
Bram Moolenaarf2bd8ef2018-03-04 18:08:14 +010010351#if defined(FEAT_SYN_HL)
10352 p->indir == PV_SYN ||
10353#endif
10354 p->indir == PV_FT)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010355 {
10356 if (fprintf(fd, "if &%s != '%s'", p->fullname,
10357 *(char_u **)(varp)) < 0
10358 || put_eol(fd) < 0)
10359 return FAIL;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010360 do_endif = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010361 }
10362 if (put_setstring(fd, cmd, p->fullname, (char_u **)varp,
10363 (p->flags & P_EXPAND) != 0) == FAIL)
10364 return FAIL;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010365 if (do_endif)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010366 {
10367 if (put_line(fd, "endif") == FAIL)
10368 return FAIL;
10369 }
10370 }
10371 }
10372 }
Bram Moolenaar7fd16022007-09-06 14:35:35 +000010373 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000010374 return OK;
10375}
10376
10377#if defined(FEAT_FOLDING) || defined(PROTO)
10378/*
10379 * Generate set commands for the local fold options only. Used when
10380 * 'sessionoptions' or 'viewoptions' contains "folds" but not "options".
10381 */
10382 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010383makefoldset(FILE *fd)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010384{
10385 if (put_setstring(fd, "setlocal", "fdm", &curwin->w_p_fdm, FALSE) == FAIL
10386# ifdef FEAT_EVAL
10387 || put_setstring(fd, "setlocal", "fde", &curwin->w_p_fde, FALSE)
10388 == FAIL
10389# endif
10390 || put_setstring(fd, "setlocal", "fmr", &curwin->w_p_fmr, FALSE)
10391 == FAIL
10392 || put_setstring(fd, "setlocal", "fdi", &curwin->w_p_fdi, FALSE)
10393 == FAIL
10394 || put_setnum(fd, "setlocal", "fdl", &curwin->w_p_fdl) == FAIL
10395 || put_setnum(fd, "setlocal", "fml", &curwin->w_p_fml) == FAIL
10396 || put_setnum(fd, "setlocal", "fdn", &curwin->w_p_fdn) == FAIL
10397 || put_setbool(fd, "setlocal", "fen", curwin->w_p_fen) == FAIL
10398 )
10399 return FAIL;
10400
10401 return OK;
10402}
10403#endif
10404
10405 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010406put_setstring(
10407 FILE *fd,
10408 char *cmd,
10409 char *name,
10410 char_u **valuep,
10411 int expand)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010412{
10413 char_u *s;
Bram Moolenaarf8441472011-04-28 17:24:58 +020010414 char_u *buf;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010415
10416 if (fprintf(fd, "%s %s=", cmd, name) < 0)
10417 return FAIL;
10418 if (*valuep != NULL)
10419 {
10420 /* Output 'pastetoggle' as key names. For other
10421 * options some characters have to be escaped with
10422 * CTRL-V or backslash */
10423 if (valuep == &p_pt)
10424 {
10425 s = *valuep;
10426 while (*s != NUL)
Bram Moolenaar7d96acd2008-06-09 15:07:54 +000010427 if (put_escstr(fd, str2special(&s, FALSE), 2) == FAIL)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010428 return FAIL;
10429 }
10430 else if (expand)
10431 {
Bram Moolenaarf8441472011-04-28 17:24:58 +020010432 buf = alloc(MAXPATHL);
10433 if (buf == NULL)
10434 return FAIL;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010435 home_replace(NULL, *valuep, buf, MAXPATHL, FALSE);
10436 if (put_escstr(fd, buf, 2) == FAIL)
Bram Moolenaarf8441472011-04-28 17:24:58 +020010437 {
10438 vim_free(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010439 return FAIL;
Bram Moolenaarf8441472011-04-28 17:24:58 +020010440 }
10441 vim_free(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010442 }
10443 else if (put_escstr(fd, *valuep, 2) == FAIL)
10444 return FAIL;
10445 }
10446 if (put_eol(fd) < 0)
10447 return FAIL;
10448 return OK;
10449}
10450
10451 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010452put_setnum(
10453 FILE *fd,
10454 char *cmd,
10455 char *name,
10456 long *valuep)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010457{
10458 long wc;
10459
10460 if (fprintf(fd, "%s %s=", cmd, name) < 0)
10461 return FAIL;
10462 if (wc_use_keyname((char_u *)valuep, &wc))
10463 {
10464 /* print 'wildchar' and 'wildcharm' as a key name */
10465 if (fputs((char *)get_special_key_name((int)wc, 0), fd) < 0)
10466 return FAIL;
10467 }
10468 else if (fprintf(fd, "%ld", *valuep) < 0)
10469 return FAIL;
10470 if (put_eol(fd) < 0)
10471 return FAIL;
10472 return OK;
10473}
10474
10475 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010476put_setbool(
10477 FILE *fd,
10478 char *cmd,
10479 char *name,
10480 int value)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010481{
Bram Moolenaar893de922007-10-02 18:40:57 +000010482 if (value < 0) /* global/local option using global value */
10483 return OK;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010484 if (fprintf(fd, "%s %s%s", cmd, value ? "" : "no", name) < 0
10485 || put_eol(fd) < 0)
10486 return FAIL;
10487 return OK;
10488}
10489
10490/*
10491 * Clear all the terminal options.
10492 * If the option has been allocated, free the memory.
10493 * Terminal options are never hidden or indirect.
10494 */
10495 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010496clear_termoptions(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010497{
Bram Moolenaar071d4272004-06-13 20:20:40 +000010498 /*
10499 * Reset a few things before clearing the old options. This may cause
10500 * outputting a few things that the terminal doesn't understand, but the
10501 * screen will be cleared later, so this is OK.
10502 */
10503#ifdef FEAT_MOUSE_TTY
10504 mch_setmouse(FALSE); /* switch mouse off */
10505#endif
10506#ifdef FEAT_TITLE
Bram Moolenaar40385db2018-08-07 22:31:44 +020010507 mch_restore_title(SAVE_RESTORE_BOTH); /* restore window titles */
Bram Moolenaar071d4272004-06-13 20:20:40 +000010508#endif
10509#if defined(FEAT_XCLIPBOARD) && defined(FEAT_GUI)
10510 /* When starting the GUI close the display opened for the clipboard.
10511 * After restoring the title, because that will need the display. */
10512 if (gui.starting)
10513 clear_xterm_clip();
10514#endif
Bram Moolenaarcea912a2016-10-12 14:20:24 +020010515 stoptermcap(); /* stop termcap mode */
Bram Moolenaar071d4272004-06-13 20:20:40 +000010516
Bram Moolenaarf461c8e2005-06-25 23:04:51 +000010517 free_termoptions();
10518}
10519
10520 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010521free_termoptions(void)
Bram Moolenaarf461c8e2005-06-25 23:04:51 +000010522{
10523 struct vimoption *p;
10524
Bram Moolenaar35bc7d62018-10-02 14:45:10 +020010525 for (p = options; p->fullname != NULL; p++)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010526 if (istermoption(p))
10527 {
10528 if (p->flags & P_ALLOCED)
10529 free_string_option(*(char_u **)(p->var));
10530 if (p->flags & P_DEF_ALLOCED)
10531 free_string_option(p->def_val[VI_DEFAULT]);
10532 *(char_u **)(p->var) = empty_option;
10533 p->def_val[VI_DEFAULT] = empty_option;
10534 p->flags &= ~(P_ALLOCED|P_DEF_ALLOCED);
Bram Moolenaar35bc7d62018-10-02 14:45:10 +020010535#ifdef FEAT_EVAL
10536 // remember where the option was cleared
10537 set_option_sctx_idx((int)(p - options), OPT_GLOBAL, current_sctx);
10538#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010539 }
10540 clear_termcodes();
10541}
10542
10543/*
Bram Moolenaar363cb672009-07-22 12:28:17 +000010544 * Free the string for one term option, if it was allocated.
10545 * Set the string to empty_option and clear allocated flag.
10546 * "var" points to the option value.
10547 */
10548 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010549free_one_termoption(char_u *var)
Bram Moolenaar363cb672009-07-22 12:28:17 +000010550{
10551 struct vimoption *p;
10552
10553 for (p = &options[0]; p->fullname != NULL; p++)
10554 if (p->var == var)
10555 {
10556 if (p->flags & P_ALLOCED)
10557 free_string_option(*(char_u **)(p->var));
10558 *(char_u **)(p->var) = empty_option;
10559 p->flags &= ~P_ALLOCED;
10560 break;
10561 }
10562}
10563
10564/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000010565 * Set the terminal option defaults to the current value.
10566 * Used after setting the terminal name.
10567 */
10568 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010569set_term_defaults(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010570{
10571 struct vimoption *p;
10572
10573 for (p = &options[0]; p->fullname != NULL; p++)
10574 {
10575 if (istermoption(p) && p->def_val[VI_DEFAULT] != *(char_u **)(p->var))
10576 {
10577 if (p->flags & P_DEF_ALLOCED)
10578 {
10579 free_string_option(p->def_val[VI_DEFAULT]);
10580 p->flags &= ~P_DEF_ALLOCED;
10581 }
10582 p->def_val[VI_DEFAULT] = *(char_u **)(p->var);
10583 if (p->flags & P_ALLOCED)
10584 {
10585 p->flags |= P_DEF_ALLOCED;
10586 p->flags &= ~P_ALLOCED; /* don't free the value now */
10587 }
10588 }
10589 }
10590}
10591
10592/*
10593 * return TRUE if 'p' starts with 't_'
10594 */
10595 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010596istermoption(struct vimoption *p)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010597{
10598 return (p->fullname[0] == 't' && p->fullname[1] == '_');
10599}
10600
10601/*
10602 * Compute columns for ruler and shown command. 'sc_col' is also used to
10603 * decide what the maximum length of a message on the status line can be.
10604 * If there is a status line for the last window, 'sc_col' is independent
10605 * of 'ru_col'.
10606 */
10607
10608#define COL_RULER 17 /* columns needed by standard ruler */
10609
10610 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010611comp_col(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010612{
Bram Moolenaar4033c552017-09-16 20:54:51 +020010613#if defined(FEAT_CMDL_INFO)
Bram Moolenaar459ca562016-11-10 18:16:33 +010010614 int last_has_status = (p_ls == 2 || (p_ls == 1 && !ONE_WINDOW));
Bram Moolenaar071d4272004-06-13 20:20:40 +000010615
10616 sc_col = 0;
10617 ru_col = 0;
10618 if (p_ru)
10619 {
Bram Moolenaar4033c552017-09-16 20:54:51 +020010620# ifdef FEAT_STL_OPT
Bram Moolenaar071d4272004-06-13 20:20:40 +000010621 ru_col = (ru_wid ? ru_wid : COL_RULER) + 1;
Bram Moolenaar4033c552017-09-16 20:54:51 +020010622# else
Bram Moolenaar071d4272004-06-13 20:20:40 +000010623 ru_col = COL_RULER + 1;
Bram Moolenaar4033c552017-09-16 20:54:51 +020010624# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010625 /* no last status line, adjust sc_col */
10626 if (!last_has_status)
10627 sc_col = ru_col;
10628 }
10629 if (p_sc)
10630 {
10631 sc_col += SHOWCMD_COLS;
10632 if (!p_ru || last_has_status) /* no need for separating space */
10633 ++sc_col;
10634 }
10635 sc_col = Columns - sc_col;
10636 ru_col = Columns - ru_col;
10637 if (sc_col <= 0) /* screen too narrow, will become a mess */
10638 sc_col = 1;
10639 if (ru_col <= 0)
10640 ru_col = 1;
10641#else
10642 sc_col = Columns;
10643 ru_col = Columns;
10644#endif
10645}
10646
10647/*
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010648 * Unset local option value, similar to ":set opt<".
10649 */
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010650 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010651unset_global_local_option(char_u *name, void *from)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010652{
10653 struct vimoption *p;
10654 int opt_idx;
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010655 buf_T *buf = (buf_T *)from;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010656
10657 opt_idx = findoption(name);
Bram Moolenaarbd8539a2015-08-11 18:53:03 +020010658 if (opt_idx < 0)
10659 return;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010660 p = &(options[opt_idx]);
10661
10662 switch ((int)p->indir)
10663 {
10664 /* global option with local value: use local value if it's been set */
10665 case PV_EP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010666 clear_string_option(&buf->b_p_ep);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010667 break;
10668 case PV_KP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010669 clear_string_option(&buf->b_p_kp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010670 break;
10671 case PV_PATH:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010672 clear_string_option(&buf->b_p_path);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010673 break;
10674 case PV_AR:
10675 buf->b_p_ar = -1;
10676 break;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010677 case PV_BKC:
10678 clear_string_option(&buf->b_p_bkc);
10679 buf->b_bkc_flags = 0;
10680 break;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010681 case PV_TAGS:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010682 clear_string_option(&buf->b_p_tags);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010683 break;
Bram Moolenaar0f6562e2015-11-24 18:48:14 +010010684 case PV_TC:
10685 clear_string_option(&buf->b_p_tc);
10686 buf->b_tc_flags = 0;
10687 break;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010688#ifdef FEAT_FIND_ID
10689 case PV_DEF:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010690 clear_string_option(&buf->b_p_def);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010691 break;
10692 case PV_INC:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010693 clear_string_option(&buf->b_p_inc);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010694 break;
10695#endif
10696#ifdef FEAT_INS_EXPAND
10697 case PV_DICT:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010698 clear_string_option(&buf->b_p_dict);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010699 break;
10700 case PV_TSR:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010701 clear_string_option(&buf->b_p_tsr);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010702 break;
10703#endif
Bram Moolenaar9be7c042017-01-14 14:28:30 +010010704 case PV_FP:
10705 clear_string_option(&buf->b_p_fp);
10706 break;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010707#ifdef FEAT_QUICKFIX
10708 case PV_EFM:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010709 clear_string_option(&buf->b_p_efm);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010710 break;
10711 case PV_GP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010712 clear_string_option(&buf->b_p_gp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010713 break;
10714 case PV_MP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010715 clear_string_option(&buf->b_p_mp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010716 break;
10717#endif
10718#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10719 case PV_BEXPR:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010720 clear_string_option(&buf->b_p_bexpr);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010721 break;
10722#endif
10723#if defined(FEAT_CRYPT)
10724 case PV_CM:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010725 clear_string_option(&buf->b_p_cm);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010726 break;
10727#endif
10728#ifdef FEAT_STL_OPT
10729 case PV_STL:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010730 clear_string_option(&((win_T *)from)->w_p_stl);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010731 break;
10732#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010733 case PV_UL:
10734 buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
10735 break;
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010736#ifdef FEAT_LISP
10737 case PV_LW:
10738 clear_string_option(&buf->b_p_lw);
10739 break;
10740#endif
Bram Moolenaar2c7292d2017-03-05 17:43:31 +010010741#ifdef FEAT_MBYTE
10742 case PV_MENC:
10743 clear_string_option(&buf->b_p_menc);
10744 break;
10745#endif
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010746 }
10747}
10748
10749/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000010750 * Get pointer to option variable, depending on local or global scope.
10751 */
10752 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +010010753get_varp_scope(struct vimoption *p, int opt_flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010754{
10755 if ((opt_flags & OPT_GLOBAL) && p->indir != PV_NONE)
10756 {
10757 if (p->var == VAR_WIN)
10758 return (char_u *)GLOBAL_WO(get_varp(p));
10759 return p->var;
10760 }
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010761 if ((opt_flags & OPT_LOCAL) && ((int)p->indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +000010762 {
10763 switch ((int)p->indir)
10764 {
Bram Moolenaar9be7c042017-01-14 14:28:30 +010010765 case PV_FP: return (char_u *)&(curbuf->b_p_fp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010766#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010767 case PV_EFM: return (char_u *)&(curbuf->b_p_efm);
10768 case PV_GP: return (char_u *)&(curbuf->b_p_gp);
10769 case PV_MP: return (char_u *)&(curbuf->b_p_mp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010770#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010771 case PV_EP: return (char_u *)&(curbuf->b_p_ep);
10772 case PV_KP: return (char_u *)&(curbuf->b_p_kp);
10773 case PV_PATH: return (char_u *)&(curbuf->b_p_path);
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010774 case PV_AR: return (char_u *)&(curbuf->b_p_ar);
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010775 case PV_TAGS: return (char_u *)&(curbuf->b_p_tags);
Bram Moolenaar0f6562e2015-11-24 18:48:14 +010010776 case PV_TC: return (char_u *)&(curbuf->b_p_tc);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010777#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010778 case PV_DEF: return (char_u *)&(curbuf->b_p_def);
10779 case PV_INC: return (char_u *)&(curbuf->b_p_inc);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010780#endif
10781#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010782 case PV_DICT: return (char_u *)&(curbuf->b_p_dict);
10783 case PV_TSR: return (char_u *)&(curbuf->b_p_tsr);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010784#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000010785#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10786 case PV_BEXPR: return (char_u *)&(curbuf->b_p_bexpr);
10787#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020010788#if defined(FEAT_CRYPT)
10789 case PV_CM: return (char_u *)&(curbuf->b_p_cm);
10790#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010791#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010792 case PV_STL: return (char_u *)&(curwin->w_p_stl);
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010793#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010794 case PV_UL: return (char_u *)&(curbuf->b_p_ul);
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010795#ifdef FEAT_LISP
10796 case PV_LW: return (char_u *)&(curbuf->b_p_lw);
10797#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010798 case PV_BKC: return (char_u *)&(curbuf->b_p_bkc);
Bram Moolenaar2c7292d2017-03-05 17:43:31 +010010799#ifdef FEAT_MBYTE
10800 case PV_MENC: return (char_u *)&(curbuf->b_p_menc);
10801#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010802 }
10803 return NULL; /* "cannot happen" */
10804 }
10805 return get_varp(p);
10806}
10807
10808/*
10809 * Get pointer to option variable.
10810 */
10811 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +010010812get_varp(struct vimoption *p)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010813{
10814 /* hidden option, always return NULL */
10815 if (p->var == NULL)
10816 return NULL;
10817
10818 switch ((int)p->indir)
10819 {
10820 case PV_NONE: return p->var;
10821
10822 /* global option with local value: use local value if it's been set */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010823 case PV_EP: return *curbuf->b_p_ep != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010824 ? (char_u *)&curbuf->b_p_ep : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010825 case PV_KP: return *curbuf->b_p_kp != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010826 ? (char_u *)&curbuf->b_p_kp : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010827 case PV_PATH: return *curbuf->b_p_path != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010828 ? (char_u *)&(curbuf->b_p_path) : p->var;
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010829 case PV_AR: return curbuf->b_p_ar >= 0
Bram Moolenaar071d4272004-06-13 20:20:40 +000010830 ? (char_u *)&(curbuf->b_p_ar) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010831 case PV_TAGS: return *curbuf->b_p_tags != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010832 ? (char_u *)&(curbuf->b_p_tags) : p->var;
Bram Moolenaar0f6562e2015-11-24 18:48:14 +010010833 case PV_TC: return *curbuf->b_p_tc != NUL
10834 ? (char_u *)&(curbuf->b_p_tc) : p->var;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010835 case PV_BKC: return *curbuf->b_p_bkc != NUL
10836 ? (char_u *)&(curbuf->b_p_bkc) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010837#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010838 case PV_DEF: return *curbuf->b_p_def != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010839 ? (char_u *)&(curbuf->b_p_def) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010840 case PV_INC: return *curbuf->b_p_inc != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010841 ? (char_u *)&(curbuf->b_p_inc) : p->var;
10842#endif
10843#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010844 case PV_DICT: return *curbuf->b_p_dict != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010845 ? (char_u *)&(curbuf->b_p_dict) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010846 case PV_TSR: return *curbuf->b_p_tsr != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010847 ? (char_u *)&(curbuf->b_p_tsr) : p->var;
10848#endif
Bram Moolenaar9be7c042017-01-14 14:28:30 +010010849 case PV_FP: return *curbuf->b_p_fp != NUL
10850 ? (char_u *)&(curbuf->b_p_fp) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010851#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010852 case PV_EFM: return *curbuf->b_p_efm != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010853 ? (char_u *)&(curbuf->b_p_efm) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010854 case PV_GP: return *curbuf->b_p_gp != NUL
10855 ? (char_u *)&(curbuf->b_p_gp) : p->var;
10856 case PV_MP: return *curbuf->b_p_mp != NUL
10857 ? (char_u *)&(curbuf->b_p_mp) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010858#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000010859#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10860 case PV_BEXPR: return *curbuf->b_p_bexpr != NUL
10861 ? (char_u *)&(curbuf->b_p_bexpr) : p->var;
10862#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020010863#if defined(FEAT_CRYPT)
10864 case PV_CM: return *curbuf->b_p_cm != NUL
10865 ? (char_u *)&(curbuf->b_p_cm) : p->var;
10866#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010867#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010868 case PV_STL: return *curwin->w_p_stl != NUL
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010869 ? (char_u *)&(curwin->w_p_stl) : p->var;
10870#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010871 case PV_UL: return curbuf->b_p_ul != NO_LOCAL_UNDOLEVEL
10872 ? (char_u *)&(curbuf->b_p_ul) : p->var;
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010873#ifdef FEAT_LISP
10874 case PV_LW: return *curbuf->b_p_lw != NUL
10875 ? (char_u *)&(curbuf->b_p_lw) : p->var;
10876#endif
Bram Moolenaar2c7292d2017-03-05 17:43:31 +010010877#ifdef FEAT_MBYTE
10878 case PV_MENC: return *curbuf->b_p_menc != NUL
10879 ? (char_u *)&(curbuf->b_p_menc) : p->var;
10880#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010881
10882#ifdef FEAT_ARABIC
10883 case PV_ARAB: return (char_u *)&(curwin->w_p_arab);
10884#endif
10885 case PV_LIST: return (char_u *)&(curwin->w_p_list);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010886#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +000010887 case PV_SPELL: return (char_u *)&(curwin->w_p_spell);
10888#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010889#ifdef FEAT_SYN_HL
10890 case PV_CUC: return (char_u *)&(curwin->w_p_cuc);
10891 case PV_CUL: return (char_u *)&(curwin->w_p_cul);
Bram Moolenaar1a384422010-07-14 19:53:30 +020010892 case PV_CC: return (char_u *)&(curwin->w_p_cc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010893#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010894#ifdef FEAT_DIFF
10895 case PV_DIFF: return (char_u *)&(curwin->w_p_diff);
10896#endif
10897#ifdef FEAT_FOLDING
10898 case PV_FDC: return (char_u *)&(curwin->w_p_fdc);
10899 case PV_FEN: return (char_u *)&(curwin->w_p_fen);
10900 case PV_FDI: return (char_u *)&(curwin->w_p_fdi);
10901 case PV_FDL: return (char_u *)&(curwin->w_p_fdl);
10902 case PV_FDM: return (char_u *)&(curwin->w_p_fdm);
10903 case PV_FML: return (char_u *)&(curwin->w_p_fml);
10904 case PV_FDN: return (char_u *)&(curwin->w_p_fdn);
10905# ifdef FEAT_EVAL
10906 case PV_FDE: return (char_u *)&(curwin->w_p_fde);
10907 case PV_FDT: return (char_u *)&(curwin->w_p_fdt);
10908# endif
10909 case PV_FMR: return (char_u *)&(curwin->w_p_fmr);
10910#endif
10911 case PV_NU: return (char_u *)&(curwin->w_p_nu);
Bram Moolenaar64486672010-05-16 15:46:46 +020010912 case PV_RNU: return (char_u *)&(curwin->w_p_rnu);
Bram Moolenaar592e0a22004-07-03 16:05:59 +000010913#ifdef FEAT_LINEBREAK
10914 case PV_NUW: return (char_u *)&(curwin->w_p_nuw);
10915#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010916 case PV_WFH: return (char_u *)&(curwin->w_p_wfh);
Bram Moolenaar97b2ad32006-03-18 21:40:56 +000010917 case PV_WFW: return (char_u *)&(curwin->w_p_wfw);
Bram Moolenaar4033c552017-09-16 20:54:51 +020010918#if defined(FEAT_QUICKFIX)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010919 case PV_PVW: return (char_u *)&(curwin->w_p_pvw);
10920#endif
10921#ifdef FEAT_RIGHTLEFT
10922 case PV_RL: return (char_u *)&(curwin->w_p_rl);
10923 case PV_RLC: return (char_u *)&(curwin->w_p_rlc);
10924#endif
10925 case PV_SCROLL: return (char_u *)&(curwin->w_p_scr);
10926 case PV_WRAP: return (char_u *)&(curwin->w_p_wrap);
10927#ifdef FEAT_LINEBREAK
10928 case PV_LBR: return (char_u *)&(curwin->w_p_lbr);
Bram Moolenaar597a4222014-06-25 14:39:50 +020010929 case PV_BRI: return (char_u *)&(curwin->w_p_bri);
10930 case PV_BRIOPT: return (char_u *)&(curwin->w_p_briopt);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010931#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010932 case PV_SCBIND: return (char_u *)&(curwin->w_p_scb);
Bram Moolenaar860cae12010-06-05 23:22:07 +020010933 case PV_CRBIND: return (char_u *)&(curwin->w_p_crb);
Bram Moolenaar860cae12010-06-05 23:22:07 +020010934#ifdef FEAT_CONCEAL
Bram Moolenaare4f25e42017-07-07 11:54:15 +020010935 case PV_COCU: return (char_u *)&(curwin->w_p_cocu);
10936 case PV_COLE: return (char_u *)&(curwin->w_p_cole);
10937#endif
10938#ifdef FEAT_TERMINAL
Bram Moolenaar6d150f72018-04-21 20:03:20 +020010939 case PV_TWK: return (char_u *)&(curwin->w_p_twk);
10940 case PV_TWS: return (char_u *)&(curwin->w_p_tws);
10941 case PV_TWSL: return (char_u *)&(curbuf->b_p_twsl);
Bram Moolenaar860cae12010-06-05 23:22:07 +020010942#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010943
10944 case PV_AI: return (char_u *)&(curbuf->b_p_ai);
10945 case PV_BIN: return (char_u *)&(curbuf->b_p_bin);
10946#ifdef FEAT_MBYTE
10947 case PV_BOMB: return (char_u *)&(curbuf->b_p_bomb);
10948#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010949 case PV_BH: return (char_u *)&(curbuf->b_p_bh);
10950 case PV_BT: return (char_u *)&(curbuf->b_p_bt);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010951 case PV_BL: return (char_u *)&(curbuf->b_p_bl);
10952 case PV_CI: return (char_u *)&(curbuf->b_p_ci);
10953#ifdef FEAT_CINDENT
10954 case PV_CIN: return (char_u *)&(curbuf->b_p_cin);
10955 case PV_CINK: return (char_u *)&(curbuf->b_p_cink);
10956 case PV_CINO: return (char_u *)&(curbuf->b_p_cino);
10957#endif
10958#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
10959 case PV_CINW: return (char_u *)&(curbuf->b_p_cinw);
10960#endif
10961#ifdef FEAT_COMMENTS
10962 case PV_COM: return (char_u *)&(curbuf->b_p_com);
10963#endif
10964#ifdef FEAT_FOLDING
10965 case PV_CMS: return (char_u *)&(curbuf->b_p_cms);
10966#endif
10967#ifdef FEAT_INS_EXPAND
10968 case PV_CPT: return (char_u *)&(curbuf->b_p_cpt);
10969#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010970#ifdef FEAT_COMPL_FUNC
10971 case PV_CFU: return (char_u *)&(curbuf->b_p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +000010972 case PV_OFU: return (char_u *)&(curbuf->b_p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010973#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010974 case PV_EOL: return (char_u *)&(curbuf->b_p_eol);
Bram Moolenaar34d72d42015-07-17 14:18:08 +020010975 case PV_FIXEOL: return (char_u *)&(curbuf->b_p_fixeol);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010976 case PV_ET: return (char_u *)&(curbuf->b_p_et);
10977#ifdef FEAT_MBYTE
10978 case PV_FENC: return (char_u *)&(curbuf->b_p_fenc);
10979#endif
10980 case PV_FF: return (char_u *)&(curbuf->b_p_ff);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010981 case PV_FT: return (char_u *)&(curbuf->b_p_ft);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010982 case PV_FO: return (char_u *)&(curbuf->b_p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +000010983 case PV_FLP: return (char_u *)&(curbuf->b_p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010984 case PV_IMI: return (char_u *)&(curbuf->b_p_iminsert);
10985 case PV_IMS: return (char_u *)&(curbuf->b_p_imsearch);
10986 case PV_INF: return (char_u *)&(curbuf->b_p_inf);
10987 case PV_ISK: return (char_u *)&(curbuf->b_p_isk);
10988#ifdef FEAT_FIND_ID
10989# ifdef FEAT_EVAL
10990 case PV_INEX: return (char_u *)&(curbuf->b_p_inex);
10991# endif
10992#endif
10993#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
10994 case PV_INDE: return (char_u *)&(curbuf->b_p_inde);
10995 case PV_INDK: return (char_u *)&(curbuf->b_p_indk);
10996#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010997#ifdef FEAT_EVAL
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +000010998 case PV_FEX: return (char_u *)&(curbuf->b_p_fex);
10999#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011000#ifdef FEAT_CRYPT
11001 case PV_KEY: return (char_u *)&(curbuf->b_p_key);
11002#endif
11003#ifdef FEAT_LISP
11004 case PV_LISP: return (char_u *)&(curbuf->b_p_lisp);
11005#endif
11006 case PV_ML: return (char_u *)&(curbuf->b_p_ml);
11007 case PV_MPS: return (char_u *)&(curbuf->b_p_mps);
11008 case PV_MA: return (char_u *)&(curbuf->b_p_ma);
11009 case PV_MOD: return (char_u *)&(curbuf->b_changed);
11010 case PV_NF: return (char_u *)&(curbuf->b_p_nf);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011011 case PV_PI: return (char_u *)&(curbuf->b_p_pi);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000011012#ifdef FEAT_TEXTOBJ
11013 case PV_QE: return (char_u *)&(curbuf->b_p_qe);
11014#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011015 case PV_RO: return (char_u *)&(curbuf->b_p_ro);
11016#ifdef FEAT_SMARTINDENT
11017 case PV_SI: return (char_u *)&(curbuf->b_p_si);
11018#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011019 case PV_SN: return (char_u *)&(curbuf->b_p_sn);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011020 case PV_STS: return (char_u *)&(curbuf->b_p_sts);
11021#ifdef FEAT_SEARCHPATH
11022 case PV_SUA: return (char_u *)&(curbuf->b_p_sua);
11023#endif
11024 case PV_SWF: return (char_u *)&(curbuf->b_p_swf);
11025#ifdef FEAT_SYN_HL
Bram Moolenaar3b56eb32005-07-11 22:40:32 +000011026 case PV_SMC: return (char_u *)&(curbuf->b_p_smc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000011027 case PV_SYN: return (char_u *)&(curbuf->b_p_syn);
11028#endif
11029#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +020011030 case PV_SPC: return (char_u *)&(curwin->w_s->b_p_spc);
11031 case PV_SPF: return (char_u *)&(curwin->w_s->b_p_spf);
11032 case PV_SPL: return (char_u *)&(curwin->w_s->b_p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011033#endif
11034 case PV_SW: return (char_u *)&(curbuf->b_p_sw);
11035 case PV_TS: return (char_u *)&(curbuf->b_p_ts);
11036 case PV_TW: return (char_u *)&(curbuf->b_p_tw);
11037 case PV_TX: return (char_u *)&(curbuf->b_p_tx);
Bram Moolenaar55debbe2010-05-23 23:34:36 +020011038#ifdef FEAT_PERSISTENT_UNDO
11039 case PV_UDF: return (char_u *)&(curbuf->b_p_udf);
11040#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011041 case PV_WM: return (char_u *)&(curbuf->b_p_wm);
11042#ifdef FEAT_KEYMAP
11043 case PV_KMAP: return (char_u *)&(curbuf->b_p_keymap);
11044#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020011045#ifdef FEAT_SIGNS
11046 case PV_SCL: return (char_u *)&(curwin->w_p_scl);
11047#endif
Bram Moolenaar04958cb2018-06-23 19:23:02 +020011048#ifdef FEAT_VARTABS
11049 case PV_VSTS: return (char_u *)&(curbuf->b_p_vsts);
11050 case PV_VTS: return (char_u *)&(curbuf->b_p_vts);
11051#endif
Bram Moolenaar95f09602016-11-10 20:01:45 +010011052 default: IEMSG(_("E356: get_varp ERROR"));
Bram Moolenaar071d4272004-06-13 20:20:40 +000011053 }
11054 /* always return a valid pointer to avoid a crash! */
11055 return (char_u *)&(curbuf->b_p_wm);
11056}
11057
11058/*
11059 * Get the value of 'equalprg', either the buffer-local one or the global one.
11060 */
11061 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +010011062get_equalprg(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011063{
11064 if (*curbuf->b_p_ep == NUL)
11065 return p_ep;
11066 return curbuf->b_p_ep;
11067}
11068
Bram Moolenaar071d4272004-06-13 20:20:40 +000011069/*
11070 * Copy options from one window to another.
11071 * Used when splitting a window.
11072 */
11073 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011074win_copy_options(win_T *wp_from, win_T *wp_to)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011075{
11076 copy_winopt(&wp_from->w_onebuf_opt, &wp_to->w_onebuf_opt);
11077 copy_winopt(&wp_from->w_allbuf_opt, &wp_to->w_allbuf_opt);
11078# ifdef FEAT_RIGHTLEFT
11079# ifdef FEAT_FKMAP
11080 /* Is this right? */
11081 wp_to->w_farsi = wp_from->w_farsi;
11082# endif
11083# endif
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020011084#if defined(FEAT_LINEBREAK)
11085 briopt_check(wp_to);
11086#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011087}
Bram Moolenaar071d4272004-06-13 20:20:40 +000011088
11089/*
11090 * Copy the options from one winopt_T to another.
11091 * Doesn't free the old option values in "to", use clear_winopt() for that.
11092 * The 'scroll' option is not copied, because it depends on the window height.
11093 * The 'previewwindow' option is reset, there can be only one preview window.
11094 */
11095 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011096copy_winopt(winopt_T *from, winopt_T *to)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011097{
11098#ifdef FEAT_ARABIC
11099 to->wo_arab = from->wo_arab;
11100#endif
11101 to->wo_list = from->wo_list;
11102 to->wo_nu = from->wo_nu;
Bram Moolenaar64486672010-05-16 15:46:46 +020011103 to->wo_rnu = from->wo_rnu;
Bram Moolenaar592e0a22004-07-03 16:05:59 +000011104#ifdef FEAT_LINEBREAK
11105 to->wo_nuw = from->wo_nuw;
11106#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011107#ifdef FEAT_RIGHTLEFT
11108 to->wo_rl = from->wo_rl;
11109 to->wo_rlc = vim_strsave(from->wo_rlc);
11110#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000011111#ifdef FEAT_STL_OPT
11112 to->wo_stl = vim_strsave(from->wo_stl);
11113#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011114 to->wo_wrap = from->wo_wrap;
Bram Moolenaara87aa802013-07-03 15:47:03 +020011115#ifdef FEAT_DIFF
11116 to->wo_wrap_save = from->wo_wrap_save;
11117#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011118#ifdef FEAT_LINEBREAK
11119 to->wo_lbr = from->wo_lbr;
Bram Moolenaar597a4222014-06-25 14:39:50 +020011120 to->wo_bri = from->wo_bri;
11121 to->wo_briopt = vim_strsave(from->wo_briopt);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011122#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011123 to->wo_scb = from->wo_scb;
Bram Moolenaara87aa802013-07-03 15:47:03 +020011124 to->wo_scb_save = from->wo_scb_save;
Bram Moolenaar4161dcc2010-12-02 15:33:21 +010011125 to->wo_crb = from->wo_crb;
Bram Moolenaara87aa802013-07-03 15:47:03 +020011126 to->wo_crb_save = from->wo_crb_save;
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000011127#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +000011128 to->wo_spell = from->wo_spell;
11129#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000011130#ifdef FEAT_SYN_HL
11131 to->wo_cuc = from->wo_cuc;
11132 to->wo_cul = from->wo_cul;
Bram Moolenaar1a384422010-07-14 19:53:30 +020011133 to->wo_cc = vim_strsave(from->wo_cc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000011134#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011135#ifdef FEAT_DIFF
11136 to->wo_diff = from->wo_diff;
Bram Moolenaara87aa802013-07-03 15:47:03 +020011137 to->wo_diff_saved = from->wo_diff_saved;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011138#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020011139#ifdef FEAT_CONCEAL
11140 to->wo_cocu = vim_strsave(from->wo_cocu);
Bram Moolenaard497a302010-07-23 22:27:03 +020011141 to->wo_cole = from->wo_cole;
Bram Moolenaarf5963f72010-07-23 22:10:27 +020011142#endif
Bram Moolenaare4f25e42017-07-07 11:54:15 +020011143#ifdef FEAT_TERMINAL
Bram Moolenaar6d150f72018-04-21 20:03:20 +020011144 to->wo_twk = vim_strsave(from->wo_twk);
11145 to->wo_tws = vim_strsave(from->wo_tws);
Bram Moolenaare4f25e42017-07-07 11:54:15 +020011146#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011147#ifdef FEAT_FOLDING
11148 to->wo_fdc = from->wo_fdc;
Bram Moolenaara87aa802013-07-03 15:47:03 +020011149 to->wo_fdc_save = from->wo_fdc_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011150 to->wo_fen = from->wo_fen;
Bram Moolenaara87aa802013-07-03 15:47:03 +020011151 to->wo_fen_save = from->wo_fen_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011152 to->wo_fdi = vim_strsave(from->wo_fdi);
11153 to->wo_fml = from->wo_fml;
11154 to->wo_fdl = from->wo_fdl;
Bram Moolenaara87aa802013-07-03 15:47:03 +020011155 to->wo_fdl_save = from->wo_fdl_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011156 to->wo_fdm = vim_strsave(from->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020011157 to->wo_fdm_save = from->wo_diff_saved
11158 ? vim_strsave(from->wo_fdm_save) : empty_option;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011159 to->wo_fdn = from->wo_fdn;
11160# ifdef FEAT_EVAL
11161 to->wo_fde = vim_strsave(from->wo_fde);
11162 to->wo_fdt = vim_strsave(from->wo_fdt);
11163# endif
11164 to->wo_fmr = vim_strsave(from->wo_fmr);
11165#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020011166#ifdef FEAT_SIGNS
11167 to->wo_scl = vim_strsave(from->wo_scl);
11168#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011169 check_winopt(to); /* don't want NULL pointers */
11170}
11171
11172/*
11173 * Check string options in a window for a NULL value.
11174 */
11175 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011176check_win_options(win_T *win)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011177{
11178 check_winopt(&win->w_onebuf_opt);
11179 check_winopt(&win->w_allbuf_opt);
11180}
11181
11182/*
11183 * Check for NULL pointers in a winopt_T and replace them with empty_option.
11184 */
Bram Moolenaar8dc907d2014-06-25 14:44:10 +020011185 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011186check_winopt(winopt_T *wop UNUSED)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011187{
11188#ifdef FEAT_FOLDING
11189 check_string_option(&wop->wo_fdi);
11190 check_string_option(&wop->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020011191 check_string_option(&wop->wo_fdm_save);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011192# ifdef FEAT_EVAL
11193 check_string_option(&wop->wo_fde);
11194 check_string_option(&wop->wo_fdt);
11195# endif
11196 check_string_option(&wop->wo_fmr);
11197#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020011198#ifdef FEAT_SIGNS
11199 check_string_option(&wop->wo_scl);
11200#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011201#ifdef FEAT_RIGHTLEFT
11202 check_string_option(&wop->wo_rlc);
11203#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000011204#ifdef FEAT_STL_OPT
11205 check_string_option(&wop->wo_stl);
11206#endif
Bram Moolenaar1a384422010-07-14 19:53:30 +020011207#ifdef FEAT_SYN_HL
11208 check_string_option(&wop->wo_cc);
11209#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020011210#ifdef FEAT_CONCEAL
11211 check_string_option(&wop->wo_cocu);
11212#endif
Bram Moolenaare4f25e42017-07-07 11:54:15 +020011213#ifdef FEAT_TERMINAL
Bram Moolenaar6d150f72018-04-21 20:03:20 +020011214 check_string_option(&wop->wo_twk);
11215 check_string_option(&wop->wo_tws);
Bram Moolenaare4f25e42017-07-07 11:54:15 +020011216#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +020011217#ifdef FEAT_LINEBREAK
11218 check_string_option(&wop->wo_briopt);
11219#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011220}
11221
11222/*
11223 * Free the allocated memory inside a winopt_T.
11224 */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011225 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011226clear_winopt(winopt_T *wop UNUSED)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011227{
11228#ifdef FEAT_FOLDING
11229 clear_string_option(&wop->wo_fdi);
11230 clear_string_option(&wop->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020011231 clear_string_option(&wop->wo_fdm_save);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011232# ifdef FEAT_EVAL
11233 clear_string_option(&wop->wo_fde);
11234 clear_string_option(&wop->wo_fdt);
11235# endif
11236 clear_string_option(&wop->wo_fmr);
11237#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020011238#ifdef FEAT_SIGNS
11239 clear_string_option(&wop->wo_scl);
11240#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +020011241#ifdef FEAT_LINEBREAK
11242 clear_string_option(&wop->wo_briopt);
11243#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011244#ifdef FEAT_RIGHTLEFT
11245 clear_string_option(&wop->wo_rlc);
11246#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000011247#ifdef FEAT_STL_OPT
11248 clear_string_option(&wop->wo_stl);
11249#endif
Bram Moolenaar1a384422010-07-14 19:53:30 +020011250#ifdef FEAT_SYN_HL
11251 clear_string_option(&wop->wo_cc);
11252#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020011253#ifdef FEAT_CONCEAL
11254 clear_string_option(&wop->wo_cocu);
11255#endif
Bram Moolenaare4f25e42017-07-07 11:54:15 +020011256#ifdef FEAT_TERMINAL
Bram Moolenaar6d150f72018-04-21 20:03:20 +020011257 clear_string_option(&wop->wo_twk);
11258 clear_string_option(&wop->wo_tws);
Bram Moolenaare4f25e42017-07-07 11:54:15 +020011259#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011260}
11261
11262/*
11263 * Copy global option values to local options for one buffer.
11264 * Used when creating a new buffer and sometimes when entering a buffer.
11265 * flags:
11266 * BCO_ENTER We will enter the buf buffer.
11267 * BCO_ALWAYS Always copy the options, but only set b_p_initialized when
11268 * appropriate.
11269 * BCO_NOHELP Don't copy the values to a help buffer.
11270 */
11271 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011272buf_copy_options(buf_T *buf, int flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011273{
11274 int should_copy = TRUE;
11275 char_u *save_p_isk = NULL; /* init for GCC */
11276 int dont_do_help;
11277 int did_isk = FALSE;
11278
11279 /*
Bram Moolenaar071d4272004-06-13 20:20:40 +000011280 * Skip this when the option defaults have not been set yet. Happens when
11281 * main() allocates the first buffer.
11282 */
11283 if (p_cpo != NULL)
11284 {
11285 /*
11286 * Always copy when entering and 'cpo' contains 'S'.
11287 * Don't copy when already initialized.
11288 * Don't copy when 'cpo' contains 's' and not entering.
11289 * 'S' BCO_ENTER initialized 's' should_copy
11290 * yes yes X X TRUE
11291 * yes no yes X FALSE
11292 * no X yes X FALSE
11293 * X no no yes FALSE
11294 * X no no no TRUE
11295 * no yes no X TRUE
11296 */
11297 if ((vim_strchr(p_cpo, CPO_BUFOPTGLOB) == NULL || !(flags & BCO_ENTER))
11298 && (buf->b_p_initialized
11299 || (!(flags & BCO_ENTER)
11300 && vim_strchr(p_cpo, CPO_BUFOPT) != NULL)))
11301 should_copy = FALSE;
11302
11303 if (should_copy || (flags & BCO_ALWAYS))
11304 {
11305 /* Don't copy the options specific to a help buffer when
11306 * BCO_NOHELP is given or the options were initialized already
11307 * (jumping back to a help file with CTRL-T or CTRL-O) */
11308 dont_do_help = ((flags & BCO_NOHELP) && buf->b_help)
11309 || buf->b_p_initialized;
11310 if (dont_do_help) /* don't free b_p_isk */
11311 {
11312 save_p_isk = buf->b_p_isk;
11313 buf->b_p_isk = NULL;
11314 }
11315 /*
Bram Moolenaar40385db2018-08-07 22:31:44 +020011316 * Always free the allocated strings. If not already initialized,
11317 * reset 'readonly' and copy 'fileformat'.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011318 */
11319 if (!buf->b_p_initialized)
11320 {
11321 free_buf_options(buf, TRUE);
11322 buf->b_p_ro = FALSE; /* don't copy readonly */
11323 buf->b_p_tx = p_tx;
11324#ifdef FEAT_MBYTE
11325 buf->b_p_fenc = vim_strsave(p_fenc);
11326#endif
Bram Moolenaare8ef3a02016-10-12 17:45:29 +020011327 switch (*p_ffs)
11328 {
11329 case 'm':
11330 buf->b_p_ff = vim_strsave((char_u *)FF_MAC); break;
11331 case 'd':
11332 buf->b_p_ff = vim_strsave((char_u *)FF_DOS); break;
11333 case 'u':
11334 buf->b_p_ff = vim_strsave((char_u *)FF_UNIX); break;
11335 default:
11336 buf->b_p_ff = vim_strsave(p_ff);
11337 }
11338 if (buf->b_p_ff != NULL)
11339 buf->b_start_ffc = *buf->b_p_ff;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011340 buf->b_p_bh = empty_option;
11341 buf->b_p_bt = empty_option;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011342 }
11343 else
11344 free_buf_options(buf, FALSE);
11345
11346 buf->b_p_ai = p_ai;
11347 buf->b_p_ai_nopaste = p_ai_nopaste;
11348 buf->b_p_sw = p_sw;
11349 buf->b_p_tw = p_tw;
11350 buf->b_p_tw_nopaste = p_tw_nopaste;
11351 buf->b_p_tw_nobin = p_tw_nobin;
11352 buf->b_p_wm = p_wm;
11353 buf->b_p_wm_nopaste = p_wm_nopaste;
11354 buf->b_p_wm_nobin = p_wm_nobin;
11355 buf->b_p_bin = p_bin;
Bram Moolenaare8bb2552005-07-08 22:26:47 +000011356#ifdef FEAT_MBYTE
11357 buf->b_p_bomb = p_bomb;
11358#endif
Bram Moolenaarb388be02015-07-22 22:19:38 +020011359 buf->b_p_fixeol = p_fixeol;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011360 buf->b_p_et = p_et;
11361 buf->b_p_et_nobin = p_et_nobin;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020011362 buf->b_p_et_nopaste = p_et_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011363 buf->b_p_ml = p_ml;
11364 buf->b_p_ml_nobin = p_ml_nobin;
11365 buf->b_p_inf = p_inf;
Bram Moolenaar3bab9392017-04-07 15:42:25 +020011366 buf->b_p_swf = cmdmod.noswapfile ? FALSE : p_swf;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011367#ifdef FEAT_INS_EXPAND
11368 buf->b_p_cpt = vim_strsave(p_cpt);
11369#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000011370#ifdef FEAT_COMPL_FUNC
11371 buf->b_p_cfu = vim_strsave(p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +000011372 buf->b_p_ofu = vim_strsave(p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000011373#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011374 buf->b_p_sts = p_sts;
11375 buf->b_p_sts_nopaste = p_sts_nopaste;
Bram Moolenaar04958cb2018-06-23 19:23:02 +020011376#ifdef FEAT_VARTABS
11377 buf->b_p_vsts = vim_strsave(p_vsts);
11378 if (p_vsts && p_vsts != empty_option)
11379 tabstop_set(p_vsts, &buf->b_p_vsts_array);
11380 else
11381 buf->b_p_vsts_array = 0;
11382 buf->b_p_vsts_nopaste = p_vsts_nopaste
11383 ? vim_strsave(p_vsts_nopaste) : NULL;
11384#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011385 buf->b_p_sn = p_sn;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011386#ifdef FEAT_COMMENTS
11387 buf->b_p_com = vim_strsave(p_com);
11388#endif
11389#ifdef FEAT_FOLDING
11390 buf->b_p_cms = vim_strsave(p_cms);
11391#endif
11392 buf->b_p_fo = vim_strsave(p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +000011393 buf->b_p_flp = vim_strsave(p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011394 buf->b_p_nf = vim_strsave(p_nf);
11395 buf->b_p_mps = vim_strsave(p_mps);
11396#ifdef FEAT_SMARTINDENT
11397 buf->b_p_si = p_si;
11398#endif
11399 buf->b_p_ci = p_ci;
11400#ifdef FEAT_CINDENT
11401 buf->b_p_cin = p_cin;
11402 buf->b_p_cink = vim_strsave(p_cink);
11403 buf->b_p_cino = vim_strsave(p_cino);
11404#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011405 /* Don't copy 'filetype', it must be detected */
11406 buf->b_p_ft = empty_option;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011407 buf->b_p_pi = p_pi;
11408#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
11409 buf->b_p_cinw = vim_strsave(p_cinw);
11410#endif
11411#ifdef FEAT_LISP
11412 buf->b_p_lisp = p_lisp;
11413#endif
11414#ifdef FEAT_SYN_HL
11415 /* Don't copy 'syntax', it must be set */
11416 buf->b_p_syn = empty_option;
Bram Moolenaar3b56eb32005-07-11 22:40:32 +000011417 buf->b_p_smc = p_smc;
Bram Moolenaarb8060fe2016-01-19 22:29:28 +010011418 buf->b_s.b_syn_isk = empty_option;
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000011419#endif
11420#ifdef FEAT_SPELL
Bram Moolenaard5784f92010-10-13 14:05:35 +020011421 buf->b_s.b_p_spc = vim_strsave(p_spc);
Bram Moolenaar860cae12010-06-05 23:22:07 +020011422 (void)compile_cap_prog(&buf->b_s);
11423 buf->b_s.b_p_spf = vim_strsave(p_spf);
11424 buf->b_s.b_p_spl = vim_strsave(p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011425#endif
11426#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
11427 buf->b_p_inde = vim_strsave(p_inde);
11428 buf->b_p_indk = vim_strsave(p_indk);
11429#endif
Bram Moolenaar9be7c042017-01-14 14:28:30 +010011430 buf->b_p_fp = empty_option;
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +000011431#if defined(FEAT_EVAL)
11432 buf->b_p_fex = vim_strsave(p_fex);
11433#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011434#ifdef FEAT_CRYPT
11435 buf->b_p_key = vim_strsave(p_key);
11436#endif
11437#ifdef FEAT_SEARCHPATH
11438 buf->b_p_sua = vim_strsave(p_sua);
11439#endif
11440#ifdef FEAT_KEYMAP
11441 buf->b_p_keymap = vim_strsave(p_keymap);
11442 buf->b_kmap_state |= KEYMAP_INIT;
11443#endif
Bram Moolenaar6d150f72018-04-21 20:03:20 +020011444#ifdef FEAT_TERMINAL
11445 buf->b_p_twsl = p_twsl;
11446#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011447 /* This isn't really an option, but copying the langmap and IME
11448 * state from the current buffer is better than resetting it. */
11449 buf->b_p_iminsert = p_iminsert;
11450 buf->b_p_imsearch = p_imsearch;
11451
11452 /* options that are normally global but also have a local value
11453 * are not copied, start using the global value */
11454 buf->b_p_ar = -1;
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010011455 buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020011456 buf->b_p_bkc = empty_option;
11457 buf->b_bkc_flags = 0;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011458#ifdef FEAT_QUICKFIX
11459 buf->b_p_gp = empty_option;
11460 buf->b_p_mp = empty_option;
11461 buf->b_p_efm = empty_option;
11462#endif
11463 buf->b_p_ep = empty_option;
11464 buf->b_p_kp = empty_option;
11465 buf->b_p_path = empty_option;
11466 buf->b_p_tags = empty_option;
Bram Moolenaar0f6562e2015-11-24 18:48:14 +010011467 buf->b_p_tc = empty_option;
11468 buf->b_tc_flags = 0;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011469#ifdef FEAT_FIND_ID
11470 buf->b_p_def = empty_option;
11471 buf->b_p_inc = empty_option;
11472# ifdef FEAT_EVAL
11473 buf->b_p_inex = vim_strsave(p_inex);
11474# endif
11475#endif
11476#ifdef FEAT_INS_EXPAND
11477 buf->b_p_dict = empty_option;
11478 buf->b_p_tsr = empty_option;
11479#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000011480#ifdef FEAT_TEXTOBJ
11481 buf->b_p_qe = vim_strsave(p_qe);
11482#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000011483#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
11484 buf->b_p_bexpr = empty_option;
11485#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020011486#if defined(FEAT_CRYPT)
11487 buf->b_p_cm = empty_option;
11488#endif
Bram Moolenaar55debbe2010-05-23 23:34:36 +020011489#ifdef FEAT_PERSISTENT_UNDO
11490 buf->b_p_udf = p_udf;
11491#endif
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010011492#ifdef FEAT_LISP
11493 buf->b_p_lw = empty_option;
11494#endif
Bram Moolenaar2c7292d2017-03-05 17:43:31 +010011495#ifdef FEAT_MBYTE
11496 buf->b_p_menc = empty_option;
11497#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011498
11499 /*
11500 * Don't copy the options set by ex_help(), use the saved values,
11501 * when going from a help buffer to a non-help buffer.
11502 * Don't touch these at all when BCO_NOHELP is used and going from
11503 * or to a help buffer.
11504 */
11505 if (dont_do_help)
Bram Moolenaar04958cb2018-06-23 19:23:02 +020011506 {
Bram Moolenaar071d4272004-06-13 20:20:40 +000011507 buf->b_p_isk = save_p_isk;
Bram Moolenaar04958cb2018-06-23 19:23:02 +020011508#ifdef FEAT_VARTABS
11509 if (p_vts && p_vts != empty_option && !buf->b_p_vts_array)
11510 tabstop_set(p_vts, &buf->b_p_vts_array);
11511 else
11512 buf->b_p_vts_array = NULL;
11513#endif
11514 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011515 else
11516 {
11517 buf->b_p_isk = vim_strsave(p_isk);
11518 did_isk = TRUE;
11519 buf->b_p_ts = p_ts;
Bram Moolenaar04958cb2018-06-23 19:23:02 +020011520#ifdef FEAT_VARTABS
11521 buf->b_p_vts = vim_strsave(p_vts);
11522 if (p_vts && p_vts != empty_option && !buf->b_p_vts_array)
11523 tabstop_set(p_vts, &buf->b_p_vts_array);
11524 else
11525 buf->b_p_vts_array = NULL;
11526#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011527 buf->b_help = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011528 if (buf->b_p_bt[0] == 'h')
11529 clear_string_option(&buf->b_p_bt);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011530 buf->b_p_ma = p_ma;
11531 }
11532 }
11533
11534 /*
11535 * When the options should be copied (ignoring BCO_ALWAYS), set the
11536 * flag that indicates that the options have been initialized.
11537 */
11538 if (should_copy)
11539 buf->b_p_initialized = TRUE;
11540 }
11541
11542 check_buf_options(buf); /* make sure we don't have NULLs */
11543 if (did_isk)
11544 (void)buf_init_chartab(buf, FALSE);
11545}
11546
11547/*
11548 * Reset the 'modifiable' option and its default value.
11549 */
11550 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011551reset_modifiable(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011552{
11553 int opt_idx;
11554
11555 curbuf->b_p_ma = FALSE;
11556 p_ma = FALSE;
11557 opt_idx = findoption((char_u *)"ma");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000011558 if (opt_idx >= 0)
11559 options[opt_idx].def_val[VI_DEFAULT] = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011560}
11561
11562/*
11563 * Set the global value for 'iminsert' to the local value.
11564 */
11565 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011566set_iminsert_global(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011567{
11568 p_iminsert = curbuf->b_p_iminsert;
11569}
11570
11571/*
11572 * Set the global value for 'imsearch' to the local value.
11573 */
11574 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011575set_imsearch_global(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011576{
11577 p_imsearch = curbuf->b_p_imsearch;
11578}
11579
11580#if defined(FEAT_CMDL_COMPL) || defined(PROTO)
11581static int expand_option_idx = -1;
11582static char_u expand_option_name[5] = {'t', '_', NUL, NUL, NUL};
11583static int expand_option_flags = 0;
11584
11585 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011586set_context_in_set_cmd(
11587 expand_T *xp,
11588 char_u *arg,
11589 int opt_flags) /* OPT_GLOBAL and/or OPT_LOCAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011590{
11591 int nextchar;
11592 long_u flags = 0; /* init for GCC */
11593 int opt_idx = 0; /* init for GCC */
11594 char_u *p;
11595 char_u *s;
11596 int is_term_option = FALSE;
11597 int key;
11598
11599 expand_option_flags = opt_flags;
11600
11601 xp->xp_context = EXPAND_SETTINGS;
11602 if (*arg == NUL)
11603 {
11604 xp->xp_pattern = arg;
11605 return;
11606 }
11607 p = arg + STRLEN(arg) - 1;
11608 if (*p == ' ' && *(p - 1) != '\\')
11609 {
11610 xp->xp_pattern = p + 1;
11611 return;
11612 }
11613 while (p > arg)
11614 {
11615 s = p;
11616 /* count number of backslashes before ' ' or ',' */
11617 if (*p == ' ' || *p == ',')
11618 {
11619 while (s > arg && *(s - 1) == '\\')
11620 --s;
11621 }
11622 /* break at a space with an even number of backslashes */
11623 if (*p == ' ' && ((p - s) & 1) == 0)
11624 {
11625 ++p;
11626 break;
11627 }
11628 --p;
11629 }
Bram Moolenaar2a7b9ee2009-06-16 15:50:33 +000011630 if (STRNCMP(p, "no", 2) == 0 && STRNCMP(p, "novice", 6) != 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011631 {
11632 xp->xp_context = EXPAND_BOOL_SETTINGS;
11633 p += 2;
11634 }
11635 if (STRNCMP(p, "inv", 3) == 0)
11636 {
11637 xp->xp_context = EXPAND_BOOL_SETTINGS;
11638 p += 3;
11639 }
11640 xp->xp_pattern = arg = p;
11641 if (*arg == '<')
11642 {
11643 while (*p != '>')
11644 if (*p++ == NUL) /* expand terminal option name */
11645 return;
11646 key = get_special_key_code(arg + 1);
11647 if (key == 0) /* unknown name */
11648 {
11649 xp->xp_context = EXPAND_NOTHING;
11650 return;
11651 }
11652 nextchar = *++p;
11653 is_term_option = TRUE;
11654 expand_option_name[2] = KEY2TERMCAP0(key);
11655 expand_option_name[3] = KEY2TERMCAP1(key);
11656 }
11657 else
11658 {
11659 if (p[0] == 't' && p[1] == '_')
11660 {
11661 p += 2;
11662 if (*p != NUL)
11663 ++p;
11664 if (*p == NUL)
11665 return; /* expand option name */
11666 nextchar = *++p;
11667 is_term_option = TRUE;
11668 expand_option_name[2] = p[-2];
11669 expand_option_name[3] = p[-1];
11670 }
11671 else
11672 {
11673 /* Allow * wildcard */
11674 while (ASCII_ISALNUM(*p) || *p == '_' || *p == '*')
11675 p++;
11676 if (*p == NUL)
11677 return;
11678 nextchar = *p;
11679 *p = NUL;
11680 opt_idx = findoption(arg);
11681 *p = nextchar;
11682 if (opt_idx == -1 || options[opt_idx].var == NULL)
11683 {
11684 xp->xp_context = EXPAND_NOTHING;
11685 return;
11686 }
11687 flags = options[opt_idx].flags;
11688 if (flags & P_BOOL)
11689 {
11690 xp->xp_context = EXPAND_NOTHING;
11691 return;
11692 }
11693 }
11694 }
11695 /* handle "-=" and "+=" */
11696 if ((nextchar == '-' || nextchar == '+' || nextchar == '^') && p[1] == '=')
11697 {
11698 ++p;
11699 nextchar = '=';
11700 }
11701 if ((nextchar != '=' && nextchar != ':')
11702 || xp->xp_context == EXPAND_BOOL_SETTINGS)
11703 {
11704 xp->xp_context = EXPAND_UNSUCCESSFUL;
11705 return;
11706 }
11707 if (xp->xp_context != EXPAND_BOOL_SETTINGS && p[1] == NUL)
11708 {
11709 xp->xp_context = EXPAND_OLD_SETTING;
11710 if (is_term_option)
11711 expand_option_idx = -1;
11712 else
11713 expand_option_idx = opt_idx;
11714 xp->xp_pattern = p + 1;
11715 return;
11716 }
11717 xp->xp_context = EXPAND_NOTHING;
11718 if (is_term_option || (flags & P_NUM))
11719 return;
11720
11721 xp->xp_pattern = p + 1;
11722
11723 if (flags & P_EXPAND)
11724 {
11725 p = options[opt_idx].var;
11726 if (p == (char_u *)&p_bdir
11727 || p == (char_u *)&p_dir
11728 || p == (char_u *)&p_path
Bram Moolenaarf6fee0e2016-02-21 23:02:49 +010011729 || p == (char_u *)&p_pp
Bram Moolenaar071d4272004-06-13 20:20:40 +000011730 || p == (char_u *)&p_rtp
11731#ifdef FEAT_SEARCHPATH
11732 || p == (char_u *)&p_cdpath
11733#endif
11734#ifdef FEAT_SESSION
11735 || p == (char_u *)&p_vdir
11736#endif
11737 )
11738 {
11739 xp->xp_context = EXPAND_DIRECTORIES;
11740 if (p == (char_u *)&p_path
11741#ifdef FEAT_SEARCHPATH
11742 || p == (char_u *)&p_cdpath
11743#endif
11744 )
11745 xp->xp_backslash = XP_BS_THREE;
11746 else
11747 xp->xp_backslash = XP_BS_ONE;
11748 }
11749 else
11750 {
11751 xp->xp_context = EXPAND_FILES;
11752 /* for 'tags' need three backslashes for a space */
11753 if (p == (char_u *)&p_tags)
11754 xp->xp_backslash = XP_BS_THREE;
11755 else
11756 xp->xp_backslash = XP_BS_ONE;
11757 }
11758 }
11759
11760 /* For an option that is a list of file names, find the start of the
11761 * last file name. */
11762 for (p = arg + STRLEN(arg) - 1; p > xp->xp_pattern; --p)
11763 {
11764 /* count number of backslashes before ' ' or ',' */
11765 if (*p == ' ' || *p == ',')
11766 {
11767 s = p;
11768 while (s > xp->xp_pattern && *(s - 1) == '\\')
11769 --s;
11770 if ((*p == ' ' && (xp->xp_backslash == XP_BS_THREE && (p - s) < 3))
11771 || (*p == ',' && (flags & P_COMMA) && ((p - s) & 1) == 0))
11772 {
11773 xp->xp_pattern = p + 1;
11774 break;
11775 }
11776 }
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +000011777
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000011778#ifdef FEAT_SPELL
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +000011779 /* for 'spellsuggest' start at "file:" */
11780 if (options[opt_idx].var == (char_u *)&p_sps
11781 && STRNCMP(p, "file:", 5) == 0)
11782 {
11783 xp->xp_pattern = p + 5;
11784 break;
11785 }
11786#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011787 }
11788
11789 return;
11790}
11791
11792 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011793ExpandSettings(
11794 expand_T *xp,
11795 regmatch_T *regmatch,
11796 int *num_file,
11797 char_u ***file)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011798{
11799 int num_normal = 0; /* Nr of matching non-term-code settings */
11800 int num_term = 0; /* Nr of matching terminal code settings */
11801 int opt_idx;
11802 int match;
11803 int count = 0;
11804 char_u *str;
11805 int loop;
11806 int is_term_opt;
11807 char_u name_buf[MAX_KEY_NAME_LEN];
11808 static char *(names[]) = {"all", "termcap"};
11809 int ic = regmatch->rm_ic; /* remember the ignore-case flag */
11810
11811 /* do this loop twice:
11812 * loop == 0: count the number of matching options
11813 * loop == 1: copy the matching options into allocated memory
11814 */
11815 for (loop = 0; loop <= 1; ++loop)
11816 {
11817 regmatch->rm_ic = ic;
11818 if (xp->xp_context != EXPAND_BOOL_SETTINGS)
11819 {
Bram Moolenaar2c4278f2009-05-17 11:33:22 +000011820 for (match = 0; match < (int)(sizeof(names) / sizeof(char *));
11821 ++match)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011822 if (vim_regexec(regmatch, (char_u *)names[match], (colnr_T)0))
11823 {
11824 if (loop == 0)
11825 num_normal++;
11826 else
11827 (*file)[count++] = vim_strsave((char_u *)names[match]);
11828 }
11829 }
11830 for (opt_idx = 0; (str = (char_u *)options[opt_idx].fullname) != NULL;
11831 opt_idx++)
11832 {
11833 if (options[opt_idx].var == NULL)
11834 continue;
11835 if (xp->xp_context == EXPAND_BOOL_SETTINGS
11836 && !(options[opt_idx].flags & P_BOOL))
11837 continue;
11838 is_term_opt = istermoption(&options[opt_idx]);
11839 if (is_term_opt && num_normal > 0)
11840 continue;
11841 match = FALSE;
11842 if (vim_regexec(regmatch, str, (colnr_T)0)
11843 || (options[opt_idx].shortname != NULL
11844 && vim_regexec(regmatch,
11845 (char_u *)options[opt_idx].shortname, (colnr_T)0)))
11846 match = TRUE;
11847 else if (is_term_opt)
11848 {
11849 name_buf[0] = '<';
11850 name_buf[1] = 't';
11851 name_buf[2] = '_';
11852 name_buf[3] = str[2];
11853 name_buf[4] = str[3];
11854 name_buf[5] = '>';
11855 name_buf[6] = NUL;
11856 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11857 {
11858 match = TRUE;
11859 str = name_buf;
11860 }
11861 }
11862 if (match)
11863 {
11864 if (loop == 0)
11865 {
11866 if (is_term_opt)
11867 num_term++;
11868 else
11869 num_normal++;
11870 }
11871 else
11872 (*file)[count++] = vim_strsave(str);
11873 }
11874 }
11875 /*
11876 * Check terminal key codes, these are not in the option table
11877 */
11878 if (xp->xp_context != EXPAND_BOOL_SETTINGS && num_normal == 0)
11879 {
11880 for (opt_idx = 0; (str = get_termcode(opt_idx)) != NULL; opt_idx++)
11881 {
11882 if (!isprint(str[0]) || !isprint(str[1]))
11883 continue;
11884
11885 name_buf[0] = 't';
11886 name_buf[1] = '_';
11887 name_buf[2] = str[0];
11888 name_buf[3] = str[1];
11889 name_buf[4] = NUL;
11890
11891 match = FALSE;
11892 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11893 match = TRUE;
11894 else
11895 {
11896 name_buf[0] = '<';
11897 name_buf[1] = 't';
11898 name_buf[2] = '_';
11899 name_buf[3] = str[0];
11900 name_buf[4] = str[1];
11901 name_buf[5] = '>';
11902 name_buf[6] = NUL;
11903
11904 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11905 match = TRUE;
11906 }
11907 if (match)
11908 {
11909 if (loop == 0)
11910 num_term++;
11911 else
11912 (*file)[count++] = vim_strsave(name_buf);
11913 }
11914 }
11915
11916 /*
11917 * Check special key names.
11918 */
11919 regmatch->rm_ic = TRUE; /* ignore case here */
11920 for (opt_idx = 0; (str = get_key_name(opt_idx)) != NULL; opt_idx++)
11921 {
11922 name_buf[0] = '<';
11923 STRCPY(name_buf + 1, str);
11924 STRCAT(name_buf, ">");
11925
11926 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11927 {
11928 if (loop == 0)
11929 num_term++;
11930 else
11931 (*file)[count++] = vim_strsave(name_buf);
11932 }
11933 }
11934 }
11935 if (loop == 0)
11936 {
11937 if (num_normal > 0)
11938 *num_file = num_normal;
11939 else if (num_term > 0)
11940 *num_file = num_term;
11941 else
11942 return OK;
11943 *file = (char_u **)alloc((unsigned)(*num_file * sizeof(char_u *)));
11944 if (*file == NULL)
11945 {
11946 *file = (char_u **)"";
11947 return FAIL;
11948 }
11949 }
11950 }
11951 return OK;
11952}
11953
11954 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011955ExpandOldSetting(int *num_file, char_u ***file)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011956{
11957 char_u *var = NULL; /* init for GCC */
11958 char_u *buf;
11959
11960 *num_file = 0;
11961 *file = (char_u **)alloc((unsigned)sizeof(char_u *));
11962 if (*file == NULL)
11963 return FAIL;
11964
11965 /*
11966 * For a terminal key code expand_option_idx is < 0.
11967 */
11968 if (expand_option_idx < 0)
11969 {
11970 var = find_termcode(expand_option_name + 2);
11971 if (var == NULL)
11972 expand_option_idx = findoption(expand_option_name);
11973 }
11974
11975 if (expand_option_idx >= 0)
11976 {
11977 /* put string of option value in NameBuff */
11978 option_value2string(&options[expand_option_idx], expand_option_flags);
11979 var = NameBuff;
11980 }
11981 else if (var == NULL)
11982 var = (char_u *)"";
11983
11984 /* A backslash is required before some characters. This is the reverse of
11985 * what happens in do_set(). */
11986 buf = vim_strsave_escaped(var, escape_chars);
11987
11988 if (buf == NULL)
11989 {
Bram Moolenaard23a8232018-02-10 18:45:26 +010011990 VIM_CLEAR(*file);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011991 return FAIL;
11992 }
11993
11994#ifdef BACKSLASH_IN_FILENAME
11995 /* For MS-Windows et al. we don't double backslashes at the start and
11996 * before a file name character. */
Bram Moolenaar91acfff2017-03-12 19:22:36 +010011997 for (var = buf; *var != NUL; MB_PTR_ADV(var))
Bram Moolenaar071d4272004-06-13 20:20:40 +000011998 if (var[0] == '\\' && var[1] == '\\'
11999 && expand_option_idx >= 0
12000 && (options[expand_option_idx].flags & P_EXPAND)
12001 && vim_isfilec(var[2])
12002 && (var[2] != '\\' || (var == buf && var[4] != '\\')))
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +000012003 STRMOVE(var, var + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +000012004#endif
12005
12006 *file[0] = buf;
12007 *num_file = 1;
12008 return OK;
12009}
12010#endif
12011
12012/*
12013 * Get the value for the numeric or string option *opp in a nice format into
12014 * NameBuff[]. Must not be called with a hidden option!
12015 */
12016 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012017option_value2string(
12018 struct vimoption *opp,
12019 int opt_flags) /* OPT_GLOBAL and/or OPT_LOCAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012020{
12021 char_u *varp;
12022
12023 varp = get_varp_scope(opp, opt_flags);
12024
12025 if (opp->flags & P_NUM)
12026 {
12027 long wc = 0;
12028
12029 if (wc_use_keyname(varp, &wc))
12030 STRCPY(NameBuff, get_special_key_name((int)wc, 0));
12031 else if (wc != 0)
12032 STRCPY(NameBuff, transchar((int)wc));
12033 else
12034 sprintf((char *)NameBuff, "%ld", *(long *)varp);
12035 }
12036 else /* P_STRING */
12037 {
12038 varp = *(char_u **)(varp);
12039 if (varp == NULL) /* just in case */
12040 NameBuff[0] = NUL;
12041#ifdef FEAT_CRYPT
12042 /* don't show the actual value of 'key', only that it's set */
Bram Moolenaareb3593b2006-04-22 22:33:57 +000012043 else if (opp->var == (char_u *)&p_key && *varp)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012044 STRCPY(NameBuff, "*****");
12045#endif
12046 else if (opp->flags & P_EXPAND)
12047 home_replace(NULL, varp, NameBuff, MAXPATHL, FALSE);
12048 /* Translate 'pastetoggle' into special key names */
12049 else if ((char_u **)opp->var == &p_pt)
12050 str2specialbuf(p_pt, NameBuff, MAXPATHL);
12051 else
Bram Moolenaarce0842a2005-07-18 21:58:11 +000012052 vim_strncpy(NameBuff, varp, MAXPATHL - 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +000012053 }
12054}
12055
12056/*
12057 * Return TRUE if "varp" points to 'wildchar' or 'wildcharm' and it can be
12058 * printed as a keyname.
12059 * "*wcp" is set to the value of the option if it's 'wildchar' or 'wildcharm'.
12060 */
12061 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012062wc_use_keyname(char_u *varp, long *wcp)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012063{
12064 if (((long *)varp == &p_wc) || ((long *)varp == &p_wcm))
12065 {
12066 *wcp = *(long *)varp;
12067 if (IS_SPECIAL(*wcp) || find_special_key_in_table((int)*wcp) >= 0)
12068 return TRUE;
12069 }
12070 return FALSE;
12071}
12072
Bram Moolenaar01615492015-02-03 13:00:38 +010012073#if defined(FEAT_LANGMAP) || defined(PROTO)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012074/*
Bram Moolenaar28e8d272009-02-21 19:28:48 +000012075 * Any character has an equivalent 'langmap' character. This is used for
12076 * keyboards that have a special language mode that sends characters above
12077 * 128 (although other characters can be translated too). The "to" field is a
12078 * Vim command character. This avoids having to switch the keyboard back to
12079 * ASCII mode when leaving Insert mode.
12080 *
12081 * langmap_mapchar[] maps any of 256 chars to an ASCII char used for Vim
12082 * commands.
12083 * When FEAT_MBYTE is defined langmap_mapga.ga_data is a sorted table of
12084 * langmap_entry_T. This does the same as langmap_mapchar[] for characters >=
12085 * 256.
Bram Moolenaar071d4272004-06-13 20:20:40 +000012086 */
Bram Moolenaar01615492015-02-03 13:00:38 +010012087# if defined(FEAT_MBYTE) || defined(PROTO)
Bram Moolenaar28e8d272009-02-21 19:28:48 +000012088/*
12089 * With multi-byte support use growarray for 'langmap' chars >= 256
12090 */
12091typedef struct
12092{
12093 int from;
12094 int to;
12095} langmap_entry_T;
12096
12097static garray_T langmap_mapga;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012098
12099/*
Bram Moolenaar28e8d272009-02-21 19:28:48 +000012100 * Search for an entry in "langmap_mapga" for "from". If found set the "to"
12101 * field. If not found insert a new entry at the appropriate location.
Bram Moolenaar071d4272004-06-13 20:20:40 +000012102 */
Bram Moolenaar28e8d272009-02-21 19:28:48 +000012103 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012104langmap_set_entry(int from, int to)
Bram Moolenaar28e8d272009-02-21 19:28:48 +000012105{
12106 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
Bram Moolenaarcc448b32010-07-14 16:52:17 +020012107 int a = 0;
12108 int b = langmap_mapga.ga_len;
Bram Moolenaar28e8d272009-02-21 19:28:48 +000012109
12110 /* Do a binary search for an existing entry. */
12111 while (a != b)
12112 {
12113 int i = (a + b) / 2;
12114 int d = entries[i].from - from;
12115
12116 if (d == 0)
12117 {
12118 entries[i].to = to;
12119 return;
12120 }
12121 if (d < 0)
12122 a = i + 1;
12123 else
12124 b = i;
12125 }
12126
12127 if (ga_grow(&langmap_mapga, 1) != OK)
12128 return; /* out of memory */
12129
12130 /* insert new entry at position "a" */
12131 entries = (langmap_entry_T *)(langmap_mapga.ga_data) + a;
12132 mch_memmove(entries + 1, entries,
12133 (langmap_mapga.ga_len - a) * sizeof(langmap_entry_T));
12134 ++langmap_mapga.ga_len;
12135 entries[0].from = from;
12136 entries[0].to = to;
12137}
12138
12139/*
12140 * Apply 'langmap' to multi-byte character "c" and return the result.
12141 */
12142 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012143langmap_adjust_mb(int c)
Bram Moolenaar28e8d272009-02-21 19:28:48 +000012144{
12145 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
12146 int a = 0;
12147 int b = langmap_mapga.ga_len;
12148
12149 while (a != b)
12150 {
12151 int i = (a + b) / 2;
12152 int d = entries[i].from - c;
12153
12154 if (d == 0)
12155 return entries[i].to; /* found matching entry */
12156 if (d < 0)
12157 a = i + 1;
12158 else
12159 b = i;
12160 }
12161 return c; /* no entry found, return "c" unmodified */
12162}
12163# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000012164
12165 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012166langmap_init(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012167{
12168 int i;
12169
Bram Moolenaar28e8d272009-02-21 19:28:48 +000012170 for (i = 0; i < 256; i++)
12171 langmap_mapchar[i] = i; /* we init with a one-to-one map */
12172# ifdef FEAT_MBYTE
12173 ga_init2(&langmap_mapga, sizeof(langmap_entry_T), 8);
12174# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000012175}
12176
12177/*
12178 * Called when langmap option is set; the language map can be
12179 * changed at any time!
12180 */
12181 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012182langmap_set(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012183{
12184 char_u *p;
12185 char_u *p2;
12186 int from, to;
12187
Bram Moolenaar28e8d272009-02-21 19:28:48 +000012188#ifdef FEAT_MBYTE
12189 ga_clear(&langmap_mapga); /* clear the previous map first */
12190#endif
12191 langmap_init(); /* back to one-to-one map */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012192
12193 for (p = p_langmap; p[0] != NUL; )
12194 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000012195 for (p2 = p; p2[0] != NUL && p2[0] != ',' && p2[0] != ';';
Bram Moolenaar91acfff2017-03-12 19:22:36 +010012196 MB_PTR_ADV(p2))
Bram Moolenaar071d4272004-06-13 20:20:40 +000012197 {
12198 if (p2[0] == '\\' && p2[1] != NUL)
12199 ++p2;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012200 }
12201 if (p2[0] == ';')
12202 ++p2; /* abcd;ABCD form, p2 points to A */
12203 else
12204 p2 = NULL; /* aAbBcCdD form, p2 is NULL */
12205 while (p[0])
12206 {
Bram Moolenaar6af05062010-05-14 17:32:58 +020012207 if (p[0] == ',')
12208 {
12209 ++p;
12210 break;
12211 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000012212 if (p[0] == '\\' && p[1] != NUL)
12213 ++p;
12214#ifdef FEAT_MBYTE
12215 from = (*mb_ptr2char)(p);
12216#else
12217 from = p[0];
12218#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020012219 to = NUL;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012220 if (p2 == NULL)
12221 {
Bram Moolenaar91acfff2017-03-12 19:22:36 +010012222 MB_PTR_ADV(p);
Bram Moolenaar6af05062010-05-14 17:32:58 +020012223 if (p[0] != ',')
12224 {
12225 if (p[0] == '\\')
12226 ++p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012227#ifdef FEAT_MBYTE
Bram Moolenaar6af05062010-05-14 17:32:58 +020012228 to = (*mb_ptr2char)(p);
Bram Moolenaar071d4272004-06-13 20:20:40 +000012229#else
Bram Moolenaar6af05062010-05-14 17:32:58 +020012230 to = p[0];
Bram Moolenaar071d4272004-06-13 20:20:40 +000012231#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020012232 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000012233 }
12234 else
12235 {
Bram Moolenaar6af05062010-05-14 17:32:58 +020012236 if (p2[0] != ',')
12237 {
12238 if (p2[0] == '\\')
12239 ++p2;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012240#ifdef FEAT_MBYTE
Bram Moolenaar6af05062010-05-14 17:32:58 +020012241 to = (*mb_ptr2char)(p2);
Bram Moolenaar071d4272004-06-13 20:20:40 +000012242#else
Bram Moolenaar6af05062010-05-14 17:32:58 +020012243 to = p2[0];
Bram Moolenaar071d4272004-06-13 20:20:40 +000012244#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020012245 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000012246 }
12247 if (to == NUL)
12248 {
12249 EMSG2(_("E357: 'langmap': Matching character missing for %s"),
12250 transchar(from));
12251 return;
12252 }
Bram Moolenaar28e8d272009-02-21 19:28:48 +000012253
12254#ifdef FEAT_MBYTE
12255 if (from >= 256)
12256 langmap_set_entry(from, to);
12257 else
12258#endif
12259 langmap_mapchar[from & 255] = to;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012260
12261 /* Advance to next pair */
Bram Moolenaar91acfff2017-03-12 19:22:36 +010012262 MB_PTR_ADV(p);
Bram Moolenaar6af05062010-05-14 17:32:58 +020012263 if (p2 != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012264 {
Bram Moolenaar91acfff2017-03-12 19:22:36 +010012265 MB_PTR_ADV(p2);
Bram Moolenaar071d4272004-06-13 20:20:40 +000012266 if (*p == ';')
12267 {
12268 p = p2;
12269 if (p[0] != NUL)
12270 {
12271 if (p[0] != ',')
12272 {
12273 EMSG2(_("E358: 'langmap': Extra characters after semicolon: %s"), p);
12274 return;
12275 }
12276 ++p;
12277 }
12278 break;
12279 }
12280 }
12281 }
12282 }
12283}
12284#endif
12285
12286/*
12287 * Return TRUE if format option 'x' is in effect.
12288 * Take care of no formatting when 'paste' is set.
12289 */
12290 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012291has_format_option(int x)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012292{
12293 if (p_paste)
12294 return FALSE;
12295 return (vim_strchr(curbuf->b_p_fo, x) != NULL);
12296}
12297
12298/*
12299 * Return TRUE if "x" is present in 'shortmess' option, or
12300 * 'shortmess' contains 'a' and "x" is present in SHM_A.
12301 */
12302 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012303shortmess(int x)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012304{
Bram Moolenaar7f29f7a2012-02-29 13:51:37 +010012305 return p_shm != NULL &&
12306 ( vim_strchr(p_shm, x) != NULL
Bram Moolenaar071d4272004-06-13 20:20:40 +000012307 || (vim_strchr(p_shm, 'a') != NULL
12308 && vim_strchr((char_u *)SHM_A, x) != NULL));
12309}
12310
12311/*
12312 * paste_option_changed() - Called after p_paste was set or reset.
12313 */
12314 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012315paste_option_changed(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012316{
12317 static int old_p_paste = FALSE;
12318 static int save_sm = 0;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012319 static int save_sta = 0;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012320#ifdef FEAT_CMDL_INFO
12321 static int save_ru = 0;
12322#endif
12323#ifdef FEAT_RIGHTLEFT
12324 static int save_ri = 0;
12325 static int save_hkmap = 0;
12326#endif
12327 buf_T *buf;
12328
12329 if (p_paste)
12330 {
12331 /*
12332 * Paste switched from off to on.
12333 * Save the current values, so they can be restored later.
12334 */
12335 if (!old_p_paste)
12336 {
12337 /* save options for each buffer */
Bram Moolenaar29323592016-07-24 22:04:11 +020012338 FOR_ALL_BUFFERS(buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012339 {
12340 buf->b_p_tw_nopaste = buf->b_p_tw;
12341 buf->b_p_wm_nopaste = buf->b_p_wm;
12342 buf->b_p_sts_nopaste = buf->b_p_sts;
12343 buf->b_p_ai_nopaste = buf->b_p_ai;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012344 buf->b_p_et_nopaste = buf->b_p_et;
Bram Moolenaar04958cb2018-06-23 19:23:02 +020012345#ifdef FEAT_VARTABS
12346 if (buf->b_p_vsts_nopaste)
12347 vim_free(buf->b_p_vsts_nopaste);
12348 buf->b_p_vsts_nopaste = buf->b_p_vsts && buf->b_p_vsts != empty_option
12349 ? vim_strsave(buf->b_p_vsts) : NULL;
12350#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000012351 }
12352
12353 /* save global options */
12354 save_sm = p_sm;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012355 save_sta = p_sta;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012356#ifdef FEAT_CMDL_INFO
12357 save_ru = p_ru;
12358#endif
12359#ifdef FEAT_RIGHTLEFT
12360 save_ri = p_ri;
12361 save_hkmap = p_hkmap;
12362#endif
12363 /* save global values for local buffer options */
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012364 p_ai_nopaste = p_ai;
12365 p_et_nopaste = p_et;
12366 p_sts_nopaste = p_sts;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012367 p_tw_nopaste = p_tw;
12368 p_wm_nopaste = p_wm;
Bram Moolenaar04958cb2018-06-23 19:23:02 +020012369#ifdef FEAT_VARTABS
12370 if (p_vsts_nopaste)
12371 vim_free(p_vsts_nopaste);
12372 p_vsts_nopaste = p_vsts && p_vsts != empty_option ? vim_strsave(p_vsts) : NULL;
12373#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000012374 }
12375
12376 /*
12377 * Always set the option values, also when 'paste' is set when it is
12378 * already on.
12379 */
12380 /* set options for each buffer */
Bram Moolenaar29323592016-07-24 22:04:11 +020012381 FOR_ALL_BUFFERS(buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012382 {
12383 buf->b_p_tw = 0; /* textwidth is 0 */
12384 buf->b_p_wm = 0; /* wrapmargin is 0 */
12385 buf->b_p_sts = 0; /* softtabstop is 0 */
12386 buf->b_p_ai = 0; /* no auto-indent */
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012387 buf->b_p_et = 0; /* no expandtab */
Bram Moolenaar04958cb2018-06-23 19:23:02 +020012388#ifdef FEAT_VARTABS
12389 if (buf->b_p_vsts)
12390 free_string_option(buf->b_p_vsts);
12391 buf->b_p_vsts = empty_option;
12392 if (buf->b_p_vsts_array)
12393 vim_free(buf->b_p_vsts_array);
12394 buf->b_p_vsts_array = 0;
12395#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000012396 }
12397
12398 /* set global options */
12399 p_sm = 0; /* no showmatch */
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012400 p_sta = 0; /* no smarttab */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012401#ifdef FEAT_CMDL_INFO
Bram Moolenaar071d4272004-06-13 20:20:40 +000012402 if (p_ru)
12403 status_redraw_all(); /* redraw to remove the ruler */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012404 p_ru = 0; /* no ruler */
12405#endif
12406#ifdef FEAT_RIGHTLEFT
12407 p_ri = 0; /* no reverse insert */
12408 p_hkmap = 0; /* no Hebrew keyboard */
12409#endif
12410 /* set global values for local buffer options */
12411 p_tw = 0;
12412 p_wm = 0;
12413 p_sts = 0;
12414 p_ai = 0;
Bram Moolenaar04958cb2018-06-23 19:23:02 +020012415#ifdef FEAT_VARTABS
12416 if (p_vsts)
12417 free_string_option(p_vsts);
12418 p_vsts = empty_option;
12419#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000012420 }
12421
12422 /*
12423 * Paste switched from on to off: Restore saved values.
12424 */
12425 else if (old_p_paste)
12426 {
12427 /* restore options for each buffer */
Bram Moolenaar29323592016-07-24 22:04:11 +020012428 FOR_ALL_BUFFERS(buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012429 {
12430 buf->b_p_tw = buf->b_p_tw_nopaste;
12431 buf->b_p_wm = buf->b_p_wm_nopaste;
12432 buf->b_p_sts = buf->b_p_sts_nopaste;
12433 buf->b_p_ai = buf->b_p_ai_nopaste;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012434 buf->b_p_et = buf->b_p_et_nopaste;
Bram Moolenaar04958cb2018-06-23 19:23:02 +020012435#ifdef FEAT_VARTABS
12436 if (buf->b_p_vsts)
12437 free_string_option(buf->b_p_vsts);
12438 buf->b_p_vsts = buf->b_p_vsts_nopaste
12439 ? vim_strsave(buf->b_p_vsts_nopaste) : empty_option;
12440 if (buf->b_p_vsts_array)
12441 vim_free(buf->b_p_vsts_array);
12442 if (buf->b_p_vsts && buf->b_p_vsts != empty_option)
12443 tabstop_set(buf->b_p_vsts, &buf->b_p_vsts_array);
12444 else
12445 buf->b_p_vsts_array = 0;
12446#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000012447 }
12448
12449 /* restore global options */
12450 p_sm = save_sm;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012451 p_sta = save_sta;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012452#ifdef FEAT_CMDL_INFO
Bram Moolenaar071d4272004-06-13 20:20:40 +000012453 if (p_ru != save_ru)
12454 status_redraw_all(); /* redraw to draw the ruler */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012455 p_ru = save_ru;
12456#endif
12457#ifdef FEAT_RIGHTLEFT
12458 p_ri = save_ri;
12459 p_hkmap = save_hkmap;
12460#endif
12461 /* set global values for local buffer options */
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012462 p_ai = p_ai_nopaste;
12463 p_et = p_et_nopaste;
12464 p_sts = p_sts_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012465 p_tw = p_tw_nopaste;
12466 p_wm = p_wm_nopaste;
Bram Moolenaar04958cb2018-06-23 19:23:02 +020012467#ifdef FEAT_VARTABS
12468 if (p_vsts)
12469 free_string_option(p_vsts);
12470 p_vsts = p_vsts_nopaste ? vim_strsave(p_vsts_nopaste) : empty_option;
12471#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000012472 }
12473
12474 old_p_paste = p_paste;
12475}
12476
12477/*
12478 * vimrc_found() - Called when a ".vimrc" or "VIMINIT" has been found.
12479 *
12480 * Reset 'compatible' and set the values for options that didn't get set yet
12481 * to the Vim defaults.
12482 * Don't do this if the 'compatible' option has been set or reset before.
Bram Moolenaar910f66f2006-04-05 20:41:53 +000012483 * When "fname" is not NULL, use it to set $"envname" when it wasn't set yet.
Bram Moolenaar071d4272004-06-13 20:20:40 +000012484 */
12485 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012486vimrc_found(char_u *fname, char_u *envname)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012487{
Bram Moolenaar910f66f2006-04-05 20:41:53 +000012488 int opt_idx;
Bram Moolenaar4c3f5362006-04-11 21:38:50 +000012489 int dofree = FALSE;
Bram Moolenaar910f66f2006-04-05 20:41:53 +000012490 char_u *p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012491
12492 if (!option_was_set((char_u *)"cp"))
12493 {
12494 p_cp = FALSE;
12495 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
12496 if (!(options[opt_idx].flags & (P_WAS_SET|P_VI_DEF)))
12497 set_option_default(opt_idx, OPT_FREE, FALSE);
12498 didset_options();
Bram Moolenaare68c25c2015-08-25 15:39:55 +020012499 didset_options2();
Bram Moolenaar071d4272004-06-13 20:20:40 +000012500 }
Bram Moolenaar910f66f2006-04-05 20:41:53 +000012501
12502 if (fname != NULL)
12503 {
12504 p = vim_getenv(envname, &dofree);
12505 if (p == NULL)
12506 {
12507 /* Set $MYVIMRC to the first vimrc file found. */
12508 p = FullName_save(fname, FALSE);
12509 if (p != NULL)
12510 {
12511 vim_setenv(envname, p);
12512 vim_free(p);
12513 }
12514 }
12515 else if (dofree)
12516 vim_free(p);
12517 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000012518}
12519
12520/*
12521 * Set 'compatible' on or off. Called for "-C" and "-N" command line arg.
12522 */
12523 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012524change_compatible(int on)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012525{
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000012526 int opt_idx;
12527
Bram Moolenaar071d4272004-06-13 20:20:40 +000012528 if (p_cp != on)
12529 {
12530 p_cp = on;
12531 compatible_set();
12532 }
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000012533 opt_idx = findoption((char_u *)"cp");
12534 if (opt_idx >= 0)
12535 options[opt_idx].flags |= P_WAS_SET;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012536}
12537
12538/*
12539 * Return TRUE when option "name" has been set.
Bram Moolenaar1a4a75c2013-07-28 16:03:06 +020012540 * Only works correctly for global options.
Bram Moolenaar071d4272004-06-13 20:20:40 +000012541 */
12542 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012543option_was_set(char_u *name)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012544{
12545 int idx;
12546
12547 idx = findoption(name);
12548 if (idx < 0) /* unknown option */
12549 return FALSE;
12550 if (options[idx].flags & P_WAS_SET)
12551 return TRUE;
12552 return FALSE;
12553}
12554
12555/*
Bram Moolenaar15d55de2012-12-05 14:43:02 +010012556 * Reset the flag indicating option "name" was set.
12557 */
Bram Moolenaarfe8ef982018-09-13 20:31:54 +020012558 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012559reset_option_was_set(char_u *name)
Bram Moolenaar15d55de2012-12-05 14:43:02 +010012560{
12561 int idx = findoption(name);
12562
12563 if (idx >= 0)
Bram Moolenaarfe8ef982018-09-13 20:31:54 +020012564 {
Bram Moolenaar15d55de2012-12-05 14:43:02 +010012565 options[idx].flags &= ~P_WAS_SET;
Bram Moolenaarfe8ef982018-09-13 20:31:54 +020012566 return OK;
12567 }
12568 return FAIL;
Bram Moolenaar15d55de2012-12-05 14:43:02 +010012569}
12570
12571/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000012572 * compatible_set() - Called when 'compatible' has been set or unset.
12573 *
12574 * When 'compatible' set: Set all relevant options (those that have the P_VIM)
12575 * flag) to a Vi compatible value.
12576 * When 'compatible' is unset: Set all options that have a different default
12577 * for Vim (without the P_VI_DEF flag) to that default.
12578 */
12579 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012580compatible_set(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012581{
12582 int opt_idx;
12583
12584 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
12585 if ( ((options[opt_idx].flags & P_VIM) && p_cp)
12586 || (!(options[opt_idx].flags & P_VI_DEF) && !p_cp))
12587 set_option_default(opt_idx, OPT_FREE, p_cp);
12588 didset_options();
Bram Moolenaare68c25c2015-08-25 15:39:55 +020012589 didset_options2();
Bram Moolenaar071d4272004-06-13 20:20:40 +000012590}
12591
12592#ifdef FEAT_LINEBREAK
12593
12594# if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
12595 /* Borland C++ screws up loop optimisation here (negri) */
Bram Moolenaar8f999f12005-01-25 22:12:55 +000012596 #pragma option -O-l
Bram Moolenaar071d4272004-06-13 20:20:40 +000012597# endif
12598
12599/*
12600 * fill_breakat_flags() -- called when 'breakat' changes value.
12601 */
12602 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012603fill_breakat_flags(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012604{
Bram Moolenaarac6e65f2005-08-29 22:25:38 +000012605 char_u *p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012606 int i;
12607
12608 for (i = 0; i < 256; i++)
12609 breakat_flags[i] = FALSE;
12610
12611 if (p_breakat != NULL)
Bram Moolenaarac6e65f2005-08-29 22:25:38 +000012612 for (p = p_breakat; *p; p++)
12613 breakat_flags[*p] = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012614}
12615
12616# if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
Bram Moolenaar8f999f12005-01-25 22:12:55 +000012617 #pragma option -O.l
Bram Moolenaar071d4272004-06-13 20:20:40 +000012618# endif
12619
12620#endif
12621
12622/*
12623 * Check an option that can be a range of string values.
12624 *
12625 * Return OK for correct value, FAIL otherwise.
12626 * Empty is always OK.
12627 */
12628 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012629check_opt_strings(
12630 char_u *val,
12631 char **values,
12632 int list) /* when TRUE: accept a list of values */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012633{
12634 return opt_strings_flags(val, values, NULL, list);
12635}
12636
12637/*
12638 * Handle an option that can be a range of string values.
12639 * Set a flag in "*flagp" for each string present.
12640 *
12641 * Return OK for correct value, FAIL otherwise.
12642 * Empty is always OK.
12643 */
12644 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012645opt_strings_flags(
12646 char_u *val, /* new value */
12647 char **values, /* array of valid string values */
12648 unsigned *flagp,
12649 int list) /* when TRUE: accept a list of values */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012650{
12651 int i;
12652 int len;
12653 unsigned new_flags = 0;
12654
12655 while (*val)
12656 {
12657 for (i = 0; ; ++i)
12658 {
12659 if (values[i] == NULL) /* val not found in values[] */
12660 return FAIL;
12661
12662 len = (int)STRLEN(values[i]);
12663 if (STRNCMP(values[i], val, len) == 0
12664 && ((list && val[len] == ',') || val[len] == NUL))
12665 {
12666 val += len + (val[len] == ',');
12667 new_flags |= (1 << i);
12668 break; /* check next item in val list */
12669 }
12670 }
12671 }
12672 if (flagp != NULL)
12673 *flagp = new_flags;
12674
12675 return OK;
12676}
12677
12678/*
12679 * Read the 'wildmode' option, fill wim_flags[].
12680 */
12681 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012682check_opt_wim(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012683{
12684 char_u new_wim_flags[4];
12685 char_u *p;
12686 int i;
12687 int idx = 0;
12688
12689 for (i = 0; i < 4; ++i)
12690 new_wim_flags[i] = 0;
12691
12692 for (p = p_wim; *p; ++p)
12693 {
12694 for (i = 0; ASCII_ISALPHA(p[i]); ++i)
12695 ;
12696 if (p[i] != NUL && p[i] != ',' && p[i] != ':')
12697 return FAIL;
12698 if (i == 7 && STRNCMP(p, "longest", 7) == 0)
12699 new_wim_flags[idx] |= WIM_LONGEST;
12700 else if (i == 4 && STRNCMP(p, "full", 4) == 0)
12701 new_wim_flags[idx] |= WIM_FULL;
12702 else if (i == 4 && STRNCMP(p, "list", 4) == 0)
12703 new_wim_flags[idx] |= WIM_LIST;
12704 else
12705 return FAIL;
12706 p += i;
12707 if (*p == NUL)
12708 break;
12709 if (*p == ',')
12710 {
12711 if (idx == 3)
12712 return FAIL;
12713 ++idx;
12714 }
12715 }
12716
12717 /* fill remaining entries with last flag */
12718 while (idx < 3)
12719 {
12720 new_wim_flags[idx + 1] = new_wim_flags[idx];
12721 ++idx;
12722 }
12723
12724 /* only when there are no errors, wim_flags[] is changed */
12725 for (i = 0; i < 4; ++i)
12726 wim_flags[i] = new_wim_flags[i];
12727 return OK;
12728}
12729
12730/*
12731 * Check if backspacing over something is allowed.
12732 */
12733 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012734can_bs(
12735 int what) /* BS_INDENT, BS_EOL or BS_START */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012736{
Bram Moolenaar6b810d92018-06-04 17:28:44 +020012737#ifdef FEAT_JOB_CHANNEL
12738 if (what == BS_START && bt_prompt(curbuf))
12739 return FALSE;
12740#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000012741 switch (*p_bs)
12742 {
12743 case '2': return TRUE;
12744 case '1': return (what != BS_START);
12745 case '0': return FALSE;
12746 }
12747 return vim_strchr(p_bs, what) != NULL;
12748}
12749
12750/*
12751 * Save the current values of 'fileformat' and 'fileencoding', so that we know
12752 * the file must be considered changed when the value is different.
12753 */
12754 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012755save_file_ff(buf_T *buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012756{
12757 buf->b_start_ffc = *buf->b_p_ff;
12758 buf->b_start_eol = buf->b_p_eol;
12759#ifdef FEAT_MBYTE
Bram Moolenaar83eb8852007-08-12 13:51:26 +000012760 buf->b_start_bomb = buf->b_p_bomb;
12761
Bram Moolenaar071d4272004-06-13 20:20:40 +000012762 /* Only use free/alloc when necessary, they take time. */
12763 if (buf->b_start_fenc == NULL
12764 || STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0)
12765 {
12766 vim_free(buf->b_start_fenc);
12767 buf->b_start_fenc = vim_strsave(buf->b_p_fenc);
12768 }
12769#endif
12770}
12771
12772/*
12773 * Return TRUE if 'fileformat' and/or 'fileencoding' has a different value
12774 * from when editing started (save_file_ff() called).
Bram Moolenaar83eb8852007-08-12 13:51:26 +000012775 * Also when 'endofline' was changed and 'binary' is set, or when 'bomb' was
12776 * changed and 'binary' is not set.
Bram Moolenaar34d72d42015-07-17 14:18:08 +020012777 * Also when 'endofline' was changed and 'fixeol' is not set.
Bram Moolenaar164c60f2011-01-22 00:11:50 +010012778 * When "ignore_empty" is true don't consider a new, empty buffer to be
12779 * changed.
Bram Moolenaar071d4272004-06-13 20:20:40 +000012780 */
12781 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012782file_ff_differs(buf_T *buf, int ignore_empty)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012783{
Bram Moolenaar9cffde92007-07-24 07:51:18 +000012784 /* In a buffer that was never loaded the options are not valid. */
12785 if (buf->b_flags & BF_NEVERLOADED)
12786 return FALSE;
Bram Moolenaar164c60f2011-01-22 00:11:50 +010012787 if (ignore_empty
12788 && (buf->b_flags & BF_NEW)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012789 && buf->b_ml.ml_line_count == 1
12790 && *ml_get_buf(buf, (linenr_T)1, FALSE) == NUL)
12791 return FALSE;
12792 if (buf->b_start_ffc != *buf->b_p_ff)
12793 return TRUE;
Bram Moolenaar34d72d42015-07-17 14:18:08 +020012794 if ((buf->b_p_bin || !buf->b_p_fixeol) && buf->b_start_eol != buf->b_p_eol)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012795 return TRUE;
12796#ifdef FEAT_MBYTE
Bram Moolenaar83eb8852007-08-12 13:51:26 +000012797 if (!buf->b_p_bin && buf->b_start_bomb != buf->b_p_bomb)
12798 return TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012799 if (buf->b_start_fenc == NULL)
12800 return (*buf->b_p_fenc != NUL);
12801 return (STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0);
12802#else
12803 return FALSE;
12804#endif
12805}
12806
12807/*
12808 * return OK if "p" is a valid fileformat name, FAIL otherwise.
12809 */
12810 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012811check_ff_value(char_u *p)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012812{
12813 return check_opt_strings(p, p_ff_values, FALSE);
12814}
Bram Moolenaar14f24742012-08-08 18:01:05 +020012815
Bram Moolenaar04958cb2018-06-23 19:23:02 +020012816#ifdef FEAT_VARTABS
12817
12818/*
12819 * Set the integer values corresponding to the string setting of 'vartabstop'.
12820 */
12821 int
12822tabstop_set(char_u *var, int **array)
12823{
12824 int valcount = 1;
12825 int t;
12826 char_u *cp;
12827
Bram Moolenaar64f41072018-10-15 22:51:50 +020012828 if (var[0] == NUL || (var[0] == '0' && var[1] == NUL))
Bram Moolenaar04958cb2018-06-23 19:23:02 +020012829 {
12830 *array = NULL;
12831 return TRUE;
12832 }
12833
Bram Moolenaar64f41072018-10-15 22:51:50 +020012834 for (cp = var; *cp != NUL; ++cp)
Bram Moolenaar04958cb2018-06-23 19:23:02 +020012835 {
Bram Moolenaar64f41072018-10-15 22:51:50 +020012836 if (cp == var || cp[-1] == ',')
Bram Moolenaar04958cb2018-06-23 19:23:02 +020012837 {
12838 char_u *end;
Bram Moolenaar64f41072018-10-15 22:51:50 +020012839
Bram Moolenaar04958cb2018-06-23 19:23:02 +020012840 if (strtol((char *)cp, (char **)&end, 10) <= 0)
12841 {
12842 if (cp != end)
12843 EMSG(_(e_positive));
12844 else
12845 EMSG(_(e_invarg));
12846 return FALSE;
12847 }
12848 }
12849
12850 if (VIM_ISDIGIT(*cp))
12851 continue;
Bram Moolenaar64f41072018-10-15 22:51:50 +020012852 if (cp[0] == ',' && cp > var && cp[-1] != ',' && cp[1] != NUL)
Bram Moolenaar04958cb2018-06-23 19:23:02 +020012853 {
12854 ++valcount;
12855 continue;
12856 }
12857 EMSG(_(e_invarg));
12858 return FALSE;
12859 }
12860
Bram Moolenaar64f41072018-10-15 22:51:50 +020012861 *array = (int *)alloc((unsigned) ((valcount + 1) * sizeof(int)));
Bram Moolenaar04958cb2018-06-23 19:23:02 +020012862 (*array)[0] = valcount;
12863
12864 t = 1;
Bram Moolenaar64f41072018-10-15 22:51:50 +020012865 for (cp = var; *cp != NUL;)
Bram Moolenaar04958cb2018-06-23 19:23:02 +020012866 {
12867 (*array)[t++] = atoi((char *)cp);
Bram Moolenaar64f41072018-10-15 22:51:50 +020012868 while (*cp != NUL && *cp != ',')
Bram Moolenaar04958cb2018-06-23 19:23:02 +020012869 ++cp;
Bram Moolenaar64f41072018-10-15 22:51:50 +020012870 if (*cp != NUL)
Bram Moolenaar04958cb2018-06-23 19:23:02 +020012871 ++cp;
12872 }
12873
12874 return TRUE;
12875}
12876
12877/*
12878 * Calculate the number of screen spaces a tab will occupy.
12879 * If "vts" is set then the tab widths are taken from that array,
12880 * otherwise the value of ts is used.
12881 */
12882 int
12883tabstop_padding(colnr_T col, int ts_arg, int *vts)
12884{
12885 int ts = ts_arg == 0 ? 8 : ts_arg;
12886 int tabcount;
12887 colnr_T tabcol = 0;
12888 int t;
12889 int padding = 0;
12890
12891 if (vts == NULL || vts[0] == 0)
12892 return ts - (col % ts);
12893
12894 tabcount = vts[0];
12895
12896 for (t = 1; t <= tabcount; ++t)
12897 {
12898 tabcol += vts[t];
12899 if (tabcol > col)
12900 {
12901 padding = (int)(tabcol - col);
12902 break;
12903 }
12904 }
12905 if (t > tabcount)
12906 padding = vts[tabcount] - (int)((col - tabcol) % vts[tabcount]);
12907
12908 return padding;
12909}
12910
12911/*
12912 * Find the size of the tab that covers a particular column.
12913 */
12914 int
12915tabstop_at(colnr_T col, int ts, int *vts)
12916{
12917 int tabcount;
12918 colnr_T tabcol = 0;
12919 int t;
12920 int tab_size = 0;
12921
12922 if (vts == 0 || vts[0] == 0)
12923 return ts;
12924
12925 tabcount = vts[0];
12926 for (t = 1; t <= tabcount; ++t)
12927 {
12928 tabcol += vts[t];
12929 if (tabcol > col)
12930 {
12931 tab_size = vts[t];
12932 break;
12933 }
12934 }
12935 if (t > tabcount)
12936 tab_size = vts[tabcount];
12937
12938 return tab_size;
12939}
12940
12941/*
12942 * Find the column on which a tab starts.
12943 */
12944 colnr_T
12945tabstop_start(colnr_T col, int ts, int *vts)
12946{
12947 int tabcount;
12948 colnr_T tabcol = 0;
12949 int t;
12950 int excess;
12951
Bram Moolenaar0119a592018-06-24 23:53:28 +020012952 if (vts == NULL || vts[0] == 0)
Bram Moolenaar04958cb2018-06-23 19:23:02 +020012953 return (col / ts) * ts;
12954
12955 tabcount = vts[0];
12956 for (t = 1; t <= tabcount; ++t)
12957 {
12958 tabcol += vts[t];
12959 if (tabcol > col)
12960 return tabcol - vts[t];
12961 }
12962
12963 excess = tabcol % vts[tabcount];
12964 return excess + ((col - excess) / vts[tabcount]) * vts[tabcount];
12965}
12966
12967/*
12968 * Find the number of tabs and spaces necessary to get from one column
12969 * to another.
12970 */
12971 void
12972tabstop_fromto(
12973 colnr_T start_col,
12974 colnr_T end_col,
Bram Moolenaar307ac5c2018-06-28 22:23:00 +020012975 int ts_arg,
Bram Moolenaar04958cb2018-06-23 19:23:02 +020012976 int *vts,
12977 int *ntabs,
12978 int *nspcs)
12979{
12980 int spaces = end_col - start_col;
12981 colnr_T tabcol = 0;
12982 int padding = 0;
12983 int tabcount;
12984 int t;
Bram Moolenaar307ac5c2018-06-28 22:23:00 +020012985 int ts = ts_arg == 0 ? curbuf->b_p_ts : ts_arg;
Bram Moolenaar04958cb2018-06-23 19:23:02 +020012986
Bram Moolenaar0119a592018-06-24 23:53:28 +020012987 if (vts == NULL || vts[0] == 0)
Bram Moolenaar04958cb2018-06-23 19:23:02 +020012988 {
12989 int tabs = 0;
Bram Moolenaar307ac5c2018-06-28 22:23:00 +020012990 int initspc = 0;
Bram Moolenaar0119a592018-06-24 23:53:28 +020012991
Bram Moolenaar307ac5c2018-06-28 22:23:00 +020012992 initspc = ts - (start_col % ts);
Bram Moolenaar04958cb2018-06-23 19:23:02 +020012993 if (spaces >= initspc)
12994 {
12995 spaces -= initspc;
12996 tabs++;
12997 }
12998 tabs += spaces / ts;
12999 spaces -= (spaces / ts) * ts;
13000
13001 *ntabs = tabs;
13002 *nspcs = spaces;
13003 return;
13004 }
13005
13006 /* Find the padding needed to reach the next tabstop. */
13007 tabcount = vts[0];
13008 for (t = 1; t <= tabcount; ++t)
13009 {
13010 tabcol += vts[t];
13011 if (tabcol > start_col)
13012 {
13013 padding = (int)(tabcol - start_col);
13014 break;
13015 }
13016 }
13017 if (t > tabcount)
13018 padding = vts[tabcount] - (int)((start_col - tabcol) % vts[tabcount]);
13019
13020 /* If the space needed is less than the padding no tabs can be used. */
13021 if (spaces < padding)
13022 {
13023 *ntabs = 0;
13024 *nspcs = spaces;
13025 return;
13026 }
13027
13028 *ntabs = 1;
13029 spaces -= padding;
13030
13031 /* At least one tab has been used. See if any more will fit. */
13032 while (spaces != 0 && ++t <= tabcount)
13033 {
13034 padding = vts[t];
13035 if (spaces < padding)
13036 {
13037 *nspcs = spaces;
13038 return;
13039 }
13040 ++*ntabs;
13041 spaces -= padding;
13042 }
13043
13044 *ntabs += spaces / vts[tabcount];
13045 *nspcs = spaces % vts[tabcount];
13046}
13047
13048/*
13049 * See if two tabstop arrays contain the same values.
13050 */
13051 int
13052tabstop_eq(int *ts1, int *ts2)
13053{
13054 int t;
13055
13056 if ((ts1 == 0 && ts2) || (ts1 && ts2 == 0))
13057 return FALSE;
13058 if (ts1 == ts2)
13059 return TRUE;
13060 if (ts1[0] != ts2[0])
13061 return FALSE;
13062
13063 for (t = 1; t <= ts1[0]; ++t)
13064 if (ts1[t] != ts2[t])
13065 return FALSE;
13066
13067 return TRUE;
13068}
13069
13070/*
13071 * Copy a tabstop array, allocating space for the new array.
13072 */
13073 int *
13074tabstop_copy(int *oldts)
13075{
13076 int *newts;
13077 int t;
13078
13079 if (oldts == 0)
13080 return 0;
13081
13082 newts = (int *) alloc((unsigned) ((oldts[0] + 1) * sizeof(int)));
13083 for (t = 0; t <= oldts[0]; ++t)
13084 newts[t] = oldts[t];
13085
13086 return newts;
13087}
13088
13089/*
13090 * Return a count of the number of tabstops.
13091 */
13092 int
13093tabstop_count(int *ts)
13094{
13095 return ts != NULL ? ts[0] : 0;
13096}
13097
13098/*
13099 * Return the first tabstop, or 8 if there are no tabstops defined.
13100 */
13101 int
13102tabstop_first(int *ts)
13103{
13104 return ts != NULL ? ts[1] : 8;
13105}
13106
13107#endif
13108
Bram Moolenaar14f24742012-08-08 18:01:05 +020013109/*
13110 * Return the effective shiftwidth value for current buffer, using the
13111 * 'tabstop' value when 'shiftwidth' is zero.
13112 */
13113 long
Bram Moolenaar9b578142016-01-30 19:39:49 +010013114get_sw_value(buf_T *buf)
Bram Moolenaar14f24742012-08-08 18:01:05 +020013115{
Bram Moolenaarf9514162018-11-22 03:08:29 +010013116 return get_sw_value_col(buf, 0);
13117}
13118
13119/*
13120 * Idem, using the first non-black in the current line.
13121 */
13122 long
13123get_sw_value_indent(buf_T *buf)
13124{
13125 pos_T pos = curwin->w_cursor;
13126
13127 pos.col = getwhitecols_curline();
13128 return get_sw_value_pos(buf, &pos);
13129}
13130
13131/*
13132 * Idem, using "pos".
13133 */
13134 long
13135get_sw_value_pos(buf_T *buf, pos_T *pos)
13136{
13137 pos_T save_cursor = curwin->w_cursor;
13138 long sw_value;
13139
13140 curwin->w_cursor = *pos;
13141 sw_value = get_sw_value_col(buf, get_nolist_virtcol());
13142 curwin->w_cursor = save_cursor;
13143 return sw_value;
13144}
13145
13146/*
13147 * Idem, using virtual column "col".
13148 */
13149 long
13150get_sw_value_col(buf_T *buf, colnr_T col UNUSED)
13151{
13152 return buf->b_p_sw ? buf->b_p_sw :
13153 #ifdef FEAT_VARTABS
13154 tabstop_at(col, buf->b_p_ts, buf->b_p_vts_array);
13155 #else
13156 buf->b_p_ts;
13157 #endif
Bram Moolenaar14f24742012-08-08 18:01:05 +020013158}
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020013159
13160/*
13161 * Return the effective softtabstop value for the current buffer, using the
Bram Moolenaar33d5ab32018-07-02 20:51:24 +020013162 * 'shiftwidth' value when 'softtabstop' is negative.
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020013163 */
13164 long
Bram Moolenaar9b578142016-01-30 19:39:49 +010013165get_sts_value(void)
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020013166{
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +010013167 return curbuf->b_p_sts < 0 ? get_sw_value(curbuf) : curbuf->b_p_sts;
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020013168}
Bram Moolenaar8c7694a2013-01-17 17:02:05 +010013169
13170/*
13171 * Check matchpairs option for "*initc".
13172 * If there is a match set "*initc" to the matching character and "*findc" to
13173 * the opposite character. Set "*backwards" to the direction.
13174 * When "switchit" is TRUE swap the direction.
13175 */
13176 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010013177find_mps_values(
13178 int *initc,
13179 int *findc,
13180 int *backwards,
13181 int switchit)
Bram Moolenaar8c7694a2013-01-17 17:02:05 +010013182{
13183 char_u *ptr;
13184
13185 ptr = curbuf->b_p_mps;
13186 while (*ptr != NUL)
13187 {
13188#ifdef FEAT_MBYTE
13189 if (has_mbyte)
13190 {
13191 char_u *prev;
13192
13193 if (mb_ptr2char(ptr) == *initc)
13194 {
13195 if (switchit)
13196 {
13197 *findc = *initc;
13198 *initc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1);
13199 *backwards = TRUE;
13200 }
13201 else
13202 {
13203 *findc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1);
13204 *backwards = FALSE;
13205 }
13206 return;
13207 }
13208 prev = ptr;
13209 ptr += mb_ptr2len(ptr) + 1;
13210 if (mb_ptr2char(ptr) == *initc)
13211 {
13212 if (switchit)
13213 {
13214 *findc = *initc;
13215 *initc = mb_ptr2char(prev);
13216 *backwards = FALSE;
13217 }
13218 else
13219 {
13220 *findc = mb_ptr2char(prev);
13221 *backwards = TRUE;
13222 }
13223 return;
13224 }
13225 ptr += mb_ptr2len(ptr);
13226 }
13227 else
13228#endif
13229 {
13230 if (*ptr == *initc)
13231 {
13232 if (switchit)
13233 {
13234 *backwards = TRUE;
13235 *findc = *initc;
13236 *initc = ptr[2];
13237 }
13238 else
13239 {
13240 *backwards = FALSE;
13241 *findc = ptr[2];
13242 }
13243 return;
13244 }
13245 ptr += 2;
13246 if (*ptr == *initc)
13247 {
13248 if (switchit)
13249 {
13250 *backwards = FALSE;
13251 *findc = *initc;
13252 *initc = ptr[-2];
13253 }
13254 else
13255 {
13256 *backwards = TRUE;
13257 *findc = ptr[-2];
13258 }
13259 return;
13260 }
13261 ++ptr;
13262 }
13263 if (*ptr == ',')
13264 ++ptr;
13265 }
13266}
Bram Moolenaar597a4222014-06-25 14:39:50 +020013267
13268#if defined(FEAT_LINEBREAK) || defined(PROTO)
13269/*
13270 * This is called when 'breakindentopt' is changed and when a window is
13271 * initialized.
13272 */
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020013273 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010013274briopt_check(win_T *wp)
Bram Moolenaar597a4222014-06-25 14:39:50 +020013275{
13276 char_u *p;
13277 int bri_shift = 0;
13278 long bri_min = 20;
13279 int bri_sbr = FALSE;
13280
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020013281 p = wp->w_p_briopt;
Bram Moolenaar597a4222014-06-25 14:39:50 +020013282 while (*p != NUL)
13283 {
13284 if (STRNCMP(p, "shift:", 6) == 0
13285 && ((p[6] == '-' && VIM_ISDIGIT(p[7])) || VIM_ISDIGIT(p[6])))
13286 {
13287 p += 6;
13288 bri_shift = getdigits(&p);
13289 }
13290 else if (STRNCMP(p, "min:", 4) == 0 && VIM_ISDIGIT(p[4]))
13291 {
13292 p += 4;
13293 bri_min = getdigits(&p);
13294 }
13295 else if (STRNCMP(p, "sbr", 3) == 0)
13296 {
13297 p += 3;
13298 bri_sbr = TRUE;
13299 }
13300 if (*p != ',' && *p != NUL)
13301 return FAIL;
13302 if (*p == ',')
13303 ++p;
13304 }
13305
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020013306 wp->w_p_brishift = bri_shift;
13307 wp->w_p_brimin = bri_min;
13308 wp->w_p_brisbr = bri_sbr;
Bram Moolenaar597a4222014-06-25 14:39:50 +020013309
13310 return OK;
13311}
13312#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020013313
13314/*
13315 * Get the local or global value of 'backupcopy'.
13316 */
13317 unsigned int
Bram Moolenaar9b578142016-01-30 19:39:49 +010013318get_bkc_value(buf_T *buf)
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020013319{
13320 return buf->b_bkc_flags ? buf->b_bkc_flags : bkc_flags;
13321}
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020013322
13323#if defined(FEAT_SIGNS) || defined(PROTO)
13324/*
13325 * Return TRUE when window "wp" has a column to draw signs in.
13326 */
13327 int
13328signcolumn_on(win_T *wp)
13329{
13330 if (*wp->w_p_scl == 'n')
13331 return FALSE;
13332 if (*wp->w_p_scl == 'y')
13333 return TRUE;
13334 return (wp->w_buffer->b_signlist != NULL
13335# ifdef FEAT_NETBEANS_INTG
13336 || wp->w_buffer->b_has_sign_column
13337# endif
13338 );
13339}
13340#endif
Bram Moolenaarb5ae48e2016-08-12 22:23:25 +020013341
13342#if defined(FEAT_EVAL) || defined(PROTO)
13343/*
13344 * Get window or buffer local options.
13345 */
13346 dict_T *
13347get_winbuf_options(int bufopt)
13348{
13349 dict_T *d;
13350 int opt_idx;
13351
13352 d = dict_alloc();
13353 if (d == NULL)
13354 return NULL;
13355
13356 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
13357 {
13358 struct vimoption *opt = &options[opt_idx];
13359
13360 if ((bufopt && (opt->indir & PV_BUF))
13361 || (!bufopt && (opt->indir & PV_WIN)))
13362 {
13363 char_u *varp = get_varp(opt);
13364
13365 if (varp != NULL)
13366 {
13367 if (opt->flags & P_STRING)
Bram Moolenaare0be1672018-07-08 16:50:37 +020013368 dict_add_string(d, opt->fullname, *(char_u **)varp);
Bram Moolenaar789a5c02016-09-12 19:51:11 +020013369 else if (opt->flags & P_NUM)
Bram Moolenaare0be1672018-07-08 16:50:37 +020013370 dict_add_number(d, opt->fullname, *(long *)varp);
Bram Moolenaarb5ae48e2016-08-12 22:23:25 +020013371 else
Bram Moolenaare0be1672018-07-08 16:50:37 +020013372 dict_add_number(d, opt->fullname, *(int *)varp);
Bram Moolenaarb5ae48e2016-08-12 22:23:25 +020013373 }
13374 }
13375 }
13376
13377 return d;
13378}
13379#endif