blob: 52330f7904d1fa6f56746274a6a7632828a6f1c6 [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 Moolenaar5e3cb7e2006-02-27 23:58:35 +000060#ifdef FEAT_QUICKFIX
Bram Moolenaara23ccb82006-02-27 00:08:02 +000061# define PV_BH OPT_BUF(BV_BH)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000062# define PV_BT OPT_BUF(BV_BT)
63# 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 Moolenaar5e3cb7e2006-02-27 23:58:35 +0000110#ifdef FEAT_EVAL
111# define PV_FEX OPT_BUF(BV_FEX)
112#endif
113#define PV_FF OPT_BUF(BV_FF)
114#define PV_FLP OPT_BUF(BV_FLP)
115#define PV_FO OPT_BUF(BV_FO)
116#ifdef FEAT_AUTOCMD
117# define PV_FT OPT_BUF(BV_FT)
118#endif
119#define PV_IMI OPT_BUF(BV_IMI)
120#define PV_IMS OPT_BUF(BV_IMS)
121#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
122# define PV_INDE OPT_BUF(BV_INDE)
123# define PV_INDK OPT_BUF(BV_INDK)
124#endif
125#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
126# define PV_INEX OPT_BUF(BV_INEX)
127#endif
128#define PV_INF OPT_BUF(BV_INF)
129#define PV_ISK OPT_BUF(BV_ISK)
130#ifdef FEAT_CRYPT
131# define PV_KEY OPT_BUF(BV_KEY)
132#endif
133#ifdef FEAT_KEYMAP
134# define PV_KMAP OPT_BUF(BV_KMAP)
135#endif
136#define PV_KP OPT_BOTH(OPT_BUF(BV_KP))
137#ifdef FEAT_LISP
138# define PV_LISP OPT_BUF(BV_LISP)
Bram Moolenaaraf6c1312014-03-12 18:55:58 +0100139# define PV_LW OPT_BOTH(OPT_BUF(BV_LW))
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000140#endif
141#define PV_MA OPT_BUF(BV_MA)
142#define PV_ML OPT_BUF(BV_ML)
143#define PV_MOD OPT_BUF(BV_MOD)
144#define PV_MPS OPT_BUF(BV_MPS)
145#define PV_NF OPT_BUF(BV_NF)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000146#ifdef FEAT_COMPL_FUNC
147# define PV_OFU OPT_BUF(BV_OFU)
148#endif
149#define PV_PATH OPT_BOTH(OPT_BUF(BV_PATH))
150#define PV_PI OPT_BUF(BV_PI)
151#ifdef FEAT_TEXTOBJ
152# define PV_QE OPT_BUF(BV_QE)
153#endif
154#define PV_RO OPT_BUF(BV_RO)
155#ifdef FEAT_SMARTINDENT
156# define PV_SI OPT_BUF(BV_SI)
157#endif
Bram Moolenaar48e330a2016-02-23 14:53:34 +0100158#define PV_SN OPT_BUF(BV_SN)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000159#ifdef FEAT_SYN_HL
160# define PV_SMC OPT_BUF(BV_SMC)
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000161# define PV_SYN OPT_BUF(BV_SYN)
162#endif
163#ifdef FEAT_SPELL
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000164# define PV_SPC OPT_BUF(BV_SPC)
165# define PV_SPF OPT_BUF(BV_SPF)
166# define PV_SPL OPT_BUF(BV_SPL)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000167#endif
168#define PV_STS OPT_BUF(BV_STS)
169#ifdef FEAT_SEARCHPATH
170# define PV_SUA OPT_BUF(BV_SUA)
171#endif
172#define PV_SW OPT_BUF(BV_SW)
173#define PV_SWF OPT_BUF(BV_SWF)
174#define PV_TAGS OPT_BOTH(OPT_BUF(BV_TAGS))
Bram Moolenaar0f6562e2015-11-24 18:48:14 +0100175#define PV_TC OPT_BOTH(OPT_BUF(BV_TC))
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000176#define PV_TS OPT_BUF(BV_TS)
177#define PV_TW OPT_BUF(BV_TW)
178#define PV_TX OPT_BUF(BV_TX)
Bram Moolenaar55debbe2010-05-23 23:34:36 +0200179#ifdef FEAT_PERSISTENT_UNDO
180# define PV_UDF OPT_BUF(BV_UDF)
181#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000182#define PV_WM OPT_BUF(BV_WM)
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000183
184/*
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000185 * Definition of the PV_ values for window-local options.
186 * The WV_ values are defined in option.h.
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000187 */
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000188#define PV_LIST OPT_WIN(WV_LIST)
189#ifdef FEAT_ARABIC
190# define PV_ARAB OPT_WIN(WV_ARAB)
191#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +0200192#ifdef FEAT_LINEBREAK
193# define PV_BRI OPT_WIN(WV_BRI)
194# define PV_BRIOPT OPT_WIN(WV_BRIOPT)
195#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000196#ifdef FEAT_DIFF
197# define PV_DIFF OPT_WIN(WV_DIFF)
198#endif
199#ifdef FEAT_FOLDING
200# define PV_FDC OPT_WIN(WV_FDC)
201# define PV_FEN OPT_WIN(WV_FEN)
202# define PV_FDI OPT_WIN(WV_FDI)
203# define PV_FDL OPT_WIN(WV_FDL)
204# define PV_FDM OPT_WIN(WV_FDM)
205# define PV_FML OPT_WIN(WV_FML)
206# define PV_FDN OPT_WIN(WV_FDN)
207# ifdef FEAT_EVAL
208# define PV_FDE OPT_WIN(WV_FDE)
209# define PV_FDT OPT_WIN(WV_FDT)
210# endif
211# define PV_FMR OPT_WIN(WV_FMR)
212#endif
213#ifdef FEAT_LINEBREAK
214# define PV_LBR OPT_WIN(WV_LBR)
215#endif
216#define PV_NU OPT_WIN(WV_NU)
Bram Moolenaar64486672010-05-16 15:46:46 +0200217#define PV_RNU OPT_WIN(WV_RNU)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000218#ifdef FEAT_LINEBREAK
219# define PV_NUW OPT_WIN(WV_NUW)
220#endif
221#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
222# define PV_PVW OPT_WIN(WV_PVW)
223#endif
224#ifdef FEAT_RIGHTLEFT
225# define PV_RL OPT_WIN(WV_RL)
226# define PV_RLC OPT_WIN(WV_RLC)
227#endif
228#ifdef FEAT_SCROLLBIND
229# define PV_SCBIND OPT_WIN(WV_SCBIND)
230#endif
231#define PV_SCROLL OPT_WIN(WV_SCROLL)
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000232#ifdef FEAT_SPELL
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000233# define PV_SPELL OPT_WIN(WV_SPELL)
234#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000235#ifdef FEAT_SYN_HL
236# define PV_CUC OPT_WIN(WV_CUC)
237# define PV_CUL OPT_WIN(WV_CUL)
Bram Moolenaar1a384422010-07-14 19:53:30 +0200238# define PV_CC OPT_WIN(WV_CC)
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000239#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000240#ifdef FEAT_STL_OPT
241# define PV_STL OPT_BOTH(OPT_WIN(WV_STL))
242#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +0100243#define PV_UL OPT_BOTH(OPT_BUF(BV_UL))
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000244#ifdef FEAT_WINDOWS
245# define PV_WFH OPT_WIN(WV_WFH)
Bram Moolenaar97b2ad32006-03-18 21:40:56 +0000246# define PV_WFW OPT_WIN(WV_WFW)
247#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000248#define PV_WRAP OPT_WIN(WV_WRAP)
Bram Moolenaar860cae12010-06-05 23:22:07 +0200249#ifdef FEAT_CURSORBIND
250# define PV_CRBIND OPT_WIN(WV_CRBIND)
251#endif
252#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 Moolenaar95ec9d62016-08-12 18:29:59 +0200256#ifdef FEAT_SIGNS
257# define PV_SCL OPT_WIN(WV_SCL)
258#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000259
260/* WV_ and BV_ values get typecasted to this for the "indir" field */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000261typedef enum
262{
Bram Moolenaar7d96acd2008-06-09 15:07:54 +0000263 PV_NONE = 0,
264 PV_MAXVAL = 0xffff /* to avoid warnings for value out of range */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000265} idopt_T;
266
267/*
268 * Options local to a window have a value local to a buffer and global to all
269 * buffers. Indicate this by setting "var" to VAR_WIN.
270 */
271#define VAR_WIN ((char_u *)-1)
272
273/*
Bram Moolenaar9b2200a2006-03-20 21:55:45 +0000274 * These are the global values for options which are also local to a buffer.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000275 * Only to be used in option.c!
276 */
277static int p_ai;
278static int p_bin;
279#ifdef FEAT_MBYTE
280static int p_bomb;
281#endif
282#if defined(FEAT_QUICKFIX)
283static char_u *p_bh;
284static char_u *p_bt;
285#endif
286static int p_bl;
287static int p_ci;
288#ifdef FEAT_CINDENT
289static int p_cin;
290static char_u *p_cink;
291static char_u *p_cino;
292#endif
293#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
294static char_u *p_cinw;
295#endif
296#ifdef FEAT_COMMENTS
297static char_u *p_com;
298#endif
299#ifdef FEAT_FOLDING
300static char_u *p_cms;
301#endif
302#ifdef FEAT_INS_EXPAND
303static char_u *p_cpt;
304#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000305#ifdef FEAT_COMPL_FUNC
306static char_u *p_cfu;
Bram Moolenaare344bea2005-09-01 20:46:49 +0000307static char_u *p_ofu;
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000308#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000309static int p_eol;
Bram Moolenaar34d72d42015-07-17 14:18:08 +0200310static int p_fixeol;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000311static int p_et;
312#ifdef FEAT_MBYTE
313static char_u *p_fenc;
314#endif
315static char_u *p_ff;
316static char_u *p_fo;
Bram Moolenaar86b68352004-12-27 21:59:20 +0000317static char_u *p_flp;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000318#ifdef FEAT_AUTOCMD
319static char_u *p_ft;
320#endif
321static long p_iminsert;
322static long p_imsearch;
323#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
324static char_u *p_inex;
325#endif
326#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
327static char_u *p_inde;
328static char_u *p_indk;
329#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +0000330#if defined(FEAT_EVAL)
331static char_u *p_fex;
332#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000333static int p_inf;
334static char_u *p_isk;
335#ifdef FEAT_CRYPT
336static char_u *p_key;
337#endif
338#ifdef FEAT_LISP
339static int p_lisp;
340#endif
341static int p_ml;
342static int p_ma;
343static int p_mod;
344static char_u *p_mps;
345static char_u *p_nf;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000346static int p_pi;
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000347#ifdef FEAT_TEXTOBJ
348static char_u *p_qe;
349#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000350static int p_ro;
351#ifdef FEAT_SMARTINDENT
352static int p_si;
353#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000354static int p_sn;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000355static long p_sts;
356#if defined(FEAT_SEARCHPATH)
357static char_u *p_sua;
358#endif
359static long p_sw;
360static int p_swf;
361#ifdef FEAT_SYN_HL
Bram Moolenaar3b56eb32005-07-11 22:40:32 +0000362static long p_smc;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000363static char_u *p_syn;
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000364#endif
365#ifdef FEAT_SPELL
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +0000366static char_u *p_spc;
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000367static char_u *p_spf;
Bram Moolenaar217ad922005-03-20 22:37:15 +0000368static char_u *p_spl;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000369#endif
370static long p_ts;
371static long p_tw;
372static int p_tx;
Bram Moolenaar55debbe2010-05-23 23:34:36 +0200373#ifdef FEAT_PERSISTENT_UNDO
374static int p_udf;
375#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000376static long p_wm;
377#ifdef FEAT_KEYMAP
378static char_u *p_keymap;
379#endif
380
381/* Saved values for when 'bin' is set. */
382static int p_et_nobin;
383static int p_ml_nobin;
384static long p_tw_nobin;
385static long p_wm_nobin;
386
387/* Saved values for when 'paste' is set */
Bram Moolenaar54f018c2015-09-15 17:30:40 +0200388static int p_ai_nopaste;
389static int p_et_nopaste;
390static long p_sts_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000391static long p_tw_nopaste;
392static long p_wm_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000393
394struct vimoption
395{
396 char *fullname; /* full option name */
397 char *shortname; /* permissible abbreviation */
398 long_u flags; /* see below */
399 char_u *var; /* global option: pointer to variable;
400 * window-local option: VAR_WIN;
401 * buffer-local option: global value */
402 idopt_T indir; /* global option: PV_NONE;
403 * local option: indirect option index */
404 char_u *def_val[2]; /* default values for variable (vi and vim) */
405#ifdef FEAT_EVAL
406 scid_T scriptID; /* script in which the option was last set */
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000407# define SCRIPTID_INIT , 0
408#else
409# define SCRIPTID_INIT
Bram Moolenaar071d4272004-06-13 20:20:40 +0000410#endif
411};
412
413#define VI_DEFAULT 0 /* def_val[VI_DEFAULT] is Vi default value */
414#define VIM_DEFAULT 1 /* def_val[VIM_DEFAULT] is Vim default value */
415
416/*
417 * Flags
418 */
419#define P_BOOL 0x01 /* the option is boolean */
420#define P_NUM 0x02 /* the option is numeric */
421#define P_STRING 0x04 /* the option is a string */
422#define P_ALLOCED 0x08 /* the string option is in allocated memory,
Bram Moolenaar363cb672009-07-22 12:28:17 +0000423 must use free_string_option() when
424 assigning new value. Not set if default is
425 the same. */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000426#define P_EXPAND 0x10 /* environment expansion. NOTE: P_EXPAND can
427 never be used for local or hidden options! */
428#define P_NODEFAULT 0x40 /* don't set to default value */
429#define P_DEF_ALLOCED 0x80 /* default value is in allocated memory, must
430 use vim_free() when assigning new value */
431#define P_WAS_SET 0x100 /* option has been set/reset */
432#define P_NO_MKRC 0x200 /* don't include in :mkvimrc output */
433#define P_VI_DEF 0x400 /* Use Vi default for Vim */
434#define P_VIM 0x800 /* Vim option, reset when 'cp' set */
435
436 /* when option changed, what to display: */
437#define P_RSTAT 0x1000 /* redraw status lines */
438#define P_RWIN 0x2000 /* redraw current window */
439#define P_RBUF 0x4000 /* redraw current buffer */
440#define P_RALL 0x6000 /* redraw all windows */
441#define P_RCLR 0x7000 /* clear and redraw all */
442
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200443#define P_COMMA 0x8000 /* comma separated list */
444#define P_ONECOMMA 0x18000L /* P_COMMA and cannot have two consecutive
445 * commas */
446#define P_NODUP 0x20000L /* don't allow duplicate strings */
447#define P_FLAGLIST 0x40000L /* list of single-char flags */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000448
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200449#define P_SECURE 0x80000L /* cannot change in modeline or secure mode */
450#define P_GETTEXT 0x100000L /* expand default value with _() */
451#define P_NOGLOB 0x200000L /* do not use local value for global vimrc */
452#define P_NFNAME 0x400000L /* only normal file name chars allowed */
453#define P_INSECURE 0x800000L /* option was set from a modeline */
454#define P_PRI_MKRC 0x1000000L /* priority for :mkvimrc (setting option has
Bram Moolenaar7fd16022007-09-06 14:35:35 +0000455 side effects) */
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200456#define P_NO_ML 0x2000000L /* not allowed in modeline */
457#define P_CURSWANT 0x4000000L /* update curswant required; not needed when
Bram Moolenaar913077c2012-03-28 19:59:04 +0200458 * there is a redraw flag */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000459
Bram Moolenaar362e1a32006-03-06 23:29:24 +0000460#define ISK_LATIN1 (char_u *)"@,48-57,_,192-255"
461
Bram Moolenaar910f66f2006-04-05 20:41:53 +0000462/* 'isprint' for latin1 is also used for MS-Windows cp1252, where 0x80 is used
463 * for the currency sign. */
Bram Moolenaar48e330a2016-02-23 14:53:34 +0100464#if defined(MSWIN)
Bram Moolenaare2f98b92006-03-29 21:18:24 +0000465# define ISP_LATIN1 (char_u *)"@,~-255"
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +0000466#else
467# define ISP_LATIN1 (char_u *)"@,161-255"
468#endif
469
Bram Moolenaar44a2f922016-03-19 22:11:51 +0100470/* Make the string as short as possible when compiling with few features. */
Bram Moolenaar3991dab2006-03-27 17:01:56 +0000471#if defined(FEAT_DIFF) || defined(FEAT_FOLDING) || defined(FEAT_SPELL) \
Bram Moolenaar44a2f922016-03-19 22:11:51 +0100472 || defined(FEAT_WINDOWS) || defined(FEAT_CLIPBOARD) \
Bram Moolenaar860cae12010-06-05 23:22:07 +0200473 || defined(FEAT_INS_EXPAND) || defined(FEAT_SYN_HL) || defined(FEAT_CONCEAL)
Bram Moolenaar58b85342016-08-14 19:54:54 +0200474# 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"
Bram Moolenaar3991dab2006-03-27 17:01:56 +0000475#else
Bram Moolenaar06ca5132012-03-23 16:25:17 +0100476# define HIGHLIGHT_INIT "8:SpecialKey,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,m:MoreMsg,M:ModeMsg,n:LineNr,N:CursorLineNr,r:Question,s:StatusLine,S:StatusLineNC,t:Title,v:Visual,w:WarningMsg,W:WildMenu,>:SignColumn,*:TabLine,#:TabLineSel,_:TabLineFill"
Bram Moolenaar3991dab2006-03-27 17:01:56 +0000477#endif
478
Bram Moolenaar071d4272004-06-13 20:20:40 +0000479/*
480 * options[] is initialized here.
481 * The order of the options MUST be alphabetic for ":set all" and findoption().
482 * All option names MUST start with a lowercase letter (for findoption()).
483 * Exception: "t_" options are at the end.
484 * The options with a NULL variable are 'hidden': a set command for them is
485 * ignored and they are not printed.
486 */
Bram Moolenaare89ff042016-02-20 22:17:05 +0100487static struct vimoption options[] =
Bram Moolenaar071d4272004-06-13 20:20:40 +0000488{
Bram Moolenaar913077c2012-03-28 19:59:04 +0200489 {"aleph", "al", P_NUM|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000490#ifdef FEAT_RIGHTLEFT
491 (char_u *)&p_aleph, PV_NONE,
492#else
493 (char_u *)NULL, PV_NONE,
494#endif
495 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +0100496#if (defined(WIN3264)) && !defined(FEAT_GUI_W32)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000497 (char_u *)128L,
498#else
499 (char_u *)224L,
500#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000501 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000502 {"antialias", "anti", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
503#if defined(FEAT_GUI) && defined(MACOS_X)
504 (char_u *)&p_antialias, PV_NONE,
505 {(char_u *)FALSE, (char_u *)FALSE}
506#else
507 (char_u *)NULL, PV_NONE,
508 {(char_u *)FALSE, (char_u *)FALSE}
509#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000510 SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +0200511 {"arabic", "arab", P_BOOL|P_VI_DEF|P_VIM|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000512#ifdef FEAT_ARABIC
513 (char_u *)VAR_WIN, PV_ARAB,
514#else
515 (char_u *)NULL, PV_NONE,
516#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000517 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000518 {"arabicshape", "arshape", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
519#ifdef FEAT_ARABIC
520 (char_u *)&p_arshape, PV_NONE,
521#else
522 (char_u *)NULL, PV_NONE,
523#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000524 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000525 {"allowrevins", "ari", P_BOOL|P_VI_DEF|P_VIM,
526#ifdef FEAT_RIGHTLEFT
527 (char_u *)&p_ari, PV_NONE,
528#else
529 (char_u *)NULL, PV_NONE,
530#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000531 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000532 {"altkeymap", "akm", P_BOOL|P_VI_DEF,
533#ifdef FEAT_FKMAP
534 (char_u *)&p_altkeymap, PV_NONE,
535#else
536 (char_u *)NULL, PV_NONE,
537#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000538 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000539 {"ambiwidth", "ambw", P_STRING|P_VI_DEF|P_RCLR,
540#if defined(FEAT_MBYTE)
541 (char_u *)&p_ambw, PV_NONE,
542 {(char_u *)"single", (char_u *)0L}
543#else
544 (char_u *)NULL, PV_NONE,
545 {(char_u *)0L, (char_u *)0L}
546#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000547 SCRIPTID_INIT},
Bram Moolenaar8dff8182006-04-06 20:18:50 +0000548#ifdef FEAT_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +0000549 {"autochdir", "acd", P_BOOL|P_VI_DEF,
550 (char_u *)&p_acd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000551 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000552#endif
553 {"autoindent", "ai", P_BOOL|P_VI_DEF,
554 (char_u *)&p_ai, PV_AI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000555 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000556 {"autoprint", "ap", P_BOOL|P_VI_DEF,
557 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000558 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000559 {"autoread", "ar", P_BOOL|P_VI_DEF,
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000560 (char_u *)&p_ar, PV_AR,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000561 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000562 {"autowrite", "aw", P_BOOL|P_VI_DEF,
563 (char_u *)&p_aw, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000564 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000565 {"autowriteall","awa", P_BOOL|P_VI_DEF,
566 (char_u *)&p_awa, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000567 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000568 {"background", "bg", P_STRING|P_VI_DEF|P_RCLR,
569 (char_u *)&p_bg, PV_NONE,
570 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +0100571#if (defined(WIN3264)) && !defined(FEAT_GUI)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000572 (char_u *)"dark",
573#else
574 (char_u *)"light",
575#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000576 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200577 {"backspace", "bs", P_STRING|P_VI_DEF|P_VIM|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000578 (char_u *)&p_bs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000579 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000580 {"backup", "bk", P_BOOL|P_VI_DEF|P_VIM,
581 (char_u *)&p_bk, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000582 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200583 {"backupcopy", "bkc", P_STRING|P_VIM|P_ONECOMMA|P_NODUP,
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +0200584 (char_u *)&p_bkc, PV_BKC,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000585#ifdef UNIX
586 {(char_u *)"yes", (char_u *)"auto"}
587#else
588 {(char_u *)"auto", (char_u *)"auto"}
589#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000590 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200591 {"backupdir", "bdir", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA
592 |P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000593 (char_u *)&p_bdir, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000594 {(char_u *)DFLT_BDIR, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +0000595 {"backupext", "bex", P_STRING|P_VI_DEF|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000596 (char_u *)&p_bex, PV_NONE,
597 {
598#ifdef VMS
599 (char_u *)"_",
600#else
601 (char_u *)"~",
602#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000603 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200604 {"backupskip", "bsk", P_STRING|P_VI_DEF|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000605#ifdef FEAT_WILDIGN
606 (char_u *)&p_bsk, PV_NONE,
607 {(char_u *)"", (char_u *)0L}
608#else
609 (char_u *)NULL, PV_NONE,
610 {(char_u *)0L, (char_u *)0L}
611#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000612 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000613#ifdef FEAT_BEVAL
614 {"balloondelay","bdlay",P_NUM|P_VI_DEF,
615 (char_u *)&p_bdlay, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000616 {(char_u *)600L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000617 {"ballooneval", "beval",P_BOOL|P_VI_DEF|P_NO_MKRC,
618 (char_u *)&p_beval, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000619 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +0000620# ifdef FEAT_EVAL
Bram Moolenaar39f05632006-03-19 22:15:26 +0000621 {"balloonexpr", "bexpr", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
Bram Moolenaar9b2200a2006-03-20 21:55:45 +0000622 (char_u *)&p_bexpr, PV_BEXPR,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000623 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +0000624# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000625#endif
626 {"beautify", "bf", P_BOOL|P_VI_DEF,
627 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000628 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar165bc692015-07-21 17:53:25 +0200629 {"belloff", "bo", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
630 (char_u *)&p_bo, PV_NONE,
631 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000632 {"binary", "bin", P_BOOL|P_VI_DEF|P_RSTAT,
633 (char_u *)&p_bin, PV_BIN,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000634 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000635 {"bioskey", "biosk",P_BOOL|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000636 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000637 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000638 {"bomb", NULL, P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
639#ifdef FEAT_MBYTE
640 (char_u *)&p_bomb, PV_BOMB,
641#else
642 (char_u *)NULL, PV_NONE,
643#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000644 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000645 {"breakat", "brk", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST,
646#ifdef FEAT_LINEBREAK
647 (char_u *)&p_breakat, PV_NONE,
648 {(char_u *)" \t!@*-+;:,./?", (char_u *)0L}
649#else
650 (char_u *)NULL, PV_NONE,
651 {(char_u *)0L, (char_u *)0L}
652#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000653 SCRIPTID_INIT},
Bram Moolenaar597a4222014-06-25 14:39:50 +0200654 {"breakindent", "bri", P_BOOL|P_VI_DEF|P_VIM|P_RWIN,
655#ifdef FEAT_LINEBREAK
656 (char_u *)VAR_WIN, PV_BRI,
657 {(char_u *)FALSE, (char_u *)0L}
658#else
659 (char_u *)NULL, PV_NONE,
660 {(char_u *)0L, (char_u *)0L}
661#endif
662 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200663 {"breakindentopt", "briopt", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF
664 |P_ONECOMMA|P_NODUP,
Bram Moolenaar597a4222014-06-25 14:39:50 +0200665#ifdef FEAT_LINEBREAK
666 (char_u *)VAR_WIN, PV_BRIOPT,
667 {(char_u *)"", (char_u *)NULL}
668#else
669 (char_u *)NULL, PV_NONE,
670 {(char_u *)"", (char_u *)NULL}
671#endif
672 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000673 {"browsedir", "bsdir",P_STRING|P_VI_DEF,
674#ifdef FEAT_BROWSE
675 (char_u *)&p_bsdir, PV_NONE,
676 {(char_u *)"last", (char_u *)0L}
677#else
678 (char_u *)NULL, PV_NONE,
679 {(char_u *)0L, (char_u *)0L}
680#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000681 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000682 {"bufhidden", "bh", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB,
683#if defined(FEAT_QUICKFIX)
684 (char_u *)&p_bh, PV_BH,
685 {(char_u *)"", (char_u *)0L}
686#else
687 (char_u *)NULL, PV_NONE,
688 {(char_u *)0L, (char_u *)0L}
689#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000690 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000691 {"buflisted", "bl", P_BOOL|P_VI_DEF|P_NOGLOB,
692 (char_u *)&p_bl, PV_BL,
693 {(char_u *)1L, (char_u *)0L}
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000694 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000695 {"buftype", "bt", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB,
696#if defined(FEAT_QUICKFIX)
697 (char_u *)&p_bt, PV_BT,
698 {(char_u *)"", (char_u *)0L}
699#else
700 (char_u *)NULL, PV_NONE,
701 {(char_u *)0L, (char_u *)0L}
702#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000703 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200704 {"casemap", "cmp", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaarfa1d1402006-03-25 21:59:56 +0000705#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +0000706 (char_u *)&p_cmp, PV_NONE,
707 {(char_u *)"internal,keepascii", (char_u *)0L}
Bram Moolenaarfa1d1402006-03-25 21:59:56 +0000708#else
709 (char_u *)NULL, PV_NONE,
710 {(char_u *)0L, (char_u *)0L}
711#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000712 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000713 {"cdpath", "cd", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
714#ifdef FEAT_SEARCHPATH
715 (char_u *)&p_cdpath, PV_NONE,
716 {(char_u *)",,", (char_u *)0L}
717#else
718 (char_u *)NULL, PV_NONE,
719 {(char_u *)0L, (char_u *)0L}
720#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000721 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000722 {"cedit", NULL, P_STRING,
723#ifdef FEAT_CMDWIN
724 (char_u *)&p_cedit, PV_NONE,
725 {(char_u *)"", (char_u *)CTRL_F_STR}
726#else
727 (char_u *)NULL, PV_NONE,
728 {(char_u *)0L, (char_u *)0L}
729#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000730 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000731 {"charconvert", "ccv", P_STRING|P_VI_DEF|P_SECURE,
732#if defined(FEAT_MBYTE) && defined(FEAT_EVAL)
733 (char_u *)&p_ccv, PV_NONE,
734 {(char_u *)"", (char_u *)0L}
735#else
736 (char_u *)NULL, PV_NONE,
737 {(char_u *)0L, (char_u *)0L}
738#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000739 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000740 {"cindent", "cin", P_BOOL|P_VI_DEF|P_VIM,
741#ifdef FEAT_CINDENT
742 (char_u *)&p_cin, PV_CIN,
743#else
744 (char_u *)NULL, PV_NONE,
745#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000746 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200747 {"cinkeys", "cink", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000748#ifdef FEAT_CINDENT
749 (char_u *)&p_cink, PV_CINK,
750 {(char_u *)"0{,0},0),:,0#,!^F,o,O,e", (char_u *)0L}
751#else
752 (char_u *)NULL, PV_NONE,
753 {(char_u *)0L, (char_u *)0L}
754#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000755 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200756 {"cinoptions", "cino", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000757#ifdef FEAT_CINDENT
758 (char_u *)&p_cino, PV_CINO,
759#else
760 (char_u *)NULL, PV_NONE,
761#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000762 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200763 {"cinwords", "cinw", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000764#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
765 (char_u *)&p_cinw, PV_CINW,
766 {(char_u *)"if,else,while,do,for,switch",
767 (char_u *)0L}
768#else
769 (char_u *)NULL, PV_NONE,
770 {(char_u *)0L, (char_u *)0L}
771#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000772 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200773 {"clipboard", "cb", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000774#ifdef FEAT_CLIPBOARD
775 (char_u *)&p_cb, PV_NONE,
776# ifdef FEAT_XCLIPBOARD
777 {(char_u *)"autoselect,exclude:cons\\|linux",
778 (char_u *)0L}
779# else
780 {(char_u *)"", (char_u *)0L}
781# endif
782#else
783 (char_u *)NULL, PV_NONE,
784 {(char_u *)"", (char_u *)0L}
785#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000786 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000787 {"cmdheight", "ch", P_NUM|P_VI_DEF|P_RALL,
788 (char_u *)&p_ch, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000789 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000790 {"cmdwinheight", "cwh", P_NUM|P_VI_DEF,
791#ifdef FEAT_CMDWIN
792 (char_u *)&p_cwh, PV_NONE,
793#else
794 (char_u *)NULL, PV_NONE,
795#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000796 {(char_u *)7L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200797 {"colorcolumn", "cc", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_RWIN,
Bram Moolenaar1a384422010-07-14 19:53:30 +0200798#ifdef FEAT_SYN_HL
799 (char_u *)VAR_WIN, PV_CC,
800#else
801 (char_u *)NULL, PV_NONE,
802#endif
803 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000804 {"columns", "co", P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR,
805 (char_u *)&Columns, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000806 {(char_u *)80L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200807 {"comments", "com", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA
808 |P_NODUP|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000809#ifdef FEAT_COMMENTS
810 (char_u *)&p_com, PV_COM,
811 {(char_u *)"s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-",
812 (char_u *)0L}
813#else
814 (char_u *)NULL, PV_NONE,
815 {(char_u *)0L, (char_u *)0L}
816#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000817 SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +0200818 {"commentstring", "cms", P_STRING|P_ALLOCED|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000819#ifdef FEAT_FOLDING
820 (char_u *)&p_cms, PV_CMS,
821 {(char_u *)"/*%s*/", (char_u *)0L}
822#else
823 (char_u *)NULL, PV_NONE,
824 {(char_u *)0L, (char_u *)0L}
825#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000826 SCRIPTID_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +0000827 /* P_PRI_MKRC isn't needed here, optval_default()
828 * always returns TRUE for 'compatible' */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000829 {"compatible", "cp", P_BOOL|P_RALL,
830 (char_u *)&p_cp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000831 {(char_u *)TRUE, (char_u *)FALSE} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200832 {"complete", "cpt", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000833#ifdef FEAT_INS_EXPAND
834 (char_u *)&p_cpt, PV_CPT,
835 {(char_u *)".,w,b,u,t,i", (char_u *)0L}
836#else
837 (char_u *)NULL, PV_NONE,
838 {(char_u *)0L, (char_u *)0L}
839#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000840 SCRIPTID_INIT},
Bram Moolenaarf5963f72010-07-23 22:10:27 +0200841 {"concealcursor","cocu", P_STRING|P_ALLOCED|P_RWIN|P_VI_DEF,
Bram Moolenaar860cae12010-06-05 23:22:07 +0200842#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +0200843 (char_u *)VAR_WIN, PV_COCU,
844 {(char_u *)"", (char_u *)NULL}
845#else
846 (char_u *)NULL, PV_NONE,
847 {(char_u *)NULL, (char_u *)0L}
848#endif
849 SCRIPTID_INIT},
850 {"conceallevel","cole", P_NUM|P_RWIN|P_VI_DEF,
851#ifdef FEAT_CONCEAL
852 (char_u *)VAR_WIN, PV_COLE,
Bram Moolenaar860cae12010-06-05 23:22:07 +0200853#else
854 (char_u *)NULL, PV_NONE,
855#endif
856 {(char_u *)0L, (char_u *)0L}
857 SCRIPTID_INIT},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000858 {"completefunc", "cfu", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE,
859#ifdef FEAT_COMPL_FUNC
860 (char_u *)&p_cfu, PV_CFU,
861 {(char_u *)"", (char_u *)0L}
862#else
863 (char_u *)NULL, PV_NONE,
864 {(char_u *)0L, (char_u *)0L}
865#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000866 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200867 {"completeopt", "cot", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar1c7715d2005-10-03 22:02:18 +0000868#ifdef FEAT_INS_EXPAND
869 (char_u *)&p_cot, PV_NONE,
Bram Moolenaarc270d802006-03-11 21:29:41 +0000870 {(char_u *)"menu,preview", (char_u *)0L}
Bram Moolenaar1c7715d2005-10-03 22:02:18 +0000871#else
872 (char_u *)NULL, PV_NONE,
873 {(char_u *)0L, (char_u *)0L}
874#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000875 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000876 {"confirm", "cf", P_BOOL|P_VI_DEF,
877#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
878 (char_u *)&p_confirm, PV_NONE,
879#else
880 (char_u *)NULL, PV_NONE,
881#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000882 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000883 {"conskey", "consk",P_BOOL|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000884 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000885 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000886 {"copyindent", "ci", P_BOOL|P_VI_DEF|P_VIM,
887 (char_u *)&p_ci, PV_CI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000888 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000889 {"cpoptions", "cpo", P_STRING|P_VIM|P_RALL|P_FLAGLIST,
890 (char_u *)&p_cpo, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000891 {(char_u *)CPO_VI, (char_u *)CPO_VIM}
892 SCRIPTID_INIT},
Bram Moolenaar49771f42010-07-20 17:32:38 +0200893 {"cryptmethod", "cm", P_STRING|P_ALLOCED|P_VI_DEF,
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200894#ifdef FEAT_CRYPT
Bram Moolenaar40e6a712010-05-16 22:32:54 +0200895 (char_u *)&p_cm, PV_CM,
Bram Moolenaar49771f42010-07-20 17:32:38 +0200896 {(char_u *)"zip", (char_u *)0L}
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200897#else
898 (char_u *)NULL, PV_NONE,
Bram Moolenaar49771f42010-07-20 17:32:38 +0200899 {(char_u *)0L, (char_u *)0L}
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200900#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +0200901 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000902 {"cscopepathcomp", "cspc", P_NUM|P_VI_DEF|P_VIM,
903#ifdef FEAT_CSCOPE
904 (char_u *)&p_cspc, PV_NONE,
905#else
906 (char_u *)NULL, PV_NONE,
907#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000908 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000909 {"cscopeprg", "csprg", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
910#ifdef FEAT_CSCOPE
911 (char_u *)&p_csprg, PV_NONE,
912 {(char_u *)"cscope", (char_u *)0L}
913#else
914 (char_u *)NULL, PV_NONE,
915 {(char_u *)0L, (char_u *)0L}
916#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000917 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200918 {"cscopequickfix", "csqf", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000919#if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX)
920 (char_u *)&p_csqf, PV_NONE,
921 {(char_u *)"", (char_u *)0L}
922#else
923 (char_u *)NULL, PV_NONE,
924 {(char_u *)0L, (char_u *)0L}
925#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000926 SCRIPTID_INIT},
Bram Moolenaarf7befa92011-06-12 22:13:40 +0200927 {"cscoperelative", "csre", P_BOOL|P_VI_DEF|P_VIM,
928#ifdef FEAT_CSCOPE
929 (char_u *)&p_csre, PV_NONE,
930#else
931 (char_u *)NULL, PV_NONE,
932#endif
933 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000934 {"cscopetag", "cst", P_BOOL|P_VI_DEF|P_VIM,
935#ifdef FEAT_CSCOPE
936 (char_u *)&p_cst, PV_NONE,
937#else
938 (char_u *)NULL, PV_NONE,
939#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000940 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000941 {"cscopetagorder", "csto", P_NUM|P_VI_DEF|P_VIM,
942#ifdef FEAT_CSCOPE
943 (char_u *)&p_csto, PV_NONE,
944#else
945 (char_u *)NULL, PV_NONE,
946#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000947 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000948 {"cscopeverbose", "csverb", P_BOOL|P_VI_DEF|P_VIM,
949#ifdef FEAT_CSCOPE
950 (char_u *)&p_csverbose, PV_NONE,
951#else
952 (char_u *)NULL, PV_NONE,
953#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000954 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar860cae12010-06-05 23:22:07 +0200955 {"cursorbind", "crb", P_BOOL|P_VI_DEF,
956#ifdef FEAT_CURSORBIND
957 (char_u *)VAR_WIN, PV_CRBIND,
958#else
959 (char_u *)NULL, PV_NONE,
960#endif
961 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000962 {"cursorcolumn", "cuc", P_BOOL|P_VI_DEF|P_RWIN,
963#ifdef FEAT_SYN_HL
964 (char_u *)VAR_WIN, PV_CUC,
965#else
966 (char_u *)NULL, PV_NONE,
967#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000968 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000969 {"cursorline", "cul", P_BOOL|P_VI_DEF|P_RWIN,
970#ifdef FEAT_SYN_HL
971 (char_u *)VAR_WIN, PV_CUL,
972#else
973 (char_u *)NULL, PV_NONE,
974#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000975 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000976 {"debug", NULL, P_STRING|P_VI_DEF,
977 (char_u *)&p_debug, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000978 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +0200979 {"define", "def", P_STRING|P_ALLOCED|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000980#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000981 (char_u *)&p_def, PV_DEF,
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000982 {(char_u *)"^\\s*#\\s*define", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000983#else
984 (char_u *)NULL, PV_NONE,
985 {(char_u *)NULL, (char_u *)0L}
986#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000987 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000988 {"delcombine", "deco", P_BOOL|P_VI_DEF|P_VIM,
989#ifdef FEAT_MBYTE
990 (char_u *)&p_deco, PV_NONE,
991#else
992 (char_u *)NULL, PV_NONE,
993#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000994 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar031cb742016-11-24 21:46:19 +0100995 {"dictionary", "dict", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000996#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000997 (char_u *)&p_dict, PV_DICT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000998#else
999 (char_u *)NULL, PV_NONE,
1000#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001001 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001002 {"diff", NULL, P_BOOL|P_VI_DEF|P_RWIN|P_NOGLOB,
1003#ifdef FEAT_DIFF
1004 (char_u *)VAR_WIN, PV_DIFF,
1005#else
1006 (char_u *)NULL, PV_NONE,
1007#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001008 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001009 {"diffexpr", "dex", P_STRING|P_VI_DEF|P_SECURE|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001010#if defined(FEAT_DIFF) && defined(FEAT_EVAL)
1011 (char_u *)&p_dex, PV_NONE,
1012 {(char_u *)"", (char_u *)0L}
1013#else
1014 (char_u *)NULL, PV_NONE,
1015 {(char_u *)0L, (char_u *)0L}
1016#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001017 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001018 {"diffopt", "dip", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN|P_ONECOMMA
1019 |P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001020#ifdef FEAT_DIFF
1021 (char_u *)&p_dip, PV_NONE,
1022 {(char_u *)"filler", (char_u *)NULL}
1023#else
1024 (char_u *)NULL, PV_NONE,
1025 {(char_u *)"", (char_u *)NULL}
1026#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001027 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001028 {"digraph", "dg", P_BOOL|P_VI_DEF|P_VIM,
1029#ifdef FEAT_DIGRAPHS
1030 (char_u *)&p_dg, PV_NONE,
1031#else
1032 (char_u *)NULL, PV_NONE,
1033#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001034 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001035 {"directory", "dir", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA
1036 |P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001037 (char_u *)&p_dir, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001038 {(char_u *)DFLT_DIR, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001039 {"display", "dy", P_STRING|P_VI_DEF|P_ONECOMMA|P_RALL|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001040 (char_u *)&p_dy, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001041 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001042 {"eadirection", "ead", P_STRING|P_VI_DEF,
Bram Moolenaar44a2f922016-03-19 22:11:51 +01001043#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00001044 (char_u *)&p_ead, PV_NONE,
1045 {(char_u *)"both", (char_u *)0L}
1046#else
1047 (char_u *)NULL, PV_NONE,
1048 {(char_u *)NULL, (char_u *)0L}
1049#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001050 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001051 {"edcompatible","ed", P_BOOL|P_VI_DEF,
1052 (char_u *)&p_ed, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001053 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar3848e002016-03-19 18:42:29 +01001054 {"emoji", "emo", P_BOOL|P_VI_DEF|P_RCLR,
1055#if defined(FEAT_MBYTE)
1056 (char_u *)&p_emoji, PV_NONE,
1057 {(char_u *)TRUE, (char_u *)0L}
1058#else
1059 (char_u *)NULL, PV_NONE,
1060 {(char_u *)0L, (char_u *)0L}
1061#endif
1062 SCRIPTID_INIT},
Bram Moolenaar865242e2010-07-14 21:12:05 +02001063 {"encoding", "enc", P_STRING|P_VI_DEF|P_RCLR|P_NO_ML,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001064#ifdef FEAT_MBYTE
1065 (char_u *)&p_enc, PV_NONE,
1066 {(char_u *)ENC_DFLT, (char_u *)0L}
1067#else
1068 (char_u *)NULL, PV_NONE,
1069 {(char_u *)0L, (char_u *)0L}
1070#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001071 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001072 {"endofline", "eol", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
1073 (char_u *)&p_eol, PV_EOL,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001074 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001075 {"equalalways", "ea", P_BOOL|P_VI_DEF|P_RALL,
1076 (char_u *)&p_ea, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001077 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001078 {"equalprg", "ep", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001079 (char_u *)&p_ep, PV_EP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001080 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001081 {"errorbells", "eb", P_BOOL|P_VI_DEF,
1082 (char_u *)&p_eb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001083 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001084 {"errorfile", "ef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1085#ifdef FEAT_QUICKFIX
1086 (char_u *)&p_ef, PV_NONE,
1087 {(char_u *)DFLT_ERRORFILE, (char_u *)0L}
1088#else
1089 (char_u *)NULL, PV_NONE,
1090 {(char_u *)NULL, (char_u *)0L}
1091#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001092 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001093 {"errorformat", "efm", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001094#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001095 (char_u *)&p_efm, PV_EFM,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001096 {(char_u *)DFLT_EFM, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001097#else
1098 (char_u *)NULL, PV_NONE,
1099 {(char_u *)NULL, (char_u *)0L}
1100#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001101 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001102 {"esckeys", "ek", P_BOOL|P_VIM,
1103 (char_u *)&p_ek, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001104 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001105 {"eventignore", "ei", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001106#ifdef FEAT_AUTOCMD
1107 (char_u *)&p_ei, PV_NONE,
1108#else
1109 (char_u *)NULL, PV_NONE,
1110#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001111 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001112 {"expandtab", "et", P_BOOL|P_VI_DEF|P_VIM,
1113 (char_u *)&p_et, PV_ET,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001114 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001115 {"exrc", "ex", P_BOOL|P_VI_DEF|P_SECURE,
1116 (char_u *)&p_exrc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001117 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001118 {"fileencoding","fenc", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_RBUF
1119 |P_NO_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001120#ifdef FEAT_MBYTE
1121 (char_u *)&p_fenc, PV_FENC,
1122 {(char_u *)"", (char_u *)0L}
1123#else
1124 (char_u *)NULL, PV_NONE,
1125 {(char_u *)0L, (char_u *)0L}
1126#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001127 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001128 {"fileencodings","fencs", P_STRING|P_VI_DEF|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001129#ifdef FEAT_MBYTE
1130 (char_u *)&p_fencs, PV_NONE,
1131 {(char_u *)"ucs-bom", (char_u *)0L}
1132#else
1133 (char_u *)NULL, PV_NONE,
1134 {(char_u *)0L, (char_u *)0L}
1135#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001136 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001137 {"fileformat", "ff", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_NO_MKRC
1138 |P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001139 (char_u *)&p_ff, PV_FF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001140 {(char_u *)DFLT_FF, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001141 {"fileformats", "ffs", P_STRING|P_VIM|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001142 (char_u *)&p_ffs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001143 {(char_u *)DFLT_FFS_VI, (char_u *)DFLT_FFS_VIM}
1144 SCRIPTID_INIT},
Bram Moolenaar71afbfe2013-03-19 16:49:16 +01001145 {"fileignorecase", "fic", P_BOOL|P_VI_DEF,
1146 (char_u *)&p_fic, PV_NONE,
1147 {
1148#ifdef CASE_INSENSITIVE_FILENAME
1149 (char_u *)TRUE,
1150#else
1151 (char_u *)FALSE,
1152#endif
1153 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001154 {"filetype", "ft", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001155#ifdef FEAT_AUTOCMD
1156 (char_u *)&p_ft, PV_FT,
1157 {(char_u *)"", (char_u *)0L}
1158#else
1159 (char_u *)NULL, PV_NONE,
1160 {(char_u *)0L, (char_u *)0L}
1161#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001162 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001163 {"fillchars", "fcs", P_STRING|P_VI_DEF|P_RALL|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001164#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
1165 (char_u *)&p_fcs, PV_NONE,
1166 {(char_u *)"vert:|,fold:-", (char_u *)0L}
1167#else
1168 (char_u *)NULL, PV_NONE,
1169 {(char_u *)"", (char_u *)0L}
1170#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001171 SCRIPTID_INIT},
Bram Moolenaar34d72d42015-07-17 14:18:08 +02001172 {"fixendofline", "fixeol", P_BOOL|P_VI_DEF|P_RSTAT,
1173 (char_u *)&p_fixeol, PV_FIXEOL,
1174 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001175 {"fkmap", "fk", P_BOOL|P_VI_DEF,
1176#ifdef FEAT_FKMAP
1177 (char_u *)&p_fkmap, PV_NONE,
1178#else
1179 (char_u *)NULL, PV_NONE,
1180#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001181 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001182 {"flash", "fl", P_BOOL|P_VI_DEF,
1183 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001184 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001185#ifdef FEAT_FOLDING
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001186 {"foldclose", "fcl", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_RWIN,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001187 (char_u *)&p_fcl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001188 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001189 {"foldcolumn", "fdc", P_NUM|P_VI_DEF|P_RWIN,
1190 (char_u *)VAR_WIN, PV_FDC,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001191 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001192 {"foldenable", "fen", P_BOOL|P_VI_DEF|P_RWIN,
1193 (char_u *)VAR_WIN, PV_FEN,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001194 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001195 {"foldexpr", "fde", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1196# ifdef FEAT_EVAL
1197 (char_u *)VAR_WIN, PV_FDE,
1198 {(char_u *)"0", (char_u *)NULL}
1199# else
1200 (char_u *)NULL, PV_NONE,
1201 {(char_u *)NULL, (char_u *)0L}
1202# endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001203 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001204 {"foldignore", "fdi", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1205 (char_u *)VAR_WIN, PV_FDI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001206 {(char_u *)"#", (char_u *)NULL} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001207 {"foldlevel", "fdl", P_NUM|P_VI_DEF|P_RWIN,
1208 (char_u *)VAR_WIN, PV_FDL,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001209 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001210 {"foldlevelstart","fdls", P_NUM|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001211 (char_u *)&p_fdls, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001212 {(char_u *)-1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001213 {"foldmarker", "fmr", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001214 P_RWIN|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001215 (char_u *)VAR_WIN, PV_FMR,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001216 {(char_u *)"{{{,}}}", (char_u *)NULL}
1217 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001218 {"foldmethod", "fdm", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1219 (char_u *)VAR_WIN, PV_FDM,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001220 {(char_u *)"manual", (char_u *)NULL} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001221 {"foldminlines","fml", P_NUM|P_VI_DEF|P_RWIN,
1222 (char_u *)VAR_WIN, PV_FML,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001223 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001224 {"foldnestmax", "fdn", P_NUM|P_VI_DEF|P_RWIN,
1225 (char_u *)VAR_WIN, PV_FDN,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001226 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001227 {"foldopen", "fdo", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001228 (char_u *)&p_fdo, PV_NONE,
1229 {(char_u *)"block,hor,mark,percent,quickfix,search,tag,undo",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001230 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001231 {"foldtext", "fdt", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1232# ifdef FEAT_EVAL
1233 (char_u *)VAR_WIN, PV_FDT,
1234 {(char_u *)"foldtext()", (char_u *)NULL}
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00001235# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00001236 (char_u *)NULL, PV_NONE,
1237 {(char_u *)NULL, (char_u *)0L}
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00001238# endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001239 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001240#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00001241 {"formatexpr", "fex", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001242#ifdef FEAT_EVAL
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00001243 (char_u *)&p_fex, PV_FEX,
1244 {(char_u *)"", (char_u *)0L}
1245#else
1246 (char_u *)NULL, PV_NONE,
1247 {(char_u *)0L, (char_u *)0L}
1248#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001249 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001250 {"formatoptions","fo", P_STRING|P_ALLOCED|P_VIM|P_FLAGLIST,
1251 (char_u *)&p_fo, PV_FO,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001252 {(char_u *)DFLT_FO_VI, (char_u *)DFLT_FO_VIM}
1253 SCRIPTID_INIT},
Bram Moolenaar86b68352004-12-27 21:59:20 +00001254 {"formatlistpat","flp", P_STRING|P_ALLOCED|P_VI_DEF,
1255 (char_u *)&p_flp, PV_FLP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001256 {(char_u *)"^\\s*\\d\\+[\\]:.)}\\t ]\\s*",
1257 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001258 {"formatprg", "fp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1259 (char_u *)&p_fp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001260 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001261 {"fsync", "fs", P_BOOL|P_SECURE|P_VI_DEF,
1262#ifdef HAVE_FSYNC
1263 (char_u *)&p_fs, PV_NONE,
1264 {(char_u *)TRUE, (char_u *)0L}
1265#else
1266 (char_u *)NULL, PV_NONE,
1267 {(char_u *)FALSE, (char_u *)0L}
1268#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001269 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001270 {"gdefault", "gd", P_BOOL|P_VI_DEF|P_VIM,
1271 (char_u *)&p_gd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001272 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001273 {"graphic", "gr", P_BOOL|P_VI_DEF,
1274 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001275 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001276 {"grepformat", "gfm", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001277#ifdef FEAT_QUICKFIX
1278 (char_u *)&p_gefm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001279 {(char_u *)DFLT_GREPFORMAT, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001280#else
1281 (char_u *)NULL, PV_NONE,
1282 {(char_u *)NULL, (char_u *)0L}
1283#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001284 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001285 {"grepprg", "gp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1286#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001287 (char_u *)&p_gp, PV_GP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001288 {
1289# ifdef WIN3264
1290 /* may be changed to "grep -n" in os_win32.c */
1291 (char_u *)"findstr /n",
1292# else
1293# ifdef UNIX
1294 /* Add an extra file name so that grep will always
1295 * insert a file name in the match line. */
1296 (char_u *)"grep -n $* /dev/null",
1297# else
1298# ifdef VMS
1299 (char_u *)"SEARCH/NUMBERS ",
1300# else
1301 (char_u *)"grep -n ",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001302# endif
1303# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00001304# endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001305 (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001306#else
1307 (char_u *)NULL, PV_NONE,
1308 {(char_u *)NULL, (char_u *)0L}
1309#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001310 SCRIPTID_INIT},
Bram Moolenaar8a633e32016-04-21 21:10:14 +02001311 {"guicursor", "gcr", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001312#ifdef CURSOR_SHAPE
1313 (char_u *)&p_guicursor, PV_NONE,
1314 {
1315# ifdef FEAT_GUI
1316 (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 +01001317# else /* Win32 console */
Bram Moolenaar071d4272004-06-13 20:20:40 +00001318 (char_u *)"n-v-c:block,o:hor50,i-ci:hor15,r-cr:hor30,sm:block",
1319# endif
1320 (char_u *)0L}
1321#else
1322 (char_u *)NULL, PV_NONE,
1323 {(char_u *)NULL, (char_u *)0L}
1324#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001325 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001326 {"guifont", "gfn", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001327#ifdef FEAT_GUI
1328 (char_u *)&p_guifont, PV_NONE,
1329 {(char_u *)"", (char_u *)0L}
1330#else
1331 (char_u *)NULL, PV_NONE,
1332 {(char_u *)NULL, (char_u *)0L}
1333#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001334 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001335 {"guifontset", "gfs", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001336#if defined(FEAT_GUI) && defined(FEAT_XFONTSET)
1337 (char_u *)&p_guifontset, PV_NONE,
1338 {(char_u *)"", (char_u *)0L}
1339#else
1340 (char_u *)NULL, PV_NONE,
1341 {(char_u *)NULL, (char_u *)0L}
1342#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001343 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001344 {"guifontwide", "gfw", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001345#if defined(FEAT_GUI) && defined(FEAT_MBYTE)
1346 (char_u *)&p_guifontwide, PV_NONE,
1347 {(char_u *)"", (char_u *)0L}
1348#else
1349 (char_u *)NULL, PV_NONE,
1350 {(char_u *)NULL, (char_u *)0L}
1351#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001352 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001353 {"guiheadroom", "ghr", P_NUM|P_VI_DEF,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001354#if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001355 (char_u *)&p_ghr, PV_NONE,
1356#else
1357 (char_u *)NULL, PV_NONE,
1358#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001359 {(char_u *)50L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001360 {"guioptions", "go", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001361#if defined(FEAT_GUI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001362 (char_u *)&p_go, PV_NONE,
1363# if defined(UNIX) && !defined(MACOS)
Bram Moolenaar32466aa2006-02-24 23:53:04 +00001364 {(char_u *)"aegimrLtT", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001365# else
Bram Moolenaar32466aa2006-02-24 23:53:04 +00001366 {(char_u *)"egmrLtT", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001367# endif
1368#else
1369 (char_u *)NULL, PV_NONE,
1370 {(char_u *)NULL, (char_u *)0L}
1371#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001372 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001373 {"guipty", NULL, P_BOOL|P_VI_DEF,
1374#if defined(FEAT_GUI)
1375 (char_u *)&p_guipty, PV_NONE,
1376#else
1377 (char_u *)NULL, PV_NONE,
1378#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001379 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar18144c82006-04-12 21:52:12 +00001380 {"guitablabel", "gtl", P_STRING|P_VI_DEF|P_RWIN,
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00001381#if defined(FEAT_GUI_TABLINE)
1382 (char_u *)&p_gtl, PV_NONE,
1383 {(char_u *)"", (char_u *)0L}
1384#else
1385 (char_u *)NULL, PV_NONE,
1386 {(char_u *)NULL, (char_u *)0L}
1387#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001388 SCRIPTID_INIT},
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001389 {"guitabtooltip", "gtt", P_STRING|P_VI_DEF|P_RWIN,
Bram Moolenaar57657d82006-04-21 22:12:41 +00001390#if defined(FEAT_GUI_TABLINE)
1391 (char_u *)&p_gtt, PV_NONE,
1392 {(char_u *)"", (char_u *)0L}
1393#else
1394 (char_u *)NULL, PV_NONE,
1395 {(char_u *)NULL, (char_u *)0L}
1396#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001397 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001398 {"hardtabs", "ht", P_NUM|P_VI_DEF,
1399 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001400 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001401 {"helpfile", "hf", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1402 (char_u *)&p_hf, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001403 {(char_u *)DFLT_HELPFILE, (char_u *)0L}
1404 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001405 {"helpheight", "hh", P_NUM|P_VI_DEF,
1406#ifdef FEAT_WINDOWS
1407 (char_u *)&p_hh, PV_NONE,
1408#else
1409 (char_u *)NULL, PV_NONE,
1410#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001411 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001412 {"helplang", "hlg", P_STRING|P_VI_DEF|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001413#ifdef FEAT_MULTI_LANG
1414 (char_u *)&p_hlg, PV_NONE,
1415 {(char_u *)"", (char_u *)0L}
1416#else
1417 (char_u *)NULL, PV_NONE,
1418 {(char_u *)0L, (char_u *)0L}
1419#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001420 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001421 {"hidden", "hid", P_BOOL|P_VI_DEF,
1422 (char_u *)&p_hid, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001423 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001424 {"highlight", "hl", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001425 (char_u *)&p_hl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001426 {(char_u *)HIGHLIGHT_INIT, (char_u *)0L}
1427 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001428 {"history", "hi", P_NUM|P_VIM,
1429 (char_u *)&p_hi, PV_NONE,
Bram Moolenaar78159bb2014-06-25 11:48:54 +02001430 {(char_u *)0L, (char_u *)50L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001431 {"hkmap", "hk", P_BOOL|P_VI_DEF|P_VIM,
1432#ifdef FEAT_RIGHTLEFT
1433 (char_u *)&p_hkmap, PV_NONE,
1434#else
1435 (char_u *)NULL, PV_NONE,
1436#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001437 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001438 {"hkmapp", "hkp", P_BOOL|P_VI_DEF|P_VIM,
1439#ifdef FEAT_RIGHTLEFT
1440 (char_u *)&p_hkmapp, PV_NONE,
1441#else
1442 (char_u *)NULL, PV_NONE,
1443#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001444 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001445 {"hlsearch", "hls", P_BOOL|P_VI_DEF|P_VIM|P_RALL,
1446 (char_u *)&p_hls, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001447 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001448 {"icon", NULL, P_BOOL|P_VI_DEF,
1449#ifdef FEAT_TITLE
1450 (char_u *)&p_icon, PV_NONE,
1451#else
1452 (char_u *)NULL, PV_NONE,
1453#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001454 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001455 {"iconstring", NULL, P_STRING|P_VI_DEF,
1456#ifdef FEAT_TITLE
1457 (char_u *)&p_iconstring, PV_NONE,
1458#else
1459 (char_u *)NULL, PV_NONE,
1460#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001461 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001462 {"ignorecase", "ic", P_BOOL|P_VI_DEF,
1463 (char_u *)&p_ic, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001464 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarabab85a2013-06-26 19:18:05 +02001465 {"imactivatefunc","imaf",P_STRING|P_VI_DEF|P_SECURE,
1466# if defined(FEAT_EVAL) && defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
1467 (char_u *)&p_imaf, PV_NONE,
1468 {(char_u *)"", (char_u *)NULL}
1469# else
1470 (char_u *)NULL, PV_NONE,
1471 {(char_u *)NULL, (char_u *)0L}
1472# endif
1473 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001474 {"imactivatekey","imak",P_STRING|P_VI_DEF,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001475#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001476 (char_u *)&p_imak, PV_NONE,
1477#else
1478 (char_u *)NULL, PV_NONE,
1479#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001480 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001481 {"imcmdline", "imc", P_BOOL|P_VI_DEF,
1482#ifdef USE_IM_CONTROL
1483 (char_u *)&p_imcmdline, PV_NONE,
1484#else
1485 (char_u *)NULL, PV_NONE,
1486#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001487 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001488 {"imdisable", "imd", P_BOOL|P_VI_DEF,
1489#ifdef USE_IM_CONTROL
1490 (char_u *)&p_imdisable, PV_NONE,
1491#else
1492 (char_u *)NULL, PV_NONE,
1493#endif
1494#ifdef __sgi
1495 {(char_u *)TRUE, (char_u *)0L}
1496#else
1497 {(char_u *)FALSE, (char_u *)0L}
1498#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001499 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001500 {"iminsert", "imi", P_NUM|P_VI_DEF,
1501 (char_u *)&p_iminsert, PV_IMI,
1502#ifdef B_IMODE_IM
1503 {(char_u *)B_IMODE_IM, (char_u *)0L}
1504#else
1505 {(char_u *)B_IMODE_NONE, (char_u *)0L}
1506#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001507 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001508 {"imsearch", "ims", P_NUM|P_VI_DEF,
1509 (char_u *)&p_imsearch, PV_IMS,
1510#ifdef B_IMODE_IM
1511 {(char_u *)B_IMODE_IM, (char_u *)0L}
1512#else
1513 {(char_u *)B_IMODE_NONE, (char_u *)0L}
1514#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001515 SCRIPTID_INIT},
Bram Moolenaar4a460702013-06-29 14:42:26 +02001516 {"imstatusfunc","imsf",P_STRING|P_VI_DEF|P_SECURE,
Bram Moolenaarabab85a2013-06-26 19:18:05 +02001517# if defined(FEAT_EVAL) && defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
1518 (char_u *)&p_imsf, PV_NONE,
1519 {(char_u *)"", (char_u *)NULL}
1520# else
1521 (char_u *)NULL, PV_NONE,
1522 {(char_u *)NULL, (char_u *)0L}
1523# endif
1524 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001525 {"include", "inc", P_STRING|P_ALLOCED|P_VI_DEF,
1526#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001527 (char_u *)&p_inc, PV_INC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001528 {(char_u *)"^\\s*#\\s*include", (char_u *)0L}
1529#else
1530 (char_u *)NULL, PV_NONE,
1531 {(char_u *)0L, (char_u *)0L}
1532#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001533 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001534 {"includeexpr", "inex", P_STRING|P_ALLOCED|P_VI_DEF,
1535#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
1536 (char_u *)&p_inex, PV_INEX,
1537 {(char_u *)"", (char_u *)0L}
1538#else
1539 (char_u *)NULL, PV_NONE,
1540 {(char_u *)0L, (char_u *)0L}
1541#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001542 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001543 {"incsearch", "is", P_BOOL|P_VI_DEF|P_VIM,
1544 (char_u *)&p_is, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001545 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001546 {"indentexpr", "inde", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
1547#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
1548 (char_u *)&p_inde, PV_INDE,
1549 {(char_u *)"", (char_u *)0L}
1550#else
1551 (char_u *)NULL, PV_NONE,
1552 {(char_u *)0L, (char_u *)0L}
1553#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001554 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001555 {"indentkeys", "indk", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001556#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
1557 (char_u *)&p_indk, PV_INDK,
1558 {(char_u *)"0{,0},:,0#,!^F,o,O,e", (char_u *)0L}
1559#else
1560 (char_u *)NULL, PV_NONE,
1561 {(char_u *)0L, (char_u *)0L}
1562#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001563 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001564 {"infercase", "inf", P_BOOL|P_VI_DEF,
1565 (char_u *)&p_inf, PV_INF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001566 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001567 {"insertmode", "im", P_BOOL|P_VI_DEF|P_VIM,
1568 (char_u *)&p_im, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001569 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001570 {"isfname", "isf", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1571 (char_u *)&p_isf, PV_NONE,
1572 {
1573#ifdef BACKSLASH_IN_FILENAME
1574 /* Excluded are: & and ^ are special in cmd.exe
1575 * ( and ) are used in text separating fnames */
1576 (char_u *)"@,48-57,/,\\,.,-,_,+,,,#,$,%,{,},[,],:,@-@,!,~,=",
1577#else
1578# ifdef AMIGA
1579 (char_u *)"@,48-57,/,.,-,_,+,,,$,:",
1580# else
1581# ifdef VMS
1582 (char_u *)"@,48-57,/,.,-,_,+,,,#,$,%,<,>,[,],:,;,~",
1583# else /* UNIX et al. */
1584# ifdef EBCDIC
1585 (char_u *)"@,240-249,/,.,-,_,+,,,#,$,%,~,=",
1586# else
1587 (char_u *)"@,48-57,/,.,-,_,+,,,#,$,%,~,=",
1588# endif
1589# endif
1590# endif
1591#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001592 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001593 {"isident", "isi", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1594 (char_u *)&p_isi, PV_NONE,
1595 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001596#if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001597 (char_u *)"@,48-57,_,128-167,224-235",
1598#else
1599# ifdef EBCDIC
1600 /* TODO: EBCDIC Check this! @ == isalpha()*/
1601 (char_u *)"@,240-249,_,66-73,81-89,98-105,"
1602 "112-120,128,140-142,156,158,172,"
1603 "174,186,191,203-207,219-225,235-239,"
1604 "251-254",
1605# else
1606 (char_u *)"@,48-57,_,192-255",
1607# endif
1608#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001609 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001610 {"iskeyword", "isk", P_STRING|P_ALLOCED|P_VIM|P_COMMA|P_NODUP,
1611 (char_u *)&p_isk, PV_ISK,
1612 {
1613#ifdef EBCDIC
1614 (char_u *)"@,240-249,_",
1615 /* TODO: EBCDIC Check this! @ == isalpha()*/
1616 (char_u *)"@,240-249,_,66-73,81-89,98-105,"
1617 "112-120,128,140-142,156,158,172,"
1618 "174,186,191,203-207,219-225,235-239,"
1619 "251-254",
1620#else
1621 (char_u *)"@,48-57,_",
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001622# if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001623 (char_u *)"@,48-57,_,128-167,224-235"
1624# else
Bram Moolenaar362e1a32006-03-06 23:29:24 +00001625 ISK_LATIN1
Bram Moolenaar071d4272004-06-13 20:20:40 +00001626# endif
1627#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001628 } SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001629 {"isprint", "isp", P_STRING|P_VI_DEF|P_RALL|P_COMMA|P_NODUP,
1630 (char_u *)&p_isp, PV_NONE,
1631 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001632#if defined(MSWIN) || (defined(MACOS) && !defined(MACOS_X)) \
Bram Moolenaar071d4272004-06-13 20:20:40 +00001633 || defined(VMS)
1634 (char_u *)"@,~-255",
1635#else
1636# ifdef EBCDIC
1637 /* all chars above 63 are printable */
1638 (char_u *)"63-255",
1639# else
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +00001640 ISP_LATIN1,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001641# endif
1642#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001643 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001644 {"joinspaces", "js", P_BOOL|P_VI_DEF|P_VIM,
1645 (char_u *)&p_js, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001646 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001647 {"key", NULL, P_STRING|P_ALLOCED|P_VI_DEF|P_NO_MKRC,
1648#ifdef FEAT_CRYPT
1649 (char_u *)&p_key, PV_KEY,
1650 {(char_u *)"", (char_u *)0L}
1651#else
1652 (char_u *)NULL, PV_NONE,
1653 {(char_u *)0L, (char_u *)0L}
1654#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001655 SCRIPTID_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +00001656 {"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 +00001657#ifdef FEAT_KEYMAP
1658 (char_u *)&p_keymap, PV_KMAP,
1659 {(char_u *)"", (char_u *)0L}
1660#else
1661 (char_u *)NULL, PV_NONE,
1662 {(char_u *)"", (char_u *)0L}
1663#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001664 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001665 {"keymodel", "km", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001666 (char_u *)&p_km, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001667 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001668 {"keywordprg", "kp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001669 (char_u *)&p_kp, PV_KP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001670 {
Bram Moolenaarfd89d7e2016-06-04 20:25:05 +02001671#ifdef MSWIN
Bram Moolenaar071d4272004-06-13 20:20:40 +00001672 (char_u *)":help",
1673#else
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001674# ifdef VMS
Bram Moolenaar071d4272004-06-13 20:20:40 +00001675 (char_u *)"help",
Bram Moolenaare7fedb62015-12-31 19:07:19 +01001676# else
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001677# ifdef USEMAN_S
1678 (char_u *)"man -s",
1679# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00001680 (char_u *)"man",
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001681# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00001682# endif
1683#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001684 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001685 {"langmap", "lmap", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001686#ifdef FEAT_LANGMAP
1687 (char_u *)&p_langmap, PV_NONE,
1688 {(char_u *)"", /* unmatched } */
1689#else
1690 (char_u *)NULL, PV_NONE,
1691 {(char_u *)NULL,
1692#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001693 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001694 {"langmenu", "lm", P_STRING|P_VI_DEF|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001695#if defined(FEAT_MENU) && defined(FEAT_MULTI_LANG)
1696 (char_u *)&p_lm, PV_NONE,
1697#else
1698 (char_u *)NULL, PV_NONE,
1699#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001700 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar4391cf92014-11-05 17:44:52 +01001701 {"langnoremap", "lnr", P_BOOL|P_VI_DEF,
1702#ifdef FEAT_LANGMAP
1703 (char_u *)&p_lnr, PV_NONE,
1704#else
1705 (char_u *)NULL, PV_NONE,
1706#endif
1707 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar920694c2016-08-21 17:45:02 +02001708 {"langremap", "lrm", P_BOOL|P_VI_DEF,
1709#ifdef FEAT_LANGMAP
1710 (char_u *)&p_lrm, PV_NONE,
1711#else
1712 (char_u *)NULL, PV_NONE,
1713#endif
Bram Moolenaarda9ce2c2016-09-02 19:34:10 +02001714 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001715 {"laststatus", "ls", P_NUM|P_VI_DEF|P_RALL,
1716#ifdef FEAT_WINDOWS
1717 (char_u *)&p_ls, PV_NONE,
1718#else
1719 (char_u *)NULL, PV_NONE,
1720#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001721 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001722 {"lazyredraw", "lz", P_BOOL|P_VI_DEF,
1723 (char_u *)&p_lz, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001724 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001725 {"linebreak", "lbr", P_BOOL|P_VI_DEF|P_RWIN,
1726#ifdef FEAT_LINEBREAK
1727 (char_u *)VAR_WIN, PV_LBR,
1728#else
1729 (char_u *)NULL, PV_NONE,
1730#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001731 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001732 {"lines", NULL, P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR,
1733 (char_u *)&Rows, PV_NONE,
1734 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001735#if defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001736 (char_u *)25L,
1737#else
1738 (char_u *)24L,
1739#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001740 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001741 {"linespace", "lsp", P_NUM|P_VI_DEF|P_RCLR,
1742#ifdef FEAT_GUI
1743 (char_u *)&p_linespace, PV_NONE,
1744#else
1745 (char_u *)NULL, PV_NONE,
1746#endif
1747#ifdef FEAT_GUI_W32
1748 {(char_u *)1L, (char_u *)0L}
1749#else
1750 {(char_u *)0L, (char_u *)0L}
1751#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001752 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001753 {"lisp", NULL, P_BOOL|P_VI_DEF,
1754#ifdef FEAT_LISP
1755 (char_u *)&p_lisp, PV_LISP,
1756#else
1757 (char_u *)NULL, PV_NONE,
1758#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001759 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001760 {"lispwords", "lw", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001761#ifdef FEAT_LISP
Bram Moolenaaraf6c1312014-03-12 18:55:58 +01001762 (char_u *)&p_lispwords, PV_LW,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001763 {(char_u *)LISPWORD_VALUE, (char_u *)0L}
1764#else
1765 (char_u *)NULL, PV_NONE,
1766 {(char_u *)"", (char_u *)0L}
1767#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001768 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001769 {"list", NULL, P_BOOL|P_VI_DEF|P_RWIN,
1770 (char_u *)VAR_WIN, PV_LIST,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001771 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001772 {"listchars", "lcs", P_STRING|P_VI_DEF|P_RALL|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001773 (char_u *)&p_lcs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001774 {(char_u *)"eol:$", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001775 {"loadplugins", "lpl", P_BOOL|P_VI_DEF,
1776 (char_u *)&p_lpl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001777 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01001778#if defined(DYNAMIC_LUA)
Bram Moolenaara6e42502016-04-20 16:19:52 +02001779 {"luadll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaard94464e2015-11-02 15:28:18 +01001780 (char_u *)&p_luadll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01001781 {(char_u *)DYNAMIC_LUA_DLL, (char_u *)0L}
1782 SCRIPTID_INIT},
Bram Moolenaard94464e2015-11-02 15:28:18 +01001783#endif
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001784#ifdef FEAT_GUI_MAC
1785 {"macatsui", NULL, P_BOOL|P_VI_DEF|P_RCLR,
1786 (char_u *)&p_macatsui, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001787 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001788#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00001789 {"magic", NULL, P_BOOL|P_VI_DEF,
1790 (char_u *)&p_magic, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001791 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00001792 {"makeef", "mef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001793#ifdef FEAT_QUICKFIX
1794 (char_u *)&p_mef, PV_NONE,
1795 {(char_u *)"", (char_u *)0L}
1796#else
1797 (char_u *)NULL, PV_NONE,
1798 {(char_u *)NULL, (char_u *)0L}
1799#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001800 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001801 {"makeprg", "mp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1802#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001803 (char_u *)&p_mp, PV_MP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001804# ifdef VMS
1805 {(char_u *)"MMS", (char_u *)0L}
1806# else
1807 {(char_u *)"make", (char_u *)0L}
1808# endif
1809#else
1810 (char_u *)NULL, PV_NONE,
1811 {(char_u *)NULL, (char_u *)0L}
1812#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001813 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001814 {"matchpairs", "mps", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001815 (char_u *)&p_mps, PV_MPS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001816 {(char_u *)"(:),{:},[:]", (char_u *)0L}
1817 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001818 {"matchtime", "mat", P_NUM|P_VI_DEF,
1819 (char_u *)&p_mat, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001820 {(char_u *)5L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001821 {"maxcombine", "mco", P_NUM|P_VI_DEF|P_CURSWANT,
Bram Moolenaar362e1a32006-03-06 23:29:24 +00001822#ifdef FEAT_MBYTE
1823 (char_u *)&p_mco, PV_NONE,
1824#else
1825 (char_u *)NULL, PV_NONE,
1826#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001827 {(char_u *)2, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001828 {"maxfuncdepth", "mfd", P_NUM|P_VI_DEF,
1829#ifdef FEAT_EVAL
1830 (char_u *)&p_mfd, PV_NONE,
1831#else
1832 (char_u *)NULL, PV_NONE,
1833#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001834 {(char_u *)100L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001835 {"maxmapdepth", "mmd", P_NUM|P_VI_DEF,
1836 (char_u *)&p_mmd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001837 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001838 {"maxmem", "mm", P_NUM|P_VI_DEF,
1839 (char_u *)&p_mm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001840 {(char_u *)DFLT_MAXMEM, (char_u *)0L}
1841 SCRIPTID_INIT},
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00001842 {"maxmempattern","mmp", P_NUM|P_VI_DEF,
1843 (char_u *)&p_mmp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001844 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001845 {"maxmemtot", "mmt", P_NUM|P_VI_DEF,
1846 (char_u *)&p_mmt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001847 {(char_u *)DFLT_MAXMEMTOT, (char_u *)0L}
1848 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001849 {"menuitems", "mis", P_NUM|P_VI_DEF,
1850#ifdef FEAT_MENU
1851 (char_u *)&p_mis, PV_NONE,
1852#else
1853 (char_u *)NULL, PV_NONE,
1854#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001855 {(char_u *)25L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001856 {"mesg", NULL, P_BOOL|P_VI_DEF,
1857 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001858 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001859 {"mkspellmem", "msm", P_STRING|P_VI_DEF|P_EXPAND|P_SECURE,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00001860#ifdef FEAT_SPELL
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001861 (char_u *)&p_msm, PV_NONE,
1862 {(char_u *)"460000,2000,500", (char_u *)0L}
1863#else
1864 (char_u *)NULL, PV_NONE,
1865 {(char_u *)0L, (char_u *)0L}
1866#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001867 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001868 {"modeline", "ml", P_BOOL|P_VIM,
1869 (char_u *)&p_ml, PV_ML,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001870 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001871 {"modelines", "mls", P_NUM|P_VI_DEF,
1872 (char_u *)&p_mls, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001873 {(char_u *)5L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001874 {"modifiable", "ma", P_BOOL|P_VI_DEF|P_NOGLOB,
1875 (char_u *)&p_ma, PV_MA,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001876 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001877 {"modified", "mod", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
1878 (char_u *)&p_mod, PV_MOD,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001879 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001880 {"more", NULL, P_BOOL|P_VIM,
1881 (char_u *)&p_more, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001882 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001883 {"mouse", NULL, P_STRING|P_VI_DEF|P_FLAGLIST,
1884 (char_u *)&p_mouse, PV_NONE,
1885 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001886#if defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001887 (char_u *)"a",
1888#else
1889 (char_u *)"",
1890#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001891 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001892 {"mousefocus", "mousef", P_BOOL|P_VI_DEF,
1893#ifdef FEAT_GUI
1894 (char_u *)&p_mousef, PV_NONE,
1895#else
1896 (char_u *)NULL, PV_NONE,
1897#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001898 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001899 {"mousehide", "mh", P_BOOL|P_VI_DEF,
1900#ifdef FEAT_GUI
1901 (char_u *)&p_mh, PV_NONE,
1902#else
1903 (char_u *)NULL, PV_NONE,
1904#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001905 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001906 {"mousemodel", "mousem", P_STRING|P_VI_DEF,
1907 (char_u *)&p_mousem, PV_NONE,
1908 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001909#if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001910 (char_u *)"popup",
1911#else
1912# if defined(MACOS)
1913 (char_u *)"popup_setpos",
1914# else
1915 (char_u *)"extend",
1916# endif
1917#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001918 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001919 {"mouseshape", "mouses", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001920#ifdef FEAT_MOUSESHAPE
1921 (char_u *)&p_mouseshape, PV_NONE,
1922 {(char_u *)"i-r:beam,s:updown,sd:udsizing,vs:leftright,vd:lrsizing,m:no,ml:up-arrow,v:rightup-arrow", (char_u *)0L}
1923#else
1924 (char_u *)NULL, PV_NONE,
1925 {(char_u *)NULL, (char_u *)0L}
1926#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001927 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001928 {"mousetime", "mouset", P_NUM|P_VI_DEF,
1929 (char_u *)&p_mouset, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001930 {(char_u *)500L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar325b7a22004-07-05 15:58:32 +00001931 {"mzquantum", "mzq", P_NUM,
1932#ifdef FEAT_MZSCHEME
1933 (char_u *)&p_mzq, PV_NONE,
1934#else
1935 (char_u *)NULL, PV_NONE,
1936#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001937 {(char_u *)100L, (char_u *)100L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001938 {"novice", NULL, P_BOOL|P_VI_DEF,
1939 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001940 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001941 {"nrformats", "nf", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001942 (char_u *)&p_nf, PV_NF,
Bram Moolenaar887c1fe2016-01-02 17:56:35 +01001943 {(char_u *)"bin,octal,hex", (char_u *)0L}
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001944 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001945 {"number", "nu", P_BOOL|P_VI_DEF|P_RWIN,
1946 (char_u *)VAR_WIN, PV_NU,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001947 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar592e0a22004-07-03 16:05:59 +00001948 {"numberwidth", "nuw", P_NUM|P_RWIN|P_VIM,
1949#ifdef FEAT_LINEBREAK
1950 (char_u *)VAR_WIN, PV_NUW,
1951#else
1952 (char_u *)NULL, PV_NONE,
1953#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001954 {(char_u *)8L, (char_u *)4L} SCRIPTID_INIT},
Bram Moolenaarf75a9632005-09-13 21:20:47 +00001955 {"omnifunc", "ofu", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE,
Bram Moolenaare344bea2005-09-01 20:46:49 +00001956#ifdef FEAT_COMPL_FUNC
1957 (char_u *)&p_ofu, PV_OFU,
1958 {(char_u *)"", (char_u *)0L}
1959#else
1960 (char_u *)NULL, PV_NONE,
1961 {(char_u *)0L, (char_u *)0L}
1962#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001963 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001964 {"open", NULL, P_BOOL|P_VI_DEF,
1965 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001966 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar043545e2006-10-10 16:44:07 +00001967 {"opendevice", "odev", P_BOOL|P_VI_DEF,
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001968#if defined(MSWIN)
Bram Moolenaar043545e2006-10-10 16:44:07 +00001969 (char_u *)&p_odev, PV_NONE,
1970#else
1971 (char_u *)NULL, PV_NONE,
1972#endif
1973 {(char_u *)FALSE, (char_u *)FALSE}
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001974 SCRIPTID_INIT},
Bram Moolenaar2c7a29c2005-12-12 22:02:31 +00001975 {"operatorfunc", "opfunc", P_STRING|P_VI_DEF|P_SECURE,
1976 (char_u *)&p_opfunc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001977 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001978 {"optimize", "opt", P_BOOL|P_VI_DEF,
1979 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001980 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001981 {"osfiletype", "oft", P_STRING|P_ALLOCED|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001982 (char_u *)NULL, PV_NONE,
Bram Moolenaarb07269a2011-05-19 13:41:14 +02001983 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf6fee0e2016-02-21 23:02:49 +01001984 {"packpath", "pp", P_STRING|P_VI_DEF|P_EXPAND|P_ONECOMMA|P_NODUP
1985 |P_SECURE,
1986 (char_u *)&p_pp, PV_NONE,
1987 {(char_u *)DFLT_RUNTIMEPATH, (char_u *)0L}
1988 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001989 {"paragraphs", "para", P_STRING|P_VI_DEF,
1990 (char_u *)&p_para, PV_NONE,
Bram Moolenaar57e48462008-03-12 16:38:55 +00001991 {(char_u *)"IPLPPPQPP TPHPLIPpLpItpplpipbp",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001992 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +00001993 {"paste", NULL, P_BOOL|P_VI_DEF|P_PRI_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001994 (char_u *)&p_paste, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001995 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001996 {"pastetoggle", "pt", P_STRING|P_VI_DEF,
1997 (char_u *)&p_pt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001998 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001999 {"patchexpr", "pex", P_STRING|P_VI_DEF|P_SECURE,
2000#if defined(FEAT_DIFF) && defined(FEAT_EVAL)
2001 (char_u *)&p_pex, PV_NONE,
2002 {(char_u *)"", (char_u *)0L}
2003#else
2004 (char_u *)NULL, PV_NONE,
2005 {(char_u *)0L, (char_u *)0L}
2006#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002007 SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002008 {"patchmode", "pm", P_STRING|P_VI_DEF|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002009 (char_u *)&p_pm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002010 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002011 {"path", "pa", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002012 (char_u *)&p_path, PV_PATH,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002013 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002014#if defined(AMIGA) || defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002015 (char_u *)".,,",
2016#else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002017 (char_u *)".,/usr/include,,",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002018#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002019 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002020#if defined(DYNAMIC_PERL)
Bram Moolenaara6e42502016-04-20 16:19:52 +02002021 {"perldll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaard94464e2015-11-02 15:28:18 +01002022 (char_u *)&p_perldll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002023 {(char_u *)DYNAMIC_PERL_DLL, (char_u *)0L}
2024 SCRIPTID_INIT},
Bram Moolenaard94464e2015-11-02 15:28:18 +01002025#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002026 {"preserveindent", "pi", P_BOOL|P_VI_DEF|P_VIM,
2027 (char_u *)&p_pi, PV_PI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002028 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar592e0a22004-07-03 16:05:59 +00002029 {"previewheight", "pvh", P_NUM|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002030#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
2031 (char_u *)&p_pvh, PV_NONE,
2032#else
2033 (char_u *)NULL, PV_NONE,
2034#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002035 {(char_u *)12L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002036 {"previewwindow", "pvw", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB,
2037#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
2038 (char_u *)VAR_WIN, PV_PVW,
2039#else
2040 (char_u *)NULL, PV_NONE,
2041#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002042 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002043 {"printdevice", "pdev", P_STRING|P_VI_DEF|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002044#ifdef FEAT_PRINTER
2045 (char_u *)&p_pdev, PV_NONE,
2046 {(char_u *)"", (char_u *)0L}
2047#else
2048 (char_u *)NULL, PV_NONE,
2049 {(char_u *)NULL, (char_u *)0L}
2050#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002051 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002052 {"printencoding", "penc", P_STRING|P_VI_DEF,
2053#ifdef FEAT_POSTSCRIPT
2054 (char_u *)&p_penc, PV_NONE,
2055 {(char_u *)"", (char_u *)0L}
2056#else
2057 (char_u *)NULL, PV_NONE,
2058 {(char_u *)NULL, (char_u *)0L}
2059#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002060 SCRIPTID_INIT},
Bram Moolenaar031cb742016-11-24 21:46:19 +01002061 {"printexpr", "pexpr", P_STRING|P_VI_DEF|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002062#ifdef FEAT_POSTSCRIPT
2063 (char_u *)&p_pexpr, PV_NONE,
2064 {(char_u *)"", (char_u *)0L}
2065#else
2066 (char_u *)NULL, PV_NONE,
2067 {(char_u *)NULL, (char_u *)0L}
2068#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002069 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002070 {"printfont", "pfn", P_STRING|P_VI_DEF,
2071#ifdef FEAT_PRINTER
2072 (char_u *)&p_pfn, PV_NONE,
2073 {
2074# ifdef MSWIN
2075 (char_u *)"Courier_New:h10",
2076# else
2077 (char_u *)"courier",
2078# endif
2079 (char_u *)0L}
2080#else
2081 (char_u *)NULL, PV_NONE,
2082 {(char_u *)NULL, (char_u *)0L}
2083#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002084 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002085 {"printheader", "pheader", P_STRING|P_VI_DEF|P_GETTEXT,
2086#ifdef FEAT_PRINTER
2087 (char_u *)&p_header, PV_NONE,
2088 {(char_u *)N_("%<%f%h%m%=Page %N"), (char_u *)0L}
2089#else
2090 (char_u *)NULL, PV_NONE,
2091 {(char_u *)NULL, (char_u *)0L}
2092#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002093 SCRIPTID_INIT},
Bram Moolenaar8299df92004-07-10 09:47:34 +00002094 {"printmbcharset", "pmbcs", P_STRING|P_VI_DEF,
2095#if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE)
2096 (char_u *)&p_pmcs, PV_NONE,
2097 {(char_u *)"", (char_u *)0L}
2098#else
2099 (char_u *)NULL, PV_NONE,
2100 {(char_u *)NULL, (char_u *)0L}
2101#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002102 SCRIPTID_INIT},
Bram Moolenaar8299df92004-07-10 09:47:34 +00002103 {"printmbfont", "pmbfn", P_STRING|P_VI_DEF,
2104#if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE)
2105 (char_u *)&p_pmfn, PV_NONE,
2106 {(char_u *)"", (char_u *)0L}
2107#else
2108 (char_u *)NULL, PV_NONE,
2109 {(char_u *)NULL, (char_u *)0L}
2110#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002111 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002112 {"printoptions", "popt", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002113#ifdef FEAT_PRINTER
2114 (char_u *)&p_popt, PV_NONE,
2115 {(char_u *)"", (char_u *)0L}
2116#else
2117 (char_u *)NULL, PV_NONE,
2118 {(char_u *)NULL, (char_u *)0L}
2119#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002120 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002121 {"prompt", NULL, P_BOOL|P_VI_DEF,
Bram Moolenaar26a60b42005-02-22 08:49:11 +00002122 (char_u *)&p_prompt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002123 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar9d47f172006-03-15 23:03:01 +00002124 {"pumheight", "ph", P_NUM|P_VI_DEF,
2125#ifdef FEAT_INS_EXPAND
2126 (char_u *)&p_ph, PV_NONE,
2127#else
2128 (char_u *)NULL, PV_NONE,
2129#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002130 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002131#if defined(DYNAMIC_PYTHON3)
Bram Moolenaara6e42502016-04-20 16:19:52 +02002132 {"pythonthreedll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaard94464e2015-11-02 15:28:18 +01002133 (char_u *)&p_py3dll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002134 {(char_u *)DYNAMIC_PYTHON3_DLL, (char_u *)0L}
2135 SCRIPTID_INIT},
Bram Moolenaard94464e2015-11-02 15:28:18 +01002136#endif
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002137#if defined(DYNAMIC_PYTHON)
Bram Moolenaara6e42502016-04-20 16:19:52 +02002138 {"pythondll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaard94464e2015-11-02 15:28:18 +01002139 (char_u *)&p_pydll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002140 {(char_u *)DYNAMIC_PYTHON_DLL, (char_u *)0L}
2141 SCRIPTID_INIT},
Bram Moolenaard94464e2015-11-02 15:28:18 +01002142#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00002143 {"quoteescape", "qe", P_STRING|P_ALLOCED|P_VI_DEF,
2144#ifdef FEAT_TEXTOBJ
2145 (char_u *)&p_qe, PV_QE,
2146 {(char_u *)"\\", (char_u *)0L}
2147#else
2148 (char_u *)NULL, PV_NONE,
2149 {(char_u *)NULL, (char_u *)0L}
2150#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002151 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002152 {"readonly", "ro", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB,
2153 (char_u *)&p_ro, PV_RO,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002154 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002155 {"redraw", NULL, P_BOOL|P_VI_DEF,
2156 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002157 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar91a4e822008-01-19 14:59:58 +00002158 {"redrawtime", "rdt", P_NUM|P_VI_DEF,
2159#ifdef FEAT_RELTIME
2160 (char_u *)&p_rdt, PV_NONE,
2161#else
2162 (char_u *)NULL, PV_NONE,
2163#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002164 {(char_u *)2000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarfbc0d2e2013-05-19 19:40:29 +02002165 {"regexpengine", "re", P_NUM|P_VI_DEF,
2166 (char_u *)&p_re, PV_NONE,
2167 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar64486672010-05-16 15:46:46 +02002168 {"relativenumber", "rnu", P_BOOL|P_VI_DEF|P_RWIN,
2169 (char_u *)VAR_WIN, PV_RNU,
2170 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002171 {"remap", NULL, P_BOOL|P_VI_DEF,
2172 (char_u *)&p_remap, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002173 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002174 {"renderoptions", "rop", P_STRING|P_ONECOMMA|P_RCLR|P_VI_DEF,
Bram Moolenaarb5a7a8b2014-08-06 14:52:30 +02002175#ifdef FEAT_RENDER_OPTIONS
2176 (char_u *)&p_rop, PV_NONE,
2177 {(char_u *)"", (char_u *)0L}
2178#else
2179 (char_u *)NULL, PV_NONE,
2180 {(char_u *)NULL, (char_u *)0L}
2181#endif
2182 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002183 {"report", NULL, P_NUM|P_VI_DEF,
2184 (char_u *)&p_report, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002185 {(char_u *)2L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002186 {"restorescreen", "rs", P_BOOL|P_VI_DEF,
2187#ifdef WIN3264
2188 (char_u *)&p_rs, PV_NONE,
2189#else
2190 (char_u *)NULL, PV_NONE,
2191#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002192 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002193 {"revins", "ri", P_BOOL|P_VI_DEF|P_VIM,
2194#ifdef FEAT_RIGHTLEFT
2195 (char_u *)&p_ri, PV_NONE,
2196#else
2197 (char_u *)NULL, PV_NONE,
2198#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002199 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002200 {"rightleft", "rl", P_BOOL|P_VI_DEF|P_RWIN,
2201#ifdef FEAT_RIGHTLEFT
2202 (char_u *)VAR_WIN, PV_RL,
2203#else
2204 (char_u *)NULL, PV_NONE,
2205#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002206 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002207 {"rightleftcmd", "rlc", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN,
2208#ifdef FEAT_RIGHTLEFT
2209 (char_u *)VAR_WIN, PV_RLC,
2210 {(char_u *)"search", (char_u *)NULL}
2211#else
2212 (char_u *)NULL, PV_NONE,
2213 {(char_u *)NULL, (char_u *)0L}
2214#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002215 SCRIPTID_INIT},
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002216#if defined(DYNAMIC_RUBY)
Bram Moolenaara6e42502016-04-20 16:19:52 +02002217 {"rubydll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaard94464e2015-11-02 15:28:18 +01002218 (char_u *)&p_rubydll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002219 {(char_u *)DYNAMIC_RUBY_DLL, (char_u *)0L}
2220 SCRIPTID_INIT},
Bram Moolenaard94464e2015-11-02 15:28:18 +01002221#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002222 {"ruler", "ru", P_BOOL|P_VI_DEF|P_VIM|P_RSTAT,
2223#ifdef FEAT_CMDL_INFO
2224 (char_u *)&p_ru, PV_NONE,
2225#else
2226 (char_u *)NULL, PV_NONE,
2227#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002228 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002229 {"rulerformat", "ruf", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT,
2230#ifdef FEAT_STL_OPT
2231 (char_u *)&p_ruf, PV_NONE,
2232#else
2233 (char_u *)NULL, PV_NONE,
2234#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002235 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002236 {"runtimepath", "rtp", P_STRING|P_VI_DEF|P_EXPAND|P_ONECOMMA|P_NODUP
2237 |P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002238 (char_u *)&p_rtp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002239 {(char_u *)DFLT_RUNTIMEPATH, (char_u *)0L}
2240 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002241 {"scroll", "scr", P_NUM|P_NO_MKRC|P_VI_DEF,
2242 (char_u *)VAR_WIN, PV_SCROLL,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002243 {(char_u *)12L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002244 {"scrollbind", "scb", P_BOOL|P_VI_DEF,
2245#ifdef FEAT_SCROLLBIND
2246 (char_u *)VAR_WIN, PV_SCBIND,
2247#else
2248 (char_u *)NULL, PV_NONE,
2249#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002250 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002251 {"scrolljump", "sj", P_NUM|P_VI_DEF|P_VIM,
2252 (char_u *)&p_sj, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002253 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002254 {"scrolloff", "so", P_NUM|P_VI_DEF|P_VIM|P_RALL,
2255 (char_u *)&p_so, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002256 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002257 {"scrollopt", "sbo", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002258#ifdef FEAT_SCROLLBIND
2259 (char_u *)&p_sbo, PV_NONE,
2260 {(char_u *)"ver,jump", (char_u *)0L}
2261#else
2262 (char_u *)NULL, PV_NONE,
2263 {(char_u *)0L, (char_u *)0L}
2264#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002265 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002266 {"sections", "sect", P_STRING|P_VI_DEF,
2267 (char_u *)&p_sections, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002268 {(char_u *)"SHNHH HUnhsh", (char_u *)0L}
2269 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002270 {"secure", NULL, P_BOOL|P_VI_DEF|P_SECURE,
2271 (char_u *)&p_secure, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002272 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002273 {"selection", "sel", P_STRING|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002274 (char_u *)&p_sel, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002275 {(char_u *)"inclusive", (char_u *)0L}
2276 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002277 {"selectmode", "slm", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002278 (char_u *)&p_slm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002279 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002280 {"sessionoptions", "ssop", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002281#ifdef FEAT_SESSION
2282 (char_u *)&p_ssop, PV_NONE,
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00002283 {(char_u *)"blank,buffers,curdir,folds,help,options,tabpages,winsize",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002284 (char_u *)0L}
2285#else
2286 (char_u *)NULL, PV_NONE,
2287 {(char_u *)0L, (char_u *)0L}
2288#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002289 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002290 {"shell", "sh", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2291 (char_u *)&p_sh, PV_NONE,
2292 {
2293#ifdef VMS
2294 (char_u *)"-",
2295#else
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002296# if defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002297 (char_u *)"", /* set in set_init_1() */
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002298# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002299 (char_u *)"sh",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002300# endif
2301#endif /* VMS */
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002302 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002303 {"shellcmdflag","shcf", P_STRING|P_VI_DEF|P_SECURE,
2304 (char_u *)&p_shcf, PV_NONE,
2305 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002306#if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002307 (char_u *)"/c",
2308#else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002309 (char_u *)"-c",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002310#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002311 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002312 {"shellpipe", "sp", P_STRING|P_VI_DEF|P_SECURE,
2313#ifdef FEAT_QUICKFIX
2314 (char_u *)&p_sp, PV_NONE,
2315 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01002316#if defined(UNIX)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002317 (char_u *)"| tee",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002318#else
2319 (char_u *)">",
2320#endif
2321 (char_u *)0L}
2322#else
2323 (char_u *)NULL, PV_NONE,
2324 {(char_u *)0L, (char_u *)0L}
2325#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002326 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002327 {"shellquote", "shq", P_STRING|P_VI_DEF|P_SECURE,
2328 (char_u *)&p_shq, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002329 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002330 {"shellredir", "srr", P_STRING|P_VI_DEF|P_SECURE,
2331 (char_u *)&p_srr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002332 {(char_u *)">", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002333 {"shellslash", "ssl", P_BOOL|P_VI_DEF,
2334#ifdef BACKSLASH_IN_FILENAME
2335 (char_u *)&p_ssl, PV_NONE,
2336#else
2337 (char_u *)NULL, PV_NONE,
2338#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002339 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar26a60b42005-02-22 08:49:11 +00002340 {"shelltemp", "stmp", P_BOOL,
2341 (char_u *)&p_stmp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002342 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002343 {"shelltype", "st", P_NUM|P_VI_DEF,
2344#ifdef AMIGA
2345 (char_u *)&p_st, PV_NONE,
2346#else
2347 (char_u *)NULL, PV_NONE,
2348#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002349 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002350 {"shellxquote", "sxq", P_STRING|P_VI_DEF|P_SECURE,
2351 (char_u *)&p_sxq, PV_NONE,
2352 {
Bram Moolenaara06ecab2016-07-16 14:47:36 +02002353#if defined(UNIX) && defined(USE_SYSTEM)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002354 (char_u *)"\"",
2355#else
2356 (char_u *)"",
2357#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002358 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf66b3fc2012-02-20 22:18:30 +01002359 {"shellxescape", "sxe", P_STRING|P_VI_DEF|P_SECURE,
2360 (char_u *)&p_sxe, PV_NONE,
2361 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002362#if defined(WIN3264)
Bram Moolenaarf66b3fc2012-02-20 22:18:30 +01002363 (char_u *)"\"&|<>()@^",
2364#else
2365 (char_u *)"",
2366#endif
2367 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002368 {"shiftround", "sr", P_BOOL|P_VI_DEF|P_VIM,
2369 (char_u *)&p_sr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002370 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002371 {"shiftwidth", "sw", P_NUM|P_VI_DEF,
2372 (char_u *)&p_sw, PV_SW,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002373 {(char_u *)8L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002374 {"shortmess", "shm", P_STRING|P_VIM|P_FLAGLIST,
2375 (char_u *)&p_shm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002376 {(char_u *)"", (char_u *)"filnxtToO"}
2377 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002378 {"shortname", "sn", P_BOOL|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002379 (char_u *)&p_sn, PV_SN,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002380 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002381 {"showbreak", "sbr", P_STRING|P_VI_DEF|P_RALL,
2382#ifdef FEAT_LINEBREAK
2383 (char_u *)&p_sbr, PV_NONE,
2384#else
2385 (char_u *)NULL, PV_NONE,
2386#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002387 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002388 {"showcmd", "sc", P_BOOL|P_VIM,
2389#ifdef FEAT_CMDL_INFO
2390 (char_u *)&p_sc, PV_NONE,
2391#else
2392 (char_u *)NULL, PV_NONE,
2393#endif
2394 {(char_u *)FALSE,
2395#ifdef UNIX
2396 (char_u *)FALSE
2397#else
2398 (char_u *)TRUE
2399#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002400 } SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002401 {"showfulltag", "sft", P_BOOL|P_VI_DEF,
2402 (char_u *)&p_sft, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002403 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002404 {"showmatch", "sm", P_BOOL|P_VI_DEF,
2405 (char_u *)&p_sm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002406 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002407 {"showmode", "smd", P_BOOL|P_VIM,
2408 (char_u *)&p_smd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002409 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00002410 {"showtabline", "stal", P_NUM|P_VI_DEF|P_RALL,
2411#ifdef FEAT_WINDOWS
2412 (char_u *)&p_stal, PV_NONE,
2413#else
2414 (char_u *)NULL, PV_NONE,
2415#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002416 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002417 {"sidescroll", "ss", P_NUM|P_VI_DEF,
2418 (char_u *)&p_ss, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002419 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002420 {"sidescrolloff", "siso", P_NUM|P_VI_DEF|P_VIM|P_RBUF,
2421 (char_u *)&p_siso, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002422 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar95ec9d62016-08-12 18:29:59 +02002423 {"signcolumn", "scl", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN,
2424#ifdef FEAT_SIGNS
2425 (char_u *)VAR_WIN, PV_SCL,
Bram Moolenaarb3384832016-08-12 18:51:58 +02002426 {(char_u *)"auto", (char_u *)0L}
Bram Moolenaar95ec9d62016-08-12 18:29:59 +02002427#else
2428 (char_u *)NULL, PV_NONE,
2429 {(char_u *)NULL, (char_u *)0L}
2430#endif
Bram Moolenaarb3384832016-08-12 18:51:58 +02002431 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002432 {"slowopen", "slow", P_BOOL|P_VI_DEF,
2433 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002434 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002435 {"smartcase", "scs", P_BOOL|P_VI_DEF|P_VIM,
2436 (char_u *)&p_scs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002437 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002438 {"smartindent", "si", P_BOOL|P_VI_DEF|P_VIM,
2439#ifdef FEAT_SMARTINDENT
2440 (char_u *)&p_si, PV_SI,
2441#else
2442 (char_u *)NULL, PV_NONE,
2443#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002444 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002445 {"smarttab", "sta", P_BOOL|P_VI_DEF|P_VIM,
2446 (char_u *)&p_sta, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002447 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002448 {"softtabstop", "sts", P_NUM|P_VI_DEF|P_VIM,
2449 (char_u *)&p_sts, PV_STS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002450 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002451 {"sourceany", NULL, P_BOOL|P_VI_DEF,
2452 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002453 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar217ad922005-03-20 22:37:15 +00002454 {"spell", NULL, P_BOOL|P_VI_DEF|P_RWIN,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002455#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +00002456 (char_u *)VAR_WIN, PV_SPELL,
2457#else
2458 (char_u *)NULL, PV_NONE,
2459#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002460 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar488c6512005-08-11 20:09:58 +00002461 {"spellcapcheck", "spc", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002462#ifdef FEAT_SPELL
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00002463 (char_u *)&p_spc, PV_SPC,
Bram Moolenaar0dc065e2005-07-04 22:49:24 +00002464 {(char_u *)"[.?!]\\_[\\])'\" ]\\+", (char_u *)0L}
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00002465#else
2466 (char_u *)NULL, PV_NONE,
2467 {(char_u *)0L, (char_u *)0L}
2468#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002469 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002470 {"spellfile", "spf", P_STRING|P_EXPAND|P_ALLOCED|P_VI_DEF|P_SECURE
2471 |P_ONECOMMA,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002472#ifdef FEAT_SPELL
Bram Moolenaar82cf9b62005-06-07 21:09:25 +00002473 (char_u *)&p_spf, PV_SPF,
2474 {(char_u *)"", (char_u *)0L}
2475#else
2476 (char_u *)NULL, PV_NONE,
2477 {(char_u *)0L, (char_u *)0L}
2478#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002479 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002480 {"spelllang", "spl", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA
2481 |P_RBUF|P_EXPAND,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002482#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +00002483 (char_u *)&p_spl, PV_SPL,
Bram Moolenaar82cf9b62005-06-07 21:09:25 +00002484 {(char_u *)"en", (char_u *)0L}
Bram Moolenaar217ad922005-03-20 22:37:15 +00002485#else
2486 (char_u *)NULL, PV_NONE,
2487 {(char_u *)0L, (char_u *)0L}
2488#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002489 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002490 {"spellsuggest", "sps", P_STRING|P_VI_DEF|P_EXPAND|P_SECURE|P_ONECOMMA,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002491#ifdef FEAT_SPELL
Bram Moolenaard857f0e2005-06-21 22:37:39 +00002492 (char_u *)&p_sps, PV_NONE,
2493 {(char_u *)"best", (char_u *)0L}
2494#else
2495 (char_u *)NULL, PV_NONE,
2496 {(char_u *)0L, (char_u *)0L}
2497#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002498 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002499 {"splitbelow", "sb", P_BOOL|P_VI_DEF,
2500#ifdef FEAT_WINDOWS
2501 (char_u *)&p_sb, PV_NONE,
2502#else
2503 (char_u *)NULL, PV_NONE,
2504#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002505 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002506 {"splitright", "spr", P_BOOL|P_VI_DEF,
Bram Moolenaar44a2f922016-03-19 22:11:51 +01002507#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002508 (char_u *)&p_spr, PV_NONE,
2509#else
2510 (char_u *)NULL, PV_NONE,
2511#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002512 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002513 {"startofline", "sol", P_BOOL|P_VI_DEF|P_VIM,
2514 (char_u *)&p_sol, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002515 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002516 {"statusline" ,"stl", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT,
2517#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002518 (char_u *)&p_stl, PV_STL,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002519#else
2520 (char_u *)NULL, PV_NONE,
2521#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002522 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002523 {"suffixes", "su", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002524 (char_u *)&p_su, PV_NONE,
2525 {(char_u *)".bak,~,.o,.h,.info,.swp,.obj",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002526 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002527 {"suffixesadd", "sua", P_STRING|P_VI_DEF|P_ALLOCED|P_ONECOMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002528#ifdef FEAT_SEARCHPATH
Bram Moolenaar071d4272004-06-13 20:20:40 +00002529 (char_u *)&p_sua, PV_SUA,
2530 {(char_u *)"", (char_u *)0L}
2531#else
2532 (char_u *)NULL, PV_NONE,
2533 {(char_u *)0L, (char_u *)0L}
2534#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002535 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002536 {"swapfile", "swf", P_BOOL|P_VI_DEF|P_RSTAT,
2537 (char_u *)&p_swf, PV_SWF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002538 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002539 {"swapsync", "sws", P_STRING|P_VI_DEF,
2540 (char_u *)&p_sws, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002541 {(char_u *)"fsync", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002542 {"switchbuf", "swb", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002543 (char_u *)&p_swb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002544 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar3b56eb32005-07-11 22:40:32 +00002545 {"synmaxcol", "smc", P_NUM|P_VI_DEF|P_RBUF,
2546#ifdef FEAT_SYN_HL
2547 (char_u *)&p_smc, PV_SMC,
2548 {(char_u *)3000L, (char_u *)0L}
2549#else
2550 (char_u *)NULL, PV_NONE,
2551 {(char_u *)0L, (char_u *)0L}
2552#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002553 SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002554 {"syntax", "syn", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002555#ifdef FEAT_SYN_HL
2556 (char_u *)&p_syn, PV_SYN,
2557 {(char_u *)"", (char_u *)0L}
2558#else
2559 (char_u *)NULL, PV_NONE,
2560 {(char_u *)0L, (char_u *)0L}
2561#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002562 SCRIPTID_INIT},
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00002563 {"tabline", "tal", P_STRING|P_VI_DEF|P_RALL,
2564#ifdef FEAT_STL_OPT
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00002565 (char_u *)&p_tal, PV_NONE,
2566#else
2567 (char_u *)NULL, PV_NONE,
2568#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002569 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarfd2ac762006-03-01 22:09:21 +00002570 {"tabpagemax", "tpm", P_NUM|P_VI_DEF,
2571#ifdef FEAT_WINDOWS
2572 (char_u *)&p_tpm, PV_NONE,
2573#else
2574 (char_u *)NULL, PV_NONE,
2575#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002576 {(char_u *)10L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002577 {"tabstop", "ts", P_NUM|P_VI_DEF|P_RBUF,
2578 (char_u *)&p_ts, PV_TS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002579 {(char_u *)8L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002580 {"tagbsearch", "tbs", P_BOOL|P_VI_DEF,
2581 (char_u *)&p_tbs, PV_NONE,
2582#ifdef VMS /* binary searching doesn't appear to work on VMS */
2583 {(char_u *)0L, (char_u *)0L}
2584#else
2585 {(char_u *)TRUE, (char_u *)0L}
2586#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002587 SCRIPTID_INIT},
Bram Moolenaar0f6562e2015-11-24 18:48:14 +01002588 {"tagcase", "tc", P_STRING|P_VIM,
2589 (char_u *)&p_tc, PV_TC,
2590 {(char_u *)"followic", (char_u *)"followic"} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002591 {"taglength", "tl", P_NUM|P_VI_DEF,
2592 (char_u *)&p_tl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002593 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002594 {"tagrelative", "tr", P_BOOL|P_VIM,
2595 (char_u *)&p_tr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002596 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002597 {"tags", "tag", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002598 (char_u *)&p_tags, PV_TAGS,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002599 {
2600#if defined(FEAT_EMACS_TAGS) && !defined(CASE_INSENSITIVE_FILENAME)
2601 (char_u *)"./tags,./TAGS,tags,TAGS",
2602#else
2603 (char_u *)"./tags,tags",
2604#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002605 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002606 {"tagstack", "tgst", P_BOOL|P_VI_DEF,
2607 (char_u *)&p_tgst, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002608 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01002609#if defined(DYNAMIC_TCL)
Bram Moolenaara6e42502016-04-20 16:19:52 +02002610 {"tcldll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01002611 (char_u *)&p_tcldll, PV_NONE,
2612 {(char_u *)DYNAMIC_TCL_DLL, (char_u *)0L}
2613 SCRIPTID_INIT},
2614#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002615 {"term", NULL, P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL,
2616 (char_u *)&T_NAME, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002617 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002618 {"termbidi", "tbidi", P_BOOL|P_VI_DEF,
2619#ifdef FEAT_ARABIC
2620 (char_u *)&p_tbidi, PV_NONE,
2621#else
2622 (char_u *)NULL, PV_NONE,
2623#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002624 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002625 {"termencoding", "tenc", P_STRING|P_VI_DEF|P_RCLR,
2626#ifdef FEAT_MBYTE
2627 (char_u *)&p_tenc, PV_NONE,
2628 {(char_u *)"", (char_u *)0L}
2629#else
2630 (char_u *)NULL, PV_NONE,
2631 {(char_u *)0L, (char_u *)0L}
2632#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002633 SCRIPTID_INIT},
Bram Moolenaar61be73b2016-04-29 22:59:22 +02002634 {"termguicolors", "tgc", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
2635#ifdef FEAT_TERMGUICOLORS
2636 (char_u *)&p_tgc, PV_NONE,
2637 {(char_u *)FALSE, (char_u *)FALSE}
2638#else
2639 (char_u*)NULL, PV_NONE,
2640 {(char_u *)FALSE, (char_u *)FALSE}
2641#endif
2642 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002643 {"terse", NULL, P_BOOL|P_VI_DEF,
2644 (char_u *)&p_terse, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002645 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002646 {"textauto", "ta", P_BOOL|P_VIM,
2647 (char_u *)&p_ta, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002648 {(char_u *)DFLT_TEXTAUTO, (char_u *)TRUE}
2649 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002650 {"textmode", "tx", P_BOOL|P_VI_DEF|P_NO_MKRC,
2651 (char_u *)&p_tx, PV_TX,
2652 {
2653#ifdef USE_CRNL
2654 (char_u *)TRUE,
2655#else
2656 (char_u *)FALSE,
2657#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002658 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar1a384422010-07-14 19:53:30 +02002659 {"textwidth", "tw", P_NUM|P_VI_DEF|P_VIM|P_RBUF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002660 (char_u *)&p_tw, PV_TW,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002661 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002662 {"thesaurus", "tsr", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002663#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002664 (char_u *)&p_tsr, PV_TSR,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002665#else
2666 (char_u *)NULL, PV_NONE,
2667#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002668 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002669 {"tildeop", "top", P_BOOL|P_VI_DEF|P_VIM,
2670 (char_u *)&p_to, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002671 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002672 {"timeout", "to", P_BOOL|P_VI_DEF,
2673 (char_u *)&p_timeout, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002674 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002675 {"timeoutlen", "tm", P_NUM|P_VI_DEF,
2676 (char_u *)&p_tm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002677 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002678 {"title", NULL, P_BOOL|P_VI_DEF,
2679#ifdef FEAT_TITLE
2680 (char_u *)&p_title, PV_NONE,
2681#else
2682 (char_u *)NULL, PV_NONE,
2683#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002684 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002685 {"titlelen", NULL, P_NUM|P_VI_DEF,
2686#ifdef FEAT_TITLE
2687 (char_u *)&p_titlelen, PV_NONE,
2688#else
2689 (char_u *)NULL, PV_NONE,
2690#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002691 {(char_u *)85L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00002692 {"titleold", NULL, P_STRING|P_VI_DEF|P_GETTEXT|P_SECURE|P_NO_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002693#ifdef FEAT_TITLE
2694 (char_u *)&p_titleold, PV_NONE,
2695 {(char_u *)N_("Thanks for flying Vim"),
2696 (char_u *)0L}
2697#else
2698 (char_u *)NULL, PV_NONE,
2699 {(char_u *)0L, (char_u *)0L}
2700#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002701 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002702 {"titlestring", NULL, P_STRING|P_VI_DEF,
2703#ifdef FEAT_TITLE
2704 (char_u *)&p_titlestring, PV_NONE,
2705#else
2706 (char_u *)NULL, PV_NONE,
2707#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002708 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002709#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002710 {"toolbar", "tb", P_STRING|P_ONECOMMA|P_VI_DEF|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002711 (char_u *)&p_toolbar, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002712 {(char_u *)"icons,tooltips", (char_u *)0L}
2713 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002714#endif
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002715#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002716 {"toolbariconsize", "tbis", P_STRING|P_VI_DEF,
2717 (char_u *)&p_tbis, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002718 {(char_u *)"small", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002719#endif
2720 {"ttimeout", NULL, P_BOOL|P_VI_DEF|P_VIM,
2721 (char_u *)&p_ttimeout, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002722 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002723 {"ttimeoutlen", "ttm", P_NUM|P_VI_DEF,
2724 (char_u *)&p_ttm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002725 {(char_u *)-1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002726 {"ttybuiltin", "tbi", P_BOOL|P_VI_DEF,
2727 (char_u *)&p_tbi, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002728 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002729 {"ttyfast", "tf", P_BOOL|P_NO_MKRC|P_VI_DEF,
2730 (char_u *)&p_tf, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002731 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002732 {"ttymouse", "ttym", P_STRING|P_NODEFAULT|P_NO_MKRC|P_VI_DEF,
2733#if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
2734 (char_u *)&p_ttym, PV_NONE,
2735#else
2736 (char_u *)NULL, PV_NONE,
2737#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002738 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002739 {"ttyscroll", "tsl", P_NUM|P_VI_DEF,
2740 (char_u *)&p_ttyscroll, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002741 {(char_u *)999L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002742 {"ttytype", "tty", P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL,
2743 (char_u *)&T_NAME, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002744 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002745 {"undodir", "udir", P_STRING|P_EXPAND|P_ONECOMMA|P_NODUP|P_SECURE
2746 |P_VI_DEF,
Bram Moolenaar55debbe2010-05-23 23:34:36 +02002747#ifdef FEAT_PERSISTENT_UNDO
2748 (char_u *)&p_udir, PV_NONE,
2749 {(char_u *)".", (char_u *)0L}
2750#else
2751 (char_u *)NULL, PV_NONE,
2752 {(char_u *)0L, (char_u *)0L}
2753#endif
2754 SCRIPTID_INIT},
2755 {"undofile", "udf", P_BOOL|P_VI_DEF|P_VIM,
2756#ifdef FEAT_PERSISTENT_UNDO
2757 (char_u *)&p_udf, PV_UDF,
2758#else
2759 (char_u *)NULL, PV_NONE,
2760#endif
2761 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002762 {"undolevels", "ul", P_NUM|P_VI_DEF,
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01002763 (char_u *)&p_ul, PV_UL,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002764 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01002765#if defined(UNIX) || defined(WIN3264) || defined(VMS)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002766 (char_u *)1000L,
2767#else
2768 (char_u *)100L,
2769#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002770 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar59f931e2010-07-24 20:27:03 +02002771 {"undoreload", "ur", P_NUM|P_VI_DEF,
2772 (char_u *)&p_ur, PV_NONE,
2773 { (char_u *)10000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002774 {"updatecount", "uc", P_NUM|P_VI_DEF,
2775 (char_u *)&p_uc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002776 {(char_u *)200L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002777 {"updatetime", "ut", P_NUM|P_VI_DEF,
2778 (char_u *)&p_ut, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002779 {(char_u *)4000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002780 {"verbose", "vbs", P_NUM|P_VI_DEF,
2781 (char_u *)&p_verbose, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002782 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar54ee7752005-05-31 22:22:17 +00002783 {"verbosefile", "vfile", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2784 (char_u *)&p_vfile, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002785 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002786 {"viewdir", "vdir", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2787#ifdef FEAT_SESSION
2788 (char_u *)&p_vdir, PV_NONE,
2789 {(char_u *)DFLT_VDIR, (char_u *)0L}
2790#else
2791 (char_u *)NULL, PV_NONE,
2792 {(char_u *)0L, (char_u *)0L}
2793#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002794 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002795 {"viewoptions", "vop", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002796#ifdef FEAT_SESSION
2797 (char_u *)&p_vop, PV_NONE,
2798 {(char_u *)"folds,options,cursor", (char_u *)0L}
2799#else
2800 (char_u *)NULL, PV_NONE,
2801 {(char_u *)0L, (char_u *)0L}
2802#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002803 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002804 {"viminfo", "vi", P_STRING|P_ONECOMMA|P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002805#ifdef FEAT_VIMINFO
2806 (char_u *)&p_viminfo, PV_NONE,
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002807#if defined(MSWIN)
Bram Moolenaard812df62008-11-09 12:46:09 +00002808 {(char_u *)"", (char_u *)"'100,<50,s10,h,rA:,rB:"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002809#else
2810# ifdef AMIGA
2811 {(char_u *)"",
Bram Moolenaard812df62008-11-09 12:46:09 +00002812 (char_u *)"'100,<50,s10,h,rdf0:,rdf1:,rdf2:"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002813# else
Bram Moolenaard812df62008-11-09 12:46:09 +00002814 {(char_u *)"", (char_u *)"'100,<50,s10,h"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002815# endif
2816#endif
2817#else
2818 (char_u *)NULL, PV_NONE,
2819 {(char_u *)0L, (char_u *)0L}
2820#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002821 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002822 {"virtualedit", "ve", P_STRING|P_ONECOMMA|P_NODUP|P_VI_DEF
2823 |P_VIM|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002824#ifdef FEAT_VIRTUALEDIT
2825 (char_u *)&p_ve, PV_NONE,
2826 {(char_u *)"", (char_u *)""}
2827#else
2828 (char_u *)NULL, PV_NONE,
2829 {(char_u *)0L, (char_u *)0L}
2830#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002831 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002832 {"visualbell", "vb", P_BOOL|P_VI_DEF,
2833 (char_u *)&p_vb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002834 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002835 {"w300", NULL, P_NUM|P_VI_DEF,
2836 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002837 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002838 {"w1200", NULL, P_NUM|P_VI_DEF,
2839 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002840 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002841 {"w9600", NULL, P_NUM|P_VI_DEF,
2842 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002843 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002844 {"warn", NULL, P_BOOL|P_VI_DEF,
2845 (char_u *)&p_warn, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002846 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002847 {"weirdinvert", "wiv", P_BOOL|P_VI_DEF|P_RCLR,
2848 (char_u *)&p_wiv, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002849 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002850 {"whichwrap", "ww", P_STRING|P_VIM|P_ONECOMMA|P_FLAGLIST,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002851 (char_u *)&p_ww, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002852 {(char_u *)"", (char_u *)"b,s"} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002853 {"wildchar", "wc", P_NUM|P_VIM,
2854 (char_u *)&p_wc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002855 {(char_u *)(long)Ctrl_E, (char_u *)(long)TAB}
2856 SCRIPTID_INIT},
Bram Moolenaar94950a92010-12-02 16:01:29 +01002857 {"wildcharm", "wcm", P_NUM|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002858 (char_u *)&p_wcm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002859 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002860 {"wildignore", "wig", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002861#ifdef FEAT_WILDIGN
2862 (char_u *)&p_wig, PV_NONE,
2863#else
2864 (char_u *)NULL, PV_NONE,
2865#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002866 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar94950a92010-12-02 16:01:29 +01002867 {"wildignorecase", "wic", P_BOOL|P_VI_DEF,
2868 (char_u *)&p_wic, PV_NONE,
2869 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002870 {"wildmenu", "wmnu", P_BOOL|P_VI_DEF,
2871#ifdef FEAT_WILDMENU
2872 (char_u *)&p_wmnu, PV_NONE,
2873#else
2874 (char_u *)NULL, PV_NONE,
2875#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002876 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002877 {"wildmode", "wim", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002878 (char_u *)&p_wim, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002879 {(char_u *)"full", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00002880 {"wildoptions", "wop", P_STRING|P_VI_DEF,
2881#ifdef FEAT_CMDL_COMPL
2882 (char_u *)&p_wop, PV_NONE,
2883 {(char_u *)"", (char_u *)0L}
2884#else
2885 (char_u *)NULL, PV_NONE,
2886 {(char_u *)NULL, (char_u *)0L}
2887#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002888 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002889 {"winaltkeys", "wak", P_STRING|P_VI_DEF,
2890#ifdef FEAT_WAK
2891 (char_u *)&p_wak, PV_NONE,
2892 {(char_u *)"menu", (char_u *)0L}
2893#else
2894 (char_u *)NULL, PV_NONE,
2895 {(char_u *)NULL, (char_u *)0L}
2896#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002897 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002898 {"window", "wi", P_NUM|P_VI_DEF,
Bram Moolenaar4399ef42005-02-12 14:29:27 +00002899 (char_u *)&p_window, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002900 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002901 {"winheight", "wh", P_NUM|P_VI_DEF,
2902#ifdef FEAT_WINDOWS
2903 (char_u *)&p_wh, PV_NONE,
2904#else
2905 (char_u *)NULL, PV_NONE,
2906#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002907 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002908 {"winfixheight", "wfh", P_BOOL|P_VI_DEF|P_RSTAT,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002909#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002910 (char_u *)VAR_WIN, PV_WFH,
2911#else
2912 (char_u *)NULL, PV_NONE,
2913#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002914 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002915 {"winfixwidth", "wfw", P_BOOL|P_VI_DEF|P_RSTAT,
Bram Moolenaar44a2f922016-03-19 22:11:51 +01002916#ifdef FEAT_WINDOWS
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002917 (char_u *)VAR_WIN, PV_WFW,
2918#else
2919 (char_u *)NULL, PV_NONE,
2920#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002921 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002922 {"winminheight", "wmh", P_NUM|P_VI_DEF,
2923#ifdef FEAT_WINDOWS
2924 (char_u *)&p_wmh, PV_NONE,
2925#else
2926 (char_u *)NULL, PV_NONE,
2927#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002928 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002929 {"winminwidth", "wmw", P_NUM|P_VI_DEF,
Bram Moolenaar44a2f922016-03-19 22:11:51 +01002930#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002931 (char_u *)&p_wmw, PV_NONE,
2932#else
2933 (char_u *)NULL, PV_NONE,
2934#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002935 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002936 {"winwidth", "wiw", P_NUM|P_VI_DEF,
Bram Moolenaar44a2f922016-03-19 22:11:51 +01002937#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002938 (char_u *)&p_wiw, PV_NONE,
2939#else
2940 (char_u *)NULL, PV_NONE,
2941#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002942 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002943 {"wrap", NULL, P_BOOL|P_VI_DEF|P_RWIN,
2944 (char_u *)VAR_WIN, PV_WRAP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002945 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002946 {"wrapmargin", "wm", P_NUM|P_VI_DEF,
2947 (char_u *)&p_wm, PV_WM,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002948 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002949 {"wrapscan", "ws", P_BOOL|P_VI_DEF,
2950 (char_u *)&p_ws, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002951 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002952 {"write", NULL, P_BOOL|P_VI_DEF,
2953 (char_u *)&p_write, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002954 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002955 {"writeany", "wa", P_BOOL|P_VI_DEF,
2956 (char_u *)&p_wa, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002957 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002958 {"writebackup", "wb", P_BOOL|P_VI_DEF|P_VIM,
2959 (char_u *)&p_wb, PV_NONE,
2960 {
2961#ifdef FEAT_WRITEBACKUP
2962 (char_u *)TRUE,
2963#else
2964 (char_u *)FALSE,
2965#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002966 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002967 {"writedelay", "wd", P_NUM|P_VI_DEF,
2968 (char_u *)&p_wd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002969 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002970
2971/* terminal output codes */
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002972#define p_term(sss, vvv) {sss, NULL, P_STRING|P_VI_DEF|P_RALL|P_SECURE, \
Bram Moolenaar071d4272004-06-13 20:20:40 +00002973 (char_u *)&vvv, PV_NONE, \
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002974 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002975
2976 p_term("t_AB", T_CAB)
2977 p_term("t_AF", T_CAF)
2978 p_term("t_AL", T_CAL)
2979 p_term("t_al", T_AL)
2980 p_term("t_bc", T_BC)
2981 p_term("t_cd", T_CD)
2982 p_term("t_ce", T_CE)
2983 p_term("t_cl", T_CL)
2984 p_term("t_cm", T_CM)
Bram Moolenaar450ca432015-11-10 13:30:39 +01002985 p_term("t_Ce", T_UCE)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002986 p_term("t_Co", T_CCO)
2987 p_term("t_CS", T_CCS)
Bram Moolenaar450ca432015-11-10 13:30:39 +01002988 p_term("t_Cs", T_UCS)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002989 p_term("t_cs", T_CS)
Bram Moolenaar44a2f922016-03-19 22:11:51 +01002990#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002991 p_term("t_CV", T_CSV)
2992#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002993 p_term("t_da", T_DA)
2994 p_term("t_db", T_DB)
2995 p_term("t_DL", T_CDL)
2996 p_term("t_dl", T_DL)
Bram Moolenaare5401222015-06-25 19:16:56 +02002997 p_term("t_EI", T_CEI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002998 p_term("t_fs", T_FS)
2999 p_term("t_IE", T_CIE)
3000 p_term("t_IS", T_CIS)
3001 p_term("t_ke", T_KE)
3002 p_term("t_ks", T_KS)
3003 p_term("t_le", T_LE)
3004 p_term("t_mb", T_MB)
3005 p_term("t_md", T_MD)
3006 p_term("t_me", T_ME)
3007 p_term("t_mr", T_MR)
3008 p_term("t_ms", T_MS)
3009 p_term("t_nd", T_ND)
3010 p_term("t_op", T_OP)
Bram Moolenaare5401222015-06-25 19:16:56 +02003011 p_term("t_RB", T_RBG)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003012 p_term("t_RI", T_CRI)
3013 p_term("t_RV", T_CRV)
3014 p_term("t_Sb", T_CSB)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003015 p_term("t_se", T_SE)
Bram Moolenaare5401222015-06-25 19:16:56 +02003016 p_term("t_Sf", T_CSF)
3017 p_term("t_SI", T_CSI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003018 p_term("t_so", T_SO)
Bram Moolenaare5401222015-06-25 19:16:56 +02003019 p_term("t_SR", T_CSR)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003020 p_term("t_sr", T_SR)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003021 p_term("t_te", T_TE)
3022 p_term("t_ti", T_TI)
Bram Moolenaare5401222015-06-25 19:16:56 +02003023 p_term("t_ts", T_TS)
3024 p_term("t_u7", T_U7)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003025 p_term("t_ue", T_UE)
3026 p_term("t_us", T_US)
Bram Moolenaare5401222015-06-25 19:16:56 +02003027 p_term("t_ut", T_UT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003028 p_term("t_vb", T_VB)
3029 p_term("t_ve", T_VE)
3030 p_term("t_vi", T_VI)
3031 p_term("t_vs", T_VS)
3032 p_term("t_WP", T_CWP)
3033 p_term("t_WS", T_CWS)
Bram Moolenaar494838a2015-02-10 19:20:37 +01003034 p_term("t_xn", T_XN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003035 p_term("t_xs", T_XS)
3036 p_term("t_ZH", T_CZH)
3037 p_term("t_ZR", T_CZR)
Bram Moolenaar8a633e32016-04-21 21:10:14 +02003038 p_term("t_8f", T_8F)
3039 p_term("t_8b", T_8B)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003040
3041/* terminal key codes are not in here */
3042
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003043 /* end marker */
3044 {NULL, NULL, 0, NULL, PV_NONE, {NULL, NULL} SCRIPTID_INIT}
Bram Moolenaar071d4272004-06-13 20:20:40 +00003045};
3046
3047#define PARAM_COUNT (sizeof(options) / sizeof(struct vimoption))
3048
3049#ifdef FEAT_MBYTE
3050static char *(p_ambw_values[]) = {"single", "double", NULL};
3051#endif
3052static char *(p_bg_values[]) = {"light", "dark", NULL};
Bram Moolenaar887c1fe2016-01-02 17:56:35 +01003053static char *(p_nf_values[]) = {"bin", "octal", "hex", "alpha", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003054static char *(p_ff_values[]) = {FF_UNIX, FF_DOS, FF_MAC, NULL};
Bram Moolenaar49771f42010-07-20 17:32:38 +02003055#ifdef FEAT_CRYPT
Bram Moolenaar8f4ac012014-08-10 13:38:34 +02003056static char *(p_cm_values[]) = {"zip", "blowfish", "blowfish2", NULL};
Bram Moolenaar49771f42010-07-20 17:32:38 +02003057#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00003058#ifdef FEAT_CMDL_COMPL
3059static char *(p_wop_values[]) = {"tagfile", NULL};
3060#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003061#ifdef FEAT_WAK
3062static char *(p_wak_values[]) = {"yes", "menu", "no", NULL};
3063#endif
3064static char *(p_mousem_values[]) = {"extend", "popup", "popup_setpos", "mac", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003065static char *(p_sel_values[]) = {"inclusive", "exclusive", "old", NULL};
3066static char *(p_slm_values[]) = {"mouse", "key", "cmd", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003067static char *(p_km_values[]) = {"startsel", "stopsel", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003068#ifdef FEAT_BROWSE
3069static char *(p_bsdir_values[]) = {"current", "last", "buffer", NULL};
3070#endif
3071#ifdef FEAT_SCROLLBIND
3072static char *(p_scbopt_values[]) = {"ver", "hor", "jump", NULL};
3073#endif
Bram Moolenaar57657d82006-04-21 22:12:41 +00003074static char *(p_debug_values[]) = {"msg", "throw", "beep", NULL};
Bram Moolenaar44a2f922016-03-19 22:11:51 +01003075#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00003076static char *(p_ead_values[]) = {"both", "ver", "hor", NULL};
3077#endif
3078#if defined(FEAT_QUICKFIX)
Bram Moolenaar21cf8232004-07-16 20:18:37 +00003079# ifdef FEAT_AUTOCMD
3080static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", "acwrite", NULL};
3081# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00003082static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", NULL};
Bram Moolenaar21cf8232004-07-16 20:18:37 +00003083# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003084static char *(p_bufhidden_values[]) = {"hide", "unload", "delete", "wipe", NULL};
3085#endif
3086static char *(p_bs_values[]) = {"indent", "eol", "start", NULL};
3087#ifdef FEAT_FOLDING
3088static char *(p_fdm_values[]) = {"manual", "expr", "marker", "indent", "syntax",
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003089# ifdef FEAT_DIFF
Bram Moolenaar071d4272004-06-13 20:20:40 +00003090 "diff",
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003091# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003092 NULL};
3093static char *(p_fcl_values[]) = {"all", NULL};
3094#endif
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003095#ifdef FEAT_INS_EXPAND
Bram Moolenaarb6be1e22015-07-10 18:18:40 +02003096static char *(p_cot_values[]) = {"menu", "menuone", "longest", "preview", "noinsert", "noselect", NULL};
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003097#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +02003098#ifdef FEAT_SIGNS
3099static char *(p_scl_values[]) = {"yes", "no", "auto", NULL};
3100#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003101
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003102static void set_option_default(int, int opt_flags, int compatible);
3103static void set_options_default(int opt_flags);
3104static char_u *term_bg_default(void);
3105static void did_set_option(int opt_idx, int opt_flags, int new_value);
3106static char_u *illegal_char(char_u *, int);
3107static int string_to_key(char_u *arg);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003108#ifdef FEAT_CMDWIN
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003109static char_u *check_cedit(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003110#endif
3111#ifdef FEAT_TITLE
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003112static void did_set_title(int icon);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003113#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003114static char_u *option_expand(int opt_idx, char_u *val);
3115static void didset_options(void);
3116static void didset_options2(void);
3117static void check_string_option(char_u **pp);
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003118#if defined(FEAT_EVAL) || defined(PROTO)
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003119static long_u *insecure_flag(int opt_idx, int opt_flags);
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003120#else
3121# define insecure_flag(opt_idx, opt_flags) (&options[opt_idx].flags)
3122#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003123static void set_string_option_global(int opt_idx, char_u **varp);
3124static char_u *set_string_option(int opt_idx, char_u *value, int opt_flags);
3125static 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);
3126static char_u *set_chars_option(char_u **varp);
Bram Moolenaar1a384422010-07-14 19:53:30 +02003127#ifdef FEAT_SYN_HL
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003128static int int_cmp(const void *a, const void *b);
Bram Moolenaar1a384422010-07-14 19:53:30 +02003129#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003130#ifdef FEAT_CLIPBOARD
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003131static char_u *check_clipboard_option(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003132#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00003133#ifdef FEAT_SPELL
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003134static char_u *did_set_spell_option(int is_spellfile);
3135static char_u *compile_cap_prog(synblock_T *synblock);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00003136#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003137#ifdef FEAT_EVAL
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003138static void set_option_scriptID_idx(int opt_idx, int opt_flags, int id);
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003139#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003140static char_u *set_bool_option(int opt_idx, char_u *varp, int value, int opt_flags);
3141static char_u *set_num_option(int opt_idx, char_u *varp, long value, char_u *errbuf, size_t errbuflen, int opt_flags);
3142static void check_redraw(long_u flags);
3143static int findoption(char_u *);
3144static int find_key_option(char_u *);
3145static void showoptions(int all, int opt_flags);
3146static int optval_default(struct vimoption *, char_u *varp);
3147static void showoneopt(struct vimoption *, int opt_flags);
3148static int put_setstring(FILE *fd, char *cmd, char *name, char_u **valuep, int expand);
3149static int put_setnum(FILE *fd, char *cmd, char *name, long *valuep);
3150static int put_setbool(FILE *fd, char *cmd, char *name, int value);
3151static int istermoption(struct vimoption *);
3152static char_u *get_varp_scope(struct vimoption *p, int opt_flags);
3153static char_u *get_varp(struct vimoption *);
3154static void option_value2string(struct vimoption *, int opt_flags);
3155static void check_winopt(winopt_T *wop);
3156static int wc_use_keyname(char_u *varp, long *wcp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003157#ifdef FEAT_LANGMAP
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003158static void langmap_init(void);
3159static void langmap_set(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003160#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003161static void paste_option_changed(void);
3162static void compatible_set(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003163#ifdef FEAT_LINEBREAK
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003164static void fill_breakat_flags(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003165#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003166static int opt_strings_flags(char_u *val, char **values, unsigned *flagp, int list);
3167static int check_opt_strings(char_u *val, char **values, int);
3168static int check_opt_wim(void);
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02003169#ifdef FEAT_LINEBREAK
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003170static int briopt_check(win_T *wp);
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02003171#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003172
3173/*
3174 * Initialize the options, first part.
3175 *
3176 * Called only once from main(), just after creating the first buffer.
3177 */
3178 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003179set_init_1(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003180{
3181 char_u *p;
3182 int opt_idx;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00003183 long_u n;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003184
3185#ifdef FEAT_LANGMAP
3186 langmap_init();
3187#endif
3188
3189 /* Be Vi compatible by default */
3190 p_cp = TRUE;
3191
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003192 /* Use POSIX compatibility when $VIM_POSIX is set. */
3193 if (mch_getenv((char_u *)"VIM_POSIX") != NULL)
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003194 {
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003195 set_string_default("cpo", (char_u *)CPO_ALL);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003196 set_string_default("shm", (char_u *)"A");
3197 }
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003198
Bram Moolenaar071d4272004-06-13 20:20:40 +00003199 /*
3200 * Find default value for 'shell' option.
Bram Moolenaar7c626922005-02-07 22:01:03 +00003201 * Don't use it if it is empty.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003202 */
Bram Moolenaar7c626922005-02-07 22:01:03 +00003203 if (((p = mch_getenv((char_u *)"SHELL")) != NULL && *p != NUL)
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003204#if defined(MSWIN)
Bram Moolenaar7c626922005-02-07 22:01:03 +00003205 || ((p = mch_getenv((char_u *)"COMSPEC")) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003206# ifdef WIN3264
Bram Moolenaar6aa2cd42016-02-16 15:06:59 +01003207 || ((p = (char_u *)default_shell()) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003208# endif
3209#endif
Bram Moolenaar7c626922005-02-07 22:01:03 +00003210 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00003211 set_string_default("sh", p);
3212
3213#ifdef FEAT_WILDIGN
3214 /*
3215 * Set the default for 'backupskip' to include environment variables for
3216 * temp files.
3217 */
3218 {
3219# ifdef UNIX
3220 static char *(names[4]) = {"", "TMPDIR", "TEMP", "TMP"};
3221# else
3222 static char *(names[3]) = {"TMPDIR", "TEMP", "TMP"};
3223# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003224 int len;
3225 garray_T ga;
3226 int mustfree;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003227
3228 ga_init2(&ga, 1, 100);
3229 for (n = 0; n < (long)(sizeof(names) / sizeof(char *)); ++n)
3230 {
Bram Moolenaar05159a02005-02-26 23:04:13 +00003231 mustfree = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003232# ifdef UNIX
3233 if (*names[n] == NUL)
3234 p = (char_u *)"/tmp";
3235 else
3236# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003237 p = vim_getenv((char_u *)names[n], &mustfree);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003238 if (p != NULL && *p != NUL)
3239 {
3240 /* First time count the NUL, otherwise count the ','. */
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00003241 len = (int)STRLEN(p) + 3;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003242 if (ga_grow(&ga, len) == OK)
3243 {
3244 if (ga.ga_len > 0)
3245 STRCAT(ga.ga_data, ",");
3246 STRCAT(ga.ga_data, p);
3247 add_pathsep(ga.ga_data);
3248 STRCAT(ga.ga_data, "*");
Bram Moolenaar071d4272004-06-13 20:20:40 +00003249 ga.ga_len += len;
3250 }
3251 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00003252 if (mustfree)
3253 vim_free(p);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003254 }
3255 if (ga.ga_data != NULL)
3256 {
3257 set_string_default("bsk", ga.ga_data);
3258 vim_free(ga.ga_data);
3259 }
3260 }
3261#endif
3262
3263 /*
3264 * 'maxmemtot' and 'maxmem' may have to be adjusted for available memory
3265 */
3266 opt_idx = findoption((char_u *)"maxmemtot");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003267 if (opt_idx >= 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003268 {
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003269#if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM)
3270 if (options[opt_idx].def_val[VI_DEFAULT] == (char_u *)0L)
3271#endif
3272 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00003273#ifdef HAVE_AVAIL_MEM
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003274 /* Use amount of memory available at this moment. */
Bram Moolenaar11b73d62012-06-29 15:51:30 +02003275 n = (mch_avail_mem(FALSE) >> 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003276#else
3277# ifdef HAVE_TOTAL_MEM
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003278 /* Use amount of memory available to Vim. */
Bram Moolenaar914572a2007-05-01 11:37:47 +00003279 n = (mch_total_mem(FALSE) >> 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003280# else
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003281 n = (0x7fffffff >> 11);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003282# endif
3283#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003284 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n;
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003285 opt_idx = findoption((char_u *)"maxmem");
3286 if (opt_idx >= 0)
3287 {
3288#if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM)
Bram Moolenaar35be4532015-12-11 22:38:36 +01003289 if ((long)(long_i)options[opt_idx].def_val[VI_DEFAULT] > (long)n
3290 || (long)(long_i)options[opt_idx].def_val[VI_DEFAULT] == 0L)
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003291#endif
3292 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n;
3293 }
3294 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003295 }
3296
Bram Moolenaar071d4272004-06-13 20:20:40 +00003297#ifdef FEAT_SEARCHPATH
3298 {
3299 char_u *cdpath;
3300 char_u *buf;
3301 int i;
3302 int j;
Bram Moolenaar05159a02005-02-26 23:04:13 +00003303 int mustfree = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003304
3305 /* Initialize the 'cdpath' option's default value. */
Bram Moolenaar05159a02005-02-26 23:04:13 +00003306 cdpath = vim_getenv((char_u *)"CDPATH", &mustfree);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003307 if (cdpath != NULL)
3308 {
3309 buf = alloc((unsigned)((STRLEN(cdpath) << 1) + 2));
3310 if (buf != NULL)
3311 {
3312 buf[0] = ','; /* start with ",", current dir first */
3313 j = 1;
3314 for (i = 0; cdpath[i] != NUL; ++i)
3315 {
3316 if (vim_ispathlistsep(cdpath[i]))
3317 buf[j++] = ',';
3318 else
3319 {
3320 if (cdpath[i] == ' ' || cdpath[i] == ',')
3321 buf[j++] = '\\';
3322 buf[j++] = cdpath[i];
3323 }
3324 }
3325 buf[j] = NUL;
3326 opt_idx = findoption((char_u *)"cdpath");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003327 if (opt_idx >= 0)
3328 {
3329 options[opt_idx].def_val[VI_DEFAULT] = buf;
3330 options[opt_idx].flags |= P_DEF_ALLOCED;
3331 }
Bram Moolenaara9d52e32010-07-31 16:44:19 +02003332 else
3333 vim_free(buf); /* cannot happen */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003334 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00003335 if (mustfree)
3336 vim_free(cdpath);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003337 }
3338 }
3339#endif
3340
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003341#if defined(FEAT_POSTSCRIPT) && (defined(MSWIN) || defined(VMS) || defined(EBCDIC) || defined(MAC) || defined(hpux))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003342 /* Set print encoding on platforms that don't default to latin1 */
3343 set_string_default("penc",
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003344# if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003345 (char_u *)"cp1252"
3346# else
3347# ifdef VMS
3348 (char_u *)"dec-mcs"
3349# else
3350# ifdef EBCDIC
3351 (char_u *)"ebcdic-uk"
3352# else
3353# ifdef MAC
3354 (char_u *)"mac-roman"
3355# else /* HPUX */
3356 (char_u *)"hp-roman8"
3357# endif
3358# endif
3359# endif
3360# endif
3361 );
3362#endif
3363
3364#ifdef FEAT_POSTSCRIPT
3365 /* 'printexpr' must be allocated to be able to evaluate it. */
3366 set_string_default("pexpr",
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003367# if defined(MSWIN)
Bram Moolenaared203462004-06-16 11:19:22 +00003368 (char_u *)"system('copy' . ' ' . v:fname_in . (&printdevice == '' ? ' LPT1:' : (' \"' . &printdevice . '\"'))) . delete(v:fname_in)"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003369# else
3370# ifdef VMS
3371 (char_u *)"system('print/delete' . (&printdevice == '' ? '' : ' /queue=' . &printdevice) . ' ' . v:fname_in)"
3372
3373# else
3374 (char_u *)"system('lpr' . (&printdevice == '' ? '' : ' -P' . &printdevice) . ' ' . v:fname_in) . delete(v:fname_in) + v:shell_error"
3375# endif
3376# endif
3377 );
3378#endif
3379
3380 /*
3381 * Set all the options (except the terminal options) to their default
3382 * value. Also set the global value for local options.
3383 */
3384 set_options_default(0);
3385
3386#ifdef FEAT_GUI
3387 if (found_reverse_arg)
3388 set_option_value((char_u *)"bg", 0L, (char_u *)"dark", 0);
3389#endif
3390
3391 curbuf->b_p_initialized = TRUE;
3392 curbuf->b_p_ar = -1; /* no local 'autoread' value */
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01003393 curbuf->b_p_ul = NO_LOCAL_UNDOLEVEL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003394 check_buf_options(curbuf);
3395 check_win_options(curwin);
3396 check_options();
3397
3398 /* Must be before option_expand(), because that one needs vim_isIDc() */
3399 didset_options();
3400
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00003401#ifdef FEAT_SPELL
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003402 /* Use the current chartab for the generic chartab. This is not in
3403 * didset_options() because it only depends on 'encoding'. */
Bram Moolenaar6bb68362005-03-22 23:03:44 +00003404 init_spell_chartab();
3405#endif
3406
Bram Moolenaar071d4272004-06-13 20:20:40 +00003407 /*
3408 * Expand environment variables and things like "~" for the defaults.
3409 * If option_expand() returns non-NULL the variable is expanded. This can
3410 * only happen for non-indirect options.
3411 * Also set the default to the expanded value, so ":set" does not list
3412 * them.
3413 * Don't set the P_ALLOCED flag, because we don't want to free the
3414 * default.
3415 */
3416 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
3417 {
3418 if ((options[opt_idx].flags & P_GETTEXT)
3419 && options[opt_idx].var != NULL)
3420 p = (char_u *)_(*(char **)options[opt_idx].var);
3421 else
3422 p = option_expand(opt_idx, NULL);
3423 if (p != NULL && (p = vim_strsave(p)) != NULL)
3424 {
3425 *(char_u **)options[opt_idx].var = p;
3426 /* VIMEXP
3427 * Defaults for all expanded options are currently the same for Vi
3428 * and Vim. When this changes, add some code here! Also need to
3429 * split P_DEF_ALLOCED in two.
3430 */
3431 if (options[opt_idx].flags & P_DEF_ALLOCED)
3432 vim_free(options[opt_idx].def_val[VI_DEFAULT]);
3433 options[opt_idx].def_val[VI_DEFAULT] = p;
3434 options[opt_idx].flags |= P_DEF_ALLOCED;
3435 }
3436 }
3437
Bram Moolenaar071d4272004-06-13 20:20:40 +00003438 save_file_ff(curbuf); /* Buffer is unchanged */
3439
Bram Moolenaar071d4272004-06-13 20:20:40 +00003440#if defined(FEAT_ARABIC)
3441 /* Detect use of mlterm.
3442 * Mlterm is a terminal emulator akin to xterm that has some special
3443 * abilities (bidi namely).
3444 * NOTE: mlterm's author is being asked to 'set' a variable
3445 * instead of an environment variable due to inheritance.
3446 */
3447 if (mch_getenv((char_u *)"MLTERM") != NULL)
3448 set_option_value((char_u *)"tbidi", 1L, NULL, 0);
3449#endif
3450
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003451 didset_options2();
Bram Moolenaar071d4272004-06-13 20:20:40 +00003452
3453#ifdef FEAT_MBYTE
3454# if defined(WIN3264) && defined(FEAT_GETTEXT)
3455 /*
3456 * If $LANG isn't set, try to get a good value for it. This makes the
3457 * right language be used automatically. Don't do this for English.
3458 */
3459 if (mch_getenv((char_u *)"LANG") == NULL)
3460 {
3461 char buf[20];
3462
3463 /* Could use LOCALE_SISO639LANGNAME, but it's not in Win95.
3464 * LOCALE_SABBREVLANGNAME gives us three letters, like "enu", we use
3465 * only the first two. */
3466 n = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME,
3467 (LPTSTR)buf, 20);
3468 if (n >= 2 && STRNICMP(buf, "en", 2) != 0)
3469 {
3470 /* There are a few exceptions (probably more) */
3471 if (STRNICMP(buf, "cht", 3) == 0 || STRNICMP(buf, "zht", 3) == 0)
3472 STRCPY(buf, "zh_TW");
3473 else if (STRNICMP(buf, "chs", 3) == 0
3474 || STRNICMP(buf, "zhc", 3) == 0)
3475 STRCPY(buf, "zh_CN");
3476 else if (STRNICMP(buf, "jp", 2) == 0)
3477 STRCPY(buf, "ja");
3478 else
3479 buf[2] = NUL; /* truncate to two-letter code */
Bram Moolenaar6aa2cd42016-02-16 15:06:59 +01003480 vim_setenv((char_u *)"LANG", (char_u *)buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003481 }
3482 }
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003483# else
Bram Moolenaar9d47f172006-03-15 23:03:01 +00003484# ifdef MACOS_CONVERT
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00003485 /* Moved to os_mac_conv.c to avoid dependency problems. */
3486 mac_lang_init();
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003487# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003488# endif
3489
3490 /* enc_locale() will try to find the encoding of the current locale. */
3491 p = enc_locale();
3492 if (p != NULL)
3493 {
3494 char_u *save_enc;
3495
3496 /* Try setting 'encoding' and check if the value is valid.
3497 * If not, go back to the default "latin1". */
3498 save_enc = p_enc;
3499 p_enc = p;
Bram Moolenaar733f0a22007-03-02 18:56:27 +00003500 if (STRCMP(p_enc, "gb18030") == 0)
3501 {
3502 /* We don't support "gb18030", but "cp936" is a good substitute
3503 * for practical purposes, thus use that. It's not an alias to
3504 * still support conversion between gb18030 and utf-8. */
3505 p_enc = vim_strsave((char_u *)"cp936");
3506 vim_free(p);
3507 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003508 if (mb_init() == NULL)
3509 {
3510 opt_idx = findoption((char_u *)"encoding");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003511 if (opt_idx >= 0)
3512 {
3513 options[opt_idx].def_val[VI_DEFAULT] = p_enc;
3514 options[opt_idx].flags |= P_DEF_ALLOCED;
3515 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003516
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003517#if defined(MSWIN) || defined(MACOS) || defined(VMS)
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003518 if (STRCMP(p_enc, "latin1") == 0
3519# ifdef FEAT_MBYTE
3520 || enc_utf8
3521# endif
3522 )
3523 {
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003524 /* Adjust the default for 'isprint' and 'iskeyword' to match
3525 * latin1. Also set the defaults for when 'nocompatible' is
3526 * set. */
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003527 set_string_option_direct((char_u *)"isp", -1,
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +00003528 ISP_LATIN1, OPT_FREE, SID_NONE);
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003529 set_string_option_direct((char_u *)"isk", -1,
3530 ISK_LATIN1, OPT_FREE, SID_NONE);
3531 opt_idx = findoption((char_u *)"isp");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003532 if (opt_idx >= 0)
3533 options[opt_idx].def_val[VIM_DEFAULT] = ISP_LATIN1;
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003534 opt_idx = findoption((char_u *)"isk");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003535 if (opt_idx >= 0)
3536 options[opt_idx].def_val[VIM_DEFAULT] = ISK_LATIN1;
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003537 (void)init_chartab();
3538 }
3539#endif
3540
Bram Moolenaar071d4272004-06-13 20:20:40 +00003541# if defined(WIN3264) && !defined(FEAT_GUI)
3542 /* Win32 console: When GetACP() returns a different value from
3543 * GetConsoleCP() set 'termencoding'. */
3544 if (GetACP() != GetConsoleCP())
3545 {
3546 char buf[50];
3547
3548 sprintf(buf, "cp%ld", (long)GetConsoleCP());
3549 p_tenc = vim_strsave((char_u *)buf);
3550 if (p_tenc != NULL)
3551 {
3552 opt_idx = findoption((char_u *)"termencoding");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003553 if (opt_idx >= 0)
3554 {
3555 options[opt_idx].def_val[VI_DEFAULT] = p_tenc;
3556 options[opt_idx].flags |= P_DEF_ALLOCED;
3557 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003558 convert_setup(&input_conv, p_tenc, p_enc);
3559 convert_setup(&output_conv, p_enc, p_tenc);
3560 }
3561 else
3562 p_tenc = empty_option;
3563 }
3564# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003565# if defined(WIN3264) && defined(FEAT_MBYTE)
3566 /* $HOME may have characters in active code page. */
3567 init_homedir();
3568# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003569 }
3570 else
3571 {
3572 vim_free(p_enc);
3573 p_enc = save_enc;
3574 }
3575 }
3576#endif
3577
3578#ifdef FEAT_MULTI_LANG
3579 /* Set the default for 'helplang'. */
3580 set_helplang_default(get_mess_lang());
3581#endif
3582}
3583
3584/*
3585 * Set an option to its default value.
3586 * This does not take care of side effects!
3587 */
3588 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003589set_option_default(
3590 int opt_idx,
3591 int opt_flags, /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
3592 int compatible) /* use Vi default value */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003593{
3594 char_u *varp; /* pointer to variable for current option */
3595 int dvi; /* index in def_val[] */
3596 long_u flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003597 long_u *flagsp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003598 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
3599
3600 varp = get_varp_scope(&(options[opt_idx]), both ? OPT_LOCAL : opt_flags);
3601 flags = options[opt_idx].flags;
Bram Moolenaar3638c682005-06-08 22:05:14 +00003602 if (varp != NULL) /* skip hidden option, nothing to do for it */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003603 {
3604 dvi = ((flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT;
3605 if (flags & P_STRING)
3606 {
3607 /* Use set_string_option_direct() for local options to handle
3608 * freeing and allocating the value. */
3609 if (options[opt_idx].indir != PV_NONE)
3610 set_string_option_direct(NULL, opt_idx,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003611 options[opt_idx].def_val[dvi], opt_flags, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003612 else
3613 {
3614 if ((opt_flags & OPT_FREE) && (flags & P_ALLOCED))
3615 free_string_option(*(char_u **)(varp));
3616 *(char_u **)varp = options[opt_idx].def_val[dvi];
3617 options[opt_idx].flags &= ~P_ALLOCED;
3618 }
3619 }
3620 else if (flags & P_NUM)
3621 {
Bram Moolenaar5fc1a8b2006-10-17 16:34:24 +00003622 if (options[opt_idx].indir == PV_SCROLL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003623 win_comp_scroll(curwin);
3624 else
3625 {
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003626 *(long *)varp = (long)(long_i)options[opt_idx].def_val[dvi];
Bram Moolenaar071d4272004-06-13 20:20:40 +00003627 /* May also set global value for local option. */
3628 if (both)
3629 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) =
3630 *(long *)varp;
3631 }
3632 }
3633 else /* P_BOOL */
3634 {
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003635 /* the cast to long is required for Manx C, long_i is needed for
3636 * MSVC */
3637 *(int *)varp = (int)(long)(long_i)options[opt_idx].def_val[dvi];
Bram Moolenaar8243a792007-05-01 17:05:03 +00003638#ifdef UNIX
3639 /* 'modeline' defaults to off for root */
3640 if (options[opt_idx].indir == PV_ML && getuid() == ROOT_UID)
3641 *(int *)varp = FALSE;
3642#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003643 /* May also set global value for local option. */
3644 if (both)
3645 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) =
3646 *(int *)varp;
3647 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00003648
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003649 /* The default value is not insecure. */
3650 flagsp = insecure_flag(opt_idx, opt_flags);
3651 *flagsp = *flagsp & ~P_INSECURE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003652 }
3653
3654#ifdef FEAT_EVAL
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003655 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003656#endif
3657}
3658
3659/*
3660 * Set all options (except terminal options) to their default value.
Bram Moolenaarb341dda2015-08-25 12:56:31 +02003661 * When "opt_flags" is non-zero skip 'encoding'.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003662 */
3663 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003664set_options_default(
3665 int opt_flags) /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003666{
3667 int i;
3668#ifdef FEAT_WINDOWS
3669 win_T *wp;
Bram Moolenaarf740b292006-02-16 22:11:02 +00003670 tabpage_T *tp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003671#endif
3672
3673 for (i = 0; !istermoption(&options[i]); i++)
Bram Moolenaarb341dda2015-08-25 12:56:31 +02003674 if (!(options[i].flags & P_NODEFAULT)
Bram Moolenaar5ea87a02015-08-26 23:24:09 +02003675#if defined(FEAT_MBYTE) || defined(FEAT_CRYPT)
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003676 && (opt_flags == 0
Bram Moolenaar5ea87a02015-08-26 23:24:09 +02003677 || (TRUE
3678# if defined(FEAT_MBYTE)
3679 && options[i].var != (char_u *)&p_enc
3680# endif
3681# if defined(FEAT_CRYPT)
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003682 && options[i].var != (char_u *)&p_cm
Bram Moolenaar80606872015-08-25 21:27:35 +02003683 && options[i].var != (char_u *)&p_key
Bram Moolenaar5ea87a02015-08-26 23:24:09 +02003684# endif
3685 ))
Bram Moolenaar80606872015-08-25 21:27:35 +02003686#endif
Bram Moolenaar5ea87a02015-08-26 23:24:09 +02003687 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00003688 set_option_default(i, opt_flags, p_cp);
3689
3690#ifdef FEAT_WINDOWS
3691 /* The 'scroll' option must be computed for all windows. */
Bram Moolenaarf740b292006-02-16 22:11:02 +00003692 FOR_ALL_TAB_WINDOWS(tp, wp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003693 win_comp_scroll(wp);
3694#else
3695 win_comp_scroll(curwin);
3696#endif
Bram Moolenaar5a4eceb2014-09-09 17:33:07 +02003697#ifdef FEAT_CINDENT
3698 parse_cino(curbuf);
3699#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003700}
3701
3702/*
3703 * Set the Vi-default value of a string option.
3704 * Used for 'sh', 'backupskip' and 'term'.
3705 */
3706 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003707set_string_default(char *name, char_u *val)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003708{
3709 char_u *p;
3710 int opt_idx;
3711
3712 p = vim_strsave(val);
3713 if (p != NULL) /* we don't want a NULL */
3714 {
3715 opt_idx = findoption((char_u *)name);
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003716 if (opt_idx >= 0)
3717 {
3718 if (options[opt_idx].flags & P_DEF_ALLOCED)
3719 vim_free(options[opt_idx].def_val[VI_DEFAULT]);
3720 options[opt_idx].def_val[VI_DEFAULT] = p;
3721 options[opt_idx].flags |= P_DEF_ALLOCED;
3722 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003723 }
3724}
3725
3726/*
3727 * Set the Vi-default value of a number option.
3728 * Used for 'lines' and 'columns'.
3729 */
3730 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003731set_number_default(char *name, long val)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003732{
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003733 int opt_idx;
3734
3735 opt_idx = findoption((char_u *)name);
3736 if (opt_idx >= 0)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003737 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003738}
3739
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00003740#if defined(EXITFREE) || defined(PROTO)
3741/*
3742 * Free all options.
3743 */
3744 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003745free_all_options(void)
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00003746{
3747 int i;
3748
3749 for (i = 0; !istermoption(&options[i]); i++)
3750 {
3751 if (options[i].indir == PV_NONE)
3752 {
3753 /* global option: free value and default value. */
3754 if (options[i].flags & P_ALLOCED && options[i].var != NULL)
3755 free_string_option(*(char_u **)options[i].var);
3756 if (options[i].flags & P_DEF_ALLOCED)
3757 free_string_option(options[i].def_val[VI_DEFAULT]);
3758 }
3759 else if (options[i].var != VAR_WIN
3760 && (options[i].flags & P_STRING))
3761 /* buffer-local option: free global value */
3762 free_string_option(*(char_u **)options[i].var);
3763 }
3764}
3765#endif
3766
3767
Bram Moolenaar071d4272004-06-13 20:20:40 +00003768/*
3769 * Initialize the options, part two: After getting Rows and Columns and
3770 * setting 'term'.
3771 */
3772 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003773set_init_2(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003774{
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003775 int idx;
3776
Bram Moolenaar071d4272004-06-13 20:20:40 +00003777 /*
3778 * 'scroll' defaults to half the window height. Note that this default is
3779 * wrong when the window height changes.
3780 */
Bram Moolenaarc1e37902006-04-18 21:55:01 +00003781 set_number_default("scroll", (long)((long_u)Rows >> 1));
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003782 idx = findoption((char_u *)"scroll");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003783 if (idx >= 0 && !(options[idx].flags & P_WAS_SET))
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003784 set_option_default(idx, OPT_LOCAL, p_cp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003785 comp_col();
3786
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003787 /*
3788 * 'window' is only for backwards compatibility with Vi.
3789 * Default is Rows - 1.
3790 */
Bram Moolenaard68071d2006-05-02 22:08:30 +00003791 if (!option_was_set((char_u *)"window"))
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003792 p_window = Rows - 1;
3793 set_number_default("window", Rows - 1);
3794
Bram Moolenaarf740b292006-02-16 22:11:02 +00003795 /* For DOS console the default is always black. */
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003796#if !((defined(WIN3264)) && !defined(FEAT_GUI))
Bram Moolenaarf740b292006-02-16 22:11:02 +00003797 /*
3798 * If 'background' wasn't set by the user, try guessing the value,
3799 * depending on the terminal name. Only need to check for terminals
3800 * with a dark background, that can handle color.
3801 */
3802 idx = findoption((char_u *)"bg");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003803 if (idx >= 0 && !(options[idx].flags & P_WAS_SET)
3804 && *term_bg_default() == 'd')
Bram Moolenaar071d4272004-06-13 20:20:40 +00003805 {
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003806 set_string_option_direct(NULL, idx, (char_u *)"dark", OPT_FREE, 0);
Bram Moolenaarf740b292006-02-16 22:11:02 +00003807 /* don't mark it as set, when starting the GUI it may be
3808 * changed again */
3809 options[idx].flags &= ~P_WAS_SET;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003810 }
3811#endif
Bram Moolenaar58d98232005-07-23 22:25:46 +00003812
3813#ifdef CURSOR_SHAPE
3814 parse_shape_opt(SHAPE_CURSOR); /* set cursor shapes from 'guicursor' */
3815#endif
3816#ifdef FEAT_MOUSESHAPE
3817 parse_shape_opt(SHAPE_MOUSE); /* set mouse shapes from 'mouseshape' */
3818#endif
3819#ifdef FEAT_PRINTER
3820 (void)parse_printoptions(); /* parse 'printoptions' default value */
3821#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003822}
3823
3824/*
Bram Moolenaarf740b292006-02-16 22:11:02 +00003825 * Return "dark" or "light" depending on the kind of terminal.
3826 * This is just guessing! Recognized are:
3827 * "linux" Linux console
3828 * "screen.linux" Linux console with screen
3829 * "cygwin" Cygwin shell
3830 * "putty" Putty program
3831 * We also check the COLORFGBG environment variable, which is set by
3832 * rxvt and derivatives. This variable contains either two or three
3833 * values separated by semicolons; we want the last value in either
3834 * case. If this value is 0-6 or 8, our background is dark.
3835 */
3836 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01003837term_bg_default(void)
Bram Moolenaarf740b292006-02-16 22:11:02 +00003838{
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003839#if defined(WIN3264)
Bram Moolenaarf740b292006-02-16 22:11:02 +00003840 /* DOS console nearly always black */
3841 return (char_u *)"dark";
3842#else
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00003843 char_u *p;
3844
Bram Moolenaarf740b292006-02-16 22:11:02 +00003845 if (STRCMP(T_NAME, "linux") == 0
3846 || STRCMP(T_NAME, "screen.linux") == 0
3847 || STRCMP(T_NAME, "cygwin") == 0
3848 || STRCMP(T_NAME, "putty") == 0
3849 || ((p = mch_getenv((char_u *)"COLORFGBG")) != NULL
3850 && (p = vim_strrchr(p, ';')) != NULL
3851 && ((p[1] >= '0' && p[1] <= '6') || p[1] == '8')
3852 && p[2] == NUL))
3853 return (char_u *)"dark";
3854 return (char_u *)"light";
3855#endif
3856}
3857
3858/*
Bram Moolenaar071d4272004-06-13 20:20:40 +00003859 * Initialize the options, part three: After reading the .vimrc
3860 */
3861 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003862set_init_3(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003863{
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003864#if defined(UNIX) || defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003865/*
3866 * Set 'shellpipe' and 'shellredir', depending on the 'shell' option.
3867 * This is done after other initializations, where 'shell' might have been
3868 * set, but only if they have not been set before.
3869 */
3870 char_u *p;
3871 int idx_srr;
3872 int do_srr;
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003873# ifdef FEAT_QUICKFIX
Bram Moolenaar071d4272004-06-13 20:20:40 +00003874 int idx_sp;
3875 int do_sp;
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003876# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003877
3878 idx_srr = findoption((char_u *)"srr");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003879 if (idx_srr < 0)
3880 do_srr = FALSE;
3881 else
3882 do_srr = !(options[idx_srr].flags & P_WAS_SET);
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003883# ifdef FEAT_QUICKFIX
Bram Moolenaar071d4272004-06-13 20:20:40 +00003884 idx_sp = findoption((char_u *)"sp");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003885 if (idx_sp < 0)
3886 do_sp = FALSE;
3887 else
3888 do_sp = !(options[idx_sp].flags & P_WAS_SET);
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003889# endif
Bram Moolenaar75a8d742014-05-07 15:10:21 +02003890 p = get_isolated_shell_name();
Bram Moolenaar071d4272004-06-13 20:20:40 +00003891 if (p != NULL)
3892 {
3893 /*
3894 * Default for p_sp is "| tee", for p_srr is ">".
3895 * For known shells it is changed here to include stderr.
3896 */
3897 if ( fnamecmp(p, "csh") == 0
3898 || fnamecmp(p, "tcsh") == 0
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003899# if defined(WIN3264) /* also check with .exe extension */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003900 || fnamecmp(p, "csh.exe") == 0
3901 || fnamecmp(p, "tcsh.exe") == 0
3902# endif
3903 )
3904 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003905# if defined(FEAT_QUICKFIX)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003906 if (do_sp)
3907 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003908# ifdef WIN3264
Bram Moolenaar071d4272004-06-13 20:20:40 +00003909 p_sp = (char_u *)">&";
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003910# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00003911 p_sp = (char_u *)"|& tee";
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003912# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003913 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
3914 }
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003915# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003916 if (do_srr)
3917 {
3918 p_srr = (char_u *)">&";
3919 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
3920 }
3921 }
3922 else
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003923 /* Always use bourne shell style redirection if we reach this */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003924 if ( fnamecmp(p, "sh") == 0
3925 || fnamecmp(p, "ksh") == 0
Bram Moolenaarf1fda2d2011-04-28 12:57:36 +02003926 || fnamecmp(p, "mksh") == 0
3927 || fnamecmp(p, "pdksh") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003928 || fnamecmp(p, "zsh") == 0
Bram Moolenaarc1e37902006-04-18 21:55:01 +00003929 || fnamecmp(p, "zsh-beta") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003930 || fnamecmp(p, "bash") == 0
Bram Moolenaar75a8d742014-05-07 15:10:21 +02003931 || fnamecmp(p, "fish") == 0
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003932# ifdef WIN3264
Bram Moolenaar071d4272004-06-13 20:20:40 +00003933 || fnamecmp(p, "cmd") == 0
3934 || fnamecmp(p, "sh.exe") == 0
3935 || fnamecmp(p, "ksh.exe") == 0
Bram Moolenaarf1fda2d2011-04-28 12:57:36 +02003936 || fnamecmp(p, "mksh.exe") == 0
3937 || fnamecmp(p, "pdksh.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003938 || fnamecmp(p, "zsh.exe") == 0
Bram Moolenaarc1e37902006-04-18 21:55:01 +00003939 || fnamecmp(p, "zsh-beta.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003940 || fnamecmp(p, "bash.exe") == 0
3941 || fnamecmp(p, "cmd.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003942# endif
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003943 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00003944 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003945# if defined(FEAT_QUICKFIX)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003946 if (do_sp)
3947 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003948# ifdef WIN3264
Bram Moolenaar071d4272004-06-13 20:20:40 +00003949 p_sp = (char_u *)">%s 2>&1";
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003950# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00003951 p_sp = (char_u *)"2>&1| tee";
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003952# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003953 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
3954 }
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003955# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003956 if (do_srr)
3957 {
3958 p_srr = (char_u *)">%s 2>&1";
3959 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
3960 }
3961 }
3962 vim_free(p);
3963 }
3964#endif
3965
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003966#if defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003967 /*
Bram Moolenaara64ba222012-02-12 23:23:31 +01003968 * Set 'shellcmdflag', 'shellxquote', and 'shellquote' depending on the
3969 * 'shell' option.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003970 * This is done after other initializations, where 'shell' might have been
3971 * set, but only if they have not been set before. Default for p_shcf is
3972 * "/c", for p_shq is "". For "sh" like shells it is changed here to
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003973 * "-c" and "\"". And for Win32 we need to set p_sxq instead.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003974 */
Bram Moolenaarf4b8e572004-06-24 15:53:16 +00003975 if (strstr((char *)gettail(p_sh), "sh") != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003976 {
3977 int idx3;
3978
3979 idx3 = findoption((char_u *)"shcf");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003980 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003981 {
3982 p_shcf = (char_u *)"-c";
3983 options[idx3].def_val[VI_DEFAULT] = p_shcf;
3984 }
3985
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003986# ifdef WIN3264
Bram Moolenaar071d4272004-06-13 20:20:40 +00003987 /* Somehow Win32 requires the quotes around the redirection too */
3988 idx3 = findoption((char_u *)"sxq");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003989 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003990 {
3991 p_sxq = (char_u *)"\"";
3992 options[idx3].def_val[VI_DEFAULT] = p_sxq;
3993 }
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003994# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00003995 idx3 = findoption((char_u *)"shq");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003996 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003997 {
3998 p_shq = (char_u *)"\"";
3999 options[idx3].def_val[VI_DEFAULT] = p_shq;
4000 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004001# endif
4002 }
Bram Moolenaara64ba222012-02-12 23:23:31 +01004003 else if (strstr((char *)gettail(p_sh), "cmd.exe") != NULL)
4004 {
4005 int idx3;
4006
4007 /*
4008 * cmd.exe on Windows will strip the first and last double quote given
4009 * on the command line, e.g. most of the time things like:
4010 * cmd /c "my path/to/echo" "my args to echo"
4011 * become:
4012 * my path/to/echo" "my args to echo
4013 * when executed.
4014 *
Bram Moolenaar034b1152012-02-19 18:19:30 +01004015 * To avoid this, set shellxquote to surround the command in
4016 * parenthesis. This appears to make most commands work, without
4017 * breaking commands that worked previously, such as
4018 * '"path with spaces/cmd" "a&b"'.
Bram Moolenaara64ba222012-02-12 23:23:31 +01004019 */
Bram Moolenaara64ba222012-02-12 23:23:31 +01004020 idx3 = findoption((char_u *)"sxq");
4021 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
4022 {
Bram Moolenaar034b1152012-02-19 18:19:30 +01004023 p_sxq = (char_u *)"(";
Bram Moolenaara64ba222012-02-12 23:23:31 +01004024 options[idx3].def_val[VI_DEFAULT] = p_sxq;
4025 }
4026
Bram Moolenaara64ba222012-02-12 23:23:31 +01004027 idx3 = findoption((char_u *)"shcf");
4028 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
4029 {
Bram Moolenaar034b1152012-02-19 18:19:30 +01004030 p_shcf = (char_u *)"/c";
Bram Moolenaara64ba222012-02-12 23:23:31 +01004031 options[idx3].def_val[VI_DEFAULT] = p_shcf;
4032 }
4033 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004034#endif
4035
Bram Moolenaar364fa5c2016-03-20 17:53:25 +01004036 if (bufempty())
4037 {
4038 int idx_ffs = findoption((char_u *)"ffs");
4039
4040 /* Apply the first entry of 'fileformats' to the initial buffer. */
4041 if (idx_ffs >= 0 && (options[idx_ffs].flags & P_WAS_SET))
4042 set_fileformat(default_fileformat(), OPT_LOCAL);
4043 }
4044
Bram Moolenaar071d4272004-06-13 20:20:40 +00004045#ifdef FEAT_TITLE
4046 set_title_defaults();
4047#endif
4048}
4049
4050#if defined(FEAT_MULTI_LANG) || defined(PROTO)
4051/*
4052 * When 'helplang' is still at its default value, set it to "lang".
4053 * Only the first two characters of "lang" are used.
4054 */
4055 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01004056set_helplang_default(char_u *lang)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004057{
4058 int idx;
4059
4060 if (lang == NULL || STRLEN(lang) < 2) /* safety check */
4061 return;
4062 idx = findoption((char_u *)"hlg");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004063 if (idx >= 0 && !(options[idx].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004064 {
4065 if (options[idx].flags & P_ALLOCED)
4066 free_string_option(p_hlg);
4067 p_hlg = vim_strsave(lang);
4068 if (p_hlg == NULL)
4069 p_hlg = empty_option;
4070 else
Bram Moolenaarab79bcb2004-07-18 21:34:53 +00004071 {
4072 /* zh_CN becomes "cn", zh_TW becomes "tw". */
4073 if (STRNICMP(p_hlg, "zh_", 3) == 0 && STRLEN(p_hlg) >= 5)
4074 {
4075 p_hlg[0] = TOLOWER_ASC(p_hlg[3]);
4076 p_hlg[1] = TOLOWER_ASC(p_hlg[4]);
4077 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004078 p_hlg[2] = NUL;
Bram Moolenaarab79bcb2004-07-18 21:34:53 +00004079 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004080 options[idx].flags |= P_ALLOCED;
4081 }
4082}
4083#endif
4084
4085#ifdef FEAT_GUI
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01004086static char_u *gui_bg_default(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004087
4088 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01004089gui_bg_default(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004090{
4091 if (gui_get_lightness(gui.back_pixel) < 127)
4092 return (char_u *)"dark";
4093 return (char_u *)"light";
4094}
4095
4096/*
4097 * Option initializations that can only be done after opening the GUI window.
4098 */
4099 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01004100init_gui_options(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004101{
4102 /* Set the 'background' option according to the lightness of the
4103 * background color, unless the user has set it already. */
4104 if (!option_was_set((char_u *)"bg") && STRCMP(p_bg, gui_bg_default()) != 0)
4105 {
4106 set_option_value((char_u *)"bg", 0L, gui_bg_default(), 0);
4107 highlight_changed();
4108 }
4109}
4110#endif
4111
4112#ifdef FEAT_TITLE
4113/*
4114 * 'title' and 'icon' only default to true if they have not been set or reset
4115 * in .vimrc and we can read the old value.
4116 * When 'title' and 'icon' have been reset in .vimrc, we won't even check if
4117 * they can be reset. This reduces startup time when using X on a remote
4118 * machine.
4119 */
4120 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01004121set_title_defaults(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004122{
4123 int idx1;
4124 long val;
4125
4126 /*
4127 * If GUI is (going to be) used, we can always set the window title and
4128 * icon name. Saves a bit of time, because the X11 display server does
4129 * not need to be contacted.
4130 */
4131 idx1 = findoption((char_u *)"title");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004132 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004133 {
4134#ifdef FEAT_GUI
4135 if (gui.starting || gui.in_use)
4136 val = TRUE;
4137 else
4138#endif
4139 val = mch_can_restore_title();
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004140 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004141 p_title = val;
4142 }
4143 idx1 = findoption((char_u *)"icon");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004144 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004145 {
4146#ifdef FEAT_GUI
4147 if (gui.starting || gui.in_use)
4148 val = TRUE;
4149 else
4150#endif
4151 val = mch_can_restore_icon();
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004152 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004153 p_icon = val;
4154 }
4155}
4156#endif
4157
4158/*
4159 * Parse 'arg' for option settings.
4160 *
4161 * 'arg' may be IObuff, but only when no errors can be present and option
4162 * does not need to be expanded with option_expand().
4163 * "opt_flags":
4164 * 0 for ":set"
Bram Moolenaara3227e22006-03-08 21:32:40 +00004165 * OPT_GLOBAL for ":setglobal"
4166 * OPT_LOCAL for ":setlocal" and a modeline
Bram Moolenaar071d4272004-06-13 20:20:40 +00004167 * OPT_MODELINE for a modeline
Bram Moolenaara3227e22006-03-08 21:32:40 +00004168 * OPT_WINONLY to only set window-local options
4169 * OPT_NOWIN to skip setting window-local options
Bram Moolenaar071d4272004-06-13 20:20:40 +00004170 *
4171 * returns FAIL if an error is detected, OK otherwise
4172 */
4173 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01004174do_set(
4175 char_u *arg, /* option string (may be written to!) */
4176 int opt_flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004177{
4178 int opt_idx;
4179 char_u *errmsg;
4180 char_u errbuf[80];
4181 char_u *startarg;
4182 int prefix; /* 1: nothing, 0: "no", 2: "inv" in front of name */
4183 int nextchar; /* next non-white char after option name */
4184 int afterchar; /* character just after option name */
4185 int len;
4186 int i;
Bram Moolenaar22fcfad2016-07-01 18:17:26 +02004187 varnumber_T value;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004188 int key;
4189 long_u flags; /* flags for current option */
4190 char_u *varp = NULL; /* pointer to variable for current option */
4191 int did_show = FALSE; /* already showed one value */
4192 int adding; /* "opt+=arg" */
4193 int prepending; /* "opt^=arg" */
4194 int removing; /* "opt-=arg" */
4195 int cp_val = 0;
4196 char_u key_name[2];
4197
4198 if (*arg == NUL)
4199 {
4200 showoptions(0, opt_flags);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004201 did_show = TRUE;
4202 goto theend;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004203 }
4204
4205 while (*arg != NUL) /* loop to process all options */
4206 {
4207 errmsg = NULL;
4208 startarg = arg; /* remember for error message */
4209
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00004210 if (STRNCMP(arg, "all", 3) == 0 && !isalpha(arg[3])
4211 && !(opt_flags & OPT_MODELINE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004212 {
4213 /*
4214 * ":set all" show all options.
4215 * ":set all&" set all options to their default value.
4216 */
4217 arg += 3;
4218 if (*arg == '&')
4219 {
4220 ++arg;
4221 /* Only for :set command set global value of local options. */
4222 set_options_default(OPT_FREE | opt_flags);
Bram Moolenaare68c25c2015-08-25 15:39:55 +02004223 didset_options();
4224 didset_options2();
Bram Moolenaarb341dda2015-08-25 12:56:31 +02004225 redraw_all_later(CLEAR);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004226 }
4227 else
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004228 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00004229 showoptions(1, opt_flags);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004230 did_show = TRUE;
4231 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004232 }
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00004233 else if (STRNCMP(arg, "termcap", 7) == 0 && !(opt_flags & OPT_MODELINE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004234 {
4235 showoptions(2, opt_flags);
4236 show_termcodes();
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004237 did_show = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004238 arg += 7;
4239 }
4240 else
4241 {
4242 prefix = 1;
Bram Moolenaar2a7b9ee2009-06-16 15:50:33 +00004243 if (STRNCMP(arg, "no", 2) == 0 && STRNCMP(arg, "novice", 6) != 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004244 {
4245 prefix = 0;
4246 arg += 2;
4247 }
4248 else if (STRNCMP(arg, "inv", 3) == 0)
4249 {
4250 prefix = 2;
4251 arg += 3;
4252 }
4253
4254 /* find end of name */
4255 key = 0;
4256 if (*arg == '<')
4257 {
4258 nextchar = 0;
4259 opt_idx = -1;
4260 /* look out for <t_>;> */
4261 if (arg[1] == 't' && arg[2] == '_' && arg[3] && arg[4])
4262 len = 5;
4263 else
4264 {
4265 len = 1;
4266 while (arg[len] != NUL && arg[len] != '>')
4267 ++len;
4268 }
4269 if (arg[len] != '>')
4270 {
4271 errmsg = e_invarg;
4272 goto skip;
4273 }
4274 arg[len] = NUL; /* put NUL after name */
4275 if (arg[1] == 't' && arg[2] == '_') /* could be term code */
4276 opt_idx = findoption(arg + 1);
4277 arg[len++] = '>'; /* restore '>' */
4278 if (opt_idx == -1)
4279 key = find_key_option(arg + 1);
4280 }
4281 else
4282 {
4283 len = 0;
4284 /*
4285 * The two characters after "t_" may not be alphanumeric.
4286 */
4287 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
4288 len = 4;
4289 else
4290 while (ASCII_ISALNUM(arg[len]) || arg[len] == '_')
4291 ++len;
4292 nextchar = arg[len];
4293 arg[len] = NUL; /* put NUL after name */
4294 opt_idx = findoption(arg);
4295 arg[len] = nextchar; /* restore nextchar */
4296 if (opt_idx == -1)
4297 key = find_key_option(arg);
4298 }
4299
4300 /* remember character after option name */
4301 afterchar = arg[len];
4302
4303 /* skip white space, allow ":set ai ?" */
4304 while (vim_iswhite(arg[len]))
4305 ++len;
4306
4307 adding = FALSE;
4308 prepending = FALSE;
4309 removing = FALSE;
4310 if (arg[len] != NUL && arg[len + 1] == '=')
4311 {
4312 if (arg[len] == '+')
4313 {
4314 adding = TRUE; /* "+=" */
4315 ++len;
4316 }
4317 else if (arg[len] == '^')
4318 {
4319 prepending = TRUE; /* "^=" */
4320 ++len;
4321 }
4322 else if (arg[len] == '-')
4323 {
4324 removing = TRUE; /* "-=" */
4325 ++len;
4326 }
4327 }
4328 nextchar = arg[len];
4329
4330 if (opt_idx == -1 && key == 0) /* found a mismatch: skip */
4331 {
4332 errmsg = (char_u *)N_("E518: Unknown option");
4333 goto skip;
4334 }
4335
4336 if (opt_idx >= 0)
4337 {
4338 if (options[opt_idx].var == NULL) /* hidden option: skip */
4339 {
4340 /* Only give an error message when requesting the value of
4341 * a hidden option, ignore setting it. */
4342 if (vim_strchr((char_u *)"=:!&<", nextchar) == NULL
4343 && (!(options[opt_idx].flags & P_BOOL)
4344 || nextchar == '?'))
4345 errmsg = (char_u *)N_("E519: Option not supported");
4346 goto skip;
4347 }
4348
4349 flags = options[opt_idx].flags;
4350 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
4351 }
4352 else
4353 {
4354 flags = P_STRING;
4355 if (key < 0)
4356 {
4357 key_name[0] = KEY2TERMCAP0(key);
4358 key_name[1] = KEY2TERMCAP1(key);
4359 }
4360 else
4361 {
4362 key_name[0] = KS_KEY;
4363 key_name[1] = (key & 0xff);
4364 }
4365 }
4366
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004367 /* Skip all options that are not window-local (used when showing
4368 * an already loaded buffer in a window). */
4369 if ((opt_flags & OPT_WINONLY)
4370 && (opt_idx < 0 || options[opt_idx].var != VAR_WIN))
4371 goto skip;
4372
Bram Moolenaara3227e22006-03-08 21:32:40 +00004373 /* Skip all options that are window-local (used for :vimgrep). */
4374 if ((opt_flags & OPT_NOWIN) && opt_idx >= 0
4375 && options[opt_idx].var == VAR_WIN)
4376 goto skip;
4377
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004378 /* Disallow changing some options from modelines. */
4379 if (opt_flags & OPT_MODELINE)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004380 {
Bram Moolenaar865242e2010-07-14 21:12:05 +02004381 if (flags & (P_SECURE | P_NO_ML))
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004382 {
4383 errmsg = (char_u *)_("E520: Not allowed in a modeline");
4384 goto skip;
4385 }
Bram Moolenaarf69d9a32009-02-11 21:48:40 +00004386#ifdef FEAT_DIFF
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004387 /* In diff mode some options are overruled. This avoids that
4388 * 'foldmethod' becomes "marker" instead of "diff" and that
4389 * "wrap" gets set. */
4390 if (curwin->w_p_diff
Bram Moolenaara9d52e32010-07-31 16:44:19 +02004391 && opt_idx >= 0 /* shut up coverity warning */
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004392 && (options[opt_idx].indir == PV_FDM
4393 || options[opt_idx].indir == PV_WRAP))
4394 goto skip;
Bram Moolenaarf69d9a32009-02-11 21:48:40 +00004395#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004396 }
4397
4398#ifdef HAVE_SANDBOX
4399 /* Disallow changing some options in the sandbox */
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004400 if (sandbox != 0 && (flags & P_SECURE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004401 {
4402 errmsg = (char_u *)_(e_sandbox);
4403 goto skip;
4404 }
4405#endif
4406
4407 if (vim_strchr((char_u *)"?=:!&<", nextchar) != NULL)
4408 {
4409 arg += len;
4410 cp_val = p_cp;
4411 if (nextchar == '&' && arg[1] == 'v' && arg[2] == 'i')
4412 {
4413 if (arg[3] == 'm') /* "opt&vim": set to Vim default */
4414 {
4415 cp_val = FALSE;
4416 arg += 3;
4417 }
4418 else /* "opt&vi": set to Vi default */
4419 {
4420 cp_val = TRUE;
4421 arg += 2;
4422 }
4423 }
4424 if (vim_strchr((char_u *)"?!&<", nextchar) != NULL
4425 && arg[1] != NUL && !vim_iswhite(arg[1]))
4426 {
4427 errmsg = e_trailing;
4428 goto skip;
4429 }
4430 }
4431
4432 /*
Bram Moolenaar48e330a2016-02-23 14:53:34 +01004433 * allow '=' and ':' for hystorical reasons (MSDOS command.com
4434 * allows only one '=' character per "set" command line. grrr. (jw)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004435 */
4436 if (nextchar == '?'
4437 || (prefix == 1
4438 && vim_strchr((char_u *)"=:&<", nextchar) == NULL
4439 && !(flags & P_BOOL)))
4440 {
4441 /*
4442 * print value
4443 */
4444 if (did_show)
4445 msg_putchar('\n'); /* cursor below last one */
4446 else
4447 {
4448 gotocmdline(TRUE); /* cursor at status line */
4449 did_show = TRUE; /* remember that we did a line */
4450 }
4451 if (opt_idx >= 0)
4452 {
4453 showoneopt(&options[opt_idx], opt_flags);
4454#ifdef FEAT_EVAL
4455 if (p_verbose > 0)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00004456 {
4457 /* Mention where the option was last set. */
4458 if (varp == options[opt_idx].var)
4459 last_set_msg(options[opt_idx].scriptID);
4460 else if ((int)options[opt_idx].indir & PV_WIN)
4461 last_set_msg(curwin->w_p_scriptID[
4462 (int)options[opt_idx].indir & PV_MASK]);
4463 else if ((int)options[opt_idx].indir & PV_BUF)
4464 last_set_msg(curbuf->b_p_scriptID[
4465 (int)options[opt_idx].indir & PV_MASK]);
4466 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004467#endif
4468 }
4469 else
4470 {
4471 char_u *p;
4472
4473 p = find_termcode(key_name);
4474 if (p == NULL)
4475 {
Bram Moolenaar0b2f94d2011-03-22 14:35:05 +01004476 errmsg = (char_u *)N_("E846: Key code not set");
Bram Moolenaar071d4272004-06-13 20:20:40 +00004477 goto skip;
4478 }
4479 else
4480 (void)show_one_termcode(key_name, p, TRUE);
4481 }
4482 if (nextchar != '?'
4483 && nextchar != NUL && !vim_iswhite(afterchar))
4484 errmsg = e_trailing;
4485 }
4486 else
4487 {
4488 if (flags & P_BOOL) /* boolean */
4489 {
4490 if (nextchar == '=' || nextchar == ':')
4491 {
4492 errmsg = e_invarg;
4493 goto skip;
4494 }
4495
4496 /*
4497 * ":set opt!": invert
4498 * ":set opt&": reset to default value
4499 * ":set opt<": reset to global value
4500 */
4501 if (nextchar == '!')
4502 value = *(int *)(varp) ^ 1;
4503 else if (nextchar == '&')
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004504 value = (int)(long)(long_i)options[opt_idx].def_val[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004505 ((flags & P_VI_DEF) || cp_val)
4506 ? VI_DEFAULT : VIM_DEFAULT];
4507 else if (nextchar == '<')
4508 {
4509 /* For 'autoread' -1 means to use global value. */
4510 if ((int *)varp == &curbuf->b_p_ar
4511 && opt_flags == OPT_LOCAL)
4512 value = -1;
4513 else
4514 value = *(int *)get_varp_scope(&(options[opt_idx]),
4515 OPT_GLOBAL);
4516 }
4517 else
4518 {
4519 /*
4520 * ":set invopt": invert
4521 * ":set opt" or ":set noopt": set or reset
4522 */
4523 if (nextchar != NUL && !vim_iswhite(afterchar))
4524 {
4525 errmsg = e_trailing;
4526 goto skip;
4527 }
4528 if (prefix == 2) /* inv */
4529 value = *(int *)(varp) ^ 1;
4530 else
4531 value = prefix;
4532 }
4533
4534 errmsg = set_bool_option(opt_idx, varp, (int)value,
4535 opt_flags);
4536 }
4537 else /* numeric or string */
4538 {
4539 if (vim_strchr((char_u *)"=:&<", nextchar) == NULL
4540 || prefix != 1)
4541 {
4542 errmsg = e_invarg;
4543 goto skip;
4544 }
4545
4546 if (flags & P_NUM) /* numeric */
4547 {
4548 /*
4549 * Different ways to set a number option:
4550 * & set to default value
4551 * < set to global value
4552 * <xx> accept special key codes for 'wildchar'
4553 * c accept any non-digit for 'wildchar'
4554 * [-]0-9 set number
4555 * other error
4556 */
4557 ++arg;
4558 if (nextchar == '&')
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004559 value = (long)(long_i)options[opt_idx].def_val[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004560 ((flags & P_VI_DEF) || cp_val)
4561 ? VI_DEFAULT : VIM_DEFAULT];
4562 else if (nextchar == '<')
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01004563 {
4564 /* For 'undolevels' NO_LOCAL_UNDOLEVEL means to
4565 * use the global value. */
4566 if ((long *)varp == &curbuf->b_p_ul
4567 && opt_flags == OPT_LOCAL)
4568 value = NO_LOCAL_UNDOLEVEL;
4569 else
4570 value = *(long *)get_varp_scope(
4571 &(options[opt_idx]), OPT_GLOBAL);
4572 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004573 else if (((long *)varp == &p_wc
4574 || (long *)varp == &p_wcm)
4575 && (*arg == '<'
4576 || *arg == '^'
4577 || ((!arg[1] || vim_iswhite(arg[1]))
4578 && !VIM_ISDIGIT(*arg))))
4579 {
4580 value = string_to_key(arg);
4581 if (value == 0 && (long *)varp != &p_wcm)
4582 {
4583 errmsg = e_invarg;
4584 goto skip;
4585 }
4586 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004587 else if (*arg == '-' || VIM_ISDIGIT(*arg))
4588 {
Bram Moolenaar18400e62015-01-27 15:58:40 +01004589 /* Allow negative (for 'undolevels'), octal and
4590 * hex numbers. */
Bram Moolenaar887c1fe2016-01-02 17:56:35 +01004591 vim_str2nr(arg, NULL, &i, STR2NR_ALL,
4592 &value, NULL, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004593 if (arg[i] != NUL && !vim_iswhite(arg[i]))
4594 {
4595 errmsg = e_invarg;
4596 goto skip;
4597 }
4598 }
4599 else
4600 {
4601 errmsg = (char_u *)N_("E521: Number required after =");
4602 goto skip;
4603 }
4604
4605 if (adding)
4606 value = *(long *)varp + value;
4607 if (prepending)
4608 value = *(long *)varp * value;
4609 if (removing)
4610 value = *(long *)varp - value;
4611 errmsg = set_num_option(opt_idx, varp, value,
Bram Moolenaar555b2802005-05-19 21:08:39 +00004612 errbuf, sizeof(errbuf), opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004613 }
4614 else if (opt_idx >= 0) /* string */
4615 {
4616 char_u *save_arg = NULL;
4617 char_u *s = NULL;
Bram Moolenaar53744302015-07-17 17:38:22 +02004618 char_u *oldval = NULL; /* previous value if *varp */
Bram Moolenaar071d4272004-06-13 20:20:40 +00004619 char_u *newval;
Bram Moolenaar53744302015-07-17 17:38:22 +02004620 char_u *origval = NULL;
4621#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
4622 char_u *saved_origval = NULL;
4623#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004624 unsigned newlen;
4625 int comma;
4626 int bs;
4627 int new_value_alloced; /* new string option
4628 was allocated */
4629
4630 /* When using ":set opt=val" for a global option
4631 * with a local value the local value will be
4632 * reset, use the global value here. */
4633 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00004634 && ((int)options[opt_idx].indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004635 varp = options[opt_idx].var;
4636
4637 /* The old value is kept until we are sure that the
4638 * new value is valid. */
4639 oldval = *(char_u **)varp;
4640 if (nextchar == '&') /* set to default val */
4641 {
4642 newval = options[opt_idx].def_val[
4643 ((flags & P_VI_DEF) || cp_val)
4644 ? VI_DEFAULT : VIM_DEFAULT];
4645 if ((char_u **)varp == &p_bg)
4646 {
4647 /* guess the value of 'background' */
4648#ifdef FEAT_GUI
4649 if (gui.in_use)
4650 newval = gui_bg_default();
4651 else
4652#endif
Bram Moolenaarf740b292006-02-16 22:11:02 +00004653 newval = term_bg_default();
Bram Moolenaar071d4272004-06-13 20:20:40 +00004654 }
4655
4656 /* expand environment variables and ~ (since the
4657 * default value was already expanded, only
4658 * required when an environment variable was set
4659 * later */
4660 if (newval == NULL)
4661 newval = empty_option;
4662 else
4663 {
4664 s = option_expand(opt_idx, newval);
4665 if (s == NULL)
4666 s = newval;
4667 newval = vim_strsave(s);
4668 }
4669 new_value_alloced = TRUE;
4670 }
4671 else if (nextchar == '<') /* set to global val */
4672 {
4673 newval = vim_strsave(*(char_u **)get_varp_scope(
4674 &(options[opt_idx]), OPT_GLOBAL));
4675 new_value_alloced = TRUE;
4676 }
4677 else
4678 {
4679 ++arg; /* jump to after the '=' or ':' */
4680
4681 /*
4682 * Set 'keywordprg' to ":help" if an empty
4683 * value was passed to :set by the user.
4684 * Misuse errbuf[] for the resulting string.
4685 */
4686 if (varp == (char_u *)&p_kp
4687 && (*arg == NUL || *arg == ' '))
4688 {
4689 STRCPY(errbuf, ":help");
4690 save_arg = arg;
4691 arg = errbuf;
4692 }
4693 /*
Bram Moolenaar4e5ccfa2011-11-30 11:15:47 +01004694 * Convert 'backspace' number to string, for
4695 * adding, prepending and removing string.
4696 */
4697 else if (varp == (char_u *)&p_bs
4698 && VIM_ISDIGIT(**(char_u **)varp))
4699 {
4700 i = getdigits((char_u **)varp);
4701 switch (i)
4702 {
4703 case 0:
4704 *(char_u **)varp = empty_option;
4705 break;
4706 case 1:
4707 *(char_u **)varp = vim_strsave(
4708 (char_u *)"indent,eol");
4709 break;
4710 case 2:
4711 *(char_u **)varp = vim_strsave(
4712 (char_u *)"indent,eol,start");
4713 break;
4714 }
4715 vim_free(oldval);
4716 oldval = *(char_u **)varp;
4717 }
4718 /*
Bram Moolenaar071d4272004-06-13 20:20:40 +00004719 * Convert 'whichwrap' number to string, for
4720 * backwards compatibility with Vim 3.0.
4721 * Misuse errbuf[] for the resulting string.
4722 */
4723 else if (varp == (char_u *)&p_ww
4724 && VIM_ISDIGIT(*arg))
4725 {
4726 *errbuf = NUL;
4727 i = getdigits(&arg);
4728 if (i & 1)
4729 STRCAT(errbuf, "b,");
4730 if (i & 2)
4731 STRCAT(errbuf, "s,");
4732 if (i & 4)
4733 STRCAT(errbuf, "h,l,");
4734 if (i & 8)
4735 STRCAT(errbuf, "<,>,");
4736 if (i & 16)
4737 STRCAT(errbuf, "[,],");
4738 if (*errbuf != NUL) /* remove trailing , */
4739 errbuf[STRLEN(errbuf) - 1] = NUL;
4740 save_arg = arg;
4741 arg = errbuf;
4742 }
4743 /*
4744 * Remove '>' before 'dir' and 'bdir', for
4745 * backwards compatibility with version 3.0
4746 */
4747 else if ( *arg == '>'
4748 && (varp == (char_u *)&p_dir
4749 || varp == (char_u *)&p_bdir))
4750 {
4751 ++arg;
4752 }
4753
4754 /* When setting the local value of a global
4755 * option, the old value may be the global value. */
Bram Moolenaara23ccb82006-02-27 00:08:02 +00004756 if (((int)options[opt_idx].indir & PV_BOTH)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004757 && (opt_flags & OPT_LOCAL))
4758 origval = *(char_u **)get_varp(
4759 &options[opt_idx]);
4760 else
4761 origval = oldval;
4762
4763 /*
4764 * Copy the new string into allocated memory.
4765 * Can't use set_string_option_direct(), because
4766 * we need to remove the backslashes.
4767 */
4768 /* get a bit too much */
4769 newlen = (unsigned)STRLEN(arg) + 1;
4770 if (adding || prepending || removing)
4771 newlen += (unsigned)STRLEN(origval) + 1;
4772 newval = alloc(newlen);
4773 if (newval == NULL) /* out of mem, don't change */
4774 break;
4775 s = newval;
4776
4777 /*
4778 * Copy the string, skip over escaped chars.
4779 * For MS-DOS and WIN32 backslashes before normal
4780 * file name characters are not removed, and keep
4781 * backslash at start, for "\\machine\path", but
4782 * do remove it for "\\\\machine\\path".
4783 * The reverse is found in ExpandOldSetting().
4784 */
4785 while (*arg && !vim_iswhite(*arg))
4786 {
4787 if (*arg == '\\' && arg[1] != NUL
4788#ifdef BACKSLASH_IN_FILENAME
4789 && !((flags & P_EXPAND)
4790 && vim_isfilec(arg[1])
4791 && (arg[1] != '\\'
4792 || (s == newval
4793 && arg[2] != '\\')))
4794#endif
4795 )
4796 ++arg; /* remove backslash */
4797#ifdef FEAT_MBYTE
4798 if (has_mbyte
Bram Moolenaar0fa313a2005-08-10 21:07:57 +00004799 && (i = (*mb_ptr2len)(arg)) > 1)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004800 {
4801 /* copy multibyte char */
4802 mch_memmove(s, arg, (size_t)i);
4803 arg += i;
4804 s += i;
4805 }
4806 else
4807#endif
4808 *s++ = *arg++;
4809 }
4810 *s = NUL;
4811
4812 /*
4813 * Expand environment variables and ~.
4814 * Don't do it when adding without inserting a
4815 * comma.
4816 */
4817 if (!(adding || prepending || removing)
4818 || (flags & P_COMMA))
4819 {
4820 s = option_expand(opt_idx, newval);
4821 if (s != NULL)
4822 {
4823 vim_free(newval);
4824 newlen = (unsigned)STRLEN(s) + 1;
4825 if (adding || prepending || removing)
4826 newlen += (unsigned)STRLEN(origval) + 1;
4827 newval = alloc(newlen);
4828 if (newval == NULL)
4829 break;
4830 STRCPY(newval, s);
4831 }
4832 }
4833
4834 /* locate newval[] in origval[] when removing it
4835 * and when adding to avoid duplicates */
4836 i = 0; /* init for GCC */
4837 if (removing || (flags & P_NODUP))
4838 {
4839 i = (int)STRLEN(newval);
4840 bs = 0;
4841 for (s = origval; *s; ++s)
4842 {
4843 if ((!(flags & P_COMMA)
4844 || s == origval
4845 || (s[-1] == ',' && !(bs & 1)))
4846 && STRNCMP(s, newval, i) == 0
4847 && (!(flags & P_COMMA)
4848 || s[i] == ','
4849 || s[i] == NUL))
4850 break;
Bram Moolenaar0b2f94d2011-03-22 14:35:05 +01004851 /* Count backslashes. Only a comma with an
Bram Moolenaar8f79acd2016-01-01 14:48:20 +01004852 * even number of backslashes or a single
4853 * backslash preceded by a comma before it
4854 * is recognized as a separator */
4855 if ((s > origval + 1
4856 && s[-1] == '\\'
4857 && s[-2] != ',')
4858 || (s == origval + 1
4859 && s[-1] == '\\'))
4860
Bram Moolenaar071d4272004-06-13 20:20:40 +00004861 ++bs;
4862 else
4863 bs = 0;
4864 }
4865
4866 /* do not add if already there */
4867 if ((adding || prepending) && *s)
4868 {
4869 prepending = FALSE;
4870 adding = FALSE;
4871 STRCPY(newval, origval);
4872 }
4873 }
4874
4875 /* concatenate the two strings; add a ',' if
4876 * needed */
4877 if (adding || prepending)
4878 {
4879 comma = ((flags & P_COMMA) && *origval != NUL
4880 && *newval != NUL);
4881 if (adding)
4882 {
4883 i = (int)STRLEN(origval);
Bram Moolenaara7b7b1c2015-06-19 14:06:43 +02004884 /* strip a trailing comma, would get 2 */
Bram Moolenaar17467472015-11-10 17:50:24 +01004885 if (comma && i > 1
4886 && (flags & P_ONECOMMA) == P_ONECOMMA
4887 && origval[i - 1] == ','
4888 && origval[i - 2] != '\\')
Bram Moolenaara7b7b1c2015-06-19 14:06:43 +02004889 i--;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004890 mch_memmove(newval + i + comma, newval,
4891 STRLEN(newval) + 1);
4892 mch_memmove(newval, origval, (size_t)i);
4893 }
4894 else
4895 {
4896 i = (int)STRLEN(newval);
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00004897 STRMOVE(newval + i + comma, origval);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004898 }
4899 if (comma)
4900 newval[i] = ',';
4901 }
4902
4903 /* Remove newval[] from origval[]. (Note: "i" has
4904 * been set above and is used here). */
4905 if (removing)
4906 {
4907 STRCPY(newval, origval);
4908 if (*s)
4909 {
4910 /* may need to remove a comma */
4911 if (flags & P_COMMA)
4912 {
4913 if (s == origval)
4914 {
4915 /* include comma after string */
4916 if (s[i] == ',')
4917 ++i;
4918 }
4919 else
4920 {
4921 /* include comma before string */
4922 --s;
4923 ++i;
4924 }
4925 }
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00004926 STRMOVE(newval + (s - origval), s + i);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004927 }
4928 }
4929
4930 if (flags & P_FLAGLIST)
4931 {
4932 /* Remove flags that appear twice. */
4933 for (s = newval; *s; ++s)
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02004934 {
4935 /* if options have P_FLAGLIST and
4936 * P_ONECOMMA such as 'whichwrap' */
4937 if (flags & P_ONECOMMA)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004938 {
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02004939 if (*s != ',' && *(s + 1) == ','
4940 && vim_strchr(s + 2, *s) != NULL)
4941 {
4942 /* Remove the duplicated value and
4943 * the next comma. */
4944 STRMOVE(s, s + 2);
4945 s -= 2;
4946 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004947 }
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02004948 else
4949 {
4950 if ((!(flags & P_COMMA) || *s != ',')
4951 && vim_strchr(s + 1, *s) != NULL)
4952 {
4953 STRMOVE(s, s + 1);
4954 --s;
4955 }
4956 }
4957 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004958 }
4959
4960 if (save_arg != NULL) /* number for 'whichwrap' */
4961 arg = save_arg;
4962 new_value_alloced = TRUE;
4963 }
4964
4965 /* Set the new value. */
4966 *(char_u **)(varp) = newval;
4967
Bram Moolenaar53744302015-07-17 17:38:22 +02004968#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
Bram Moolenaar5cbb8db2015-07-17 23:08:29 +02004969 if (!starting
4970# ifdef FEAT_CRYPT
4971 && options[opt_idx].indir != PV_KEY
4972# endif
Bram Moolenaar53744302015-07-17 17:38:22 +02004973 && origval != NULL)
4974 /* origval may be freed by
4975 * did_set_string_option(), make a copy. */
4976 saved_origval = vim_strsave(origval);
4977#endif
4978
Bram Moolenaar071d4272004-06-13 20:20:40 +00004979 /* Handle side effects, and set the global value for
4980 * ":set" on local options. */
4981 errmsg = did_set_string_option(opt_idx, (char_u **)varp,
4982 new_value_alloced, oldval, errbuf, opt_flags);
4983
4984 /* If error detected, print the error message. */
4985 if (errmsg != NULL)
Bram Moolenaara9884962015-12-13 15:08:56 +01004986 {
4987#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
4988 vim_free(saved_origval);
4989#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004990 goto skip;
Bram Moolenaara9884962015-12-13 15:08:56 +01004991 }
Bram Moolenaar53744302015-07-17 17:38:22 +02004992#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
4993 if (saved_origval != NULL)
4994 {
4995 char_u buf_type[7];
4996
4997 sprintf((char *)buf_type, "%s",
4998 (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar9cac4242015-07-19 14:42:23 +02004999 set_vim_var_string(VV_OPTION_NEW,
5000 *(char_u **)varp, -1);
Bram Moolenaar53744302015-07-17 17:38:22 +02005001 set_vim_var_string(VV_OPTION_OLD, saved_origval, -1);
5002 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
5003 apply_autocmds(EVENT_OPTIONSET,
5004 (char_u *)options[opt_idx].fullname,
5005 NULL, FALSE, NULL);
5006 reset_v_option_vars();
5007 vim_free(saved_origval);
5008 }
5009#endif
5010
Bram Moolenaar071d4272004-06-13 20:20:40 +00005011 }
5012 else /* key code option */
5013 {
5014 char_u *p;
5015
5016 if (nextchar == '&')
5017 {
5018 if (add_termcap_entry(key_name, TRUE) == FAIL)
5019 errmsg = (char_u *)N_("E522: Not found in termcap");
5020 }
5021 else
5022 {
5023 ++arg; /* jump to after the '=' or ':' */
5024 for (p = arg; *p && !vim_iswhite(*p); ++p)
5025 if (*p == '\\' && p[1] != NUL)
5026 ++p;
5027 nextchar = *p;
5028 *p = NUL;
5029 add_termcode(key_name, arg, FALSE);
5030 *p = nextchar;
5031 }
5032 if (full_screen)
5033 ttest(FALSE);
5034 redraw_all_later(CLEAR);
5035 }
5036 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005037
Bram Moolenaar071d4272004-06-13 20:20:40 +00005038 if (opt_idx >= 0)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005039 did_set_option(opt_idx, opt_flags,
5040 !prepending && !adding && !removing);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005041 }
5042
5043skip:
5044 /*
5045 * Advance to next argument.
5046 * - skip until a blank found, taking care of backslashes
5047 * - skip blanks
5048 * - skip one "=val" argument (for hidden options ":set gfn =xx")
5049 */
5050 for (i = 0; i < 2 ; ++i)
5051 {
5052 while (*arg != NUL && !vim_iswhite(*arg))
5053 if (*arg++ == '\\' && *arg != NUL)
5054 ++arg;
5055 arg = skipwhite(arg);
5056 if (*arg != '=')
5057 break;
5058 }
5059 }
5060
5061 if (errmsg != NULL)
5062 {
Bram Moolenaarce0842a2005-07-18 21:58:11 +00005063 vim_strncpy(IObuff, (char_u *)_(errmsg), IOSIZE - 1);
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00005064 i = (int)STRLEN(IObuff) + 2;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005065 if (i + (arg - startarg) < IOSIZE)
5066 {
5067 /* append the argument with the error */
5068 STRCAT(IObuff, ": ");
5069 mch_memmove(IObuff + i, startarg, (arg - startarg));
5070 IObuff[i + (arg - startarg)] = NUL;
5071 }
5072 /* make sure all characters are printable */
5073 trans_characters(IObuff, IOSIZE);
5074
5075 ++no_wait_return; /* wait_return done later */
5076 emsg(IObuff); /* show error highlighted */
5077 --no_wait_return;
5078
5079 return FAIL;
5080 }
5081
5082 arg = skipwhite(arg);
5083 }
5084
Bram Moolenaar26a60b42005-02-22 08:49:11 +00005085theend:
5086 if (silent_mode && did_show)
5087 {
5088 /* After displaying option values in silent mode. */
5089 silent_mode = FALSE;
5090 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
5091 msg_putchar('\n');
5092 cursor_on(); /* msg_start() switches it off */
5093 out_flush();
5094 silent_mode = TRUE;
5095 info_message = FALSE; /* use mch_msg(), not mch_errmsg() */
5096 }
5097
Bram Moolenaar071d4272004-06-13 20:20:40 +00005098 return OK;
5099}
5100
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005101/*
5102 * Call this when an option has been given a new value through a user command.
5103 * Sets the P_WAS_SET flag and takes care of the P_INSECURE flag.
5104 */
5105 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005106did_set_option(
5107 int opt_idx,
5108 int opt_flags, /* possibly with OPT_MODELINE */
5109 int new_value) /* value was replaced completely */
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005110{
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005111 long_u *p;
5112
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005113 options[opt_idx].flags |= P_WAS_SET;
5114
5115 /* When an option is set in the sandbox, from a modeline or in secure mode
5116 * set the P_INSECURE flag. Otherwise, if a new value is stored reset the
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005117 * flag. */
5118 p = insecure_flag(opt_idx, opt_flags);
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005119 if (secure
5120#ifdef HAVE_SANDBOX
5121 || sandbox != 0
5122#endif
5123 || (opt_flags & OPT_MODELINE))
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005124 *p = *p | P_INSECURE;
5125 else if (new_value)
5126 *p = *p & ~P_INSECURE;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005127}
5128
Bram Moolenaar071d4272004-06-13 20:20:40 +00005129 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005130illegal_char(char_u *errbuf, int c)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005131{
5132 if (errbuf == NULL)
5133 return (char_u *)"";
5134 sprintf((char *)errbuf, _("E539: Illegal character <%s>"),
Bram Moolenaar555b2802005-05-19 21:08:39 +00005135 (char *)transchar(c));
Bram Moolenaar071d4272004-06-13 20:20:40 +00005136 return errbuf;
5137}
5138
5139/*
5140 * Convert a key name or string into a key value.
5141 * Used for 'wildchar' and 'cedit' options.
5142 */
5143 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01005144string_to_key(char_u *arg)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005145{
5146 if (*arg == '<')
5147 return find_key_option(arg + 1);
5148 if (*arg == '^')
5149 return Ctrl_chr(arg[1]);
5150 return *arg;
5151}
5152
5153#ifdef FEAT_CMDWIN
5154/*
5155 * Check value of 'cedit' and set cedit_key.
5156 * Returns NULL if value is OK, error message otherwise.
5157 */
5158 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005159check_cedit(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005160{
5161 int n;
5162
5163 if (*p_cedit == NUL)
5164 cedit_key = -1;
5165 else
5166 {
5167 n = string_to_key(p_cedit);
5168 if (vim_isprintc(n))
5169 return e_invarg;
5170 cedit_key = n;
5171 }
5172 return NULL;
5173}
5174#endif
5175
5176#ifdef FEAT_TITLE
5177/*
5178 * When changing 'title', 'titlestring', 'icon' or 'iconstring', call
5179 * maketitle() to create and display it.
5180 * When switching the title or icon off, call mch_restore_title() to get
5181 * the old value back.
5182 */
5183 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005184did_set_title(
5185 int icon) /* Did set icon instead of title */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005186{
5187 if (starting != NO_SCREEN
5188#ifdef FEAT_GUI
5189 && !gui.starting
5190#endif
5191 )
5192 {
5193 maketitle();
5194 if (icon)
5195 {
5196 if (!p_icon)
5197 mch_restore_title(2);
5198 }
5199 else
5200 {
5201 if (!p_title)
5202 mch_restore_title(1);
5203 }
5204 }
5205}
5206#endif
5207
5208/*
5209 * set_options_bin - called when 'bin' changes value.
5210 */
5211 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005212set_options_bin(
5213 int oldval,
5214 int newval,
5215 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005216{
5217 /*
5218 * The option values that are changed when 'bin' changes are
5219 * copied when 'bin is set and restored when 'bin' is reset.
5220 */
5221 if (newval)
5222 {
5223 if (!oldval) /* switched on */
5224 {
5225 if (!(opt_flags & OPT_GLOBAL))
5226 {
5227 curbuf->b_p_tw_nobin = curbuf->b_p_tw;
5228 curbuf->b_p_wm_nobin = curbuf->b_p_wm;
5229 curbuf->b_p_ml_nobin = curbuf->b_p_ml;
5230 curbuf->b_p_et_nobin = curbuf->b_p_et;
5231 }
5232 if (!(opt_flags & OPT_LOCAL))
5233 {
5234 p_tw_nobin = p_tw;
5235 p_wm_nobin = p_wm;
5236 p_ml_nobin = p_ml;
5237 p_et_nobin = p_et;
5238 }
5239 }
5240
5241 if (!(opt_flags & OPT_GLOBAL))
5242 {
5243 curbuf->b_p_tw = 0; /* no automatic line wrap */
5244 curbuf->b_p_wm = 0; /* no automatic line wrap */
5245 curbuf->b_p_ml = 0; /* no modelines */
5246 curbuf->b_p_et = 0; /* no expandtab */
5247 }
5248 if (!(opt_flags & OPT_LOCAL))
5249 {
5250 p_tw = 0;
5251 p_wm = 0;
5252 p_ml = FALSE;
5253 p_et = FALSE;
5254 p_bin = TRUE; /* needed when called for the "-b" argument */
5255 }
5256 }
5257 else if (oldval) /* switched off */
5258 {
5259 if (!(opt_flags & OPT_GLOBAL))
5260 {
5261 curbuf->b_p_tw = curbuf->b_p_tw_nobin;
5262 curbuf->b_p_wm = curbuf->b_p_wm_nobin;
5263 curbuf->b_p_ml = curbuf->b_p_ml_nobin;
5264 curbuf->b_p_et = curbuf->b_p_et_nobin;
5265 }
5266 if (!(opt_flags & OPT_LOCAL))
5267 {
5268 p_tw = p_tw_nobin;
5269 p_wm = p_wm_nobin;
5270 p_ml = p_ml_nobin;
5271 p_et = p_et_nobin;
5272 }
5273 }
5274}
5275
5276#ifdef FEAT_VIMINFO
5277/*
5278 * Find the parameter represented by the given character (eg ', :, ", or /),
5279 * and return its associated value in the 'viminfo' string.
5280 * Only works for number parameters, not for 'r' or 'n'.
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +00005281 * If the parameter is not specified in the string or there is no following
5282 * number, return -1.
Bram Moolenaar071d4272004-06-13 20:20:40 +00005283 */
5284 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01005285get_viminfo_parameter(int type)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005286{
5287 char_u *p;
5288
5289 p = find_viminfo_parameter(type);
5290 if (p != NULL && VIM_ISDIGIT(*p))
5291 return atoi((char *)p);
5292 return -1;
5293}
5294
5295/*
5296 * Find the parameter represented by the given character (eg ''', ':', '"', or
5297 * '/') in the 'viminfo' option and return a pointer to the string after it.
5298 * Return NULL if the parameter is not specified in the string.
5299 */
5300 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005301find_viminfo_parameter(int type)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005302{
5303 char_u *p;
5304
5305 for (p = p_viminfo; *p; ++p)
5306 {
5307 if (*p == type)
5308 return p + 1;
5309 if (*p == 'n') /* 'n' is always the last one */
5310 break;
5311 p = vim_strchr(p, ','); /* skip until next ',' */
5312 if (p == NULL) /* hit the end without finding parameter */
5313 break;
5314 }
5315 return NULL;
5316}
5317#endif
5318
5319/*
5320 * Expand environment variables for some string options.
5321 * These string options cannot be indirect!
5322 * If "val" is NULL expand the current value of the option.
5323 * Return pointer to NameBuff, or NULL when not expanded.
5324 */
5325 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005326option_expand(int opt_idx, char_u *val)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005327{
5328 /* if option doesn't need expansion nothing to do */
5329 if (!(options[opt_idx].flags & P_EXPAND) || options[opt_idx].var == NULL)
5330 return NULL;
5331
5332 /* If val is longer than MAXPATHL no meaningful expansion can be done,
5333 * expand_env() would truncate the string. */
5334 if (val != NULL && STRLEN(val) > MAXPATHL)
5335 return NULL;
5336
5337 if (val == NULL)
5338 val = *(char_u **)options[opt_idx].var;
5339
5340 /*
5341 * Expanding this with NameBuff, expand_env() must not be passed IObuff.
5342 * Escape spaces when expanding 'tags', they are used to separate file
5343 * names.
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005344 * For 'spellsuggest' expand after "file:".
Bram Moolenaar071d4272004-06-13 20:20:40 +00005345 */
5346 expand_env_esc(val, NameBuff, MAXPATHL,
Bram Moolenaar9f0545d2007-09-26 20:36:32 +00005347 (char_u **)options[opt_idx].var == &p_tags, FALSE,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005348#ifdef FEAT_SPELL
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005349 (char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" :
5350#endif
5351 NULL);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005352 if (STRCMP(NameBuff, val) == 0) /* they are the same */
5353 return NULL;
5354
5355 return NameBuff;
5356}
5357
5358/*
5359 * After setting various option values: recompute variables that depend on
5360 * option values.
5361 */
5362 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005363didset_options(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005364{
5365 /* initialize the table for 'iskeyword' et.al. */
5366 (void)init_chartab();
5367
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00005368#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +00005369 (void)opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE);
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00005370#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005371 (void)opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, TRUE);
Bram Moolenaar165bc692015-07-21 17:53:25 +02005372 (void)opt_strings_flags(p_bo, p_bo_values, &bo_flags, TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005373#ifdef FEAT_SESSION
5374 (void)opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE);
5375 (void)opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE);
5376#endif
5377#ifdef FEAT_FOLDING
5378 (void)opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE);
5379#endif
5380 (void)opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE);
Bram Moolenaar0f6562e2015-11-24 18:48:14 +01005381 (void)opt_strings_flags(p_tc, p_tc_values, &tc_flags, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005382#ifdef FEAT_VIRTUALEDIT
5383 (void)opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE);
5384#endif
5385#if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
5386 (void)opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE);
5387#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005388#ifdef FEAT_SPELL
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00005389 (void)spell_check_msm();
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005390 (void)spell_check_sps();
Bram Moolenaar860cae12010-06-05 23:22:07 +02005391 (void)compile_cap_prog(curwin->w_s);
Bram Moolenaare68c25c2015-08-25 15:39:55 +02005392 (void)did_set_spell_option(TRUE);
Bram Moolenaard857f0e2005-06-21 22:37:39 +00005393#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005394#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
5395 (void)opt_strings_flags(p_toolbar, p_toolbar_values, &toolbar_flags, TRUE);
5396#endif
Bram Moolenaar182c5be2010-06-25 05:37:59 +02005397#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005398 (void)opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE);
5399#endif
5400#ifdef FEAT_CMDWIN
5401 /* set cedit_key */
5402 (void)check_cedit();
5403#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +02005404#ifdef FEAT_LINEBREAK
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02005405 briopt_check(curwin);
Bram Moolenaar597a4222014-06-25 14:39:50 +02005406#endif
Bram Moolenaare68c25c2015-08-25 15:39:55 +02005407#ifdef FEAT_LINEBREAK
5408 /* initialize the table for 'breakat'. */
5409 fill_breakat_flags();
5410#endif
5411
5412}
5413
5414/*
5415 * More side effects of setting options.
5416 */
5417 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005418didset_options2(void)
Bram Moolenaare68c25c2015-08-25 15:39:55 +02005419{
5420 /* Initialize the highlight_attr[] table. */
5421 (void)highlight_changed();
5422
5423 /* Parse default for 'wildmode' */
5424 check_opt_wim();
5425
5426 (void)set_chars_option(&p_lcs);
5427#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
5428 /* Parse default for 'fillchars'. */
5429 (void)set_chars_option(&p_fcs);
5430#endif
5431
5432#ifdef FEAT_CLIPBOARD
5433 /* Parse default for 'clipboard' */
5434 (void)check_clipboard_option();
5435#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005436}
5437
5438/*
5439 * Check for string options that are NULL (normally only termcap options).
5440 */
5441 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005442check_options(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005443{
5444 int opt_idx;
5445
5446 for (opt_idx = 0; options[opt_idx].fullname != NULL; opt_idx++)
5447 if ((options[opt_idx].flags & P_STRING) && options[opt_idx].var != NULL)
5448 check_string_option((char_u **)get_varp(&(options[opt_idx])));
5449}
5450
5451/*
5452 * Check string options in a buffer for NULL value.
5453 */
5454 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005455check_buf_options(buf_T *buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005456{
5457#if defined(FEAT_QUICKFIX)
5458 check_string_option(&buf->b_p_bh);
5459 check_string_option(&buf->b_p_bt);
5460#endif
5461#ifdef FEAT_MBYTE
5462 check_string_option(&buf->b_p_fenc);
5463#endif
5464 check_string_option(&buf->b_p_ff);
5465#ifdef FEAT_FIND_ID
5466 check_string_option(&buf->b_p_def);
5467 check_string_option(&buf->b_p_inc);
5468# ifdef FEAT_EVAL
5469 check_string_option(&buf->b_p_inex);
5470# endif
5471#endif
5472#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
5473 check_string_option(&buf->b_p_inde);
5474 check_string_option(&buf->b_p_indk);
5475#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00005476#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
5477 check_string_option(&buf->b_p_bexpr);
5478#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +02005479#if defined(FEAT_CRYPT)
5480 check_string_option(&buf->b_p_cm);
5481#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00005482#if defined(FEAT_EVAL)
5483 check_string_option(&buf->b_p_fex);
5484#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005485#ifdef FEAT_CRYPT
5486 check_string_option(&buf->b_p_key);
5487#endif
5488 check_string_option(&buf->b_p_kp);
5489 check_string_option(&buf->b_p_mps);
5490 check_string_option(&buf->b_p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +00005491 check_string_option(&buf->b_p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005492 check_string_option(&buf->b_p_isk);
5493#ifdef FEAT_COMMENTS
5494 check_string_option(&buf->b_p_com);
5495#endif
5496#ifdef FEAT_FOLDING
5497 check_string_option(&buf->b_p_cms);
5498#endif
5499 check_string_option(&buf->b_p_nf);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005500#ifdef FEAT_TEXTOBJ
5501 check_string_option(&buf->b_p_qe);
5502#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005503#ifdef FEAT_SYN_HL
5504 check_string_option(&buf->b_p_syn);
Bram Moolenaarb8060fe2016-01-19 22:29:28 +01005505 check_string_option(&buf->b_s.b_syn_isk);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005506#endif
5507#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02005508 check_string_option(&buf->b_s.b_p_spc);
5509 check_string_option(&buf->b_s.b_p_spf);
5510 check_string_option(&buf->b_s.b_p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005511#endif
5512#ifdef FEAT_SEARCHPATH
5513 check_string_option(&buf->b_p_sua);
5514#endif
5515#ifdef FEAT_CINDENT
5516 check_string_option(&buf->b_p_cink);
5517 check_string_option(&buf->b_p_cino);
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01005518 parse_cino(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005519#endif
5520#ifdef FEAT_AUTOCMD
5521 check_string_option(&buf->b_p_ft);
5522#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005523#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
5524 check_string_option(&buf->b_p_cinw);
5525#endif
5526#ifdef FEAT_INS_EXPAND
5527 check_string_option(&buf->b_p_cpt);
5528#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005529#ifdef FEAT_COMPL_FUNC
5530 check_string_option(&buf->b_p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +00005531 check_string_option(&buf->b_p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005532#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005533#ifdef FEAT_KEYMAP
5534 check_string_option(&buf->b_p_keymap);
5535#endif
5536#ifdef FEAT_QUICKFIX
5537 check_string_option(&buf->b_p_gp);
5538 check_string_option(&buf->b_p_mp);
5539 check_string_option(&buf->b_p_efm);
5540#endif
5541 check_string_option(&buf->b_p_ep);
5542 check_string_option(&buf->b_p_path);
5543 check_string_option(&buf->b_p_tags);
Bram Moolenaar0f6562e2015-11-24 18:48:14 +01005544 check_string_option(&buf->b_p_tc);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005545#ifdef FEAT_INS_EXPAND
5546 check_string_option(&buf->b_p_dict);
5547 check_string_option(&buf->b_p_tsr);
5548#endif
Bram Moolenaaraf6c1312014-03-12 18:55:58 +01005549#ifdef FEAT_LISP
5550 check_string_option(&buf->b_p_lw);
5551#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02005552 check_string_option(&buf->b_p_bkc);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005553}
5554
5555/*
5556 * Free the string allocated for an option.
5557 * Checks for the string being empty_option. This may happen if we're out of
5558 * memory, vim_strsave() returned NULL, which was replaced by empty_option by
5559 * check_options().
5560 * Does NOT check for P_ALLOCED flag!
5561 */
5562 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005563free_string_option(char_u *p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005564{
5565 if (p != empty_option)
5566 vim_free(p);
5567}
5568
5569 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005570clear_string_option(char_u **pp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005571{
5572 if (*pp != empty_option)
5573 vim_free(*pp);
5574 *pp = empty_option;
5575}
5576
5577 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005578check_string_option(char_u **pp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005579{
5580 if (*pp == NULL)
5581 *pp = empty_option;
5582}
5583
5584/*
5585 * Mark a terminal option as allocated, found by a pointer into term_strings[].
5586 */
5587 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005588set_term_option_alloced(char_u **p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005589{
5590 int opt_idx;
5591
5592 for (opt_idx = 1; options[opt_idx].fullname != NULL; opt_idx++)
5593 if (options[opt_idx].var == (char_u *)p)
5594 {
5595 options[opt_idx].flags |= P_ALLOCED;
5596 return;
5597 }
5598 return; /* cannot happen: didn't find it! */
5599}
5600
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005601#if defined(FEAT_EVAL) || defined(PROTO)
5602/*
5603 * Return TRUE when option "opt" was set from a modeline or in secure mode.
5604 * Return FALSE when it wasn't.
5605 * Return -1 for an unknown option.
5606 */
5607 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01005608was_set_insecurely(char_u *opt, int opt_flags)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005609{
5610 int idx = findoption(opt);
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005611 long_u *flagp;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005612
5613 if (idx >= 0)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005614 {
5615 flagp = insecure_flag(idx, opt_flags);
5616 return (*flagp & P_INSECURE) != 0;
5617 }
Bram Moolenaar95f09602016-11-10 20:01:45 +01005618 internal_error("was_set_insecurely()");
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005619 return -1;
5620}
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005621
5622/*
5623 * Get a pointer to the flags used for the P_INSECURE flag of option
5624 * "opt_idx". For some local options a local flags field is used.
5625 */
5626 static long_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005627insecure_flag(int opt_idx, int opt_flags)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005628{
5629 if (opt_flags & OPT_LOCAL)
5630 switch ((int)options[opt_idx].indir)
5631 {
5632#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005633 case PV_STL: return &curwin->w_p_stl_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005634#endif
5635#ifdef FEAT_EVAL
Bram Moolenaar2e978902006-05-13 12:37:50 +00005636# ifdef FEAT_FOLDING
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005637 case PV_FDE: return &curwin->w_p_fde_flags;
5638 case PV_FDT: return &curwin->w_p_fdt_flags;
Bram Moolenaar2e978902006-05-13 12:37:50 +00005639# endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00005640# ifdef FEAT_BEVAL
5641 case PV_BEXPR: return &curbuf->b_p_bexpr_flags;
5642# endif
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005643# if defined(FEAT_CINDENT)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005644 case PV_INDE: return &curbuf->b_p_inde_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005645# endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005646 case PV_FEX: return &curbuf->b_p_fex_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005647# ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005648 case PV_INEX: return &curbuf->b_p_inex_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005649# endif
5650#endif
5651 }
5652
5653 /* Nothing special, return global flags field. */
5654 return &options[opt_idx].flags;
5655}
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005656#endif
5657
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005658#ifdef FEAT_TITLE
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01005659static void redraw_titles(void);
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005660
5661/*
5662 * Redraw the window title and/or tab page text later.
5663 */
Bram Moolenaar9b578142016-01-30 19:39:49 +01005664static void redraw_titles(void)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005665{
5666 need_maketitle = TRUE;
5667# ifdef FEAT_WINDOWS
5668 redraw_tabline = TRUE;
5669# endif
5670}
5671#endif
5672
Bram Moolenaar071d4272004-06-13 20:20:40 +00005673/*
5674 * Set a string option to a new value (without checking the effect).
5675 * The string is copied into allocated memory.
5676 * if ("opt_idx" == -1) "name" is used, otherwise "opt_idx" is used.
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005677 * When "set_sid" is zero set the scriptID to current_SID. When "set_sid" is
Bram Moolenaard55de222007-05-06 13:38:48 +00005678 * SID_NONE don't set the scriptID. Otherwise set the scriptID to "set_sid".
Bram Moolenaar071d4272004-06-13 20:20:40 +00005679 */
5680 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005681set_string_option_direct(
5682 char_u *name,
5683 int opt_idx,
5684 char_u *val,
5685 int opt_flags, /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
5686 int set_sid UNUSED)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005687{
5688 char_u *s;
5689 char_u **varp;
5690 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
Bram Moolenaar89d40322006-08-29 15:30:07 +00005691 int idx = opt_idx;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005692
Bram Moolenaar89d40322006-08-29 15:30:07 +00005693 if (idx == -1) /* use name */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005694 {
Bram Moolenaar89d40322006-08-29 15:30:07 +00005695 idx = findoption(name);
5696 if (idx < 0) /* not found (should not happen) */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005697 {
5698 EMSG2(_(e_intern2), "set_string_option_direct()");
Bram Moolenaar95f09602016-11-10 20:01:45 +01005699 IEMSG2(_("For option %s"), name);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005700 return;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005701 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005702 }
5703
Bram Moolenaar89d40322006-08-29 15:30:07 +00005704 if (options[idx].var == NULL) /* can't set hidden option */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005705 return;
5706
5707 s = vim_strsave(val);
5708 if (s != NULL)
5709 {
Bram Moolenaar89d40322006-08-29 15:30:07 +00005710 varp = (char_u **)get_varp_scope(&(options[idx]),
Bram Moolenaar071d4272004-06-13 20:20:40 +00005711 both ? OPT_LOCAL : opt_flags);
Bram Moolenaar89d40322006-08-29 15:30:07 +00005712 if ((opt_flags & OPT_FREE) && (options[idx].flags & P_ALLOCED))
Bram Moolenaar071d4272004-06-13 20:20:40 +00005713 free_string_option(*varp);
5714 *varp = s;
5715
5716 /* For buffer/window local option may also set the global value. */
5717 if (both)
Bram Moolenaar89d40322006-08-29 15:30:07 +00005718 set_string_option_global(idx, varp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005719
Bram Moolenaar89d40322006-08-29 15:30:07 +00005720 options[idx].flags |= P_ALLOCED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005721
5722 /* When setting both values of a global option with a local value,
5723 * make the local value empty, so that the global value is used. */
Bram Moolenaar89d40322006-08-29 15:30:07 +00005724 if (((int)options[idx].indir & PV_BOTH) && both)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005725 {
5726 free_string_option(*varp);
5727 *varp = empty_option;
5728 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005729# ifdef FEAT_EVAL
5730 if (set_sid != SID_NONE)
Bram Moolenaar89d40322006-08-29 15:30:07 +00005731 set_option_scriptID_idx(idx, opt_flags,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005732 set_sid == 0 ? current_SID : set_sid);
5733# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005734 }
5735}
5736
5737/*
5738 * Set global value for string option when it's a local option.
5739 */
5740 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005741set_string_option_global(
5742 int opt_idx, /* option index */
5743 char_u **varp) /* pointer to option variable */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005744{
5745 char_u **p, *s;
5746
5747 /* the global value is always allocated */
5748 if (options[opt_idx].var == VAR_WIN)
5749 p = (char_u **)GLOBAL_WO(varp);
5750 else
5751 p = (char_u **)options[opt_idx].var;
5752 if (options[opt_idx].indir != PV_NONE
5753 && p != varp
5754 && (s = vim_strsave(*varp)) != NULL)
5755 {
5756 free_string_option(*p);
5757 *p = s;
5758 }
5759}
5760
5761/*
5762 * Set a string option to a new value, and handle the effects.
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005763 *
5764 * Returns NULL on success or error message on error.
Bram Moolenaar071d4272004-06-13 20:20:40 +00005765 */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005766 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005767set_string_option(
5768 int opt_idx,
5769 char_u *value,
5770 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005771{
5772 char_u *s;
5773 char_u **varp;
5774 char_u *oldval;
Bram Moolenaar53744302015-07-17 17:38:22 +02005775#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
5776 char_u *saved_oldval = NULL;
5777#endif
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005778 char_u *r = NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005779
5780 if (options[opt_idx].var == NULL) /* don't set hidden option */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005781 return NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005782
5783 s = vim_strsave(value);
5784 if (s != NULL)
5785 {
5786 varp = (char_u **)get_varp_scope(&(options[opt_idx]),
5787 (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00005788 ? (((int)options[opt_idx].indir & PV_BOTH)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005789 ? OPT_GLOBAL : OPT_LOCAL)
5790 : opt_flags);
5791 oldval = *varp;
5792 *varp = s;
Bram Moolenaar53744302015-07-17 17:38:22 +02005793
5794#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
Bram Moolenaar5cbb8db2015-07-17 23:08:29 +02005795 if (!starting
5796# ifdef FEAT_CRYPT
5797 && options[opt_idx].indir != PV_KEY
5798# endif
5799 )
Bram Moolenaar53744302015-07-17 17:38:22 +02005800 saved_oldval = vim_strsave(oldval);
5801#endif
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005802 if ((r = did_set_string_option(opt_idx, varp, TRUE, oldval, NULL,
5803 opt_flags)) == NULL)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005804 did_set_option(opt_idx, opt_flags, TRUE);
Bram Moolenaar53744302015-07-17 17:38:22 +02005805
5806 /* call autocomamnd after handling side effects */
5807#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
5808 if (saved_oldval != NULL)
5809 {
5810 char_u buf_type[7];
5811 sprintf((char *)buf_type, "%s",
5812 (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar9cac4242015-07-19 14:42:23 +02005813 set_vim_var_string(VV_OPTION_NEW, *varp, -1);
5814 set_vim_var_string(VV_OPTION_OLD, saved_oldval, -1);
Bram Moolenaar53744302015-07-17 17:38:22 +02005815 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
5816 apply_autocmds(EVENT_OPTIONSET, (char_u *)options[opt_idx].fullname, NULL, FALSE, NULL);
5817 reset_v_option_vars();
5818 vim_free(saved_oldval);
5819 }
5820#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005821 }
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005822 return r;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005823}
5824
Bram Moolenaar40d3f132016-11-05 20:13:35 +01005825#if defined(FEAT_KEYMAP) || defined(FEAT_AUTOCMD) || defined(FEAT_SYN_HL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005826/*
Bram Moolenaard0b51382016-11-04 15:23:45 +01005827 * Return TRUE if "val" is a valid 'filetype' name.
5828 * Also used for 'syntax' and 'keymap'.
5829 */
5830 static int
5831valid_filetype(char_u *val)
5832{
5833 char_u *s;
5834
5835 for (s = val; *s != NUL; ++s)
5836 if (!ASCII_ISALNUM(*s) && vim_strchr((char_u *)".-_", *s) == NULL)
5837 return FALSE;
5838 return TRUE;
5839}
Bram Moolenaar40d3f132016-11-05 20:13:35 +01005840#endif
Bram Moolenaard0b51382016-11-04 15:23:45 +01005841
5842/*
Bram Moolenaar071d4272004-06-13 20:20:40 +00005843 * Handle string options that need some action to perform when changed.
5844 * Returns NULL for success, or an error message for an error.
5845 */
5846 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005847did_set_string_option(
5848 int opt_idx, /* index in options[] table */
5849 char_u **varp, /* pointer to the option variable */
5850 int new_value_alloced, /* new value was allocated */
5851 char_u *oldval, /* previous value of the option */
5852 char_u *errbuf, /* buffer for errors, or NULL */
5853 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005854{
5855 char_u *errmsg = NULL;
5856 char_u *s, *p;
5857 int did_chartab = FALSE;
5858 char_u **gvarp;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00005859 long_u free_oldval = (options[opt_idx].flags & P_ALLOCED);
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00005860#ifdef FEAT_GUI
5861 /* set when changing an option that only requires a redraw in the GUI */
5862 int redraw_gui_only = FALSE;
5863#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005864
5865 /* Get the global option to compare with, otherwise we would have to check
5866 * two values for all local options. */
5867 gvarp = (char_u **)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL);
5868
5869 /* Disallow changing some options from secure mode */
5870 if ((secure
5871#ifdef HAVE_SANDBOX
5872 || sandbox != 0
5873#endif
5874 ) && (options[opt_idx].flags & P_SECURE))
5875 {
5876 errmsg = e_secure;
5877 }
5878
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00005879 /* Check for a "normal" file name in some options. Disallow a path
5880 * separator (slash and/or backslash), wildcards and characters that are
5881 * often illegal in a file name. */
5882 else if ((options[opt_idx].flags & P_NFNAME)
Bram Moolenaar319afe32016-11-24 18:30:59 +01005883 && vim_strpbrk(*varp, (char_u *)"/\\*?[|;&<>\r\n") != NULL)
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00005884 {
5885 errmsg = e_invarg;
5886 }
5887
Bram Moolenaar071d4272004-06-13 20:20:40 +00005888 /* 'term' */
5889 else if (varp == &T_NAME)
5890 {
5891 if (T_NAME[0] == NUL)
5892 errmsg = (char_u *)N_("E529: Cannot set 'term' to empty string");
5893#ifdef FEAT_GUI
5894 if (gui.in_use)
5895 errmsg = (char_u *)N_("E530: Cannot change term in GUI");
5896 else if (term_is_gui(T_NAME))
5897 errmsg = (char_u *)N_("E531: Use \":gui\" to start the GUI");
5898#endif
5899 else if (set_termname(T_NAME) == FAIL)
5900 errmsg = (char_u *)N_("E522: Not found in termcap");
5901 else
5902 /* Screen colors may have changed. */
5903 redraw_later_clear();
5904 }
5905
5906 /* 'backupcopy' */
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02005907 else if (gvarp == &p_bkc)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005908 {
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02005909 char_u *bkc = p_bkc;
5910 unsigned int *flags = &bkc_flags;
5911
5912 if (opt_flags & OPT_LOCAL)
5913 {
5914 bkc = curbuf->b_p_bkc;
5915 flags = &curbuf->b_bkc_flags;
5916 }
5917
Bram Moolenaar84d17a62014-09-29 17:15:18 +02005918 if ((opt_flags & OPT_LOCAL) && *bkc == NUL)
5919 /* make the local value empty: use the global value */
5920 *flags = 0;
5921 else
Bram Moolenaar071d4272004-06-13 20:20:40 +00005922 {
Bram Moolenaar84d17a62014-09-29 17:15:18 +02005923 if (opt_strings_flags(bkc, p_bkc_values, flags, TRUE) != OK)
5924 errmsg = e_invarg;
5925 if ((((int)*flags & BKC_AUTO) != 0)
5926 + (((int)*flags & BKC_YES) != 0)
5927 + (((int)*flags & BKC_NO) != 0) != 1)
5928 {
5929 /* Must have exactly one of "auto", "yes" and "no". */
5930 (void)opt_strings_flags(oldval, p_bkc_values, flags, TRUE);
5931 errmsg = e_invarg;
5932 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005933 }
5934 }
5935
5936 /* 'backupext' and 'patchmode' */
5937 else if (varp == &p_bex || varp == &p_pm)
5938 {
5939 if (STRCMP(*p_bex == '.' ? p_bex + 1 : p_bex,
5940 *p_pm == '.' ? p_pm + 1 : p_pm) == 0)
5941 errmsg = (char_u *)N_("E589: 'backupext' and 'patchmode' are equal");
5942 }
Bram Moolenaar597a4222014-06-25 14:39:50 +02005943#ifdef FEAT_LINEBREAK
5944 /* 'breakindentopt' */
5945 else if (varp == &curwin->w_p_briopt)
5946 {
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02005947 if (briopt_check(curwin) == FAIL)
Bram Moolenaar597a4222014-06-25 14:39:50 +02005948 errmsg = e_invarg;
5949 }
5950#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005951
5952 /*
Bram Moolenaar88e8f9f2016-01-20 22:48:02 +01005953 * 'isident', 'iskeyword', 'isprint or 'isfname' option: refill g_chartab[]
Bram Moolenaar071d4272004-06-13 20:20:40 +00005954 * If the new option is invalid, use old value. 'lisp' option: refill
Bram Moolenaar88e8f9f2016-01-20 22:48:02 +01005955 * g_chartab[] for '-' char
Bram Moolenaar071d4272004-06-13 20:20:40 +00005956 */
5957 else if ( varp == &p_isi
5958 || varp == &(curbuf->b_p_isk)
5959 || varp == &p_isp
5960 || varp == &p_isf)
5961 {
5962 if (init_chartab() == FAIL)
5963 {
5964 did_chartab = TRUE; /* need to restore it below */
5965 errmsg = e_invarg; /* error in value */
5966 }
5967 }
5968
5969 /* 'helpfile' */
5970 else if (varp == &p_hf)
5971 {
5972 /* May compute new values for $VIM and $VIMRUNTIME */
5973 if (didset_vim)
5974 {
5975 vim_setenv((char_u *)"VIM", (char_u *)"");
5976 didset_vim = FALSE;
5977 }
5978 if (didset_vimruntime)
5979 {
5980 vim_setenv((char_u *)"VIMRUNTIME", (char_u *)"");
5981 didset_vimruntime = FALSE;
5982 }
5983 }
5984
Bram Moolenaar1a384422010-07-14 19:53:30 +02005985#ifdef FEAT_SYN_HL
5986 /* 'colorcolumn' */
5987 else if (varp == &curwin->w_p_cc)
5988 errmsg = check_colorcolumn(curwin);
5989#endif
5990
Bram Moolenaar071d4272004-06-13 20:20:40 +00005991#ifdef FEAT_MULTI_LANG
5992 /* 'helplang' */
5993 else if (varp == &p_hlg)
5994 {
5995 /* Check for "", "ab", "ab,cd", etc. */
5996 for (s = p_hlg; *s != NUL; s += 3)
5997 {
5998 if (s[1] == NUL || ((s[2] != ',' || s[3] == NUL) && s[2] != NUL))
5999 {
6000 errmsg = e_invarg;
6001 break;
6002 }
6003 if (s[2] == NUL)
6004 break;
6005 }
6006 }
6007#endif
6008
6009 /* 'highlight' */
6010 else if (varp == &p_hl)
6011 {
6012 if (highlight_changed() == FAIL)
6013 errmsg = e_invarg; /* invalid flags */
6014 }
6015
6016 /* 'nrformats' */
6017 else if (gvarp == &p_nf)
6018 {
6019 if (check_opt_strings(*varp, p_nf_values, TRUE) != OK)
6020 errmsg = e_invarg;
6021 }
6022
6023#ifdef FEAT_SESSION
6024 /* 'sessionoptions' */
6025 else if (varp == &p_ssop)
6026 {
6027 if (opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE) != OK)
6028 errmsg = e_invarg;
6029 if ((ssop_flags & SSOP_CURDIR) && (ssop_flags & SSOP_SESDIR))
6030 {
6031 /* Don't allow both "sesdir" and "curdir". */
6032 (void)opt_strings_flags(oldval, p_ssop_values, &ssop_flags, TRUE);
6033 errmsg = e_invarg;
6034 }
6035 }
6036 /* 'viewoptions' */
6037 else if (varp == &p_vop)
6038 {
6039 if (opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE) != OK)
6040 errmsg = e_invarg;
6041 }
6042#endif
6043
6044 /* 'scrollopt' */
6045#ifdef FEAT_SCROLLBIND
6046 else if (varp == &p_sbo)
6047 {
6048 if (check_opt_strings(p_sbo, p_scbopt_values, TRUE) != OK)
6049 errmsg = e_invarg;
6050 }
6051#endif
6052
6053 /* 'ambiwidth' */
6054#ifdef FEAT_MBYTE
Bram Moolenaar3848e002016-03-19 18:42:29 +01006055 else if (varp == &p_ambw || varp == &p_emoji)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006056 {
6057 if (check_opt_strings(p_ambw, p_ambw_values, FALSE) != OK)
6058 errmsg = e_invarg;
Bram Moolenaar5c3bd0a2010-08-04 20:55:44 +02006059 else if (set_chars_option(&p_lcs) != NULL)
6060 errmsg = (char_u *)_("E834: Conflicts with value of 'listchars'");
6061# if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
6062 else if (set_chars_option(&p_fcs) != NULL)
6063 errmsg = (char_u *)_("E835: Conflicts with value of 'fillchars'");
6064# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006065 }
6066#endif
6067
6068 /* 'background' */
6069 else if (varp == &p_bg)
6070 {
6071 if (check_opt_strings(p_bg, p_bg_values, FALSE) == OK)
6072 {
6073#ifdef FEAT_EVAL
6074 int dark = (*p_bg == 'd');
6075#endif
6076
6077 init_highlight(FALSE, FALSE);
6078
6079#ifdef FEAT_EVAL
6080 if (dark != (*p_bg == 'd')
6081 && get_var_value((char_u *)"g:colors_name") != NULL)
6082 {
6083 /* The color scheme must have set 'background' back to another
6084 * value, that's not what we want here. Disable the color
6085 * scheme and set the colors again. */
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00006086 do_unlet((char_u *)"g:colors_name", TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006087 free_string_option(p_bg);
6088 p_bg = vim_strsave((char_u *)(dark ? "dark" : "light"));
6089 check_string_option(&p_bg);
6090 init_highlight(FALSE, FALSE);
6091 }
6092#endif
6093 }
6094 else
6095 errmsg = e_invarg;
6096 }
6097
6098 /* 'wildmode' */
6099 else if (varp == &p_wim)
6100 {
6101 if (check_opt_wim() == FAIL)
6102 errmsg = e_invarg;
6103 }
6104
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00006105#ifdef FEAT_CMDL_COMPL
6106 /* 'wildoptions' */
6107 else if (varp == &p_wop)
6108 {
6109 if (check_opt_strings(p_wop, p_wop_values, TRUE) != OK)
6110 errmsg = e_invarg;
6111 }
6112#endif
6113
Bram Moolenaar071d4272004-06-13 20:20:40 +00006114#ifdef FEAT_WAK
6115 /* 'winaltkeys' */
6116 else if (varp == &p_wak)
6117 {
6118 if (*p_wak == NUL
6119 || check_opt_strings(p_wak, p_wak_values, FALSE) != OK)
6120 errmsg = e_invarg;
6121# ifdef FEAT_MENU
6122# ifdef FEAT_GUI_MOTIF
6123 else if (gui.in_use)
6124 gui_motif_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
6125# else
6126# ifdef FEAT_GUI_GTK
6127 else if (gui.in_use)
6128 gui_gtk_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
6129# endif
6130# endif
6131# endif
6132 }
6133#endif
6134
6135#ifdef FEAT_AUTOCMD
6136 /* 'eventignore' */
6137 else if (varp == &p_ei)
6138 {
6139 if (check_ei() == FAIL)
6140 errmsg = e_invarg;
6141 }
6142#endif
6143
6144#ifdef FEAT_MBYTE
6145 /* 'encoding' and 'fileencoding' */
6146 else if (varp == &p_enc || gvarp == &p_fenc || varp == &p_tenc)
6147 {
6148 if (gvarp == &p_fenc)
6149 {
Bram Moolenaarf2f70252008-02-13 17:36:06 +00006150 if (!curbuf->b_p_ma && opt_flags != OPT_GLOBAL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006151 errmsg = e_modifiable;
6152 else if (vim_strchr(*varp, ',') != NULL)
6153 /* No comma allowed in 'fileencoding'; catches confusing it
6154 * with 'fileencodings'. */
6155 errmsg = e_invarg;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006156 else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006157 {
6158# ifdef FEAT_TITLE
Bram Moolenaar071d4272004-06-13 20:20:40 +00006159 /* May show a "+" in the title now. */
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006160 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006161# endif
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006162 /* Add 'fileencoding' to the swap file. */
6163 ml_setflags(curbuf);
6164 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006165 }
6166 if (errmsg == NULL)
6167 {
6168 /* canonize the value, so that STRCMP() can be used on it */
6169 p = enc_canonize(*varp);
6170 if (p != NULL)
6171 {
6172 vim_free(*varp);
6173 *varp = p;
6174 }
6175 if (varp == &p_enc)
6176 {
6177 errmsg = mb_init();
6178# ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006179 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006180# endif
6181 }
6182 }
6183
Bram Moolenaar182c5be2010-06-25 05:37:59 +02006184# if defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006185 if (errmsg == NULL && varp == &p_tenc && gui.in_use)
6186 {
6187 /* GTK+ 2 uses only a single encoding, and that is UTF-8. */
6188 if (STRCMP(p_tenc, "utf-8") != 0)
6189 errmsg = (char_u *)N_("E617: Cannot be changed in the GTK+ 2 GUI");
6190 }
6191# endif
6192
6193 if (errmsg == NULL)
6194 {
6195# ifdef FEAT_KEYMAP
6196 /* When 'keymap' is used and 'encoding' changes, reload the keymap
6197 * (with another encoding). */
6198 if (varp == &p_enc && *curbuf->b_p_keymap != NUL)
6199 (void)keymap_init();
6200# endif
6201
6202 /* When 'termencoding' is not empty and 'encoding' changes or when
6203 * 'termencoding' changes, need to setup for keyboard input and
6204 * display output conversion. */
6205 if (((varp == &p_enc && *p_tenc != NUL) || varp == &p_tenc))
6206 {
6207 convert_setup(&input_conv, p_tenc, p_enc);
6208 convert_setup(&output_conv, p_enc, p_tenc);
6209 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00006210
6211# if defined(WIN3264) && defined(FEAT_MBYTE)
6212 /* $HOME may have characters in active code page. */
6213 if (varp == &p_enc)
6214 init_homedir();
6215# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006216 }
6217 }
6218#endif
6219
6220#if defined(FEAT_POSTSCRIPT)
6221 else if (varp == &p_penc)
6222 {
6223 /* Canonize printencoding if VIM standard one */
6224 p = enc_canonize(p_penc);
6225 if (p != NULL)
6226 {
6227 vim_free(p_penc);
6228 p_penc = p;
6229 }
6230 else
6231 {
6232 /* Ensure lower case and '-' for '_' */
6233 for (s = p_penc; *s != NUL; s++)
6234 {
6235 if (*s == '_')
6236 *s = '-';
6237 else
6238 *s = TOLOWER_ASC(*s);
6239 }
6240 }
6241 }
6242#endif
6243
Bram Moolenaar9372a112005-12-06 19:59:18 +00006244#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006245 else if (varp == &p_imak)
6246 {
6247 if (gui.in_use && !im_xim_isvalid_imactivate())
6248 errmsg = e_invarg;
6249 }
6250#endif
6251
6252#ifdef FEAT_KEYMAP
6253 else if (varp == &curbuf->b_p_keymap)
6254 {
Bram Moolenaard0b51382016-11-04 15:23:45 +01006255 if (!valid_filetype(*varp))
6256 errmsg = e_invarg;
6257 else
6258 /* load or unload key mapping tables */
6259 errmsg = keymap_init();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006260
Bram Moolenaarfab06232009-03-04 03:13:35 +00006261 if (errmsg == NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006262 {
Bram Moolenaarfab06232009-03-04 03:13:35 +00006263 if (*curbuf->b_p_keymap != NUL)
6264 {
6265 /* Installed a new keymap, switch on using it. */
6266 curbuf->b_p_iminsert = B_IMODE_LMAP;
6267 if (curbuf->b_p_imsearch != B_IMODE_USE_INSERT)
6268 curbuf->b_p_imsearch = B_IMODE_LMAP;
6269 }
6270 else
6271 {
6272 /* Cleared the keymap, may reset 'iminsert' and 'imsearch'. */
6273 if (curbuf->b_p_iminsert == B_IMODE_LMAP)
6274 curbuf->b_p_iminsert = B_IMODE_NONE;
6275 if (curbuf->b_p_imsearch == B_IMODE_LMAP)
6276 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
6277 }
6278 if ((opt_flags & OPT_LOCAL) == 0)
6279 {
6280 set_iminsert_global();
6281 set_imsearch_global();
6282 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006283# ifdef FEAT_WINDOWS
6284 status_redraw_curbuf();
6285# endif
6286 }
6287 }
6288#endif
6289
6290 /* 'fileformat' */
6291 else if (gvarp == &p_ff)
6292 {
6293 if (!curbuf->b_p_ma && !(opt_flags & OPT_GLOBAL))
6294 errmsg = e_modifiable;
6295 else if (check_opt_strings(*varp, p_ff_values, FALSE) != OK)
6296 errmsg = e_invarg;
6297 else
6298 {
6299 /* may also change 'textmode' */
6300 if (get_fileformat(curbuf) == EOL_DOS)
6301 curbuf->b_p_tx = TRUE;
6302 else
6303 curbuf->b_p_tx = FALSE;
6304#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006305 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006306#endif
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006307 /* update flag in swap file */
6308 ml_setflags(curbuf);
Bram Moolenaar0413d482010-02-11 17:02:11 +01006309 /* Redraw needed when switching to/from "mac": a CR in the text
6310 * will be displayed differently. */
6311 if (get_fileformat(curbuf) == EOL_MAC || *oldval == 'm')
6312 redraw_curbuf_later(NOT_VALID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006313 }
6314 }
6315
6316 /* 'fileformats' */
6317 else if (varp == &p_ffs)
6318 {
6319 if (check_opt_strings(p_ffs, p_ff_values, TRUE) != OK)
6320 errmsg = e_invarg;
6321 else
6322 {
6323 /* also change 'textauto' */
6324 if (*p_ffs == NUL)
6325 p_ta = FALSE;
6326 else
6327 p_ta = TRUE;
6328 }
6329 }
6330
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006331#if defined(FEAT_CRYPT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006332 /* 'cryptkey' */
6333 else if (gvarp == &p_key)
6334 {
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006335# if defined(FEAT_CMDHIST)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006336 /* Make sure the ":set" command doesn't show the new value in the
6337 * history. */
6338 remove_key_from_history();
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006339# endif
6340 if (STRCMP(curbuf->b_p_key, oldval) != 0)
6341 /* Need to update the swapfile. */
Bram Moolenaarbc563362015-06-09 18:35:25 +02006342 ml_set_crypt_key(curbuf, oldval,
6343 *curbuf->b_p_cm == NUL ? p_cm : curbuf->b_p_cm);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006344 }
6345
6346 else if (gvarp == &p_cm)
6347 {
6348 if (opt_flags & OPT_LOCAL)
6349 p = curbuf->b_p_cm;
6350 else
6351 p = p_cm;
6352 if (check_opt_strings(p, p_cm_values, TRUE) != OK)
6353 errmsg = e_invarg;
Bram Moolenaar8f4ac012014-08-10 13:38:34 +02006354 else if (crypt_self_test() == FAIL)
Bram Moolenaar49771f42010-07-20 17:32:38 +02006355 errmsg = e_invarg;
6356 else
6357 {
6358 /* When setting the global value to empty, make it "zip". */
6359 if (*p_cm == NUL)
6360 {
6361 if (new_value_alloced)
6362 free_string_option(p_cm);
6363 p_cm = vim_strsave((char_u *)"zip");
6364 new_value_alloced = TRUE;
6365 }
Bram Moolenaar2be79502014-08-13 21:58:28 +02006366 /* When using ":set cm=name" the local value is going to be empty.
6367 * Do that here, otherwise the crypt functions will still use the
6368 * local value. */
6369 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
6370 {
6371 free_string_option(curbuf->b_p_cm);
6372 curbuf->b_p_cm = empty_option;
6373 }
Bram Moolenaar49771f42010-07-20 17:32:38 +02006374
6375 /* Need to update the swapfile when the effective method changed.
6376 * Set "s" to the effective old value, "p" to the effective new
6377 * method and compare. */
6378 if ((opt_flags & OPT_LOCAL) && *oldval == NUL)
6379 s = p_cm; /* was previously using the global value */
6380 else
6381 s = oldval;
6382 if (*curbuf->b_p_cm == NUL)
6383 p = p_cm; /* is now using the global value */
6384 else
6385 p = curbuf->b_p_cm;
6386 if (STRCMP(s, p) != 0)
Bram Moolenaarbc563362015-06-09 18:35:25 +02006387 ml_set_crypt_key(curbuf, curbuf->b_p_key, s);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006388
6389 /* If the global value changes need to update the swapfile for all
6390 * buffers using that value. */
6391 if ((opt_flags & OPT_GLOBAL) && STRCMP(p_cm, oldval) != 0)
6392 {
6393 buf_T *buf;
6394
Bram Moolenaar29323592016-07-24 22:04:11 +02006395 FOR_ALL_BUFFERS(buf)
Bram Moolenaar49771f42010-07-20 17:32:38 +02006396 if (buf != curbuf && *buf->b_p_cm == NUL)
Bram Moolenaarbc563362015-06-09 18:35:25 +02006397 ml_set_crypt_key(buf, buf->b_p_key, oldval);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006398 }
6399 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006400 }
6401#endif
6402
6403 /* 'matchpairs' */
6404 else if (gvarp == &p_mps)
6405 {
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006406#ifdef FEAT_MBYTE
6407 if (has_mbyte)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006408 {
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006409 for (p = *varp; *p != NUL; ++p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006410 {
Bram Moolenaar09365022013-01-17 17:37:35 +01006411 int x2 = -1;
6412 int x3 = -1;
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006413
6414 if (*p != NUL)
6415 p += mb_ptr2len(p);
6416 if (*p != NUL)
6417 x2 = *p++;
6418 if (*p != NUL)
6419 {
6420 x3 = mb_ptr2char(p);
6421 p += mb_ptr2len(p);
6422 }
Bram Moolenaar09365022013-01-17 17:37:35 +01006423 if (x2 != ':' || x3 == -1 || (*p != NUL && *p != ','))
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006424 {
6425 errmsg = e_invarg;
6426 break;
6427 }
6428 if (*p == NUL)
6429 break;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006430 }
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006431 }
6432 else
6433#endif
6434 {
6435 /* Check for "x:y,x:y" */
6436 for (p = *varp; *p != NUL; p += 4)
6437 {
6438 if (p[1] != ':' || p[2] == NUL || (p[3] != NUL && p[3] != ','))
6439 {
6440 errmsg = e_invarg;
6441 break;
6442 }
6443 if (p[3] == NUL)
6444 break;
6445 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006446 }
6447 }
6448
6449#ifdef FEAT_COMMENTS
6450 /* 'comments' */
6451 else if (gvarp == &p_com)
6452 {
6453 for (s = *varp; *s; )
6454 {
6455 while (*s && *s != ':')
6456 {
6457 if (vim_strchr((char_u *)COM_ALL, *s) == NULL
6458 && !VIM_ISDIGIT(*s) && *s != '-')
6459 {
6460 errmsg = illegal_char(errbuf, *s);
6461 break;
6462 }
6463 ++s;
6464 }
6465 if (*s++ == NUL)
6466 errmsg = (char_u *)N_("E524: Missing colon");
6467 else if (*s == ',' || *s == NUL)
6468 errmsg = (char_u *)N_("E525: Zero length string");
6469 if (errmsg != NULL)
6470 break;
6471 while (*s && *s != ',')
6472 {
6473 if (*s == '\\' && s[1] != NUL)
6474 ++s;
6475 ++s;
6476 }
6477 s = skip_to_option_part(s);
6478 }
6479 }
6480#endif
6481
6482 /* 'listchars' */
6483 else if (varp == &p_lcs)
6484 {
6485 errmsg = set_chars_option(varp);
6486 }
6487
6488#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
6489 /* 'fillchars' */
6490 else if (varp == &p_fcs)
6491 {
6492 errmsg = set_chars_option(varp);
6493 }
6494#endif
6495
6496#ifdef FEAT_CMDWIN
6497 /* 'cedit' */
6498 else if (varp == &p_cedit)
6499 {
6500 errmsg = check_cedit();
6501 }
6502#endif
6503
Bram Moolenaar54ee7752005-05-31 22:22:17 +00006504 /* 'verbosefile' */
6505 else if (varp == &p_vfile)
6506 {
6507 verbose_stop();
6508 if (*p_vfile != NUL && verbose_open() == FAIL)
6509 errmsg = e_invarg;
6510 }
6511
Bram Moolenaar071d4272004-06-13 20:20:40 +00006512#ifdef FEAT_VIMINFO
6513 /* 'viminfo' */
6514 else if (varp == &p_viminfo)
6515 {
6516 for (s = p_viminfo; *s;)
6517 {
6518 /* Check it's a valid character */
6519 if (vim_strchr((char_u *)"!\"%'/:<@cfhnrs", *s) == NULL)
6520 {
6521 errmsg = illegal_char(errbuf, *s);
6522 break;
6523 }
6524 if (*s == 'n') /* name is always last one */
6525 {
6526 break;
6527 }
6528 else if (*s == 'r') /* skip until next ',' */
6529 {
6530 while (*++s && *s != ',')
6531 ;
6532 }
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +00006533 else if (*s == '%')
6534 {
6535 /* optional number */
6536 while (vim_isdigit(*++s))
6537 ;
6538 }
6539 else if (*s == '!' || *s == 'h' || *s == 'c')
Bram Moolenaar071d4272004-06-13 20:20:40 +00006540 ++s; /* no extra chars */
6541 else /* must have a number */
6542 {
6543 while (vim_isdigit(*++s))
6544 ;
6545
6546 if (!VIM_ISDIGIT(*(s - 1)))
6547 {
6548 if (errbuf != NULL)
6549 {
Bram Moolenaar8f999f12005-01-25 22:12:55 +00006550 sprintf((char *)errbuf,
6551 _("E526: Missing number after <%s>"),
Bram Moolenaar071d4272004-06-13 20:20:40 +00006552 transchar_byte(*(s - 1)));
6553 errmsg = errbuf;
6554 }
6555 else
6556 errmsg = (char_u *)"";
6557 break;
6558 }
6559 }
6560 if (*s == ',')
6561 ++s;
6562 else if (*s)
6563 {
6564 if (errbuf != NULL)
6565 errmsg = (char_u *)N_("E527: Missing comma");
6566 else
6567 errmsg = (char_u *)"";
6568 break;
6569 }
6570 }
6571 if (*p_viminfo && errmsg == NULL && get_viminfo_parameter('\'') < 0)
6572 errmsg = (char_u *)N_("E528: Must specify a ' value");
6573 }
6574#endif /* FEAT_VIMINFO */
6575
6576 /* terminal options */
6577 else if (istermoption(&options[opt_idx]) && full_screen)
6578 {
6579 /* ":set t_Co=0" and ":set t_Co=1" do ":set t_Co=" */
6580 if (varp == &T_CCO)
6581 {
Bram Moolenaarc84e8952009-03-18 13:21:18 +00006582 int colors = atoi((char *)T_CCO);
6583
6584 /* Only reinitialize colors if t_Co value has really changed to
6585 * avoid expensive reload of colorscheme if t_Co is set to the
6586 * same value multiple times. */
6587 if (colors != t_colors)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006588 {
Bram Moolenaarc84e8952009-03-18 13:21:18 +00006589 t_colors = colors;
6590 if (t_colors <= 1)
6591 {
6592 if (new_value_alloced)
6593 vim_free(T_CCO);
6594 T_CCO = empty_option;
6595 }
6596 /* We now have a different color setup, initialize it again. */
6597 init_highlight(TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006598 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006599 }
6600 ttest(FALSE);
6601 if (varp == &T_ME)
6602 {
6603 out_str(T_ME);
6604 redraw_later(CLEAR);
Bram Moolenaar48e330a2016-02-23 14:53:34 +01006605#if defined(WIN3264) && !defined(FEAT_GUI_W32)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006606 /* Since t_me has been set, this probably means that the user
6607 * wants to use this as default colors. Need to reset default
6608 * background/foreground colors. */
6609 mch_set_normal_colors();
6610#endif
6611 }
6612 }
6613
6614#ifdef FEAT_LINEBREAK
6615 /* 'showbreak' */
6616 else if (varp == &p_sbr)
6617 {
6618 for (s = p_sbr; *s; )
6619 {
6620 if (ptr2cells(s) != 1)
6621 errmsg = (char_u *)N_("E595: contains unprintable or wide character");
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006622 mb_ptr_adv(s);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006623 }
6624 }
6625#endif
6626
6627#ifdef FEAT_GUI
6628 /* 'guifont' */
6629 else if (varp == &p_guifont)
6630 {
6631 if (gui.in_use)
6632 {
6633 p = p_guifont;
Bram Moolenaar9372a112005-12-06 19:59:18 +00006634# if defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006635 /*
6636 * Put up a font dialog and let the user select a new value.
6637 * If this is cancelled go back to the old value but don't
6638 * give an error message.
6639 */
6640 if (STRCMP(p, "*") == 0)
6641 {
6642 p = gui_mch_font_dialog(oldval);
6643
6644 if (new_value_alloced)
6645 free_string_option(p_guifont);
6646
6647 p_guifont = (p != NULL) ? p : vim_strsave(oldval);
6648 new_value_alloced = TRUE;
6649 }
6650# endif
6651 if (p != NULL && gui_init_font(p_guifont, FALSE) != OK)
6652 {
6653# if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_PHOTON)
6654 if (STRCMP(p_guifont, "*") == 0)
6655 {
6656 /* Dialog was cancelled: Keep the old value without giving
6657 * an error message. */
6658 if (new_value_alloced)
6659 free_string_option(p_guifont);
6660 p_guifont = vim_strsave(oldval);
6661 new_value_alloced = TRUE;
6662 }
6663 else
6664# endif
6665 errmsg = (char_u *)N_("E596: Invalid font(s)");
6666 }
6667 }
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006668 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006669 }
6670# ifdef FEAT_XFONTSET
6671 else if (varp == &p_guifontset)
6672 {
6673 if (STRCMP(p_guifontset, "*") == 0)
6674 errmsg = (char_u *)N_("E597: can't select fontset");
6675 else if (gui.in_use && gui_init_font(p_guifontset, TRUE) != OK)
6676 errmsg = (char_u *)N_("E598: Invalid fontset");
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006677 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006678 }
6679# endif
6680# ifdef FEAT_MBYTE
6681 else if (varp == &p_guifontwide)
6682 {
6683 if (STRCMP(p_guifontwide, "*") == 0)
6684 errmsg = (char_u *)N_("E533: can't select wide font");
6685 else if (gui_get_wide_font() == FAIL)
6686 errmsg = (char_u *)N_("E534: Invalid wide font");
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006687 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006688 }
6689# endif
6690#endif
6691
6692#ifdef CURSOR_SHAPE
6693 /* 'guicursor' */
6694 else if (varp == &p_guicursor)
6695 errmsg = parse_shape_opt(SHAPE_CURSOR);
6696#endif
6697
6698#ifdef FEAT_MOUSESHAPE
6699 /* 'mouseshape' */
6700 else if (varp == &p_mouseshape)
6701 {
6702 errmsg = parse_shape_opt(SHAPE_MOUSE);
6703 update_mouseshape(-1);
6704 }
6705#endif
6706
6707#ifdef FEAT_PRINTER
6708 else if (varp == &p_popt)
Bram Moolenaar58d98232005-07-23 22:25:46 +00006709 errmsg = parse_printoptions();
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00006710# if defined(FEAT_MBYTE) && defined(FEAT_POSTSCRIPT)
Bram Moolenaar8299df92004-07-10 09:47:34 +00006711 else if (varp == &p_pmfn)
Bram Moolenaar58d98232005-07-23 22:25:46 +00006712 errmsg = parse_printmbfont();
Bram Moolenaar8299df92004-07-10 09:47:34 +00006713# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006714#endif
6715
6716#ifdef FEAT_LANGMAP
6717 /* 'langmap' */
6718 else if (varp == &p_langmap)
6719 langmap_set();
6720#endif
6721
6722#ifdef FEAT_LINEBREAK
6723 /* 'breakat' */
6724 else if (varp == &p_breakat)
6725 fill_breakat_flags();
6726#endif
6727
6728#ifdef FEAT_TITLE
6729 /* 'titlestring' and 'iconstring' */
6730 else if (varp == &p_titlestring || varp == &p_iconstring)
6731 {
6732# ifdef FEAT_STL_OPT
6733 int flagval = (varp == &p_titlestring) ? STL_IN_TITLE : STL_IN_ICON;
6734
6735 /* NULL => statusline syntax */
6736 if (vim_strchr(*varp, '%') && check_stl_option(*varp) == NULL)
6737 stl_syntax |= flagval;
6738 else
6739 stl_syntax &= ~flagval;
6740# endif
6741 did_set_title(varp == &p_iconstring);
6742
6743 }
6744#endif
6745
6746#ifdef FEAT_GUI
6747 /* 'guioptions' */
6748 else if (varp == &p_go)
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006749 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00006750 gui_init_which_components(oldval);
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006751 redraw_gui_only = TRUE;
6752 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006753#endif
6754
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00006755#if defined(FEAT_GUI_TABLINE)
6756 /* 'guitablabel' */
6757 else if (varp == &p_gtl)
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006758 {
Bram Moolenaar18144c82006-04-12 21:52:12 +00006759 redraw_tabline = TRUE;
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006760 redraw_gui_only = TRUE;
6761 }
6762 /* 'guitabtooltip' */
6763 else if (varp == &p_gtt)
6764 {
6765 redraw_gui_only = TRUE;
6766 }
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00006767#endif
6768
Bram Moolenaar071d4272004-06-13 20:20:40 +00006769#if defined(FEAT_MOUSE_TTY) && (defined(UNIX) || defined(VMS))
6770 /* 'ttymouse' */
6771 else if (varp == &p_ttym)
6772 {
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00006773 /* Switch the mouse off before changing the escape sequences used for
6774 * that. */
6775 mch_setmouse(FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006776 if (opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE) != OK)
6777 errmsg = e_invarg;
6778 else
6779 check_mouse_termcode();
Bram Moolenaar6bb68362005-03-22 23:03:44 +00006780 if (termcap_active)
6781 setmouse(); /* may switch it on again */
Bram Moolenaar071d4272004-06-13 20:20:40 +00006782 }
6783#endif
6784
Bram Moolenaar071d4272004-06-13 20:20:40 +00006785 /* 'selection' */
6786 else if (varp == &p_sel)
6787 {
6788 if (*p_sel == NUL
6789 || check_opt_strings(p_sel, p_sel_values, FALSE) != OK)
6790 errmsg = e_invarg;
6791 }
6792
6793 /* 'selectmode' */
6794 else if (varp == &p_slm)
6795 {
6796 if (check_opt_strings(p_slm, p_slm_values, TRUE) != OK)
6797 errmsg = e_invarg;
6798 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006799
6800#ifdef FEAT_BROWSE
6801 /* 'browsedir' */
6802 else if (varp == &p_bsdir)
6803 {
6804 if (check_opt_strings(p_bsdir, p_bsdir_values, FALSE) != OK
6805 && !mch_isdir(p_bsdir))
6806 errmsg = e_invarg;
6807 }
6808#endif
6809
Bram Moolenaar071d4272004-06-13 20:20:40 +00006810 /* 'keymodel' */
6811 else if (varp == &p_km)
6812 {
6813 if (check_opt_strings(p_km, p_km_values, TRUE) != OK)
6814 errmsg = e_invarg;
6815 else
6816 {
6817 km_stopsel = (vim_strchr(p_km, 'o') != NULL);
6818 km_startsel = (vim_strchr(p_km, 'a') != NULL);
6819 }
6820 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006821
6822 /* 'mousemodel' */
6823 else if (varp == &p_mousem)
6824 {
6825 if (check_opt_strings(p_mousem, p_mousem_values, FALSE) != OK)
6826 errmsg = e_invarg;
6827#if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU) && (XmVersion <= 1002)
6828 else if (*p_mousem != *oldval)
6829 /* Changed from "extend" to "popup" or "popup_setpos" or vv: need
6830 * to create or delete the popup menus. */
6831 gui_motif_update_mousemodel(root_menu);
6832#endif
6833 }
6834
6835 /* 'switchbuf' */
6836 else if (varp == &p_swb)
6837 {
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00006838 if (opt_strings_flags(p_swb, p_swb_values, &swb_flags, TRUE) != OK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006839 errmsg = e_invarg;
6840 }
6841
6842 /* 'debug' */
6843 else if (varp == &p_debug)
6844 {
Bram Moolenaar57657d82006-04-21 22:12:41 +00006845 if (check_opt_strings(p_debug, p_debug_values, TRUE) != OK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006846 errmsg = e_invarg;
6847 }
6848
6849 /* 'display' */
6850 else if (varp == &p_dy)
6851 {
6852 if (opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE) != OK)
6853 errmsg = e_invarg;
6854 else
6855 (void)init_chartab();
6856
6857 }
6858
Bram Moolenaar44a2f922016-03-19 22:11:51 +01006859#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00006860 /* 'eadirection' */
6861 else if (varp == &p_ead)
6862 {
6863 if (check_opt_strings(p_ead, p_ead_values, FALSE) != OK)
6864 errmsg = e_invarg;
6865 }
6866#endif
6867
6868#ifdef FEAT_CLIPBOARD
6869 /* 'clipboard' */
6870 else if (varp == &p_cb)
6871 errmsg = check_clipboard_option();
6872#endif
6873
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00006874#ifdef FEAT_SPELL
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006875 /* When 'spelllang' or 'spellfile' is set and there is a window for this
6876 * buffer in which 'spell' is set load the wordlists. */
Bram Moolenaar2683c8e2014-11-19 19:33:16 +01006877 else if (varp == &(curwin->w_s->b_p_spl)
6878 || varp == &(curwin->w_s->b_p_spf))
Bram Moolenaar217ad922005-03-20 22:37:15 +00006879 {
Bram Moolenaare68c25c2015-08-25 15:39:55 +02006880 errmsg = did_set_spell_option(varp == &(curwin->w_s->b_p_spf));
Bram Moolenaar217ad922005-03-20 22:37:15 +00006881 }
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00006882 /* When 'spellcapcheck' is set compile the regexp program. */
Bram Moolenaar860cae12010-06-05 23:22:07 +02006883 else if (varp == &(curwin->w_s->b_p_spc))
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00006884 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02006885 errmsg = compile_cap_prog(curwin->w_s);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00006886 }
Bram Moolenaard857f0e2005-06-21 22:37:39 +00006887 /* 'spellsuggest' */
6888 else if (varp == &p_sps)
6889 {
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00006890 if (spell_check_sps() != OK)
Bram Moolenaard857f0e2005-06-21 22:37:39 +00006891 errmsg = e_invarg;
6892 }
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00006893 /* 'mkspellmem' */
6894 else if (varp == &p_msm)
6895 {
6896 if (spell_check_msm() != OK)
6897 errmsg = e_invarg;
6898 }
Bram Moolenaar217ad922005-03-20 22:37:15 +00006899#endif
6900
Bram Moolenaar071d4272004-06-13 20:20:40 +00006901#ifdef FEAT_QUICKFIX
6902 /* When 'bufhidden' is set, check for valid value. */
6903 else if (gvarp == &p_bh)
6904 {
6905 if (check_opt_strings(curbuf->b_p_bh, p_bufhidden_values, FALSE) != OK)
6906 errmsg = e_invarg;
6907 }
6908
6909 /* When 'buftype' is set, check for valid value. */
6910 else if (gvarp == &p_bt)
6911 {
6912 if (check_opt_strings(curbuf->b_p_bt, p_buftype_values, FALSE) != OK)
6913 errmsg = e_invarg;
6914 else
6915 {
6916# ifdef FEAT_WINDOWS
6917 if (curwin->w_status_height)
6918 {
6919 curwin->w_redr_status = TRUE;
6920 redraw_later(VALID);
6921 }
6922# endif
6923 curbuf->b_help = (curbuf->b_p_bt[0] == 'h');
Bram Moolenaar5075aad2010-01-27 15:58:13 +01006924# ifdef FEAT_TITLE
6925 redraw_titles();
6926# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006927 }
6928 }
6929#endif
6930
6931#ifdef FEAT_STL_OPT
6932 /* 'statusline' or 'rulerformat' */
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00006933 else if (gvarp == &p_stl || varp == &p_ruf)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006934 {
6935 int wid;
6936
6937 if (varp == &p_ruf) /* reset ru_wid first */
6938 ru_wid = 0;
6939 s = *varp;
6940 if (varp == &p_ruf && *s == '%')
6941 {
6942 /* set ru_wid if 'ruf' starts with "%99(" */
6943 if (*++s == '-') /* ignore a '-' */
6944 s++;
6945 wid = getdigits(&s);
6946 if (wid && *s == '(' && (errmsg = check_stl_option(p_ruf)) == NULL)
6947 ru_wid = wid;
6948 else
6949 errmsg = check_stl_option(p_ruf);
6950 }
Bram Moolenaar3709e7c2006-08-08 14:29:16 +00006951 /* check 'statusline' only if it doesn't start with "%!" */
Bram Moolenaar177d8c62007-09-06 11:33:37 +00006952 else if (varp == &p_ruf || s[0] != '%' || s[1] != '!')
Bram Moolenaar071d4272004-06-13 20:20:40 +00006953 errmsg = check_stl_option(s);
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00006954 if (varp == &p_ruf && errmsg == NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006955 comp_col();
6956 }
6957#endif
6958
6959#ifdef FEAT_INS_EXPAND
6960 /* check if it is a valid value for 'complete' -- Acevedo */
6961 else if (gvarp == &p_cpt)
6962 {
6963 for (s = *varp; *s;)
6964 {
Bram Moolenaar11b73d62012-06-29 15:51:30 +02006965 while (*s == ',' || *s == ' ')
Bram Moolenaar071d4272004-06-13 20:20:40 +00006966 s++;
6967 if (!*s)
6968 break;
6969 if (vim_strchr((char_u *)".wbuksid]tU", *s) == NULL)
6970 {
6971 errmsg = illegal_char(errbuf, *s);
6972 break;
6973 }
6974 if (*++s != NUL && *s != ',' && *s != ' ')
6975 {
6976 if (s[-1] == 'k' || s[-1] == 's')
6977 {
6978 /* skip optional filename after 'k' and 's' */
6979 while (*s && *s != ',' && *s != ' ')
6980 {
6981 if (*s == '\\')
6982 ++s;
6983 ++s;
6984 }
6985 }
6986 else
6987 {
6988 if (errbuf != NULL)
6989 {
6990 sprintf((char *)errbuf,
6991 _("E535: Illegal character after <%c>"),
6992 *--s);
6993 errmsg = errbuf;
6994 }
6995 else
6996 errmsg = (char_u *)"";
6997 break;
6998 }
6999 }
7000 }
7001 }
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00007002
7003 /* 'completeopt' */
7004 else if (varp == &p_cot)
7005 {
7006 if (check_opt_strings(p_cot, p_cot_values, TRUE) != OK)
7007 errmsg = e_invarg;
Bram Moolenaarc0200422016-04-20 12:02:02 +02007008 else
7009 completeopt_was_set();
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00007010 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007011#endif /* FEAT_INS_EXPAND */
7012
Bram Moolenaar95ec9d62016-08-12 18:29:59 +02007013#ifdef FEAT_SIGNS
7014 /* 'signcolumn' */
7015 else if (varp == &curwin->w_p_scl)
7016 {
7017 if (check_opt_strings(*varp, p_scl_values, FALSE) != OK)
7018 errmsg = e_invarg;
7019 }
7020#endif
7021
Bram Moolenaar071d4272004-06-13 20:20:40 +00007022
7023#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
Bram Moolenaar031cb742016-11-24 21:46:19 +01007024 /* 'toolbar' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007025 else if (varp == &p_toolbar)
7026 {
7027 if (opt_strings_flags(p_toolbar, p_toolbar_values,
7028 &toolbar_flags, TRUE) != OK)
7029 errmsg = e_invarg;
7030 else
7031 {
7032 out_flush();
7033 gui_mch_show_toolbar((toolbar_flags &
7034 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
7035 }
7036 }
7037#endif
7038
Bram Moolenaar182c5be2010-06-25 05:37:59 +02007039#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007040 /* 'toolbariconsize': GTK+ 2 only */
7041 else if (varp == &p_tbis)
7042 {
7043 if (opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE) != OK)
7044 errmsg = e_invarg;
7045 else
7046 {
7047 out_flush();
7048 gui_mch_show_toolbar((toolbar_flags &
7049 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
7050 }
7051 }
7052#endif
7053
7054 /* 'pastetoggle': translate key codes like in a mapping */
7055 else if (varp == &p_pt)
7056 {
7057 if (*p_pt)
7058 {
Bram Moolenaar9c102382006-05-03 21:26:49 +00007059 (void)replace_termcodes(p_pt, &p, TRUE, TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007060 if (p != NULL)
7061 {
7062 if (new_value_alloced)
7063 free_string_option(p_pt);
7064 p_pt = p;
7065 new_value_alloced = TRUE;
7066 }
7067 }
7068 }
7069
7070 /* 'backspace' */
7071 else if (varp == &p_bs)
7072 {
7073 if (VIM_ISDIGIT(*p_bs))
7074 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01007075 if (*p_bs > '2' || p_bs[1] != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007076 errmsg = e_invarg;
7077 }
7078 else if (check_opt_strings(p_bs, p_bs_values, TRUE) != OK)
7079 errmsg = e_invarg;
7080 }
Bram Moolenaar165bc692015-07-21 17:53:25 +02007081 else if (varp == &p_bo)
7082 {
7083 if (opt_strings_flags(p_bo, p_bo_values, &bo_flags, TRUE) != OK)
7084 errmsg = e_invarg;
7085 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007086
Bram Moolenaar0f6562e2015-11-24 18:48:14 +01007087 /* 'tagcase' */
7088 else if (gvarp == &p_tc)
7089 {
7090 unsigned int *flags;
7091
7092 if (opt_flags & OPT_LOCAL)
7093 {
7094 p = curbuf->b_p_tc;
7095 flags = &curbuf->b_tc_flags;
7096 }
7097 else
7098 {
7099 p = p_tc;
7100 flags = &tc_flags;
7101 }
7102
7103 if ((opt_flags & OPT_LOCAL) && *p == NUL)
7104 /* make the local value empty: use the global value */
7105 *flags = 0;
7106 else if (*p == NUL
7107 || opt_strings_flags(p, p_tc_values, flags, FALSE) != OK)
7108 errmsg = e_invarg;
7109 }
7110
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00007111#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +00007112 /* 'casemap' */
7113 else if (varp == &p_cmp)
7114 {
7115 if (opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE) != OK)
7116 errmsg = e_invarg;
7117 }
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00007118#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007119
7120#ifdef FEAT_DIFF
7121 /* 'diffopt' */
7122 else if (varp == &p_dip)
7123 {
7124 if (diffopt_changed() == FAIL)
7125 errmsg = e_invarg;
7126 }
7127#endif
7128
7129#ifdef FEAT_FOLDING
7130 /* 'foldmethod' */
7131 else if (gvarp == &curwin->w_allbuf_opt.wo_fdm)
7132 {
7133 if (check_opt_strings(*varp, p_fdm_values, FALSE) != OK
7134 || *curwin->w_p_fdm == NUL)
7135 errmsg = e_invarg;
7136 else
Bram Moolenaarf4d7f942010-02-24 14:34:19 +01007137 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00007138 foldUpdateAll(curwin);
Bram Moolenaarf4d7f942010-02-24 14:34:19 +01007139 if (foldmethodIsDiff(curwin))
7140 newFoldLevel();
7141 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007142 }
7143# ifdef FEAT_EVAL
7144 /* 'foldexpr' */
7145 else if (varp == &curwin->w_p_fde)
7146 {
7147 if (foldmethodIsExpr(curwin))
7148 foldUpdateAll(curwin);
7149 }
7150# endif
7151 /* 'foldmarker' */
7152 else if (gvarp == &curwin->w_allbuf_opt.wo_fmr)
7153 {
7154 p = vim_strchr(*varp, ',');
7155 if (p == NULL)
7156 errmsg = (char_u *)N_("E536: comma required");
7157 else if (p == *varp || p[1] == NUL)
7158 errmsg = e_invarg;
7159 else if (foldmethodIsMarker(curwin))
7160 foldUpdateAll(curwin);
7161 }
7162 /* 'commentstring' */
7163 else if (gvarp == &p_cms)
7164 {
7165 if (**varp != NUL && strstr((char *)*varp, "%s") == NULL)
7166 errmsg = (char_u *)N_("E537: 'commentstring' must be empty or contain %s");
7167 }
7168 /* 'foldopen' */
7169 else if (varp == &p_fdo)
7170 {
7171 if (opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE) != OK)
7172 errmsg = e_invarg;
7173 }
7174 /* 'foldclose' */
7175 else if (varp == &p_fcl)
7176 {
7177 if (check_opt_strings(p_fcl, p_fcl_values, TRUE) != OK)
7178 errmsg = e_invarg;
7179 }
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00007180 /* 'foldignore' */
7181 else if (gvarp == &curwin->w_allbuf_opt.wo_fdi)
7182 {
7183 if (foldmethodIsIndent(curwin))
7184 foldUpdateAll(curwin);
7185 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007186#endif
7187
7188#ifdef FEAT_VIRTUALEDIT
7189 /* 'virtualedit' */
7190 else if (varp == &p_ve)
7191 {
7192 if (opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE) != OK)
7193 errmsg = e_invarg;
7194 else if (STRCMP(p_ve, oldval) != 0)
7195 {
7196 /* Recompute cursor position in case the new 've' setting
7197 * changes something. */
7198 validate_virtcol();
7199 coladvance(curwin->w_virtcol);
7200 }
7201 }
7202#endif
7203
7204#if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX)
7205 else if (varp == &p_csqf)
7206 {
7207 if (p_csqf != NULL)
7208 {
7209 p = p_csqf;
7210 while (*p != NUL)
7211 {
7212 if (vim_strchr((char_u *)CSQF_CMDS, *p) == NULL
7213 || p[1] == NUL
7214 || vim_strchr((char_u *)CSQF_FLAGS, p[1]) == NULL
7215 || (p[2] != NUL && p[2] != ','))
7216 {
7217 errmsg = e_invarg;
7218 break;
7219 }
7220 else if (p[2] == NUL)
7221 break;
7222 else
7223 p += 3;
7224 }
7225 }
7226 }
7227#endif
7228
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01007229#ifdef FEAT_CINDENT
7230 /* 'cinoptions' */
7231 else if (gvarp == &p_cino)
7232 {
7233 /* TODO: recognize errors */
7234 parse_cino(curbuf);
7235 }
7236#endif
7237
Bram Moolenaarb5a7a8b2014-08-06 14:52:30 +02007238#if defined(FEAT_RENDER_OPTIONS)
Bram Moolenaar031cb742016-11-24 21:46:19 +01007239 /* 'renderoptions' */
Bram Moolenaarb5a7a8b2014-08-06 14:52:30 +02007240 else if (varp == &p_rop && gui.in_use)
7241 {
7242 if (!gui_mch_set_rendering_options(p_rop))
7243 errmsg = e_invarg;
7244 }
7245#endif
7246
Bram Moolenaard0b51382016-11-04 15:23:45 +01007247#ifdef FEAT_AUTOCMD
7248 else if (gvarp == &p_ft)
7249 {
7250 if (!valid_filetype(*varp))
7251 errmsg = e_invarg;
7252 }
7253#endif
7254
7255#ifdef FEAT_SYN_HL
7256 else if (gvarp == &p_syn)
7257 {
7258 if (!valid_filetype(*varp))
7259 errmsg = e_invarg;
7260 }
7261#endif
7262
Bram Moolenaar071d4272004-06-13 20:20:40 +00007263 /* Options that are a list of flags. */
7264 else
7265 {
7266 p = NULL;
Bram Moolenaar031cb742016-11-24 21:46:19 +01007267 if (varp == &p_ww) /* 'whichwrap' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007268 p = (char_u *)WW_ALL;
Bram Moolenaar031cb742016-11-24 21:46:19 +01007269 if (varp == &p_shm) /* 'shortmess' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007270 p = (char_u *)SHM_ALL;
Bram Moolenaar031cb742016-11-24 21:46:19 +01007271 else if (varp == &(p_cpo)) /* 'cpoptions' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007272 p = (char_u *)CPO_ALL;
Bram Moolenaar031cb742016-11-24 21:46:19 +01007273 else if (varp == &(curbuf->b_p_fo)) /* 'formatoptions' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007274 p = (char_u *)FO_ALL;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02007275#ifdef FEAT_CONCEAL
Bram Moolenaar031cb742016-11-24 21:46:19 +01007276 else if (varp == &curwin->w_p_cocu) /* 'concealcursor' */
Bram Moolenaarf5963f72010-07-23 22:10:27 +02007277 p = (char_u *)COCU_ALL;
7278#endif
Bram Moolenaar031cb742016-11-24 21:46:19 +01007279 else if (varp == &p_mouse) /* 'mouse' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007280 {
7281#ifdef FEAT_MOUSE
7282 p = (char_u *)MOUSE_ALL;
7283#else
7284 if (*p_mouse != NUL)
7285 errmsg = (char_u *)N_("E538: No mouse support");
7286#endif
7287 }
7288#if defined(FEAT_GUI)
Bram Moolenaar031cb742016-11-24 21:46:19 +01007289 else if (varp == &p_go) /* 'guioptions' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007290 p = (char_u *)GO_ALL;
7291#endif
7292 if (p != NULL)
7293 {
7294 for (s = *varp; *s; ++s)
7295 if (vim_strchr(p, *s) == NULL)
7296 {
7297 errmsg = illegal_char(errbuf, *s);
7298 break;
7299 }
7300 }
7301 }
7302
7303 /*
7304 * If error detected, restore the previous value.
7305 */
7306 if (errmsg != NULL)
7307 {
7308 if (new_value_alloced)
7309 free_string_option(*varp);
7310 *varp = oldval;
7311 /*
7312 * When resetting some values, need to act on it.
7313 */
7314 if (did_chartab)
7315 (void)init_chartab();
7316 if (varp == &p_hl)
7317 (void)highlight_changed();
7318 }
7319 else
7320 {
7321#ifdef FEAT_EVAL
7322 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007323 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007324#endif
7325 /*
7326 * Free string options that are in allocated memory.
Bram Moolenaarc0197e22004-09-13 20:26:32 +00007327 * Use "free_oldval", because recursiveness may change the flags under
7328 * our fingers (esp. init_highlight()).
Bram Moolenaar071d4272004-06-13 20:20:40 +00007329 */
Bram Moolenaarc0197e22004-09-13 20:26:32 +00007330 if (free_oldval)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007331 free_string_option(oldval);
7332 if (new_value_alloced)
7333 options[opt_idx].flags |= P_ALLOCED;
7334 else
7335 options[opt_idx].flags &= ~P_ALLOCED;
7336
7337 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00007338 && ((int)options[opt_idx].indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007339 {
7340 /* global option with local value set to use global value; free
7341 * the local value and make it empty */
7342 p = get_varp_scope(&(options[opt_idx]), OPT_LOCAL);
7343 free_string_option(*(char_u **)p);
7344 *(char_u **)p = empty_option;
7345 }
7346
7347 /* May set global value for local option. */
7348 else if (!(opt_flags & OPT_LOCAL) && opt_flags != OPT_GLOBAL)
7349 set_string_option_global(opt_idx, varp);
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007350
7351#ifdef FEAT_AUTOCMD
7352 /*
7353 * Trigger the autocommand only after setting the flags.
7354 */
7355# ifdef FEAT_SYN_HL
7356 /* When 'syntax' is set, load the syntax of that name */
7357 if (varp == &(curbuf->b_p_syn))
7358 {
7359 apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn,
7360 curbuf->b_fname, TRUE, curbuf);
7361 }
7362# endif
7363 else if (varp == &(curbuf->b_p_ft))
7364 {
7365 /* 'filetype' is set, trigger the FileType autocommand */
7366 did_filetype = TRUE;
7367 apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft,
7368 curbuf->b_fname, TRUE, curbuf);
7369 }
7370#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007371#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02007372 if (varp == &(curwin->w_s->b_p_spl))
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007373 {
7374 char_u fname[200];
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007375 char_u *q = curwin->w_s->b_p_spl;
7376
7377 /* Skip the first name if it is "cjk". */
7378 if (STRNCMP(q, "cjk,", 4) == 0)
7379 q += 4;
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007380
7381 /*
7382 * Source the spell/LANG.vim in 'runtimepath'.
7383 * They could set 'spellcapcheck' depending on the language.
7384 * Use the first name in 'spelllang' up to '_region' or
7385 * '.encoding'.
7386 */
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007387 for (p = q; *p != NUL; ++p)
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007388 if (vim_strchr((char_u *)"_.,", *p) != NULL)
7389 break;
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007390 vim_snprintf((char *)fname, 200, "spell/%.*s.vim", (int)(p - q), q);
Bram Moolenaar7f8989d2016-03-12 22:11:39 +01007391 source_runtime(fname, DIP_ALL);
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007392 }
7393#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007394 }
7395
7396#ifdef FEAT_MOUSE
7397 if (varp == &p_mouse)
7398 {
7399# ifdef FEAT_MOUSE_TTY
7400 if (*p_mouse == NUL)
7401 mch_setmouse(FALSE); /* switch mouse off */
7402 else
7403# endif
7404 setmouse(); /* in case 'mouse' changed */
7405 }
7406#endif
7407
Bram Moolenaar913077c2012-03-28 19:59:04 +02007408 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01007409 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02007410 curwin->w_set_curswant = TRUE;
7411
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00007412#ifdef FEAT_GUI
7413 /* check redraw when it's not a GUI option or the GUI is active. */
7414 if (!redraw_gui_only || gui.in_use)
7415#endif
7416 check_redraw(options[opt_idx].flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007417
7418 return errmsg;
7419}
7420
Bram Moolenaarf4e5e862013-02-13 15:44:26 +01007421#if defined(FEAT_SYN_HL) || defined(PROTO)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007422/*
7423 * Simple int comparison function for use with qsort()
7424 */
7425 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01007426int_cmp(const void *a, const void *b)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007427{
7428 return *(const int *)a - *(const int *)b;
7429}
7430
7431/*
7432 * Handle setting 'colorcolumn' or 'textwidth' in window "wp".
7433 * Returns error message, NULL if it's OK.
7434 */
7435 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007436check_colorcolumn(win_T *wp)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007437{
7438 char_u *s;
7439 int col;
7440 int count = 0;
7441 int color_cols[256];
7442 int i;
7443 int j = 0;
7444
Bram Moolenaar50f834d2011-09-21 13:40:17 +02007445 if (wp->w_buffer == NULL)
7446 return NULL; /* buffer was closed */
7447
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007448 for (s = wp->w_p_cc; *s != NUL && count < 255;)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007449 {
7450 if (*s == '-' || *s == '+')
7451 {
7452 /* -N and +N: add to 'textwidth' */
7453 col = (*s == '-') ? -1 : 1;
7454 ++s;
7455 if (!VIM_ISDIGIT(*s))
7456 return e_invarg;
7457 col = col * getdigits(&s);
7458 if (wp->w_buffer->b_p_tw == 0)
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007459 goto skip; /* 'textwidth' not set, skip this item */
Bram Moolenaar1a384422010-07-14 19:53:30 +02007460 col += wp->w_buffer->b_p_tw;
7461 if (col < 0)
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007462 goto skip;
Bram Moolenaar1a384422010-07-14 19:53:30 +02007463 }
7464 else if (VIM_ISDIGIT(*s))
7465 col = getdigits(&s);
7466 else
7467 return e_invarg;
7468 color_cols[count++] = col - 1; /* 1-based to 0-based */
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007469skip:
Bram Moolenaar1a384422010-07-14 19:53:30 +02007470 if (*s == NUL)
7471 break;
7472 if (*s != ',')
7473 return e_invarg;
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007474 if (*++s == NUL)
7475 return e_invarg; /* illegal trailing comma as in "set cc=80," */
Bram Moolenaar1a384422010-07-14 19:53:30 +02007476 }
7477
7478 vim_free(wp->w_p_cc_cols);
7479 if (count == 0)
7480 wp->w_p_cc_cols = NULL;
7481 else
7482 {
7483 wp->w_p_cc_cols = (int *)alloc((unsigned)sizeof(int) * (count + 1));
7484 if (wp->w_p_cc_cols != NULL)
7485 {
7486 /* sort the columns for faster usage on screen redraw inside
7487 * win_line() */
7488 qsort(color_cols, count, sizeof(int), int_cmp);
7489
7490 for (i = 0; i < count; ++i)
7491 /* skip duplicates */
7492 if (j == 0 || wp->w_p_cc_cols[j - 1] != color_cols[i])
7493 wp->w_p_cc_cols[j++] = color_cols[i];
7494 wp->w_p_cc_cols[j] = -1; /* end marker */
7495 }
7496 }
7497
7498 return NULL; /* no error */
7499}
7500#endif
7501
Bram Moolenaar071d4272004-06-13 20:20:40 +00007502/*
7503 * Handle setting 'listchars' or 'fillchars'.
7504 * Returns error message, NULL if it's OK.
7505 */
7506 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007507set_chars_option(char_u **varp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007508{
7509 int round, i, len, entries;
7510 char_u *p, *s;
7511 int c1, c2 = 0;
7512 struct charstab
7513 {
7514 int *cp;
7515 char *name;
7516 };
7517#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7518 static struct charstab filltab[] =
7519 {
7520 {&fill_stl, "stl"},
7521 {&fill_stlnc, "stlnc"},
7522 {&fill_vert, "vert"},
7523 {&fill_fold, "fold"},
7524 {&fill_diff, "diff"},
7525 };
7526#endif
7527 static struct charstab lcstab[] =
7528 {
7529 {&lcs_eol, "eol"},
7530 {&lcs_ext, "extends"},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00007531 {&lcs_nbsp, "nbsp"},
Bram Moolenaar071d4272004-06-13 20:20:40 +00007532 {&lcs_prec, "precedes"},
Bram Moolenaar4c6b3b22015-04-21 19:10:48 +02007533 {&lcs_space, "space"},
Bram Moolenaar071d4272004-06-13 20:20:40 +00007534 {&lcs_tab2, "tab"},
7535 {&lcs_trail, "trail"},
Bram Moolenaar860cae12010-06-05 23:22:07 +02007536#ifdef FEAT_CONCEAL
7537 {&lcs_conceal, "conceal"},
7538#else
7539 {NULL, "conceal"},
7540#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007541 };
7542 struct charstab *tab;
7543
7544#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7545 if (varp == &p_lcs)
7546#endif
7547 {
7548 tab = lcstab;
7549 entries = sizeof(lcstab) / sizeof(struct charstab);
7550 }
7551#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7552 else
7553 {
7554 tab = filltab;
7555 entries = sizeof(filltab) / sizeof(struct charstab);
7556 }
7557#endif
7558
7559 /* first round: check for valid value, second round: assign values */
7560 for (round = 0; round <= 1; ++round)
7561 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007562 if (round > 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007563 {
7564 /* After checking that the value is valid: set defaults: space for
7565 * 'fillchars', NUL for 'listchars' */
7566 for (i = 0; i < entries; ++i)
Bram Moolenaar860cae12010-06-05 23:22:07 +02007567 if (tab[i].cp != NULL)
7568 *(tab[i].cp) = (varp == &p_lcs ? NUL : ' ');
Bram Moolenaar071d4272004-06-13 20:20:40 +00007569 if (varp == &p_lcs)
7570 lcs_tab1 = NUL;
7571#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7572 else
7573 fill_diff = '-';
7574#endif
7575 }
7576 p = *varp;
7577 while (*p)
7578 {
7579 for (i = 0; i < entries; ++i)
7580 {
7581 len = (int)STRLEN(tab[i].name);
7582 if (STRNCMP(p, tab[i].name, len) == 0
7583 && p[len] == ':'
7584 && p[len + 1] != NUL)
7585 {
7586 s = p + len + 1;
7587#ifdef FEAT_MBYTE
7588 c1 = mb_ptr2char_adv(&s);
Bram Moolenaar910f66f2006-04-05 20:41:53 +00007589 if (mb_char2cells(c1) > 1)
7590 continue;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007591#else
7592 c1 = *s++;
7593#endif
7594 if (tab[i].cp == &lcs_tab2)
7595 {
7596 if (*s == NUL)
7597 continue;
7598#ifdef FEAT_MBYTE
7599 c2 = mb_ptr2char_adv(&s);
Bram Moolenaar910f66f2006-04-05 20:41:53 +00007600 if (mb_char2cells(c2) > 1)
7601 continue;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007602#else
7603 c2 = *s++;
7604#endif
7605 }
7606 if (*s == ',' || *s == NUL)
7607 {
7608 if (round)
7609 {
7610 if (tab[i].cp == &lcs_tab2)
7611 {
7612 lcs_tab1 = c1;
7613 lcs_tab2 = c2;
7614 }
Bram Moolenaar860cae12010-06-05 23:22:07 +02007615 else if (tab[i].cp != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007616 *(tab[i].cp) = c1;
7617
7618 }
7619 p = s;
7620 break;
7621 }
7622 }
7623 }
7624
7625 if (i == entries)
7626 return e_invarg;
7627 if (*p == ',')
7628 ++p;
7629 }
7630 }
7631
7632 return NULL; /* no error */
7633}
7634
7635#ifdef FEAT_STL_OPT
7636/*
7637 * Check validity of options with the 'statusline' format.
7638 * Return error message or NULL.
7639 */
7640 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007641check_stl_option(char_u *s)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007642{
7643 int itemcnt = 0;
7644 int groupdepth = 0;
7645 static char_u errbuf[80];
7646
7647 while (*s && itemcnt < STL_MAX_ITEM)
7648 {
7649 /* Check for valid keys after % sequences */
7650 while (*s && *s != '%')
7651 s++;
7652 if (!*s)
7653 break;
7654 s++;
7655 if (*s != '%' && *s != ')')
7656 ++itemcnt;
7657 if (*s == '%' || *s == STL_TRUNCMARK || *s == STL_MIDDLEMARK)
7658 {
7659 s++;
7660 continue;
7661 }
7662 if (*s == ')')
7663 {
7664 s++;
7665 if (--groupdepth < 0)
7666 break;
7667 continue;
7668 }
7669 if (*s == '-')
7670 s++;
7671 while (VIM_ISDIGIT(*s))
7672 s++;
Bram Moolenaar238a5642006-02-21 22:12:05 +00007673 if (*s == STL_USER_HL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007674 continue;
7675 if (*s == '.')
7676 {
7677 s++;
7678 while (*s && VIM_ISDIGIT(*s))
7679 s++;
7680 }
7681 if (*s == '(')
7682 {
7683 groupdepth++;
7684 continue;
7685 }
7686 if (vim_strchr(STL_ALL, *s) == NULL)
7687 {
7688 return illegal_char(errbuf, *s);
7689 }
7690 if (*s == '{')
7691 {
7692 s++;
7693 while (*s != '}' && *s)
7694 s++;
7695 if (*s != '}')
7696 return (char_u *)N_("E540: Unclosed expression sequence");
7697 }
7698 }
7699 if (itemcnt >= STL_MAX_ITEM)
7700 return (char_u *)N_("E541: too many items");
7701 if (groupdepth != 0)
7702 return (char_u *)N_("E542: unbalanced groups");
7703 return NULL;
7704}
7705#endif
7706
7707#ifdef FEAT_CLIPBOARD
7708/*
7709 * Extract the items in the 'clipboard' option and set global values.
7710 */
7711 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007712check_clipboard_option(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007713{
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007714 int new_unnamed = 0;
Bram Moolenaar89af4392012-07-10 18:31:54 +02007715 int new_autoselect_star = FALSE;
7716 int new_autoselect_plus = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007717 int new_autoselectml = FALSE;
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007718 int new_html = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007719 regprog_T *new_exclude_prog = NULL;
7720 char_u *errmsg = NULL;
7721 char_u *p;
7722
7723 for (p = p_cb; *p != NUL; )
7724 {
7725 if (STRNCMP(p, "unnamed", 7) == 0 && (p[7] == ',' || p[7] == NUL))
7726 {
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007727 new_unnamed |= CLIP_UNNAMED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007728 p += 7;
7729 }
Bram Moolenaar11b73d62012-06-29 15:51:30 +02007730 else if (STRNCMP(p, "unnamedplus", 11) == 0
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007731 && (p[11] == ',' || p[11] == NUL))
7732 {
7733 new_unnamed |= CLIP_UNNAMED_PLUS;
7734 p += 11;
7735 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007736 else if (STRNCMP(p, "autoselect", 10) == 0
Bram Moolenaar89af4392012-07-10 18:31:54 +02007737 && (p[10] == ',' || p[10] == NUL))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007738 {
Bram Moolenaar89af4392012-07-10 18:31:54 +02007739 new_autoselect_star = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007740 p += 10;
7741 }
Bram Moolenaar89af4392012-07-10 18:31:54 +02007742 else if (STRNCMP(p, "autoselectplus", 14) == 0
7743 && (p[14] == ',' || p[14] == NUL))
7744 {
7745 new_autoselect_plus = TRUE;
7746 p += 14;
7747 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007748 else if (STRNCMP(p, "autoselectml", 12) == 0
Bram Moolenaar89af4392012-07-10 18:31:54 +02007749 && (p[12] == ',' || p[12] == NUL))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007750 {
7751 new_autoselectml = TRUE;
7752 p += 12;
7753 }
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007754 else if (STRNCMP(p, "html", 4) == 0 && (p[4] == ',' || p[4] == NUL))
7755 {
7756 new_html = TRUE;
7757 p += 4;
7758 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007759 else if (STRNCMP(p, "exclude:", 8) == 0 && new_exclude_prog == NULL)
7760 {
7761 p += 8;
7762 new_exclude_prog = vim_regcomp(p, RE_MAGIC);
7763 if (new_exclude_prog == NULL)
7764 errmsg = e_invarg;
7765 break;
7766 }
7767 else
7768 {
7769 errmsg = e_invarg;
7770 break;
7771 }
7772 if (*p == ',')
7773 ++p;
7774 }
7775 if (errmsg == NULL)
7776 {
7777 clip_unnamed = new_unnamed;
Bram Moolenaar89af4392012-07-10 18:31:54 +02007778 clip_autoselect_star = new_autoselect_star;
7779 clip_autoselect_plus = new_autoselect_plus;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007780 clip_autoselectml = new_autoselectml;
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007781 clip_html = new_html;
Bram Moolenaar473de612013-06-08 18:19:48 +02007782 vim_regfree(clip_exclude_prog);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007783 clip_exclude_prog = new_exclude_prog;
Bram Moolenaara76638f2010-06-05 12:49:46 +02007784#ifdef FEAT_GUI_GTK
7785 if (gui.in_use)
7786 {
7787 gui_gtk_set_selection_targets();
7788 gui_gtk_set_dnd_targets();
7789 }
7790#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007791 }
7792 else
Bram Moolenaar473de612013-06-08 18:19:48 +02007793 vim_regfree(new_exclude_prog);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007794
7795 return errmsg;
7796}
7797#endif
7798
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007799#ifdef FEAT_SPELL
Bram Moolenaare68c25c2015-08-25 15:39:55 +02007800 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007801did_set_spell_option(int is_spellfile)
Bram Moolenaare68c25c2015-08-25 15:39:55 +02007802{
7803 char_u *errmsg = NULL;
7804 win_T *wp;
7805 int l;
7806
7807 if (is_spellfile)
7808 {
7809 l = (int)STRLEN(curwin->w_s->b_p_spf);
7810 if (l > 0 && (l < 4
7811 || STRCMP(curwin->w_s->b_p_spf + l - 4, ".add") != 0))
7812 errmsg = e_invarg;
7813 }
7814
7815 if (errmsg == NULL)
7816 {
7817 FOR_ALL_WINDOWS(wp)
7818 if (wp->w_buffer == curbuf && wp->w_p_spell)
7819 {
7820 errmsg = did_set_spelllang(wp);
7821# ifdef FEAT_WINDOWS
7822 break;
7823# endif
7824 }
7825 }
7826 return errmsg;
7827}
7828
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007829/*
7830 * Set curbuf->b_cap_prog to the regexp program for 'spellcapcheck'.
7831 * Return error message when failed, NULL when OK.
7832 */
7833 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007834compile_cap_prog(synblock_T *synblock)
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007835{
Bram Moolenaar860cae12010-06-05 23:22:07 +02007836 regprog_T *rp = synblock->b_cap_prog;
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007837 char_u *re;
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007838
Bram Moolenaar860cae12010-06-05 23:22:07 +02007839 if (*synblock->b_p_spc == NUL)
7840 synblock->b_cap_prog = NULL;
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007841 else
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007842 {
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007843 /* Prepend a ^ so that we only match at one column */
Bram Moolenaar860cae12010-06-05 23:22:07 +02007844 re = concat_str((char_u *)"^", synblock->b_p_spc);
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007845 if (re != NULL)
7846 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007847 synblock->b_cap_prog = vim_regcomp(re, RE_MAGIC);
Bram Moolenaar473de612013-06-08 18:19:48 +02007848 vim_free(re);
Bram Moolenaar860cae12010-06-05 23:22:07 +02007849 if (synblock->b_cap_prog == NULL)
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007850 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007851 synblock->b_cap_prog = rp; /* restore the previous program */
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007852 return e_invarg;
7853 }
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007854 }
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007855 }
7856
Bram Moolenaar473de612013-06-08 18:19:48 +02007857 vim_regfree(rp);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007858 return NULL;
7859}
7860#endif
7861
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007862#if defined(FEAT_EVAL) || defined(PROTO)
7863/*
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007864 * Set the scriptID for an option, taking care of setting the buffer- or
7865 * window-local value.
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007866 */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007867 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01007868set_option_scriptID_idx(int opt_idx, int opt_flags, int id)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007869{
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007870 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
7871 int indir = (int)options[opt_idx].indir;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007872
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007873 /* Remember where the option was set. For local options need to do that
7874 * in the buffer or window structure. */
7875 if (both || (opt_flags & OPT_GLOBAL) || (indir & (PV_BUF|PV_WIN)) == 0)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007876 options[opt_idx].scriptID = id;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007877 if (both || (opt_flags & OPT_LOCAL))
7878 {
7879 if (indir & PV_BUF)
7880 curbuf->b_p_scriptID[indir & PV_MASK] = id;
7881 else if (indir & PV_WIN)
7882 curwin->w_p_scriptID[indir & PV_MASK] = id;
7883 }
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007884}
7885#endif
7886
Bram Moolenaar071d4272004-06-13 20:20:40 +00007887/*
7888 * Set the value of a boolean option, and take care of side effects.
7889 * Returns NULL for success, or an error message for an error.
7890 */
7891 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007892set_bool_option(
7893 int opt_idx, /* index in options[] table */
7894 char_u *varp, /* pointer to the option variable */
7895 int value, /* new value */
7896 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007897{
7898 int old_value = *(int *)varp;
7899
Bram Moolenaar071d4272004-06-13 20:20:40 +00007900 /* Disallow changing some options from secure mode */
7901 if ((secure
7902#ifdef HAVE_SANDBOX
7903 || sandbox != 0
7904#endif
7905 ) && (options[opt_idx].flags & P_SECURE))
7906 return e_secure;
7907
7908 *(int *)varp = value; /* set the new value */
7909#ifdef FEAT_EVAL
7910 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007911 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007912#endif
7913
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00007914#ifdef FEAT_GUI
7915 need_mouse_correct = TRUE;
7916#endif
7917
Bram Moolenaar071d4272004-06-13 20:20:40 +00007918 /* May set global value for local option. */
7919 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
7920 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = value;
7921
7922 /*
7923 * Handle side effects of changing a bool option.
7924 */
7925
7926 /* 'compatible' */
7927 if ((int *)varp == &p_cp)
7928 {
7929 compatible_set();
7930 }
7931
Bram Moolenaar920694c2016-08-21 17:45:02 +02007932#ifdef FEAT_LANGMAP
7933 if ((int *)varp == &p_lrm)
7934 /* 'langremap' -> !'langnoremap' */
7935 p_lnr = !p_lrm;
7936 else if ((int *)varp == &p_lnr)
7937 /* 'langnoremap' -> !'langremap' */
7938 p_lrm = !p_lnr;
7939#endif
7940
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007941#ifdef FEAT_PERSISTENT_UNDO
7942 /* 'undofile' */
7943 else if ((int *)varp == &curbuf->b_p_udf || (int *)varp == &p_udf)
7944 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007945 /* Only take action when the option was set. When reset we do not
7946 * delete the undo file, the option may be set again without making
7947 * any changes in between. */
7948 if (curbuf->b_p_udf || p_udf)
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007949 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007950 char_u hash[UNDO_HASH_SIZE];
7951 buf_T *save_curbuf = curbuf;
7952
Bram Moolenaar29323592016-07-24 22:04:11 +02007953 FOR_ALL_BUFFERS(curbuf)
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007954 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007955 /* When 'undofile' is set globally: for every buffer, otherwise
7956 * only for the current buffer: Try to read in the undofile,
7957 * if one exists, the buffer wasn't changed and the buffer was
7958 * loaded */
7959 if ((curbuf == save_curbuf
7960 || (opt_flags & OPT_GLOBAL) || opt_flags == 0)
7961 && !curbufIsChanged() && curbuf->b_ml.ml_mfp != NULL)
7962 {
7963 u_compute_hash(hash);
7964 u_read_undo(NULL, hash, curbuf->b_fname);
7965 }
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007966 }
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007967 curbuf = save_curbuf;
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007968 }
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007969 }
7970#endif
7971
Bram Moolenaar071d4272004-06-13 20:20:40 +00007972 else if ((int *)varp == &curbuf->b_p_ro)
7973 {
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00007974 /* when 'readonly' is reset globally, also reset readonlymode */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007975 if (!curbuf->b_p_ro && (opt_flags & OPT_LOCAL) == 0)
7976 readonlymode = FALSE;
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00007977
7978 /* when 'readonly' is set may give W10 again */
7979 if (curbuf->b_p_ro)
7980 curbuf->b_did_warn = FALSE;
7981
Bram Moolenaar071d4272004-06-13 20:20:40 +00007982#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007983 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00007984#endif
7985 }
7986
Bram Moolenaar9c449722010-07-20 18:44:27 +02007987#ifdef FEAT_GUI
7988 else if ((int *)varp == &p_mh)
7989 {
7990 if (!p_mh)
7991 gui_mch_mousehide(FALSE);
7992 }
7993#endif
7994
Bram Moolenaara539df02010-08-01 14:35:05 +02007995#ifdef FEAT_TITLE
7996 /* when 'modifiable' is changed, redraw the window title */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007997 else if ((int *)varp == &curbuf->b_p_ma)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007998 {
7999 redraw_titles();
8000 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008001 /* when 'endofline' is changed, redraw the window title */
8002 else if ((int *)varp == &curbuf->b_p_eol)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008003 {
8004 redraw_titles();
8005 }
Bram Moolenaar34d72d42015-07-17 14:18:08 +02008006 /* when 'fixeol' is changed, redraw the window title */
8007 else if ((int *)varp == &curbuf->b_p_fixeol)
8008 {
8009 redraw_titles();
8010 }
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008011# ifdef FEAT_MBYTE
8012 /* when 'bomb' is changed, redraw the window title and tab page text */
Bram Moolenaar83eb8852007-08-12 13:51:26 +00008013 else if ((int *)varp == &curbuf->b_p_bomb)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008014 {
8015 redraw_titles();
8016 }
8017# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008018#endif
8019
8020 /* when 'bin' is set also set some other options */
8021 else if ((int *)varp == &curbuf->b_p_bin)
8022 {
8023 set_options_bin(old_value, curbuf->b_p_bin, opt_flags);
8024#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008025 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008026#endif
8027 }
8028
8029#ifdef FEAT_AUTOCMD
8030 /* when 'buflisted' changes, trigger autocommands */
8031 else if ((int *)varp == &curbuf->b_p_bl && old_value != curbuf->b_p_bl)
8032 {
8033 apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE,
8034 NULL, NULL, TRUE, curbuf);
8035 }
8036#endif
8037
8038 /* when 'swf' is set, create swapfile, when reset remove swapfile */
8039 else if ((int *)varp == &curbuf->b_p_swf)
8040 {
8041 if (curbuf->b_p_swf && p_uc)
8042 ml_open_file(curbuf); /* create the swap file */
8043 else
Bram Moolenaard55de222007-05-06 13:38:48 +00008044 /* no need to reset curbuf->b_may_swap, ml_open_file() will check
8045 * buf->b_p_swf */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008046 mf_close_file(curbuf, TRUE); /* remove the swap file */
8047 }
8048
8049 /* when 'terse' is set change 'shortmess' */
8050 else if ((int *)varp == &p_terse)
8051 {
8052 char_u *p;
8053
8054 p = vim_strchr(p_shm, SHM_SEARCH);
8055
8056 /* insert 's' in p_shm */
8057 if (p_terse && p == NULL)
8058 {
8059 STRCPY(IObuff, p_shm);
8060 STRCAT(IObuff, "s");
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008061 set_string_option_direct((char_u *)"shm", -1, IObuff, OPT_FREE, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008062 }
8063 /* remove 's' from p_shm */
8064 else if (!p_terse && p != NULL)
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00008065 STRMOVE(p, p + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008066 }
8067
8068 /* when 'paste' is set or reset also change other options */
8069 else if ((int *)varp == &p_paste)
8070 {
8071 paste_option_changed();
8072 }
8073
8074 /* when 'insertmode' is set from an autocommand need to do work here */
8075 else if ((int *)varp == &p_im)
8076 {
8077 if (p_im)
8078 {
8079 if ((State & INSERT) == 0)
8080 need_start_insertmode = TRUE;
8081 stop_insert_mode = FALSE;
8082 }
Bram Moolenaar00672e12016-06-26 18:38:13 +02008083 /* only reset if it was set previously */
8084 else if (old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008085 {
8086 need_start_insertmode = FALSE;
8087 stop_insert_mode = TRUE;
Bram Moolenaard12f5c12006-01-25 22:10:52 +00008088 if (restart_edit != 0 && mode_displayed)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008089 clear_cmdline = TRUE; /* remove "(insert)" */
8090 restart_edit = 0;
8091 }
8092 }
8093
8094 /* when 'ignorecase' is set or reset and 'hlsearch' is set, redraw */
8095 else if ((int *)varp == &p_ic && p_hls)
8096 {
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00008097 redraw_all_later(SOME_VALID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008098 }
8099
8100#ifdef FEAT_SEARCH_EXTRA
8101 /* when 'hlsearch' is set or reset: reset no_hlsearch */
8102 else if ((int *)varp == &p_hls)
8103 {
Bram Moolenaar8050efa2013-11-08 04:30:20 +01008104 SET_NO_HLSEARCH(FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008105 }
8106#endif
8107
8108#ifdef FEAT_SCROLLBIND
8109 /* when 'scrollbind' is set: snapshot the current position to avoid a jump
8110 * at the end of normal_cmd() */
8111 else if ((int *)varp == &curwin->w_p_scb)
8112 {
8113 if (curwin->w_p_scb)
Bram Moolenaar04c5c9e2013-07-09 13:44:59 +02008114 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00008115 do_check_scrollbind(FALSE);
Bram Moolenaar04c5c9e2013-07-09 13:44:59 +02008116 curwin->w_scbind_pos = curwin->w_topline;
8117 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008118 }
8119#endif
8120
8121#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
8122 /* There can be only one window with 'previewwindow' set. */
8123 else if ((int *)varp == &curwin->w_p_pvw)
8124 {
8125 if (curwin->w_p_pvw)
8126 {
8127 win_T *win;
8128
Bram Moolenaar29323592016-07-24 22:04:11 +02008129 FOR_ALL_WINDOWS(win)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008130 if (win->w_p_pvw && win != curwin)
8131 {
8132 curwin->w_p_pvw = FALSE;
8133 return (char_u *)N_("E590: A preview window already exists");
8134 }
8135 }
8136 }
8137#endif
8138
8139 /* when 'textmode' is set or reset also change 'fileformat' */
8140 else if ((int *)varp == &curbuf->b_p_tx)
8141 {
8142 set_fileformat(curbuf->b_p_tx ? EOL_DOS : EOL_UNIX, opt_flags);
8143 }
8144
8145 /* when 'textauto' is set or reset also change 'fileformats' */
8146 else if ((int *)varp == &p_ta)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008147 set_string_option_direct((char_u *)"ffs", -1,
8148 p_ta ? (char_u *)DFLT_FFS_VIM : (char_u *)"",
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008149 OPT_FREE | opt_flags, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008150
8151 /*
8152 * When 'lisp' option changes include/exclude '-' in
8153 * keyword characters.
8154 */
8155#ifdef FEAT_LISP
8156 else if (varp == (char_u *)&(curbuf->b_p_lisp))
8157 {
8158 (void)buf_init_chartab(curbuf, FALSE); /* ignore errors */
8159 }
8160#endif
8161
8162#ifdef FEAT_TITLE
8163 /* when 'title' changed, may need to change the title; same for 'icon' */
8164 else if ((int *)varp == &p_title)
8165 {
8166 did_set_title(FALSE);
8167 }
8168
8169 else if ((int *)varp == &p_icon)
8170 {
8171 did_set_title(TRUE);
8172 }
8173#endif
8174
8175 else if ((int *)varp == &curbuf->b_changed)
8176 {
8177 if (!value)
8178 save_file_ff(curbuf); /* Buffer is unchanged */
8179#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008180 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008181#endif
8182#ifdef FEAT_AUTOCMD
8183 modified_was_set = value;
8184#endif
8185 }
8186
8187#ifdef BACKSLASH_IN_FILENAME
8188 else if ((int *)varp == &p_ssl)
8189 {
8190 if (p_ssl)
8191 {
8192 psepc = '/';
8193 psepcN = '\\';
8194 pseps[0] = '/';
Bram Moolenaar071d4272004-06-13 20:20:40 +00008195 }
8196 else
8197 {
8198 psepc = '\\';
8199 psepcN = '/';
8200 pseps[0] = '\\';
Bram Moolenaar071d4272004-06-13 20:20:40 +00008201 }
8202
8203 /* need to adjust the file name arguments and buffer names. */
8204 buflist_slash_adjust();
8205 alist_slash_adjust();
8206# ifdef FEAT_EVAL
8207 scriptnames_slash_adjust();
8208# endif
8209 }
8210#endif
8211
8212 /* If 'wrap' is set, set w_leftcol to zero. */
8213 else if ((int *)varp == &curwin->w_p_wrap)
8214 {
8215 if (curwin->w_p_wrap)
8216 curwin->w_leftcol = 0;
8217 }
8218
8219#ifdef FEAT_WINDOWS
8220 else if ((int *)varp == &p_ea)
8221 {
8222 if (p_ea && !old_value)
8223 win_equal(curwin, FALSE, 0);
8224 }
8225#endif
8226
8227 else if ((int *)varp == &p_wiv)
8228 {
8229 /*
8230 * When 'weirdinvert' changed, set/reset 't_xs'.
8231 * Then set 'weirdinvert' according to value of 't_xs'.
8232 */
8233 if (p_wiv && !old_value)
8234 T_XS = (char_u *)"y";
8235 else if (!p_wiv && old_value)
8236 T_XS = empty_option;
8237 p_wiv = (*T_XS != NUL);
8238 }
8239
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00008240#ifdef FEAT_BEVAL
Bram Moolenaar071d4272004-06-13 20:20:40 +00008241 else if ((int *)varp == &p_beval)
8242 {
Bram Moolenaar49e4ec62011-11-30 11:31:30 +01008243 if (p_beval && !old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008244 gui_mch_enable_beval_area(balloonEval);
Bram Moolenaar49e4ec62011-11-30 11:31:30 +01008245 else if (!p_beval && old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008246 gui_mch_disable_beval_area(balloonEval);
8247 }
Bram Moolenaar8dff8182006-04-06 20:18:50 +00008248#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008249
Bram Moolenaar8dff8182006-04-06 20:18:50 +00008250#ifdef FEAT_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +00008251 else if ((int *)varp == &p_acd)
8252 {
Bram Moolenaar498efdb2006-09-05 14:31:54 +00008253 /* Change directories when the 'acd' option is set now. */
8254 DO_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +00008255 }
8256#endif
8257
8258#ifdef FEAT_DIFF
8259 /* 'diff' */
8260 else if ((int *)varp == &curwin->w_p_diff)
8261 {
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008262 /* May add or remove the buffer from the list of diff buffers. */
8263 diff_buf_adjust(curwin);
8264# ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00008265 if (foldmethodIsDiff(curwin))
8266 foldUpdateAll(curwin);
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008267# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008268 }
8269#endif
8270
8271#ifdef USE_IM_CONTROL
8272 /* 'imdisable' */
8273 else if ((int *)varp == &p_imdisable)
8274 {
8275 /* Only de-activate it here, it will be enabled when changing mode. */
8276 if (p_imdisable)
8277 im_set_active(FALSE);
Bram Moolenaar725a9622011-10-12 16:57:13 +02008278 else if (State & INSERT)
8279 /* When the option is set from an autocommand, it may need to take
8280 * effect right away. */
8281 im_set_active(curbuf->b_p_iminsert == B_IMODE_IM);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008282 }
8283#endif
8284
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00008285#ifdef FEAT_SPELL
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00008286 /* 'spell' */
8287 else if ((int *)varp == &curwin->w_p_spell)
8288 {
8289 if (curwin->w_p_spell)
8290 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02008291 char_u *errmsg = did_set_spelllang(curwin);
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00008292 if (errmsg != NULL)
8293 EMSG(_(errmsg));
8294 }
8295 }
8296#endif
8297
Bram Moolenaar071d4272004-06-13 20:20:40 +00008298#ifdef FEAT_FKMAP
8299 else if ((int *)varp == &p_altkeymap)
8300 {
8301 if (old_value != p_altkeymap)
8302 {
8303 if (!p_altkeymap)
8304 {
8305 p_hkmap = p_fkmap;
8306 p_fkmap = 0;
8307 }
8308 else
8309 {
8310 p_fkmap = p_hkmap;
8311 p_hkmap = 0;
8312 }
8313 (void)init_chartab();
8314 }
8315 }
8316
8317 /*
8318 * In case some second language keymapping options have changed, check
8319 * and correct the setting in a consistent way.
8320 */
8321
8322 /*
8323 * If hkmap or fkmap are set, reset Arabic keymapping.
8324 */
8325 if ((p_hkmap || p_fkmap) && p_altkeymap)
8326 {
8327 p_altkeymap = p_fkmap;
8328# ifdef FEAT_ARABIC
8329 curwin->w_p_arab = FALSE;
8330# endif
8331 (void)init_chartab();
8332 }
8333
8334 /*
8335 * If hkmap set, reset Farsi keymapping.
8336 */
8337 if (p_hkmap && p_altkeymap)
8338 {
8339 p_altkeymap = 0;
8340 p_fkmap = 0;
8341# ifdef FEAT_ARABIC
8342 curwin->w_p_arab = FALSE;
8343# endif
8344 (void)init_chartab();
8345 }
8346
8347 /*
8348 * If fkmap set, reset Hebrew keymapping.
8349 */
8350 if (p_fkmap && !p_altkeymap)
8351 {
8352 p_altkeymap = 1;
8353 p_hkmap = 0;
8354# ifdef FEAT_ARABIC
8355 curwin->w_p_arab = FALSE;
8356# endif
8357 (void)init_chartab();
8358 }
8359#endif
8360
8361#ifdef FEAT_ARABIC
8362 if ((int *)varp == &curwin->w_p_arab)
8363 {
8364 if (curwin->w_p_arab)
8365 {
8366 /*
8367 * 'arabic' is set, handle various sub-settings.
8368 */
8369 if (!p_tbidi)
8370 {
8371 /* set rightleft mode */
8372 if (!curwin->w_p_rl)
8373 {
8374 curwin->w_p_rl = TRUE;
8375 changed_window_setting();
8376 }
8377
8378 /* Enable Arabic shaping (major part of what Arabic requires) */
8379 if (!p_arshape)
8380 {
8381 p_arshape = TRUE;
8382 redraw_later_clear();
8383 }
8384 }
8385
8386 /* Arabic requires a utf-8 encoding, inform the user if its not
8387 * set. */
8388 if (STRCMP(p_enc, "utf-8") != 0)
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008389 {
Bram Moolenaar496c5262009-03-18 14:42:00 +00008390 static char *w_arabic = N_("W17: Arabic requires UTF-8, do ':set encoding=utf-8'");
8391
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008392 msg_source(hl_attr(HLF_W));
Bram Moolenaar496c5262009-03-18 14:42:00 +00008393 MSG_ATTR(_(w_arabic), hl_attr(HLF_W));
8394#ifdef FEAT_EVAL
8395 set_vim_var_string(VV_WARNINGMSG, (char_u *)_(w_arabic), -1);
8396#endif
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008397 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008398
8399# ifdef FEAT_MBYTE
8400 /* set 'delcombine' */
8401 p_deco = TRUE;
8402# endif
8403
8404# ifdef FEAT_KEYMAP
8405 /* Force-set the necessary keymap for arabic */
8406 set_option_value((char_u *)"keymap", 0L, (char_u *)"arabic",
8407 OPT_LOCAL);
8408# endif
8409# ifdef FEAT_FKMAP
8410 p_altkeymap = 0;
8411 p_hkmap = 0;
8412 p_fkmap = 0;
8413 (void)init_chartab();
8414# endif
8415 }
8416 else
8417 {
8418 /*
8419 * 'arabic' is reset, handle various sub-settings.
8420 */
8421 if (!p_tbidi)
8422 {
8423 /* reset rightleft mode */
8424 if (curwin->w_p_rl)
8425 {
8426 curwin->w_p_rl = FALSE;
8427 changed_window_setting();
8428 }
8429
8430 /* 'arabicshape' isn't reset, it is a global option and
8431 * another window may still need it "on". */
8432 }
8433
8434 /* 'delcombine' isn't reset, it is a global option and another
8435 * window may still want it "on". */
8436
8437# ifdef FEAT_KEYMAP
8438 /* Revert to the default keymap */
8439 curbuf->b_p_iminsert = B_IMODE_NONE;
8440 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
8441# endif
8442 }
Bram Moolenaar801f8b82009-07-29 13:42:05 +00008443 }
8444
Bram Moolenaar319bdbd2009-09-11 13:20:33 +00008445#endif
8446
Bram Moolenaar61be73b2016-04-29 22:59:22 +02008447#ifdef FEAT_TERMGUICOLORS
8448 /* 'termguicolors' */
8449 else if ((int *)varp == &p_tgc)
Bram Moolenaar8a633e32016-04-21 21:10:14 +02008450 {
8451# ifdef FEAT_GUI
8452 if (!gui.in_use && !gui.starting)
8453# endif
8454 highlight_gui_started();
8455 }
8456#endif
8457
Bram Moolenaar071d4272004-06-13 20:20:40 +00008458 /*
8459 * End of handling side effects for bool options.
8460 */
8461
Bram Moolenaar53744302015-07-17 17:38:22 +02008462 /* after handling side effects, call autocommand */
8463
Bram Moolenaar071d4272004-06-13 20:20:40 +00008464 options[opt_idx].flags |= P_WAS_SET;
8465
Bram Moolenaar53744302015-07-17 17:38:22 +02008466#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
8467 if (!starting)
8468 {
8469 char_u buf_old[2], buf_new[2], buf_type[7];
Bram Moolenaarfb9bc482015-07-17 22:04:48 +02008470 vim_snprintf((char *)buf_old, 2, "%d", old_value ? TRUE: FALSE);
8471 vim_snprintf((char *)buf_new, 2, "%d", value ? TRUE: FALSE);
8472 vim_snprintf((char *)buf_type, 7, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar53744302015-07-17 17:38:22 +02008473 set_vim_var_string(VV_OPTION_NEW, buf_new, -1);
8474 set_vim_var_string(VV_OPTION_OLD, buf_old, -1);
8475 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
8476 apply_autocmds(EVENT_OPTIONSET, (char_u *) options[opt_idx].fullname, NULL, FALSE, NULL);
8477 reset_v_option_vars();
8478 }
8479#endif
8480
Bram Moolenaar071d4272004-06-13 20:20:40 +00008481 comp_col(); /* in case 'ruler' or 'showcmd' changed */
Bram Moolenaar913077c2012-03-28 19:59:04 +02008482 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01008483 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02008484 curwin->w_set_curswant = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008485 check_redraw(options[opt_idx].flags);
8486
8487 return NULL;
8488}
8489
8490/*
8491 * Set the value of a number option, and take care of side effects.
8492 * Returns NULL for success, or an error message for an error.
8493 */
8494 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01008495set_num_option(
8496 int opt_idx, /* index in options[] table */
8497 char_u *varp, /* pointer to the option variable */
8498 long value, /* new value */
8499 char_u *errbuf, /* buffer for error messages */
8500 size_t errbuflen, /* length of "errbuf" */
8501 int opt_flags) /* OPT_LOCAL, OPT_GLOBAL and
Bram Moolenaar071d4272004-06-13 20:20:40 +00008502 OPT_MODELINE */
8503{
8504 char_u *errmsg = NULL;
8505 long old_value = *(long *)varp;
8506 long old_Rows = Rows; /* remember old Rows */
8507 long old_Columns = Columns; /* remember old Columns */
8508 long *pp = (long *)varp;
8509
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008510 /* Disallow changing some options from secure mode. */
8511 if ((secure
8512#ifdef HAVE_SANDBOX
8513 || sandbox != 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00008514#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008515 ) && (options[opt_idx].flags & P_SECURE))
8516 return e_secure;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008517
8518 *pp = value;
8519#ifdef FEAT_EVAL
8520 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008521 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008522#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008523#ifdef FEAT_GUI
8524 need_mouse_correct = TRUE;
8525#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008526
Bram Moolenaar14f24742012-08-08 18:01:05 +02008527 if (curbuf->b_p_sw < 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008528 {
8529 errmsg = e_positive;
8530 curbuf->b_p_sw = curbuf->b_p_ts;
8531 }
8532
8533 /*
8534 * Number options that need some action when changed
8535 */
8536#ifdef FEAT_WINDOWS
8537 if (pp == &p_wh || pp == &p_hh)
8538 {
8539 if (p_wh < 1)
8540 {
8541 errmsg = e_positive;
8542 p_wh = 1;
8543 }
8544 if (p_wmh > p_wh)
8545 {
8546 errmsg = e_winheight;
8547 p_wh = p_wmh;
8548 }
8549 if (p_hh < 0)
8550 {
8551 errmsg = e_positive;
8552 p_hh = 0;
8553 }
8554
8555 /* Change window height NOW */
Bram Moolenaar459ca562016-11-10 18:16:33 +01008556 if (!ONE_WINDOW)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008557 {
8558 if (pp == &p_wh && curwin->w_height < p_wh)
8559 win_setheight((int)p_wh);
8560 if (pp == &p_hh && curbuf->b_help && curwin->w_height < p_hh)
8561 win_setheight((int)p_hh);
8562 }
8563 }
8564
8565 /* 'winminheight' */
8566 else if (pp == &p_wmh)
8567 {
8568 if (p_wmh < 0)
8569 {
8570 errmsg = e_positive;
8571 p_wmh = 0;
8572 }
8573 if (p_wmh > p_wh)
8574 {
8575 errmsg = e_winheight;
8576 p_wmh = p_wh;
8577 }
8578 win_setminheight();
8579 }
8580
Bram Moolenaar44a2f922016-03-19 22:11:51 +01008581# ifdef FEAT_WINDOWS
Bram Moolenaar592e0a22004-07-03 16:05:59 +00008582 else if (pp == &p_wiw)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008583 {
8584 if (p_wiw < 1)
8585 {
8586 errmsg = e_positive;
8587 p_wiw = 1;
8588 }
8589 if (p_wmw > p_wiw)
8590 {
8591 errmsg = e_winwidth;
8592 p_wiw = p_wmw;
8593 }
8594
8595 /* Change window width NOW */
Bram Moolenaar459ca562016-11-10 18:16:33 +01008596 if (!ONE_WINDOW && curwin->w_width < p_wiw)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008597 win_setwidth((int)p_wiw);
8598 }
8599
8600 /* 'winminwidth' */
8601 else if (pp == &p_wmw)
8602 {
8603 if (p_wmw < 0)
8604 {
8605 errmsg = e_positive;
8606 p_wmw = 0;
8607 }
8608 if (p_wmw > p_wiw)
8609 {
8610 errmsg = e_winwidth;
8611 p_wmw = p_wiw;
8612 }
8613 win_setminheight();
8614 }
8615# endif
8616
8617#endif
8618
8619#ifdef FEAT_WINDOWS
8620 /* (re)set last window status line */
8621 else if (pp == &p_ls)
8622 {
8623 last_status(FALSE);
8624 }
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00008625
8626 /* (re)set tab page line */
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00008627 else if (pp == &p_stal)
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00008628 {
8629 shell_new_rows(); /* recompute window positions and heights */
8630 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008631#endif
8632
8633#ifdef FEAT_GUI
8634 else if (pp == &p_linespace)
8635 {
Bram Moolenaar02743632005-07-25 20:42:36 +00008636 /* Recompute gui.char_height and resize the Vim window to keep the
8637 * same number of lines. */
8638 if (gui.in_use && gui_mch_adjust_charheight() == OK)
Bram Moolenaar3964b7e2006-03-27 20:59:33 +00008639 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008640 }
8641#endif
8642
8643#ifdef FEAT_FOLDING
8644 /* 'foldlevel' */
8645 else if (pp == &curwin->w_p_fdl)
8646 {
8647 if (curwin->w_p_fdl < 0)
8648 curwin->w_p_fdl = 0;
8649 newFoldLevel();
8650 }
8651
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008652 /* 'foldminlines' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008653 else if (pp == &curwin->w_p_fml)
8654 {
8655 foldUpdateAll(curwin);
8656 }
8657
8658 /* 'foldnestmax' */
8659 else if (pp == &curwin->w_p_fdn)
8660 {
8661 if (foldmethodIsSyntax(curwin) || foldmethodIsIndent(curwin))
8662 foldUpdateAll(curwin);
8663 }
8664
8665 /* 'foldcolumn' */
8666 else if (pp == &curwin->w_p_fdc)
8667 {
8668 if (curwin->w_p_fdc < 0)
8669 {
8670 errmsg = e_positive;
8671 curwin->w_p_fdc = 0;
8672 }
8673 else if (curwin->w_p_fdc > 12)
8674 {
8675 errmsg = e_invarg;
8676 curwin->w_p_fdc = 12;
8677 }
8678 }
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008679#endif /* FEAT_FOLDING */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008680
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008681#if defined(FEAT_FOLDING) || defined(FEAT_CINDENT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008682 /* 'shiftwidth' or 'tabstop' */
8683 else if (pp == &curbuf->b_p_sw || pp == &curbuf->b_p_ts)
8684 {
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008685# ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00008686 if (foldmethodIsIndent(curwin))
8687 foldUpdateAll(curwin);
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008688# endif
8689# ifdef FEAT_CINDENT
8690 /* When 'shiftwidth' changes, or it's zero and 'tabstop' changes:
8691 * parse 'cinoptions'. */
8692 if (pp == &curbuf->b_p_sw || curbuf->b_p_sw == 0)
8693 parse_cino(curbuf);
8694# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008695 }
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008696#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008697
Bram Moolenaar362e1a32006-03-06 23:29:24 +00008698#ifdef FEAT_MBYTE
8699 /* 'maxcombine' */
8700 else if (pp == &p_mco)
8701 {
8702 if (p_mco > MAX_MCO)
8703 p_mco = MAX_MCO;
8704 else if (p_mco < 0)
8705 p_mco = 0;
8706 screenclear(); /* will re-allocate the screen */
8707 }
8708#endif
8709
Bram Moolenaar071d4272004-06-13 20:20:40 +00008710 else if (pp == &curbuf->b_p_iminsert)
8711 {
8712 if (curbuf->b_p_iminsert < 0 || curbuf->b_p_iminsert > B_IMODE_LAST)
8713 {
8714 errmsg = e_invarg;
8715 curbuf->b_p_iminsert = B_IMODE_NONE;
8716 }
8717 p_iminsert = curbuf->b_p_iminsert;
8718 if (termcap_active) /* don't do this in the alternate screen */
8719 showmode();
8720#if defined(FEAT_WINDOWS) && defined(FEAT_KEYMAP)
8721 /* Show/unshow value of 'keymap' in status lines. */
8722 status_redraw_curbuf();
8723#endif
8724 }
8725
Bram Moolenaar4399ef42005-02-12 14:29:27 +00008726 else if (pp == &p_window)
8727 {
8728 if (p_window < 1)
8729 p_window = 1;
8730 else if (p_window >= Rows)
8731 p_window = Rows - 1;
8732 }
8733
Bram Moolenaar071d4272004-06-13 20:20:40 +00008734 else if (pp == &curbuf->b_p_imsearch)
8735 {
8736 if (curbuf->b_p_imsearch < -1 || curbuf->b_p_imsearch > B_IMODE_LAST)
8737 {
8738 errmsg = e_invarg;
8739 curbuf->b_p_imsearch = B_IMODE_NONE;
8740 }
8741 p_imsearch = curbuf->b_p_imsearch;
8742 }
8743
8744#ifdef FEAT_TITLE
8745 /* if 'titlelen' has changed, redraw the title */
8746 else if (pp == &p_titlelen)
8747 {
8748 if (p_titlelen < 0)
8749 {
8750 errmsg = e_positive;
8751 p_titlelen = 85;
8752 }
8753 if (starting != NO_SCREEN && old_value != p_titlelen)
8754 need_maketitle = TRUE;
8755 }
8756#endif
8757
8758 /* if p_ch changed value, change the command line height */
8759 else if (pp == &p_ch)
8760 {
8761 if (p_ch < 1)
8762 {
8763 errmsg = e_positive;
8764 p_ch = 1;
8765 }
Bram Moolenaar719939c2007-09-25 12:51:28 +00008766 if (p_ch > Rows - min_rows() + 1)
8767 p_ch = Rows - min_rows() + 1;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008768
8769 /* Only compute the new window layout when startup has been
8770 * completed. Otherwise the frame sizes may be wrong. */
8771 if (p_ch != old_value && full_screen
8772#ifdef FEAT_GUI
8773 && !gui.starting
8774#endif
8775 )
Bram Moolenaarc6fe9192006-04-09 21:54:49 +00008776 command_height();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008777 }
8778
8779 /* when 'updatecount' changes from zero to non-zero, open swap files */
8780 else if (pp == &p_uc)
8781 {
8782 if (p_uc < 0)
8783 {
8784 errmsg = e_positive;
8785 p_uc = 100;
8786 }
8787 if (p_uc && !old_value)
8788 ml_open_files();
8789 }
Bram Moolenaar860cae12010-06-05 23:22:07 +02008790#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008791 else if (pp == &curwin->w_p_cole)
Bram Moolenaar860cae12010-06-05 23:22:07 +02008792 {
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008793 if (curwin->w_p_cole < 0)
Bram Moolenaar860cae12010-06-05 23:22:07 +02008794 {
8795 errmsg = e_positive;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008796 curwin->w_p_cole = 0;
Bram Moolenaar860cae12010-06-05 23:22:07 +02008797 }
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008798 else if (curwin->w_p_cole > 3)
Bram Moolenaar860cae12010-06-05 23:22:07 +02008799 {
8800 errmsg = e_invarg;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008801 curwin->w_p_cole = 3;
Bram Moolenaar860cae12010-06-05 23:22:07 +02008802 }
8803 }
8804#endif
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008805#ifdef MZSCHEME_GUI_THREADS
Bram Moolenaar325b7a22004-07-05 15:58:32 +00008806 else if (pp == &p_mzq)
8807 mzvim_reset_timer();
8808#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008809
8810 /* sync undo before 'undolevels' changes */
8811 else if (pp == &p_ul)
8812 {
8813 /* use the old value, otherwise u_sync() may not work properly */
8814 p_ul = old_value;
Bram Moolenaar779b74b2006-04-10 14:55:34 +00008815 u_sync(TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008816 p_ul = value;
8817 }
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01008818 else if (pp == &curbuf->b_p_ul)
8819 {
8820 /* use the old value, otherwise u_sync() may not work properly */
8821 curbuf->b_p_ul = old_value;
8822 u_sync(TRUE);
8823 curbuf->b_p_ul = value;
8824 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008825
Bram Moolenaar592e0a22004-07-03 16:05:59 +00008826#ifdef FEAT_LINEBREAK
8827 /* 'numberwidth' must be positive */
8828 else if (pp == &curwin->w_p_nuw)
8829 {
8830 if (curwin->w_p_nuw < 1)
8831 {
8832 errmsg = e_positive;
8833 curwin->w_p_nuw = 1;
8834 }
8835 if (curwin->w_p_nuw > 10)
8836 {
8837 errmsg = e_invarg;
8838 curwin->w_p_nuw = 10;
8839 }
Bram Moolenaar1e7813a2015-03-31 18:31:03 +02008840 curwin->w_nrwidth_line_count = 0; /* trigger a redraw */
Bram Moolenaar592e0a22004-07-03 16:05:59 +00008841 }
8842#endif
8843
Bram Moolenaar1a384422010-07-14 19:53:30 +02008844 else if (pp == &curbuf->b_p_tw)
8845 {
8846 if (curbuf->b_p_tw < 0)
8847 {
8848 errmsg = e_positive;
8849 curbuf->b_p_tw = 0;
8850 }
8851#ifdef FEAT_SYN_HL
8852# ifdef FEAT_WINDOWS
8853 {
8854 win_T *wp;
8855 tabpage_T *tp;
8856
8857 FOR_ALL_TAB_WINDOWS(tp, wp)
8858 check_colorcolumn(wp);
8859 }
8860# else
8861 check_colorcolumn(curwin);
8862# endif
8863#endif
8864 }
8865
Bram Moolenaar071d4272004-06-13 20:20:40 +00008866 /*
8867 * Check the bounds for numeric options here
8868 */
8869 if (Rows < min_rows() && full_screen)
8870 {
8871 if (errbuf != NULL)
8872 {
Bram Moolenaar555b2802005-05-19 21:08:39 +00008873 vim_snprintf((char *)errbuf, errbuflen,
8874 _("E593: Need at least %d lines"), min_rows());
Bram Moolenaar071d4272004-06-13 20:20:40 +00008875 errmsg = errbuf;
8876 }
8877 Rows = min_rows();
8878 }
8879 if (Columns < MIN_COLUMNS && full_screen)
8880 {
8881 if (errbuf != NULL)
8882 {
Bram Moolenaar555b2802005-05-19 21:08:39 +00008883 vim_snprintf((char *)errbuf, errbuflen,
8884 _("E594: Need at least %d columns"), MIN_COLUMNS);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008885 errmsg = errbuf;
8886 }
8887 Columns = MIN_COLUMNS;
8888 }
Bram Moolenaare057d402013-06-30 17:51:51 +02008889 limit_screen_size();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008890
Bram Moolenaar071d4272004-06-13 20:20:40 +00008891 /*
8892 * If the screen (shell) height has been changed, assume it is the
8893 * physical screenheight.
8894 */
8895 if (old_Rows != Rows || old_Columns != Columns)
8896 {
8897 /* Changing the screen size is not allowed while updating the screen. */
8898 if (updating_screen)
8899 *pp = old_value;
8900 else if (full_screen
8901#ifdef FEAT_GUI
8902 && !gui.starting
8903#endif
8904 )
8905 set_shellsize((int)Columns, (int)Rows, TRUE);
8906 else
8907 {
8908 /* Postpone the resizing; check the size and cmdline position for
8909 * messages. */
8910 check_shellsize();
8911 if (cmdline_row > Rows - p_ch && Rows > p_ch)
8912 cmdline_row = Rows - p_ch;
8913 }
Bram Moolenaard68071d2006-05-02 22:08:30 +00008914 if (p_window >= Rows || !option_was_set((char_u *)"window"))
Bram Moolenaar4399ef42005-02-12 14:29:27 +00008915 p_window = Rows - 1;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008916 }
8917
Bram Moolenaar071d4272004-06-13 20:20:40 +00008918 if (curbuf->b_p_ts <= 0)
8919 {
8920 errmsg = e_positive;
8921 curbuf->b_p_ts = 8;
8922 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008923 if (p_tm < 0)
8924 {
8925 errmsg = e_positive;
8926 p_tm = 0;
8927 }
8928 if ((curwin->w_p_scr <= 0
8929 || (curwin->w_p_scr > curwin->w_height
8930 && curwin->w_height > 0))
8931 && full_screen)
8932 {
8933 if (pp == &(curwin->w_p_scr))
8934 {
8935 if (curwin->w_p_scr != 0)
8936 errmsg = e_scroll;
8937 win_comp_scroll(curwin);
8938 }
8939 /* If 'scroll' became invalid because of a side effect silently adjust
8940 * it. */
8941 else if (curwin->w_p_scr <= 0)
8942 curwin->w_p_scr = 1;
8943 else /* curwin->w_p_scr > curwin->w_height */
8944 curwin->w_p_scr = curwin->w_height;
8945 }
Bram Moolenaar991e10f2008-10-02 20:48:41 +00008946 if (p_hi < 0)
8947 {
8948 errmsg = e_positive;
8949 p_hi = 0;
8950 }
Bram Moolenaar78159bb2014-06-25 11:48:54 +02008951 else if (p_hi > 10000)
8952 {
8953 errmsg = e_invarg;
8954 p_hi = 10000;
8955 }
Bram Moolenaarfbc0d2e2013-05-19 19:40:29 +02008956 if (p_re < 0 || p_re > 2)
8957 {
8958 errmsg = e_invarg;
8959 p_re = 0;
8960 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008961 if (p_report < 0)
8962 {
8963 errmsg = e_positive;
8964 p_report = 1;
8965 }
Bram Moolenaar1e015462005-09-25 22:16:38 +00008966 if ((p_sj < -100 || p_sj >= Rows) && full_screen)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008967 {
8968 if (Rows != old_Rows) /* Rows changed, just adjust p_sj */
8969 p_sj = Rows / 2;
8970 else
8971 {
8972 errmsg = e_scroll;
8973 p_sj = 1;
8974 }
8975 }
8976 if (p_so < 0 && full_screen)
8977 {
8978 errmsg = e_scroll;
8979 p_so = 0;
8980 }
8981 if (p_siso < 0 && full_screen)
8982 {
8983 errmsg = e_positive;
8984 p_siso = 0;
8985 }
8986#ifdef FEAT_CMDWIN
8987 if (p_cwh < 1)
8988 {
8989 errmsg = e_positive;
8990 p_cwh = 1;
8991 }
8992#endif
8993 if (p_ut < 0)
8994 {
8995 errmsg = e_positive;
8996 p_ut = 2000;
8997 }
8998 if (p_ss < 0)
8999 {
9000 errmsg = e_positive;
9001 p_ss = 0;
9002 }
9003
9004 /* May set global value for local option. */
9005 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
9006 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = *pp;
9007
9008 options[opt_idx].flags |= P_WAS_SET;
9009
Bram Moolenaar53744302015-07-17 17:38:22 +02009010#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
9011 if (!starting && errmsg == NULL)
9012 {
9013 char_u buf_old[11], buf_new[11], buf_type[7];
Bram Moolenaarfb9bc482015-07-17 22:04:48 +02009014 vim_snprintf((char *)buf_old, 10, "%ld", old_value);
9015 vim_snprintf((char *)buf_new, 10, "%ld", value);
9016 vim_snprintf((char *)buf_type, 7, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar53744302015-07-17 17:38:22 +02009017 set_vim_var_string(VV_OPTION_NEW, buf_new, -1);
9018 set_vim_var_string(VV_OPTION_OLD, buf_old, -1);
9019 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
9020 apply_autocmds(EVENT_OPTIONSET, (char_u *) options[opt_idx].fullname, NULL, FALSE, NULL);
9021 reset_v_option_vars();
9022 }
9023#endif
9024
Bram Moolenaar071d4272004-06-13 20:20:40 +00009025 comp_col(); /* in case 'columns' or 'ls' changed */
Bram Moolenaar913077c2012-03-28 19:59:04 +02009026 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01009027 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02009028 curwin->w_set_curswant = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009029 check_redraw(options[opt_idx].flags);
9030
9031 return errmsg;
9032}
9033
9034/*
9035 * Called after an option changed: check if something needs to be redrawn.
9036 */
9037 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01009038check_redraw(long_u flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009039{
9040 /* Careful: P_RCLR and P_RALL are a combination of other P_ flags */
Bram Moolenaar70b2a562012-01-10 22:26:17 +01009041 int doclear = (flags & P_RCLR) == P_RCLR;
9042 int all = ((flags & P_RALL) == P_RALL || doclear);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009043
9044#ifdef FEAT_WINDOWS
9045 if ((flags & P_RSTAT) || all) /* mark all status lines dirty */
9046 status_redraw_all();
9047#endif
9048
9049 if ((flags & P_RBUF) || (flags & P_RWIN) || all)
9050 changed_window_setting();
9051 if (flags & P_RBUF)
9052 redraw_curbuf_later(NOT_VALID);
Bram Moolenaar70b2a562012-01-10 22:26:17 +01009053 if (doclear)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009054 redraw_all_later(CLEAR);
9055 else if (all)
9056 redraw_all_later(NOT_VALID);
9057}
9058
9059/*
9060 * Find index for option 'arg'.
9061 * Return -1 if not found.
9062 */
9063 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009064findoption(char_u *arg)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009065{
9066 int opt_idx;
9067 char *s, *p;
9068 static short quick_tab[27] = {0, 0}; /* quick access table */
9069 int is_term_opt;
9070
9071 /*
9072 * For first call: Initialize the quick-access table.
9073 * It contains the index for the first option that starts with a certain
9074 * letter. There are 26 letters, plus the first "t_" option.
9075 */
9076 if (quick_tab[1] == 0)
9077 {
9078 p = options[0].fullname;
9079 for (opt_idx = 1; (s = options[opt_idx].fullname) != NULL; opt_idx++)
9080 {
9081 if (s[0] != p[0])
9082 {
9083 if (s[0] == 't' && s[1] == '_')
9084 quick_tab[26] = opt_idx;
9085 else
9086 quick_tab[CharOrdLow(s[0])] = opt_idx;
9087 }
9088 p = s;
9089 }
9090 }
9091
9092 /*
9093 * Check for name starting with an illegal character.
9094 */
9095#ifdef EBCDIC
9096 if (!islower(arg[0]))
9097#else
9098 if (arg[0] < 'a' || arg[0] > 'z')
9099#endif
9100 return -1;
9101
9102 is_term_opt = (arg[0] == 't' && arg[1] == '_');
9103 if (is_term_opt)
9104 opt_idx = quick_tab[26];
9105 else
9106 opt_idx = quick_tab[CharOrdLow(arg[0])];
9107 for ( ; (s = options[opt_idx].fullname) != NULL; opt_idx++)
9108 {
9109 if (STRCMP(arg, s) == 0) /* match full name */
9110 break;
9111 }
9112 if (s == NULL && !is_term_opt)
9113 {
9114 opt_idx = quick_tab[CharOrdLow(arg[0])];
9115 for ( ; options[opt_idx].fullname != NULL; opt_idx++)
9116 {
9117 s = options[opt_idx].shortname;
9118 if (s != NULL && STRCMP(arg, s) == 0) /* match short name */
9119 break;
9120 s = NULL;
9121 }
9122 }
9123 if (s == NULL)
9124 opt_idx = -1;
9125 return opt_idx;
9126}
9127
Bram Moolenaar325b7a22004-07-05 15:58:32 +00009128#if defined(FEAT_EVAL) || defined(FEAT_TCL) || defined(FEAT_MZSCHEME)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009129/*
9130 * Get the value for an option.
9131 *
9132 * Returns:
9133 * Number or Toggle option: 1, *numval gets value.
9134 * String option: 0, *stringval gets allocated string.
9135 * Hidden Number or Toggle option: -1.
9136 * hidden String option: -2.
9137 * unknown option: -3.
9138 */
9139 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009140get_option_value(
9141 char_u *name,
9142 long *numval,
9143 char_u **stringval, /* NULL when only checking existence */
9144 int opt_flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009145{
9146 int opt_idx;
9147 char_u *varp;
9148
9149 opt_idx = findoption(name);
9150 if (opt_idx < 0) /* unknown option */
9151 return -3;
9152
9153 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
9154
9155 if (options[opt_idx].flags & P_STRING)
9156 {
9157 if (varp == NULL) /* hidden option */
9158 return -2;
9159 if (stringval != NULL)
9160 {
9161#ifdef FEAT_CRYPT
9162 /* never return the value of the crypt key */
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00009163 if ((char_u **)varp == &curbuf->b_p_key
9164 && **(char_u **)(varp) != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009165 *stringval = vim_strsave((char_u *)"*****");
9166 else
9167#endif
9168 *stringval = vim_strsave(*(char_u **)(varp));
9169 }
9170 return 0;
9171 }
9172
9173 if (varp == NULL) /* hidden option */
9174 return -1;
9175 if (options[opt_idx].flags & P_NUM)
9176 *numval = *(long *)varp;
9177 else
9178 {
9179 /* Special case: 'modified' is b_changed, but we also want to consider
9180 * it set when 'ff' or 'fenc' changed. */
9181 if ((int *)varp == &curbuf->b_changed)
9182 *numval = curbufIsChanged();
9183 else
Bram Moolenaar2acfbed2016-07-01 23:14:02 +02009184 *numval = (long) *(int *)varp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009185 }
9186 return 1;
9187}
9188#endif
9189
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009190#if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009191/*
9192 * Returns the option attributes and its value. Unlike the above function it
9193 * will return either global value or local value of the option depending on
9194 * what was requested, but it will never return global value if it was
9195 * requested to return local one and vice versa. Neither it will return
9196 * buffer-local value if it was requested to return window-local one.
9197 *
9198 * Pretends that option is absent if it is not present in the requested scope
9199 * (i.e. has no global, window-local or buffer-local value depending on
9200 * opt_type). Uses
9201 *
9202 * Returned flags:
Bram Moolenaar75a8d742014-05-07 15:10:21 +02009203 * 0 hidden or unknown option, also option that does not have requested
9204 * type (see SREQ_* in vim.h)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009205 * see SOPT_* in vim.h for other flags
9206 *
9207 * Possible opt_type values: see SREQ_* in vim.h
9208 */
9209 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009210get_option_value_strict(
9211 char_u *name,
9212 long *numval,
9213 char_u **stringval, /* NULL when only obtaining attributes */
9214 int opt_type,
9215 void *from)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009216{
9217 int opt_idx;
Bram Moolenaar68001862013-05-11 13:45:05 +02009218 char_u *varp = NULL;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009219 struct vimoption *p;
9220 int r = 0;
9221
9222 opt_idx = findoption(name);
9223 if (opt_idx < 0)
9224 return 0;
9225
9226 p = &(options[opt_idx]);
9227
9228 /* Hidden option */
9229 if (p->var == NULL)
9230 return 0;
9231
9232 if (p->flags & P_BOOL)
9233 r |= SOPT_BOOL;
9234 else if (p->flags & P_NUM)
9235 r |= SOPT_NUM;
9236 else if (p->flags & P_STRING)
9237 r |= SOPT_STRING;
9238
9239 if (p->indir == PV_NONE)
9240 {
9241 if (opt_type == SREQ_GLOBAL)
9242 r |= SOPT_GLOBAL;
9243 else
9244 return 0; /* Did not request global-only option */
9245 }
9246 else
9247 {
9248 if (p->indir & PV_BOTH)
9249 r |= SOPT_GLOBAL;
9250 else if (opt_type == SREQ_GLOBAL)
9251 return 0; /* Requested global option */
9252
9253 if (p->indir & PV_WIN)
9254 {
9255 if (opt_type == SREQ_BUF)
9256 return 0; /* Did not request window-local option */
9257 else
9258 r |= SOPT_WIN;
9259 }
9260 else if (p->indir & PV_BUF)
9261 {
9262 if (opt_type == SREQ_WIN)
9263 return 0; /* Did not request buffer-local option */
9264 else
9265 r |= SOPT_BUF;
9266 }
9267 }
9268
9269 if (stringval == NULL)
9270 return r;
9271
9272 if (opt_type == SREQ_GLOBAL)
9273 varp = p->var;
9274 else
9275 {
9276 if (opt_type == SREQ_BUF)
9277 {
9278 /* Special case: 'modified' is b_changed, but we also want to
9279 * consider it set when 'ff' or 'fenc' changed. */
9280 if (p->indir == PV_MOD)
9281 {
9282 *numval = bufIsChanged((buf_T *) from);
9283 varp = NULL;
9284 }
9285#ifdef FEAT_CRYPT
9286 else if (p->indir == PV_KEY)
9287 {
9288 /* never return the value of the crypt key */
9289 *stringval = NULL;
9290 varp = NULL;
9291 }
9292#endif
9293 else
9294 {
9295 aco_save_T aco;
9296 aucmd_prepbuf(&aco, (buf_T *) from);
9297 varp = get_varp(p);
9298 aucmd_restbuf(&aco);
9299 }
9300 }
9301 else if (opt_type == SREQ_WIN)
9302 {
9303 win_T *save_curwin;
9304 save_curwin = curwin;
9305 curwin = (win_T *) from;
9306 curbuf = curwin->w_buffer;
9307 varp = get_varp(p);
9308 curwin = save_curwin;
9309 curbuf = curwin->w_buffer;
9310 }
9311 if (varp == p->var)
9312 return (r | SOPT_UNSET);
9313 }
9314
9315 if (varp != NULL)
9316 {
9317 if (p->flags & P_STRING)
9318 *stringval = vim_strsave(*(char_u **)(varp));
9319 else if (p->flags & P_NUM)
9320 *numval = *(long *) varp;
9321 else
9322 *numval = *(int *)varp;
9323 }
9324
9325 return r;
9326}
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009327
9328/*
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009329 * Iterate over options. First argument is a pointer to a pointer to a
9330 * structure inside options[] array, second is option type like in the above
9331 * function.
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009332 *
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009333 * If first argument points to NULL it is assumed that iteration just started
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009334 * and caller needs the very first value.
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009335 * If first argument points to the end marker function returns NULL and sets
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009336 * first argument to NULL.
9337 *
9338 * Returns full option name for current option on each call.
9339 */
9340 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009341option_iter_next(void **option, int opt_type)
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009342{
9343 struct vimoption *ret = NULL;
9344 do
9345 {
9346 if (*option == NULL)
9347 *option = (void *) options;
9348 else if (((struct vimoption *) (*option))->fullname == NULL)
9349 {
9350 *option = NULL;
9351 return NULL;
9352 }
9353 else
9354 *option = (void *) (((struct vimoption *) (*option)) + 1);
9355
9356 ret = ((struct vimoption *) (*option));
9357
9358 /* Hidden option */
9359 if (ret->var == NULL)
9360 {
9361 ret = NULL;
9362 continue;
9363 }
9364
9365 switch (opt_type)
9366 {
9367 case SREQ_GLOBAL:
9368 if (!(ret->indir == PV_NONE || ret->indir & PV_BOTH))
9369 ret = NULL;
9370 break;
9371 case SREQ_BUF:
9372 if (!(ret->indir & PV_BUF))
9373 ret = NULL;
9374 break;
9375 case SREQ_WIN:
9376 if (!(ret->indir & PV_WIN))
9377 ret = NULL;
9378 break;
9379 default:
Bram Moolenaar95f09602016-11-10 20:01:45 +01009380 internal_error("option_iter_next()");
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009381 return NULL;
9382 }
9383 }
9384 while (ret == NULL);
9385
9386 return (char_u *)ret->fullname;
9387}
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009388#endif
9389
Bram Moolenaar071d4272004-06-13 20:20:40 +00009390/*
9391 * Set the value of option "name".
9392 * Use "string" for string options, use "number" for other options.
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009393 *
9394 * Returns NULL on success or error message on error.
Bram Moolenaar071d4272004-06-13 20:20:40 +00009395 */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009396 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009397set_option_value(
9398 char_u *name,
9399 long number,
9400 char_u *string,
9401 int opt_flags) /* OPT_LOCAL or 0 (both) */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009402{
9403 int opt_idx;
9404 char_u *varp;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00009405 long_u flags;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009406
9407 opt_idx = findoption(name);
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00009408 if (opt_idx < 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009409 EMSG2(_("E355: Unknown option: %s"), name);
9410 else
9411 {
9412 flags = options[opt_idx].flags;
9413#ifdef HAVE_SANDBOX
9414 /* Disallow changing some options in the sandbox */
9415 if (sandbox > 0 && (flags & P_SECURE))
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009416 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00009417 EMSG(_(e_sandbox));
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009418 return NULL;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009419 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009420#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009421 if (flags & P_STRING)
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009422 return set_string_option(opt_idx, string, opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009423 else
9424 {
Bram Moolenaarb3163762008-07-08 15:15:08 +00009425 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009426 if (varp != NULL) /* hidden option is not changed */
9427 {
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009428 if (number == 0 && string != NULL)
9429 {
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009430 int idx;
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009431
9432 /* Either we are given a string or we are setting option
9433 * to zero. */
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009434 for (idx = 0; string[idx] == '0'; ++idx)
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009435 ;
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009436 if (string[idx] != NUL || idx == 0)
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009437 {
9438 /* There's another character after zeros or the string
9439 * is empty. In both cases, we are trying to set a
9440 * num option using a string. */
9441 EMSG3(_("E521: Number required: &%s = '%s'"),
9442 name, string);
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009443 return NULL; /* do nothing as we hit an error */
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009444
9445 }
9446 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009447 if (flags & P_NUM)
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009448 return set_num_option(opt_idx, varp, number,
Bram Moolenaar555b2802005-05-19 21:08:39 +00009449 NULL, 0, opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009450 else
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009451 return set_bool_option(opt_idx, varp, (int)number,
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009452 opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009453 }
9454 }
9455 }
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009456 return NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009457}
9458
9459/*
9460 * Get the terminal code for a terminal option.
9461 * Returns NULL when not found.
9462 */
9463 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009464get_term_code(char_u *tname)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009465{
9466 int opt_idx;
9467 char_u *varp;
9468
9469 if (tname[0] != 't' || tname[1] != '_' ||
9470 tname[2] == NUL || tname[3] == NUL)
9471 return NULL;
9472 if ((opt_idx = findoption(tname)) >= 0)
9473 {
9474 varp = get_varp(&(options[opt_idx]));
9475 if (varp != NULL)
9476 varp = *(char_u **)(varp);
9477 return varp;
9478 }
9479 return find_termcode(tname + 2);
9480}
9481
9482 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009483get_highlight_default(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009484{
9485 int i;
9486
9487 i = findoption((char_u *)"hl");
9488 if (i >= 0)
9489 return options[i].def_val[VI_DEFAULT];
9490 return (char_u *)NULL;
9491}
9492
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00009493#if defined(FEAT_MBYTE) || defined(PROTO)
9494 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009495get_encoding_default(void)
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00009496{
9497 int i;
9498
9499 i = findoption((char_u *)"enc");
9500 if (i >= 0)
9501 return options[i].def_val[VI_DEFAULT];
9502 return (char_u *)NULL;
9503}
9504#endif
9505
Bram Moolenaar071d4272004-06-13 20:20:40 +00009506/*
9507 * Translate a string like "t_xx", "<t_xx>" or "<S-Tab>" to a key number.
9508 */
9509 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009510find_key_option(char_u *arg)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009511{
9512 int key;
9513 int modifiers;
9514
9515 /*
9516 * Don't use get_special_key_code() for t_xx, we don't want it to call
9517 * add_termcap_entry().
9518 */
9519 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
9520 key = TERMCAP2KEY(arg[2], arg[3]);
9521 else
9522 {
9523 --arg; /* put arg at the '<' */
9524 modifiers = 0;
Bram Moolenaar35a4cfa2016-08-14 16:07:48 +02009525 key = find_special_key(&arg, &modifiers, TRUE, TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009526 if (modifiers) /* can't handle modifiers here */
9527 key = 0;
9528 }
9529 return key;
9530}
9531
9532/*
9533 * if 'all' == 0: show changed options
9534 * if 'all' == 1: show all normal options
9535 * if 'all' == 2: show all terminal options
9536 */
9537 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01009538showoptions(
9539 int all,
9540 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009541{
9542 struct vimoption *p;
9543 int col;
9544 int isterm;
9545 char_u *varp;
9546 struct vimoption **items;
9547 int item_count;
9548 int run;
9549 int row, rows;
9550 int cols;
9551 int i;
9552 int len;
9553
9554#define INC 20
9555#define GAP 3
9556
9557 items = (struct vimoption **)alloc((unsigned)(sizeof(struct vimoption *) *
9558 PARAM_COUNT));
9559 if (items == NULL)
9560 return;
9561
9562 /* Highlight title */
9563 if (all == 2)
9564 MSG_PUTS_TITLE(_("\n--- Terminal codes ---"));
9565 else if (opt_flags & OPT_GLOBAL)
9566 MSG_PUTS_TITLE(_("\n--- Global option values ---"));
9567 else if (opt_flags & OPT_LOCAL)
9568 MSG_PUTS_TITLE(_("\n--- Local option values ---"));
9569 else
9570 MSG_PUTS_TITLE(_("\n--- Options ---"));
9571
9572 /*
9573 * do the loop two times:
9574 * 1. display the short items
9575 * 2. display the long items (only strings and numbers)
9576 */
9577 for (run = 1; run <= 2 && !got_int; ++run)
9578 {
9579 /*
9580 * collect the items in items[]
9581 */
9582 item_count = 0;
9583 for (p = &options[0]; p->fullname != NULL; p++)
9584 {
9585 varp = NULL;
9586 isterm = istermoption(p);
9587 if (opt_flags != 0)
9588 {
9589 if (p->indir != PV_NONE && !isterm)
9590 varp = get_varp_scope(p, opt_flags);
9591 }
9592 else
9593 varp = get_varp(p);
9594 if (varp != NULL
9595 && ((all == 2 && isterm)
9596 || (all == 1 && !isterm)
9597 || (all == 0 && !optval_default(p, varp))))
9598 {
9599 if (p->flags & P_BOOL)
9600 len = 1; /* a toggle option fits always */
9601 else
9602 {
9603 option_value2string(p, opt_flags);
9604 len = (int)STRLEN(p->fullname) + vim_strsize(NameBuff) + 1;
9605 }
9606 if ((len <= INC - GAP && run == 1) ||
9607 (len > INC - GAP && run == 2))
9608 items[item_count++] = p;
9609 }
9610 }
9611
9612 /*
9613 * display the items
9614 */
9615 if (run == 1)
9616 {
9617 cols = (Columns + GAP - 3) / INC;
9618 if (cols == 0)
9619 cols = 1;
9620 rows = (item_count + cols - 1) / cols;
9621 }
9622 else /* run == 2 */
9623 rows = item_count;
9624 for (row = 0; row < rows && !got_int; ++row)
9625 {
9626 msg_putchar('\n'); /* go to next line */
9627 if (got_int) /* 'q' typed in more */
9628 break;
9629 col = 0;
9630 for (i = row; i < item_count; i += rows)
9631 {
9632 msg_col = col; /* make columns */
9633 showoneopt(items[i], opt_flags);
9634 col += INC;
9635 }
9636 out_flush();
9637 ui_breakcheck();
9638 }
9639 }
9640 vim_free(items);
9641}
9642
9643/*
9644 * Return TRUE if option "p" has its default value.
9645 */
9646 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009647optval_default(struct vimoption *p, char_u *varp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009648{
9649 int dvi;
9650
9651 if (varp == NULL)
9652 return TRUE; /* hidden option is always at default */
9653 dvi = ((p->flags & P_VI_DEF) || p_cp) ? VI_DEFAULT : VIM_DEFAULT;
9654 if (p->flags & P_NUM)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00009655 return (*(long *)varp == (long)(long_i)p->def_val[dvi]);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009656 if (p->flags & P_BOOL)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00009657 /* the cast to long is required for Manx C, long_i is
9658 * needed for MSVC */
9659 return (*(int *)varp == (int)(long)(long_i)p->def_val[dvi]);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009660 /* P_STRING */
9661 return (STRCMP(*(char_u **)varp, p->def_val[dvi]) == 0);
9662}
9663
9664/*
9665 * showoneopt: show the value of one option
9666 * must not be called with a hidden option!
9667 */
9668 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01009669showoneopt(
9670 struct vimoption *p,
9671 int opt_flags) /* OPT_LOCAL or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009672{
Bram Moolenaar26a60b42005-02-22 08:49:11 +00009673 char_u *varp;
9674 int save_silent = silent_mode;
9675
9676 silent_mode = FALSE;
9677 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009678
9679 varp = get_varp_scope(p, opt_flags);
9680
9681 /* for 'modified' we also need to check if 'ff' or 'fenc' changed. */
9682 if ((p->flags & P_BOOL) && ((int *)varp == &curbuf->b_changed
9683 ? !curbufIsChanged() : !*(int *)varp))
9684 MSG_PUTS("no");
9685 else if ((p->flags & P_BOOL) && *(int *)varp < 0)
9686 MSG_PUTS("--");
9687 else
9688 MSG_PUTS(" ");
9689 MSG_PUTS(p->fullname);
9690 if (!(p->flags & P_BOOL))
9691 {
9692 msg_putchar('=');
9693 /* put value string in NameBuff */
9694 option_value2string(p, opt_flags);
9695 msg_outtrans(NameBuff);
9696 }
Bram Moolenaar26a60b42005-02-22 08:49:11 +00009697
9698 silent_mode = save_silent;
9699 info_message = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009700}
9701
9702/*
9703 * Write modified options as ":set" commands to a file.
9704 *
9705 * There are three values for "opt_flags":
9706 * OPT_GLOBAL: Write global option values and fresh values of
9707 * buffer-local options (used for start of a session
9708 * file).
9709 * OPT_GLOBAL + OPT_LOCAL: Idem, add fresh values of window-local options for
9710 * curwin (used for a vimrc file).
9711 * OPT_LOCAL: Write buffer-local option values for curbuf, fresh
9712 * and local values for window-local options of
9713 * curwin. Local values are also written when at the
9714 * default value, because a modeline or autocommand
9715 * may have set them when doing ":edit file" and the
9716 * user has set them back at the default or fresh
9717 * value.
9718 * When "local_only" is TRUE, don't write fresh
9719 * values, only local values (for ":mkview").
9720 * (fresh value = value used for a new buffer or window for a local option).
9721 *
9722 * Return FAIL on error, OK otherwise.
9723 */
9724 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009725makeset(FILE *fd, int opt_flags, int local_only)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009726{
9727 struct vimoption *p;
9728 char_u *varp; /* currently used value */
9729 char_u *varp_fresh; /* local value */
9730 char_u *varp_local = NULL; /* fresh value */
9731 char *cmd;
9732 int round;
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009733 int pri;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009734
9735 /*
9736 * The options that don't have a default (terminal name, columns, lines)
9737 * are never written. Terminal options are also not written.
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009738 * Do the loop over "options[]" twice: once for options with the
9739 * P_PRI_MKRC flag and once without.
Bram Moolenaar071d4272004-06-13 20:20:40 +00009740 */
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009741 for (pri = 1; pri >= 0; --pri)
9742 {
9743 for (p = &options[0]; !istermoption(p); p++)
9744 if (!(p->flags & P_NO_MKRC)
9745 && !istermoption(p)
9746 && ((pri == 1) == ((p->flags & P_PRI_MKRC) != 0)))
Bram Moolenaar071d4272004-06-13 20:20:40 +00009747 {
9748 /* skip global option when only doing locals */
9749 if (p->indir == PV_NONE && !(opt_flags & OPT_GLOBAL))
9750 continue;
9751
9752 /* Do not store options like 'bufhidden' and 'syntax' in a vimrc
9753 * file, they are always buffer-specific. */
9754 if ((opt_flags & OPT_GLOBAL) && (p->flags & P_NOGLOB))
9755 continue;
9756
9757 /* Global values are only written when not at the default value. */
9758 varp = get_varp_scope(p, opt_flags);
9759 if ((opt_flags & OPT_GLOBAL) && optval_default(p, varp))
9760 continue;
9761
9762 round = 2;
9763 if (p->indir != PV_NONE)
9764 {
9765 if (p->var == VAR_WIN)
9766 {
9767 /* skip window-local option when only doing globals */
9768 if (!(opt_flags & OPT_LOCAL))
9769 continue;
9770 /* When fresh value of window-local option is not at the
9771 * default, need to write it too. */
9772 if (!(opt_flags & OPT_GLOBAL) && !local_only)
9773 {
9774 varp_fresh = get_varp_scope(p, OPT_GLOBAL);
9775 if (!optval_default(p, varp_fresh))
9776 {
9777 round = 1;
9778 varp_local = varp;
9779 varp = varp_fresh;
9780 }
9781 }
9782 }
9783 }
9784
9785 /* Round 1: fresh value for window-local options.
9786 * Round 2: other values */
9787 for ( ; round <= 2; varp = varp_local, ++round)
9788 {
9789 if (round == 1 || (opt_flags & OPT_GLOBAL))
9790 cmd = "set";
9791 else
9792 cmd = "setlocal";
9793
9794 if (p->flags & P_BOOL)
9795 {
9796 if (put_setbool(fd, cmd, p->fullname, *(int *)varp) == FAIL)
9797 return FAIL;
9798 }
9799 else if (p->flags & P_NUM)
9800 {
9801 if (put_setnum(fd, cmd, p->fullname, (long *)varp) == FAIL)
9802 return FAIL;
9803 }
9804 else /* P_STRING */
9805 {
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009806#if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD)
9807 int do_endif = FALSE;
9808
Bram Moolenaar071d4272004-06-13 20:20:40 +00009809 /* Don't set 'syntax' and 'filetype' again if the value is
9810 * already right, avoids reloading the syntax file. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009811 if (
9812# if defined(FEAT_SYN_HL)
9813 p->indir == PV_SYN
9814# if defined(FEAT_AUTOCMD)
9815 ||
9816# endif
9817# endif
9818# if defined(FEAT_AUTOCMD)
Bram Moolenaar15bfa092008-07-24 16:45:38 +00009819 p->indir == PV_FT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009820# endif
Bram Moolenaar15bfa092008-07-24 16:45:38 +00009821 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00009822 {
9823 if (fprintf(fd, "if &%s != '%s'", p->fullname,
9824 *(char_u **)(varp)) < 0
9825 || put_eol(fd) < 0)
9826 return FAIL;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009827 do_endif = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009828 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009829#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009830 if (put_setstring(fd, cmd, p->fullname, (char_u **)varp,
9831 (p->flags & P_EXPAND) != 0) == FAIL)
9832 return FAIL;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009833#if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD)
9834 if (do_endif)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009835 {
9836 if (put_line(fd, "endif") == FAIL)
9837 return FAIL;
9838 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009839#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009840 }
9841 }
9842 }
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009843 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009844 return OK;
9845}
9846
9847#if defined(FEAT_FOLDING) || defined(PROTO)
9848/*
9849 * Generate set commands for the local fold options only. Used when
9850 * 'sessionoptions' or 'viewoptions' contains "folds" but not "options".
9851 */
9852 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009853makefoldset(FILE *fd)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009854{
9855 if (put_setstring(fd, "setlocal", "fdm", &curwin->w_p_fdm, FALSE) == FAIL
9856# ifdef FEAT_EVAL
9857 || put_setstring(fd, "setlocal", "fde", &curwin->w_p_fde, FALSE)
9858 == FAIL
9859# endif
9860 || put_setstring(fd, "setlocal", "fmr", &curwin->w_p_fmr, FALSE)
9861 == FAIL
9862 || put_setstring(fd, "setlocal", "fdi", &curwin->w_p_fdi, FALSE)
9863 == FAIL
9864 || put_setnum(fd, "setlocal", "fdl", &curwin->w_p_fdl) == FAIL
9865 || put_setnum(fd, "setlocal", "fml", &curwin->w_p_fml) == FAIL
9866 || put_setnum(fd, "setlocal", "fdn", &curwin->w_p_fdn) == FAIL
9867 || put_setbool(fd, "setlocal", "fen", curwin->w_p_fen) == FAIL
9868 )
9869 return FAIL;
9870
9871 return OK;
9872}
9873#endif
9874
9875 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009876put_setstring(
9877 FILE *fd,
9878 char *cmd,
9879 char *name,
9880 char_u **valuep,
9881 int expand)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009882{
9883 char_u *s;
Bram Moolenaarf8441472011-04-28 17:24:58 +02009884 char_u *buf;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009885
9886 if (fprintf(fd, "%s %s=", cmd, name) < 0)
9887 return FAIL;
9888 if (*valuep != NULL)
9889 {
9890 /* Output 'pastetoggle' as key names. For other
9891 * options some characters have to be escaped with
9892 * CTRL-V or backslash */
9893 if (valuep == &p_pt)
9894 {
9895 s = *valuep;
9896 while (*s != NUL)
Bram Moolenaar7d96acd2008-06-09 15:07:54 +00009897 if (put_escstr(fd, str2special(&s, FALSE), 2) == FAIL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009898 return FAIL;
9899 }
9900 else if (expand)
9901 {
Bram Moolenaarf8441472011-04-28 17:24:58 +02009902 buf = alloc(MAXPATHL);
9903 if (buf == NULL)
9904 return FAIL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009905 home_replace(NULL, *valuep, buf, MAXPATHL, FALSE);
9906 if (put_escstr(fd, buf, 2) == FAIL)
Bram Moolenaarf8441472011-04-28 17:24:58 +02009907 {
9908 vim_free(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009909 return FAIL;
Bram Moolenaarf8441472011-04-28 17:24:58 +02009910 }
9911 vim_free(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009912 }
9913 else if (put_escstr(fd, *valuep, 2) == FAIL)
9914 return FAIL;
9915 }
9916 if (put_eol(fd) < 0)
9917 return FAIL;
9918 return OK;
9919}
9920
9921 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009922put_setnum(
9923 FILE *fd,
9924 char *cmd,
9925 char *name,
9926 long *valuep)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009927{
9928 long wc;
9929
9930 if (fprintf(fd, "%s %s=", cmd, name) < 0)
9931 return FAIL;
9932 if (wc_use_keyname((char_u *)valuep, &wc))
9933 {
9934 /* print 'wildchar' and 'wildcharm' as a key name */
9935 if (fputs((char *)get_special_key_name((int)wc, 0), fd) < 0)
9936 return FAIL;
9937 }
9938 else if (fprintf(fd, "%ld", *valuep) < 0)
9939 return FAIL;
9940 if (put_eol(fd) < 0)
9941 return FAIL;
9942 return OK;
9943}
9944
9945 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009946put_setbool(
9947 FILE *fd,
9948 char *cmd,
9949 char *name,
9950 int value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009951{
Bram Moolenaar893de922007-10-02 18:40:57 +00009952 if (value < 0) /* global/local option using global value */
9953 return OK;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009954 if (fprintf(fd, "%s %s%s", cmd, value ? "" : "no", name) < 0
9955 || put_eol(fd) < 0)
9956 return FAIL;
9957 return OK;
9958}
9959
9960/*
9961 * Clear all the terminal options.
9962 * If the option has been allocated, free the memory.
9963 * Terminal options are never hidden or indirect.
9964 */
9965 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01009966clear_termoptions(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009967{
Bram Moolenaar071d4272004-06-13 20:20:40 +00009968 /*
9969 * Reset a few things before clearing the old options. This may cause
9970 * outputting a few things that the terminal doesn't understand, but the
9971 * screen will be cleared later, so this is OK.
9972 */
9973#ifdef FEAT_MOUSE_TTY
9974 mch_setmouse(FALSE); /* switch mouse off */
9975#endif
9976#ifdef FEAT_TITLE
9977 mch_restore_title(3); /* restore window titles */
9978#endif
9979#if defined(FEAT_XCLIPBOARD) && defined(FEAT_GUI)
9980 /* When starting the GUI close the display opened for the clipboard.
9981 * After restoring the title, because that will need the display. */
9982 if (gui.starting)
9983 clear_xterm_clip();
9984#endif
Bram Moolenaarcea912a2016-10-12 14:20:24 +02009985 stoptermcap(); /* stop termcap mode */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009986
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00009987 free_termoptions();
9988}
9989
9990 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01009991free_termoptions(void)
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00009992{
9993 struct vimoption *p;
9994
Bram Moolenaar071d4272004-06-13 20:20:40 +00009995 for (p = &options[0]; p->fullname != NULL; p++)
9996 if (istermoption(p))
9997 {
9998 if (p->flags & P_ALLOCED)
9999 free_string_option(*(char_u **)(p->var));
10000 if (p->flags & P_DEF_ALLOCED)
10001 free_string_option(p->def_val[VI_DEFAULT]);
10002 *(char_u **)(p->var) = empty_option;
10003 p->def_val[VI_DEFAULT] = empty_option;
10004 p->flags &= ~(P_ALLOCED|P_DEF_ALLOCED);
10005 }
10006 clear_termcodes();
10007}
10008
10009/*
Bram Moolenaar363cb672009-07-22 12:28:17 +000010010 * Free the string for one term option, if it was allocated.
10011 * Set the string to empty_option and clear allocated flag.
10012 * "var" points to the option value.
10013 */
10014 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010015free_one_termoption(char_u *var)
Bram Moolenaar363cb672009-07-22 12:28:17 +000010016{
10017 struct vimoption *p;
10018
10019 for (p = &options[0]; p->fullname != NULL; p++)
10020 if (p->var == var)
10021 {
10022 if (p->flags & P_ALLOCED)
10023 free_string_option(*(char_u **)(p->var));
10024 *(char_u **)(p->var) = empty_option;
10025 p->flags &= ~P_ALLOCED;
10026 break;
10027 }
10028}
10029
10030/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000010031 * Set the terminal option defaults to the current value.
10032 * Used after setting the terminal name.
10033 */
10034 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010035set_term_defaults(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010036{
10037 struct vimoption *p;
10038
10039 for (p = &options[0]; p->fullname != NULL; p++)
10040 {
10041 if (istermoption(p) && p->def_val[VI_DEFAULT] != *(char_u **)(p->var))
10042 {
10043 if (p->flags & P_DEF_ALLOCED)
10044 {
10045 free_string_option(p->def_val[VI_DEFAULT]);
10046 p->flags &= ~P_DEF_ALLOCED;
10047 }
10048 p->def_val[VI_DEFAULT] = *(char_u **)(p->var);
10049 if (p->flags & P_ALLOCED)
10050 {
10051 p->flags |= P_DEF_ALLOCED;
10052 p->flags &= ~P_ALLOCED; /* don't free the value now */
10053 }
10054 }
10055 }
10056}
10057
10058/*
10059 * return TRUE if 'p' starts with 't_'
10060 */
10061 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010062istermoption(struct vimoption *p)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010063{
10064 return (p->fullname[0] == 't' && p->fullname[1] == '_');
10065}
10066
10067/*
10068 * Compute columns for ruler and shown command. 'sc_col' is also used to
10069 * decide what the maximum length of a message on the status line can be.
10070 * If there is a status line for the last window, 'sc_col' is independent
10071 * of 'ru_col'.
10072 */
10073
10074#define COL_RULER 17 /* columns needed by standard ruler */
10075
10076 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010077comp_col(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010078{
10079#if defined(FEAT_CMDL_INFO) && defined(FEAT_WINDOWS)
Bram Moolenaar459ca562016-11-10 18:16:33 +010010080 int last_has_status = (p_ls == 2 || (p_ls == 1 && !ONE_WINDOW));
Bram Moolenaar071d4272004-06-13 20:20:40 +000010081
10082 sc_col = 0;
10083 ru_col = 0;
10084 if (p_ru)
10085 {
10086#ifdef FEAT_STL_OPT
10087 ru_col = (ru_wid ? ru_wid : COL_RULER) + 1;
10088#else
10089 ru_col = COL_RULER + 1;
10090#endif
10091 /* no last status line, adjust sc_col */
10092 if (!last_has_status)
10093 sc_col = ru_col;
10094 }
10095 if (p_sc)
10096 {
10097 sc_col += SHOWCMD_COLS;
10098 if (!p_ru || last_has_status) /* no need for separating space */
10099 ++sc_col;
10100 }
10101 sc_col = Columns - sc_col;
10102 ru_col = Columns - ru_col;
10103 if (sc_col <= 0) /* screen too narrow, will become a mess */
10104 sc_col = 1;
10105 if (ru_col <= 0)
10106 ru_col = 1;
10107#else
10108 sc_col = Columns;
10109 ru_col = Columns;
10110#endif
10111}
10112
10113/*
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010114 * Unset local option value, similar to ":set opt<".
10115 */
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010116 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010117unset_global_local_option(char_u *name, void *from)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010118{
10119 struct vimoption *p;
10120 int opt_idx;
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010121 buf_T *buf = (buf_T *)from;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010122
10123 opt_idx = findoption(name);
Bram Moolenaarbd8539a2015-08-11 18:53:03 +020010124 if (opt_idx < 0)
10125 return;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010126 p = &(options[opt_idx]);
10127
10128 switch ((int)p->indir)
10129 {
10130 /* global option with local value: use local value if it's been set */
10131 case PV_EP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010132 clear_string_option(&buf->b_p_ep);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010133 break;
10134 case PV_KP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010135 clear_string_option(&buf->b_p_kp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010136 break;
10137 case PV_PATH:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010138 clear_string_option(&buf->b_p_path);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010139 break;
10140 case PV_AR:
10141 buf->b_p_ar = -1;
10142 break;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010143 case PV_BKC:
10144 clear_string_option(&buf->b_p_bkc);
10145 buf->b_bkc_flags = 0;
10146 break;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010147 case PV_TAGS:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010148 clear_string_option(&buf->b_p_tags);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010149 break;
Bram Moolenaar0f6562e2015-11-24 18:48:14 +010010150 case PV_TC:
10151 clear_string_option(&buf->b_p_tc);
10152 buf->b_tc_flags = 0;
10153 break;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010154#ifdef FEAT_FIND_ID
10155 case PV_DEF:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010156 clear_string_option(&buf->b_p_def);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010157 break;
10158 case PV_INC:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010159 clear_string_option(&buf->b_p_inc);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010160 break;
10161#endif
10162#ifdef FEAT_INS_EXPAND
10163 case PV_DICT:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010164 clear_string_option(&buf->b_p_dict);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010165 break;
10166 case PV_TSR:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010167 clear_string_option(&buf->b_p_tsr);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010168 break;
10169#endif
10170#ifdef FEAT_QUICKFIX
10171 case PV_EFM:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010172 clear_string_option(&buf->b_p_efm);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010173 break;
10174 case PV_GP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010175 clear_string_option(&buf->b_p_gp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010176 break;
10177 case PV_MP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010178 clear_string_option(&buf->b_p_mp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010179 break;
10180#endif
10181#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10182 case PV_BEXPR:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010183 clear_string_option(&buf->b_p_bexpr);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010184 break;
10185#endif
10186#if defined(FEAT_CRYPT)
10187 case PV_CM:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010188 clear_string_option(&buf->b_p_cm);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010189 break;
10190#endif
10191#ifdef FEAT_STL_OPT
10192 case PV_STL:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010193 clear_string_option(&((win_T *)from)->w_p_stl);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010194 break;
10195#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010196 case PV_UL:
10197 buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
10198 break;
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010199#ifdef FEAT_LISP
10200 case PV_LW:
10201 clear_string_option(&buf->b_p_lw);
10202 break;
10203#endif
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010204 }
10205}
10206
10207/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000010208 * Get pointer to option variable, depending on local or global scope.
10209 */
10210 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +010010211get_varp_scope(struct vimoption *p, int opt_flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010212{
10213 if ((opt_flags & OPT_GLOBAL) && p->indir != PV_NONE)
10214 {
10215 if (p->var == VAR_WIN)
10216 return (char_u *)GLOBAL_WO(get_varp(p));
10217 return p->var;
10218 }
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010219 if ((opt_flags & OPT_LOCAL) && ((int)p->indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +000010220 {
10221 switch ((int)p->indir)
10222 {
10223#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010224 case PV_EFM: return (char_u *)&(curbuf->b_p_efm);
10225 case PV_GP: return (char_u *)&(curbuf->b_p_gp);
10226 case PV_MP: return (char_u *)&(curbuf->b_p_mp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010227#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010228 case PV_EP: return (char_u *)&(curbuf->b_p_ep);
10229 case PV_KP: return (char_u *)&(curbuf->b_p_kp);
10230 case PV_PATH: return (char_u *)&(curbuf->b_p_path);
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010231 case PV_AR: return (char_u *)&(curbuf->b_p_ar);
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010232 case PV_TAGS: return (char_u *)&(curbuf->b_p_tags);
Bram Moolenaar0f6562e2015-11-24 18:48:14 +010010233 case PV_TC: return (char_u *)&(curbuf->b_p_tc);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010234#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010235 case PV_DEF: return (char_u *)&(curbuf->b_p_def);
10236 case PV_INC: return (char_u *)&(curbuf->b_p_inc);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010237#endif
10238#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010239 case PV_DICT: return (char_u *)&(curbuf->b_p_dict);
10240 case PV_TSR: return (char_u *)&(curbuf->b_p_tsr);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010241#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000010242#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10243 case PV_BEXPR: return (char_u *)&(curbuf->b_p_bexpr);
10244#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020010245#if defined(FEAT_CRYPT)
10246 case PV_CM: return (char_u *)&(curbuf->b_p_cm);
10247#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010248#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010249 case PV_STL: return (char_u *)&(curwin->w_p_stl);
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010250#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010251 case PV_UL: return (char_u *)&(curbuf->b_p_ul);
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010252#ifdef FEAT_LISP
10253 case PV_LW: return (char_u *)&(curbuf->b_p_lw);
10254#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010255 case PV_BKC: return (char_u *)&(curbuf->b_p_bkc);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010256 }
10257 return NULL; /* "cannot happen" */
10258 }
10259 return get_varp(p);
10260}
10261
10262/*
10263 * Get pointer to option variable.
10264 */
10265 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +010010266get_varp(struct vimoption *p)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010267{
10268 /* hidden option, always return NULL */
10269 if (p->var == NULL)
10270 return NULL;
10271
10272 switch ((int)p->indir)
10273 {
10274 case PV_NONE: return p->var;
10275
10276 /* global option with local value: use local value if it's been set */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010277 case PV_EP: return *curbuf->b_p_ep != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010278 ? (char_u *)&curbuf->b_p_ep : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010279 case PV_KP: return *curbuf->b_p_kp != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010280 ? (char_u *)&curbuf->b_p_kp : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010281 case PV_PATH: return *curbuf->b_p_path != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010282 ? (char_u *)&(curbuf->b_p_path) : p->var;
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010283 case PV_AR: return curbuf->b_p_ar >= 0
Bram Moolenaar071d4272004-06-13 20:20:40 +000010284 ? (char_u *)&(curbuf->b_p_ar) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010285 case PV_TAGS: return *curbuf->b_p_tags != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010286 ? (char_u *)&(curbuf->b_p_tags) : p->var;
Bram Moolenaar0f6562e2015-11-24 18:48:14 +010010287 case PV_TC: return *curbuf->b_p_tc != NUL
10288 ? (char_u *)&(curbuf->b_p_tc) : p->var;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010289 case PV_BKC: return *curbuf->b_p_bkc != NUL
10290 ? (char_u *)&(curbuf->b_p_bkc) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010291#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010292 case PV_DEF: return *curbuf->b_p_def != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010293 ? (char_u *)&(curbuf->b_p_def) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010294 case PV_INC: return *curbuf->b_p_inc != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010295 ? (char_u *)&(curbuf->b_p_inc) : p->var;
10296#endif
10297#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010298 case PV_DICT: return *curbuf->b_p_dict != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010299 ? (char_u *)&(curbuf->b_p_dict) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010300 case PV_TSR: return *curbuf->b_p_tsr != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010301 ? (char_u *)&(curbuf->b_p_tsr) : p->var;
10302#endif
10303#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010304 case PV_EFM: return *curbuf->b_p_efm != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010305 ? (char_u *)&(curbuf->b_p_efm) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010306 case PV_GP: return *curbuf->b_p_gp != NUL
10307 ? (char_u *)&(curbuf->b_p_gp) : p->var;
10308 case PV_MP: return *curbuf->b_p_mp != NUL
10309 ? (char_u *)&(curbuf->b_p_mp) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010310#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000010311#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10312 case PV_BEXPR: return *curbuf->b_p_bexpr != NUL
10313 ? (char_u *)&(curbuf->b_p_bexpr) : p->var;
10314#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020010315#if defined(FEAT_CRYPT)
10316 case PV_CM: return *curbuf->b_p_cm != NUL
10317 ? (char_u *)&(curbuf->b_p_cm) : p->var;
10318#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010319#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010320 case PV_STL: return *curwin->w_p_stl != NUL
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010321 ? (char_u *)&(curwin->w_p_stl) : p->var;
10322#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010323 case PV_UL: return curbuf->b_p_ul != NO_LOCAL_UNDOLEVEL
10324 ? (char_u *)&(curbuf->b_p_ul) : p->var;
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010325#ifdef FEAT_LISP
10326 case PV_LW: return *curbuf->b_p_lw != NUL
10327 ? (char_u *)&(curbuf->b_p_lw) : p->var;
10328#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010329
10330#ifdef FEAT_ARABIC
10331 case PV_ARAB: return (char_u *)&(curwin->w_p_arab);
10332#endif
10333 case PV_LIST: return (char_u *)&(curwin->w_p_list);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010334#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +000010335 case PV_SPELL: return (char_u *)&(curwin->w_p_spell);
10336#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010337#ifdef FEAT_SYN_HL
10338 case PV_CUC: return (char_u *)&(curwin->w_p_cuc);
10339 case PV_CUL: return (char_u *)&(curwin->w_p_cul);
Bram Moolenaar1a384422010-07-14 19:53:30 +020010340 case PV_CC: return (char_u *)&(curwin->w_p_cc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010341#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010342#ifdef FEAT_DIFF
10343 case PV_DIFF: return (char_u *)&(curwin->w_p_diff);
10344#endif
10345#ifdef FEAT_FOLDING
10346 case PV_FDC: return (char_u *)&(curwin->w_p_fdc);
10347 case PV_FEN: return (char_u *)&(curwin->w_p_fen);
10348 case PV_FDI: return (char_u *)&(curwin->w_p_fdi);
10349 case PV_FDL: return (char_u *)&(curwin->w_p_fdl);
10350 case PV_FDM: return (char_u *)&(curwin->w_p_fdm);
10351 case PV_FML: return (char_u *)&(curwin->w_p_fml);
10352 case PV_FDN: return (char_u *)&(curwin->w_p_fdn);
10353# ifdef FEAT_EVAL
10354 case PV_FDE: return (char_u *)&(curwin->w_p_fde);
10355 case PV_FDT: return (char_u *)&(curwin->w_p_fdt);
10356# endif
10357 case PV_FMR: return (char_u *)&(curwin->w_p_fmr);
10358#endif
10359 case PV_NU: return (char_u *)&(curwin->w_p_nu);
Bram Moolenaar64486672010-05-16 15:46:46 +020010360 case PV_RNU: return (char_u *)&(curwin->w_p_rnu);
Bram Moolenaar592e0a22004-07-03 16:05:59 +000010361#ifdef FEAT_LINEBREAK
10362 case PV_NUW: return (char_u *)&(curwin->w_p_nuw);
10363#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010364#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +000010365 case PV_WFH: return (char_u *)&(curwin->w_p_wfh);
Bram Moolenaar97b2ad32006-03-18 21:40:56 +000010366 case PV_WFW: return (char_u *)&(curwin->w_p_wfw);
10367#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010368#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
10369 case PV_PVW: return (char_u *)&(curwin->w_p_pvw);
10370#endif
10371#ifdef FEAT_RIGHTLEFT
10372 case PV_RL: return (char_u *)&(curwin->w_p_rl);
10373 case PV_RLC: return (char_u *)&(curwin->w_p_rlc);
10374#endif
10375 case PV_SCROLL: return (char_u *)&(curwin->w_p_scr);
10376 case PV_WRAP: return (char_u *)&(curwin->w_p_wrap);
10377#ifdef FEAT_LINEBREAK
10378 case PV_LBR: return (char_u *)&(curwin->w_p_lbr);
Bram Moolenaar597a4222014-06-25 14:39:50 +020010379 case PV_BRI: return (char_u *)&(curwin->w_p_bri);
10380 case PV_BRIOPT: return (char_u *)&(curwin->w_p_briopt);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010381#endif
10382#ifdef FEAT_SCROLLBIND
10383 case PV_SCBIND: return (char_u *)&(curwin->w_p_scb);
10384#endif
Bram Moolenaar860cae12010-06-05 23:22:07 +020010385#ifdef FEAT_CURSORBIND
10386 case PV_CRBIND: return (char_u *)&(curwin->w_p_crb);
10387#endif
10388#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010389 case PV_COCU: return (char_u *)&(curwin->w_p_cocu);
10390 case PV_COLE: return (char_u *)&(curwin->w_p_cole);
Bram Moolenaar860cae12010-06-05 23:22:07 +020010391#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010392
10393 case PV_AI: return (char_u *)&(curbuf->b_p_ai);
10394 case PV_BIN: return (char_u *)&(curbuf->b_p_bin);
10395#ifdef FEAT_MBYTE
10396 case PV_BOMB: return (char_u *)&(curbuf->b_p_bomb);
10397#endif
10398#if defined(FEAT_QUICKFIX)
10399 case PV_BH: return (char_u *)&(curbuf->b_p_bh);
10400 case PV_BT: return (char_u *)&(curbuf->b_p_bt);
10401#endif
10402 case PV_BL: return (char_u *)&(curbuf->b_p_bl);
10403 case PV_CI: return (char_u *)&(curbuf->b_p_ci);
10404#ifdef FEAT_CINDENT
10405 case PV_CIN: return (char_u *)&(curbuf->b_p_cin);
10406 case PV_CINK: return (char_u *)&(curbuf->b_p_cink);
10407 case PV_CINO: return (char_u *)&(curbuf->b_p_cino);
10408#endif
10409#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
10410 case PV_CINW: return (char_u *)&(curbuf->b_p_cinw);
10411#endif
10412#ifdef FEAT_COMMENTS
10413 case PV_COM: return (char_u *)&(curbuf->b_p_com);
10414#endif
10415#ifdef FEAT_FOLDING
10416 case PV_CMS: return (char_u *)&(curbuf->b_p_cms);
10417#endif
10418#ifdef FEAT_INS_EXPAND
10419 case PV_CPT: return (char_u *)&(curbuf->b_p_cpt);
10420#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010421#ifdef FEAT_COMPL_FUNC
10422 case PV_CFU: return (char_u *)&(curbuf->b_p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +000010423 case PV_OFU: return (char_u *)&(curbuf->b_p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010424#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010425 case PV_EOL: return (char_u *)&(curbuf->b_p_eol);
Bram Moolenaar34d72d42015-07-17 14:18:08 +020010426 case PV_FIXEOL: return (char_u *)&(curbuf->b_p_fixeol);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010427 case PV_ET: return (char_u *)&(curbuf->b_p_et);
10428#ifdef FEAT_MBYTE
10429 case PV_FENC: return (char_u *)&(curbuf->b_p_fenc);
10430#endif
10431 case PV_FF: return (char_u *)&(curbuf->b_p_ff);
10432#ifdef FEAT_AUTOCMD
10433 case PV_FT: return (char_u *)&(curbuf->b_p_ft);
10434#endif
10435 case PV_FO: return (char_u *)&(curbuf->b_p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +000010436 case PV_FLP: return (char_u *)&(curbuf->b_p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010437 case PV_IMI: return (char_u *)&(curbuf->b_p_iminsert);
10438 case PV_IMS: return (char_u *)&(curbuf->b_p_imsearch);
10439 case PV_INF: return (char_u *)&(curbuf->b_p_inf);
10440 case PV_ISK: return (char_u *)&(curbuf->b_p_isk);
10441#ifdef FEAT_FIND_ID
10442# ifdef FEAT_EVAL
10443 case PV_INEX: return (char_u *)&(curbuf->b_p_inex);
10444# endif
10445#endif
10446#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
10447 case PV_INDE: return (char_u *)&(curbuf->b_p_inde);
10448 case PV_INDK: return (char_u *)&(curbuf->b_p_indk);
10449#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010450#ifdef FEAT_EVAL
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +000010451 case PV_FEX: return (char_u *)&(curbuf->b_p_fex);
10452#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010453#ifdef FEAT_CRYPT
10454 case PV_KEY: return (char_u *)&(curbuf->b_p_key);
10455#endif
10456#ifdef FEAT_LISP
10457 case PV_LISP: return (char_u *)&(curbuf->b_p_lisp);
10458#endif
10459 case PV_ML: return (char_u *)&(curbuf->b_p_ml);
10460 case PV_MPS: return (char_u *)&(curbuf->b_p_mps);
10461 case PV_MA: return (char_u *)&(curbuf->b_p_ma);
10462 case PV_MOD: return (char_u *)&(curbuf->b_changed);
10463 case PV_NF: return (char_u *)&(curbuf->b_p_nf);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010464 case PV_PI: return (char_u *)&(curbuf->b_p_pi);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010465#ifdef FEAT_TEXTOBJ
10466 case PV_QE: return (char_u *)&(curbuf->b_p_qe);
10467#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010468 case PV_RO: return (char_u *)&(curbuf->b_p_ro);
10469#ifdef FEAT_SMARTINDENT
10470 case PV_SI: return (char_u *)&(curbuf->b_p_si);
10471#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010472 case PV_SN: return (char_u *)&(curbuf->b_p_sn);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010473 case PV_STS: return (char_u *)&(curbuf->b_p_sts);
10474#ifdef FEAT_SEARCHPATH
10475 case PV_SUA: return (char_u *)&(curbuf->b_p_sua);
10476#endif
10477 case PV_SWF: return (char_u *)&(curbuf->b_p_swf);
10478#ifdef FEAT_SYN_HL
Bram Moolenaar3b56eb32005-07-11 22:40:32 +000010479 case PV_SMC: return (char_u *)&(curbuf->b_p_smc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010480 case PV_SYN: return (char_u *)&(curbuf->b_p_syn);
10481#endif
10482#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +020010483 case PV_SPC: return (char_u *)&(curwin->w_s->b_p_spc);
10484 case PV_SPF: return (char_u *)&(curwin->w_s->b_p_spf);
10485 case PV_SPL: return (char_u *)&(curwin->w_s->b_p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010486#endif
10487 case PV_SW: return (char_u *)&(curbuf->b_p_sw);
10488 case PV_TS: return (char_u *)&(curbuf->b_p_ts);
10489 case PV_TW: return (char_u *)&(curbuf->b_p_tw);
10490 case PV_TX: return (char_u *)&(curbuf->b_p_tx);
Bram Moolenaar55debbe2010-05-23 23:34:36 +020010491#ifdef FEAT_PERSISTENT_UNDO
10492 case PV_UDF: return (char_u *)&(curbuf->b_p_udf);
10493#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010494 case PV_WM: return (char_u *)&(curbuf->b_p_wm);
10495#ifdef FEAT_KEYMAP
10496 case PV_KMAP: return (char_u *)&(curbuf->b_p_keymap);
10497#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020010498#ifdef FEAT_SIGNS
10499 case PV_SCL: return (char_u *)&(curwin->w_p_scl);
10500#endif
Bram Moolenaar95f09602016-11-10 20:01:45 +010010501 default: IEMSG(_("E356: get_varp ERROR"));
Bram Moolenaar071d4272004-06-13 20:20:40 +000010502 }
10503 /* always return a valid pointer to avoid a crash! */
10504 return (char_u *)&(curbuf->b_p_wm);
10505}
10506
10507/*
10508 * Get the value of 'equalprg', either the buffer-local one or the global one.
10509 */
10510 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +010010511get_equalprg(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010512{
10513 if (*curbuf->b_p_ep == NUL)
10514 return p_ep;
10515 return curbuf->b_p_ep;
10516}
10517
10518#if defined(FEAT_WINDOWS) || defined(PROTO)
10519/*
10520 * Copy options from one window to another.
10521 * Used when splitting a window.
10522 */
10523 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010524win_copy_options(win_T *wp_from, win_T *wp_to)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010525{
10526 copy_winopt(&wp_from->w_onebuf_opt, &wp_to->w_onebuf_opt);
10527 copy_winopt(&wp_from->w_allbuf_opt, &wp_to->w_allbuf_opt);
10528# ifdef FEAT_RIGHTLEFT
10529# ifdef FEAT_FKMAP
10530 /* Is this right? */
10531 wp_to->w_farsi = wp_from->w_farsi;
10532# endif
10533# endif
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020010534#if defined(FEAT_LINEBREAK)
10535 briopt_check(wp_to);
10536#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010537}
10538#endif
10539
10540/*
10541 * Copy the options from one winopt_T to another.
10542 * Doesn't free the old option values in "to", use clear_winopt() for that.
10543 * The 'scroll' option is not copied, because it depends on the window height.
10544 * The 'previewwindow' option is reset, there can be only one preview window.
10545 */
10546 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010547copy_winopt(winopt_T *from, winopt_T *to)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010548{
10549#ifdef FEAT_ARABIC
10550 to->wo_arab = from->wo_arab;
10551#endif
10552 to->wo_list = from->wo_list;
10553 to->wo_nu = from->wo_nu;
Bram Moolenaar64486672010-05-16 15:46:46 +020010554 to->wo_rnu = from->wo_rnu;
Bram Moolenaar592e0a22004-07-03 16:05:59 +000010555#ifdef FEAT_LINEBREAK
10556 to->wo_nuw = from->wo_nuw;
10557#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010558#ifdef FEAT_RIGHTLEFT
10559 to->wo_rl = from->wo_rl;
10560 to->wo_rlc = vim_strsave(from->wo_rlc);
10561#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010562#ifdef FEAT_STL_OPT
10563 to->wo_stl = vim_strsave(from->wo_stl);
10564#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010565 to->wo_wrap = from->wo_wrap;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010566#ifdef FEAT_DIFF
10567 to->wo_wrap_save = from->wo_wrap_save;
10568#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010569#ifdef FEAT_LINEBREAK
10570 to->wo_lbr = from->wo_lbr;
Bram Moolenaar597a4222014-06-25 14:39:50 +020010571 to->wo_bri = from->wo_bri;
10572 to->wo_briopt = vim_strsave(from->wo_briopt);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010573#endif
10574#ifdef FEAT_SCROLLBIND
10575 to->wo_scb = from->wo_scb;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010576 to->wo_scb_save = from->wo_scb_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010577#endif
Bram Moolenaar4161dcc2010-12-02 15:33:21 +010010578#ifdef FEAT_CURSORBIND
10579 to->wo_crb = from->wo_crb;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010580 to->wo_crb_save = from->wo_crb_save;
Bram Moolenaar4161dcc2010-12-02 15:33:21 +010010581#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010582#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +000010583 to->wo_spell = from->wo_spell;
10584#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010585#ifdef FEAT_SYN_HL
10586 to->wo_cuc = from->wo_cuc;
10587 to->wo_cul = from->wo_cul;
Bram Moolenaar1a384422010-07-14 19:53:30 +020010588 to->wo_cc = vim_strsave(from->wo_cc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010589#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010590#ifdef FEAT_DIFF
10591 to->wo_diff = from->wo_diff;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010592 to->wo_diff_saved = from->wo_diff_saved;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010593#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010594#ifdef FEAT_CONCEAL
10595 to->wo_cocu = vim_strsave(from->wo_cocu);
Bram Moolenaard497a302010-07-23 22:27:03 +020010596 to->wo_cole = from->wo_cole;
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010597#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010598#ifdef FEAT_FOLDING
10599 to->wo_fdc = from->wo_fdc;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010600 to->wo_fdc_save = from->wo_fdc_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010601 to->wo_fen = from->wo_fen;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010602 to->wo_fen_save = from->wo_fen_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010603 to->wo_fdi = vim_strsave(from->wo_fdi);
10604 to->wo_fml = from->wo_fml;
10605 to->wo_fdl = from->wo_fdl;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010606 to->wo_fdl_save = from->wo_fdl_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010607 to->wo_fdm = vim_strsave(from->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010608 to->wo_fdm_save = from->wo_diff_saved
10609 ? vim_strsave(from->wo_fdm_save) : empty_option;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010610 to->wo_fdn = from->wo_fdn;
10611# ifdef FEAT_EVAL
10612 to->wo_fde = vim_strsave(from->wo_fde);
10613 to->wo_fdt = vim_strsave(from->wo_fdt);
10614# endif
10615 to->wo_fmr = vim_strsave(from->wo_fmr);
10616#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020010617#ifdef FEAT_SIGNS
10618 to->wo_scl = vim_strsave(from->wo_scl);
10619#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010620 check_winopt(to); /* don't want NULL pointers */
10621}
10622
10623/*
10624 * Check string options in a window for a NULL value.
10625 */
10626 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010627check_win_options(win_T *win)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010628{
10629 check_winopt(&win->w_onebuf_opt);
10630 check_winopt(&win->w_allbuf_opt);
10631}
10632
10633/*
10634 * Check for NULL pointers in a winopt_T and replace them with empty_option.
10635 */
Bram Moolenaar8dc907d2014-06-25 14:44:10 +020010636 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010637check_winopt(winopt_T *wop UNUSED)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010638{
10639#ifdef FEAT_FOLDING
10640 check_string_option(&wop->wo_fdi);
10641 check_string_option(&wop->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010642 check_string_option(&wop->wo_fdm_save);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010643# ifdef FEAT_EVAL
10644 check_string_option(&wop->wo_fde);
10645 check_string_option(&wop->wo_fdt);
10646# endif
10647 check_string_option(&wop->wo_fmr);
10648#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020010649#ifdef FEAT_SIGNS
10650 check_string_option(&wop->wo_scl);
10651#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010652#ifdef FEAT_RIGHTLEFT
10653 check_string_option(&wop->wo_rlc);
10654#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010655#ifdef FEAT_STL_OPT
10656 check_string_option(&wop->wo_stl);
10657#endif
Bram Moolenaar1a384422010-07-14 19:53:30 +020010658#ifdef FEAT_SYN_HL
10659 check_string_option(&wop->wo_cc);
10660#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010661#ifdef FEAT_CONCEAL
10662 check_string_option(&wop->wo_cocu);
10663#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +020010664#ifdef FEAT_LINEBREAK
10665 check_string_option(&wop->wo_briopt);
10666#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010667}
10668
10669/*
10670 * Free the allocated memory inside a winopt_T.
10671 */
Bram Moolenaar071d4272004-06-13 20:20:40 +000010672 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010673clear_winopt(winopt_T *wop UNUSED)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010674{
10675#ifdef FEAT_FOLDING
10676 clear_string_option(&wop->wo_fdi);
10677 clear_string_option(&wop->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010678 clear_string_option(&wop->wo_fdm_save);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010679# ifdef FEAT_EVAL
10680 clear_string_option(&wop->wo_fde);
10681 clear_string_option(&wop->wo_fdt);
10682# endif
10683 clear_string_option(&wop->wo_fmr);
10684#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020010685#ifdef FEAT_SIGNS
10686 clear_string_option(&wop->wo_scl);
10687#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +020010688#ifdef FEAT_LINEBREAK
10689 clear_string_option(&wop->wo_briopt);
10690#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010691#ifdef FEAT_RIGHTLEFT
10692 clear_string_option(&wop->wo_rlc);
10693#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010694#ifdef FEAT_STL_OPT
10695 clear_string_option(&wop->wo_stl);
10696#endif
Bram Moolenaar1a384422010-07-14 19:53:30 +020010697#ifdef FEAT_SYN_HL
10698 clear_string_option(&wop->wo_cc);
10699#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010700#ifdef FEAT_CONCEAL
10701 clear_string_option(&wop->wo_cocu);
10702#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010703}
10704
10705/*
10706 * Copy global option values to local options for one buffer.
10707 * Used when creating a new buffer and sometimes when entering a buffer.
10708 * flags:
10709 * BCO_ENTER We will enter the buf buffer.
10710 * BCO_ALWAYS Always copy the options, but only set b_p_initialized when
10711 * appropriate.
10712 * BCO_NOHELP Don't copy the values to a help buffer.
10713 */
10714 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010715buf_copy_options(buf_T *buf, int flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010716{
10717 int should_copy = TRUE;
10718 char_u *save_p_isk = NULL; /* init for GCC */
10719 int dont_do_help;
10720 int did_isk = FALSE;
10721
10722 /*
Bram Moolenaar071d4272004-06-13 20:20:40 +000010723 * Skip this when the option defaults have not been set yet. Happens when
10724 * main() allocates the first buffer.
10725 */
10726 if (p_cpo != NULL)
10727 {
10728 /*
10729 * Always copy when entering and 'cpo' contains 'S'.
10730 * Don't copy when already initialized.
10731 * Don't copy when 'cpo' contains 's' and not entering.
10732 * 'S' BCO_ENTER initialized 's' should_copy
10733 * yes yes X X TRUE
10734 * yes no yes X FALSE
10735 * no X yes X FALSE
10736 * X no no yes FALSE
10737 * X no no no TRUE
10738 * no yes no X TRUE
10739 */
10740 if ((vim_strchr(p_cpo, CPO_BUFOPTGLOB) == NULL || !(flags & BCO_ENTER))
10741 && (buf->b_p_initialized
10742 || (!(flags & BCO_ENTER)
10743 && vim_strchr(p_cpo, CPO_BUFOPT) != NULL)))
10744 should_copy = FALSE;
10745
10746 if (should_copy || (flags & BCO_ALWAYS))
10747 {
10748 /* Don't copy the options specific to a help buffer when
10749 * BCO_NOHELP is given or the options were initialized already
10750 * (jumping back to a help file with CTRL-T or CTRL-O) */
10751 dont_do_help = ((flags & BCO_NOHELP) && buf->b_help)
10752 || buf->b_p_initialized;
10753 if (dont_do_help) /* don't free b_p_isk */
10754 {
10755 save_p_isk = buf->b_p_isk;
10756 buf->b_p_isk = NULL;
10757 }
10758 /*
10759 * Always free the allocated strings.
10760 * If not already initialized, set 'readonly' and copy 'fileformat'.
10761 */
10762 if (!buf->b_p_initialized)
10763 {
10764 free_buf_options(buf, TRUE);
10765 buf->b_p_ro = FALSE; /* don't copy readonly */
10766 buf->b_p_tx = p_tx;
10767#ifdef FEAT_MBYTE
10768 buf->b_p_fenc = vim_strsave(p_fenc);
10769#endif
Bram Moolenaare8ef3a02016-10-12 17:45:29 +020010770 switch (*p_ffs)
10771 {
10772 case 'm':
10773 buf->b_p_ff = vim_strsave((char_u *)FF_MAC); break;
10774 case 'd':
10775 buf->b_p_ff = vim_strsave((char_u *)FF_DOS); break;
10776 case 'u':
10777 buf->b_p_ff = vim_strsave((char_u *)FF_UNIX); break;
10778 default:
10779 buf->b_p_ff = vim_strsave(p_ff);
10780 }
10781 if (buf->b_p_ff != NULL)
10782 buf->b_start_ffc = *buf->b_p_ff;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010783#if defined(FEAT_QUICKFIX)
10784 buf->b_p_bh = empty_option;
10785 buf->b_p_bt = empty_option;
10786#endif
10787 }
10788 else
10789 free_buf_options(buf, FALSE);
10790
10791 buf->b_p_ai = p_ai;
10792 buf->b_p_ai_nopaste = p_ai_nopaste;
10793 buf->b_p_sw = p_sw;
10794 buf->b_p_tw = p_tw;
10795 buf->b_p_tw_nopaste = p_tw_nopaste;
10796 buf->b_p_tw_nobin = p_tw_nobin;
10797 buf->b_p_wm = p_wm;
10798 buf->b_p_wm_nopaste = p_wm_nopaste;
10799 buf->b_p_wm_nobin = p_wm_nobin;
10800 buf->b_p_bin = p_bin;
Bram Moolenaare8bb2552005-07-08 22:26:47 +000010801#ifdef FEAT_MBYTE
10802 buf->b_p_bomb = p_bomb;
10803#endif
Bram Moolenaarb388be02015-07-22 22:19:38 +020010804 buf->b_p_fixeol = p_fixeol;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010805 buf->b_p_et = p_et;
10806 buf->b_p_et_nobin = p_et_nobin;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020010807 buf->b_p_et_nopaste = p_et_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010808 buf->b_p_ml = p_ml;
10809 buf->b_p_ml_nobin = p_ml_nobin;
10810 buf->b_p_inf = p_inf;
10811 buf->b_p_swf = p_swf;
10812#ifdef FEAT_INS_EXPAND
10813 buf->b_p_cpt = vim_strsave(p_cpt);
10814#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010815#ifdef FEAT_COMPL_FUNC
10816 buf->b_p_cfu = vim_strsave(p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +000010817 buf->b_p_ofu = vim_strsave(p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010818#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010819 buf->b_p_sts = p_sts;
10820 buf->b_p_sts_nopaste = p_sts_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010821 buf->b_p_sn = p_sn;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010822#ifdef FEAT_COMMENTS
10823 buf->b_p_com = vim_strsave(p_com);
10824#endif
10825#ifdef FEAT_FOLDING
10826 buf->b_p_cms = vim_strsave(p_cms);
10827#endif
10828 buf->b_p_fo = vim_strsave(p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +000010829 buf->b_p_flp = vim_strsave(p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010830 buf->b_p_nf = vim_strsave(p_nf);
10831 buf->b_p_mps = vim_strsave(p_mps);
10832#ifdef FEAT_SMARTINDENT
10833 buf->b_p_si = p_si;
10834#endif
10835 buf->b_p_ci = p_ci;
10836#ifdef FEAT_CINDENT
10837 buf->b_p_cin = p_cin;
10838 buf->b_p_cink = vim_strsave(p_cink);
10839 buf->b_p_cino = vim_strsave(p_cino);
10840#endif
10841#ifdef FEAT_AUTOCMD
10842 /* Don't copy 'filetype', it must be detected */
10843 buf->b_p_ft = empty_option;
10844#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010845 buf->b_p_pi = p_pi;
10846#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
10847 buf->b_p_cinw = vim_strsave(p_cinw);
10848#endif
10849#ifdef FEAT_LISP
10850 buf->b_p_lisp = p_lisp;
10851#endif
10852#ifdef FEAT_SYN_HL
10853 /* Don't copy 'syntax', it must be set */
10854 buf->b_p_syn = empty_option;
Bram Moolenaar3b56eb32005-07-11 22:40:32 +000010855 buf->b_p_smc = p_smc;
Bram Moolenaarb8060fe2016-01-19 22:29:28 +010010856 buf->b_s.b_syn_isk = empty_option;
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010857#endif
10858#ifdef FEAT_SPELL
Bram Moolenaard5784f92010-10-13 14:05:35 +020010859 buf->b_s.b_p_spc = vim_strsave(p_spc);
Bram Moolenaar860cae12010-06-05 23:22:07 +020010860 (void)compile_cap_prog(&buf->b_s);
10861 buf->b_s.b_p_spf = vim_strsave(p_spf);
10862 buf->b_s.b_p_spl = vim_strsave(p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010863#endif
10864#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
10865 buf->b_p_inde = vim_strsave(p_inde);
10866 buf->b_p_indk = vim_strsave(p_indk);
10867#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +000010868#if defined(FEAT_EVAL)
10869 buf->b_p_fex = vim_strsave(p_fex);
10870#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010871#ifdef FEAT_CRYPT
10872 buf->b_p_key = vim_strsave(p_key);
10873#endif
10874#ifdef FEAT_SEARCHPATH
10875 buf->b_p_sua = vim_strsave(p_sua);
10876#endif
10877#ifdef FEAT_KEYMAP
10878 buf->b_p_keymap = vim_strsave(p_keymap);
10879 buf->b_kmap_state |= KEYMAP_INIT;
10880#endif
10881 /* This isn't really an option, but copying the langmap and IME
10882 * state from the current buffer is better than resetting it. */
10883 buf->b_p_iminsert = p_iminsert;
10884 buf->b_p_imsearch = p_imsearch;
10885
10886 /* options that are normally global but also have a local value
10887 * are not copied, start using the global value */
10888 buf->b_p_ar = -1;
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010889 buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010890 buf->b_p_bkc = empty_option;
10891 buf->b_bkc_flags = 0;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010892#ifdef FEAT_QUICKFIX
10893 buf->b_p_gp = empty_option;
10894 buf->b_p_mp = empty_option;
10895 buf->b_p_efm = empty_option;
10896#endif
10897 buf->b_p_ep = empty_option;
10898 buf->b_p_kp = empty_option;
10899 buf->b_p_path = empty_option;
10900 buf->b_p_tags = empty_option;
Bram Moolenaar0f6562e2015-11-24 18:48:14 +010010901 buf->b_p_tc = empty_option;
10902 buf->b_tc_flags = 0;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010903#ifdef FEAT_FIND_ID
10904 buf->b_p_def = empty_option;
10905 buf->b_p_inc = empty_option;
10906# ifdef FEAT_EVAL
10907 buf->b_p_inex = vim_strsave(p_inex);
10908# endif
10909#endif
10910#ifdef FEAT_INS_EXPAND
10911 buf->b_p_dict = empty_option;
10912 buf->b_p_tsr = empty_option;
10913#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010914#ifdef FEAT_TEXTOBJ
10915 buf->b_p_qe = vim_strsave(p_qe);
10916#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000010917#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10918 buf->b_p_bexpr = empty_option;
10919#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020010920#if defined(FEAT_CRYPT)
10921 buf->b_p_cm = empty_option;
10922#endif
Bram Moolenaar55debbe2010-05-23 23:34:36 +020010923#ifdef FEAT_PERSISTENT_UNDO
10924 buf->b_p_udf = p_udf;
10925#endif
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010926#ifdef FEAT_LISP
10927 buf->b_p_lw = empty_option;
10928#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010929
10930 /*
10931 * Don't copy the options set by ex_help(), use the saved values,
10932 * when going from a help buffer to a non-help buffer.
10933 * Don't touch these at all when BCO_NOHELP is used and going from
10934 * or to a help buffer.
10935 */
10936 if (dont_do_help)
10937 buf->b_p_isk = save_p_isk;
10938 else
10939 {
10940 buf->b_p_isk = vim_strsave(p_isk);
10941 did_isk = TRUE;
10942 buf->b_p_ts = p_ts;
10943 buf->b_help = FALSE;
10944#ifdef FEAT_QUICKFIX
10945 if (buf->b_p_bt[0] == 'h')
10946 clear_string_option(&buf->b_p_bt);
10947#endif
10948 buf->b_p_ma = p_ma;
10949 }
10950 }
10951
10952 /*
10953 * When the options should be copied (ignoring BCO_ALWAYS), set the
10954 * flag that indicates that the options have been initialized.
10955 */
10956 if (should_copy)
10957 buf->b_p_initialized = TRUE;
10958 }
10959
10960 check_buf_options(buf); /* make sure we don't have NULLs */
10961 if (did_isk)
10962 (void)buf_init_chartab(buf, FALSE);
10963}
10964
10965/*
10966 * Reset the 'modifiable' option and its default value.
10967 */
10968 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010969reset_modifiable(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010970{
10971 int opt_idx;
10972
10973 curbuf->b_p_ma = FALSE;
10974 p_ma = FALSE;
10975 opt_idx = findoption((char_u *)"ma");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000010976 if (opt_idx >= 0)
10977 options[opt_idx].def_val[VI_DEFAULT] = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010978}
10979
10980/*
10981 * Set the global value for 'iminsert' to the local value.
10982 */
10983 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010984set_iminsert_global(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010985{
10986 p_iminsert = curbuf->b_p_iminsert;
10987}
10988
10989/*
10990 * Set the global value for 'imsearch' to the local value.
10991 */
10992 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010993set_imsearch_global(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010994{
10995 p_imsearch = curbuf->b_p_imsearch;
10996}
10997
10998#if defined(FEAT_CMDL_COMPL) || defined(PROTO)
10999static int expand_option_idx = -1;
11000static char_u expand_option_name[5] = {'t', '_', NUL, NUL, NUL};
11001static int expand_option_flags = 0;
11002
11003 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011004set_context_in_set_cmd(
11005 expand_T *xp,
11006 char_u *arg,
11007 int opt_flags) /* OPT_GLOBAL and/or OPT_LOCAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011008{
11009 int nextchar;
11010 long_u flags = 0; /* init for GCC */
11011 int opt_idx = 0; /* init for GCC */
11012 char_u *p;
11013 char_u *s;
11014 int is_term_option = FALSE;
11015 int key;
11016
11017 expand_option_flags = opt_flags;
11018
11019 xp->xp_context = EXPAND_SETTINGS;
11020 if (*arg == NUL)
11021 {
11022 xp->xp_pattern = arg;
11023 return;
11024 }
11025 p = arg + STRLEN(arg) - 1;
11026 if (*p == ' ' && *(p - 1) != '\\')
11027 {
11028 xp->xp_pattern = p + 1;
11029 return;
11030 }
11031 while (p > arg)
11032 {
11033 s = p;
11034 /* count number of backslashes before ' ' or ',' */
11035 if (*p == ' ' || *p == ',')
11036 {
11037 while (s > arg && *(s - 1) == '\\')
11038 --s;
11039 }
11040 /* break at a space with an even number of backslashes */
11041 if (*p == ' ' && ((p - s) & 1) == 0)
11042 {
11043 ++p;
11044 break;
11045 }
11046 --p;
11047 }
Bram Moolenaar2a7b9ee2009-06-16 15:50:33 +000011048 if (STRNCMP(p, "no", 2) == 0 && STRNCMP(p, "novice", 6) != 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011049 {
11050 xp->xp_context = EXPAND_BOOL_SETTINGS;
11051 p += 2;
11052 }
11053 if (STRNCMP(p, "inv", 3) == 0)
11054 {
11055 xp->xp_context = EXPAND_BOOL_SETTINGS;
11056 p += 3;
11057 }
11058 xp->xp_pattern = arg = p;
11059 if (*arg == '<')
11060 {
11061 while (*p != '>')
11062 if (*p++ == NUL) /* expand terminal option name */
11063 return;
11064 key = get_special_key_code(arg + 1);
11065 if (key == 0) /* unknown name */
11066 {
11067 xp->xp_context = EXPAND_NOTHING;
11068 return;
11069 }
11070 nextchar = *++p;
11071 is_term_option = TRUE;
11072 expand_option_name[2] = KEY2TERMCAP0(key);
11073 expand_option_name[3] = KEY2TERMCAP1(key);
11074 }
11075 else
11076 {
11077 if (p[0] == 't' && p[1] == '_')
11078 {
11079 p += 2;
11080 if (*p != NUL)
11081 ++p;
11082 if (*p == NUL)
11083 return; /* expand option name */
11084 nextchar = *++p;
11085 is_term_option = TRUE;
11086 expand_option_name[2] = p[-2];
11087 expand_option_name[3] = p[-1];
11088 }
11089 else
11090 {
11091 /* Allow * wildcard */
11092 while (ASCII_ISALNUM(*p) || *p == '_' || *p == '*')
11093 p++;
11094 if (*p == NUL)
11095 return;
11096 nextchar = *p;
11097 *p = NUL;
11098 opt_idx = findoption(arg);
11099 *p = nextchar;
11100 if (opt_idx == -1 || options[opt_idx].var == NULL)
11101 {
11102 xp->xp_context = EXPAND_NOTHING;
11103 return;
11104 }
11105 flags = options[opt_idx].flags;
11106 if (flags & P_BOOL)
11107 {
11108 xp->xp_context = EXPAND_NOTHING;
11109 return;
11110 }
11111 }
11112 }
11113 /* handle "-=" and "+=" */
11114 if ((nextchar == '-' || nextchar == '+' || nextchar == '^') && p[1] == '=')
11115 {
11116 ++p;
11117 nextchar = '=';
11118 }
11119 if ((nextchar != '=' && nextchar != ':')
11120 || xp->xp_context == EXPAND_BOOL_SETTINGS)
11121 {
11122 xp->xp_context = EXPAND_UNSUCCESSFUL;
11123 return;
11124 }
11125 if (xp->xp_context != EXPAND_BOOL_SETTINGS && p[1] == NUL)
11126 {
11127 xp->xp_context = EXPAND_OLD_SETTING;
11128 if (is_term_option)
11129 expand_option_idx = -1;
11130 else
11131 expand_option_idx = opt_idx;
11132 xp->xp_pattern = p + 1;
11133 return;
11134 }
11135 xp->xp_context = EXPAND_NOTHING;
11136 if (is_term_option || (flags & P_NUM))
11137 return;
11138
11139 xp->xp_pattern = p + 1;
11140
11141 if (flags & P_EXPAND)
11142 {
11143 p = options[opt_idx].var;
11144 if (p == (char_u *)&p_bdir
11145 || p == (char_u *)&p_dir
11146 || p == (char_u *)&p_path
Bram Moolenaarf6fee0e2016-02-21 23:02:49 +010011147 || p == (char_u *)&p_pp
Bram Moolenaar071d4272004-06-13 20:20:40 +000011148 || p == (char_u *)&p_rtp
11149#ifdef FEAT_SEARCHPATH
11150 || p == (char_u *)&p_cdpath
11151#endif
11152#ifdef FEAT_SESSION
11153 || p == (char_u *)&p_vdir
11154#endif
11155 )
11156 {
11157 xp->xp_context = EXPAND_DIRECTORIES;
11158 if (p == (char_u *)&p_path
11159#ifdef FEAT_SEARCHPATH
11160 || p == (char_u *)&p_cdpath
11161#endif
11162 )
11163 xp->xp_backslash = XP_BS_THREE;
11164 else
11165 xp->xp_backslash = XP_BS_ONE;
11166 }
11167 else
11168 {
11169 xp->xp_context = EXPAND_FILES;
11170 /* for 'tags' need three backslashes for a space */
11171 if (p == (char_u *)&p_tags)
11172 xp->xp_backslash = XP_BS_THREE;
11173 else
11174 xp->xp_backslash = XP_BS_ONE;
11175 }
11176 }
11177
11178 /* For an option that is a list of file names, find the start of the
11179 * last file name. */
11180 for (p = arg + STRLEN(arg) - 1; p > xp->xp_pattern; --p)
11181 {
11182 /* count number of backslashes before ' ' or ',' */
11183 if (*p == ' ' || *p == ',')
11184 {
11185 s = p;
11186 while (s > xp->xp_pattern && *(s - 1) == '\\')
11187 --s;
11188 if ((*p == ' ' && (xp->xp_backslash == XP_BS_THREE && (p - s) < 3))
11189 || (*p == ',' && (flags & P_COMMA) && ((p - s) & 1) == 0))
11190 {
11191 xp->xp_pattern = p + 1;
11192 break;
11193 }
11194 }
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +000011195
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000011196#ifdef FEAT_SPELL
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +000011197 /* for 'spellsuggest' start at "file:" */
11198 if (options[opt_idx].var == (char_u *)&p_sps
11199 && STRNCMP(p, "file:", 5) == 0)
11200 {
11201 xp->xp_pattern = p + 5;
11202 break;
11203 }
11204#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011205 }
11206
11207 return;
11208}
11209
11210 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011211ExpandSettings(
11212 expand_T *xp,
11213 regmatch_T *regmatch,
11214 int *num_file,
11215 char_u ***file)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011216{
11217 int num_normal = 0; /* Nr of matching non-term-code settings */
11218 int num_term = 0; /* Nr of matching terminal code settings */
11219 int opt_idx;
11220 int match;
11221 int count = 0;
11222 char_u *str;
11223 int loop;
11224 int is_term_opt;
11225 char_u name_buf[MAX_KEY_NAME_LEN];
11226 static char *(names[]) = {"all", "termcap"};
11227 int ic = regmatch->rm_ic; /* remember the ignore-case flag */
11228
11229 /* do this loop twice:
11230 * loop == 0: count the number of matching options
11231 * loop == 1: copy the matching options into allocated memory
11232 */
11233 for (loop = 0; loop <= 1; ++loop)
11234 {
11235 regmatch->rm_ic = ic;
11236 if (xp->xp_context != EXPAND_BOOL_SETTINGS)
11237 {
Bram Moolenaar2c4278f2009-05-17 11:33:22 +000011238 for (match = 0; match < (int)(sizeof(names) / sizeof(char *));
11239 ++match)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011240 if (vim_regexec(regmatch, (char_u *)names[match], (colnr_T)0))
11241 {
11242 if (loop == 0)
11243 num_normal++;
11244 else
11245 (*file)[count++] = vim_strsave((char_u *)names[match]);
11246 }
11247 }
11248 for (opt_idx = 0; (str = (char_u *)options[opt_idx].fullname) != NULL;
11249 opt_idx++)
11250 {
11251 if (options[opt_idx].var == NULL)
11252 continue;
11253 if (xp->xp_context == EXPAND_BOOL_SETTINGS
11254 && !(options[opt_idx].flags & P_BOOL))
11255 continue;
11256 is_term_opt = istermoption(&options[opt_idx]);
11257 if (is_term_opt && num_normal > 0)
11258 continue;
11259 match = FALSE;
11260 if (vim_regexec(regmatch, str, (colnr_T)0)
11261 || (options[opt_idx].shortname != NULL
11262 && vim_regexec(regmatch,
11263 (char_u *)options[opt_idx].shortname, (colnr_T)0)))
11264 match = TRUE;
11265 else if (is_term_opt)
11266 {
11267 name_buf[0] = '<';
11268 name_buf[1] = 't';
11269 name_buf[2] = '_';
11270 name_buf[3] = str[2];
11271 name_buf[4] = str[3];
11272 name_buf[5] = '>';
11273 name_buf[6] = NUL;
11274 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11275 {
11276 match = TRUE;
11277 str = name_buf;
11278 }
11279 }
11280 if (match)
11281 {
11282 if (loop == 0)
11283 {
11284 if (is_term_opt)
11285 num_term++;
11286 else
11287 num_normal++;
11288 }
11289 else
11290 (*file)[count++] = vim_strsave(str);
11291 }
11292 }
11293 /*
11294 * Check terminal key codes, these are not in the option table
11295 */
11296 if (xp->xp_context != EXPAND_BOOL_SETTINGS && num_normal == 0)
11297 {
11298 for (opt_idx = 0; (str = get_termcode(opt_idx)) != NULL; opt_idx++)
11299 {
11300 if (!isprint(str[0]) || !isprint(str[1]))
11301 continue;
11302
11303 name_buf[0] = 't';
11304 name_buf[1] = '_';
11305 name_buf[2] = str[0];
11306 name_buf[3] = str[1];
11307 name_buf[4] = NUL;
11308
11309 match = FALSE;
11310 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11311 match = TRUE;
11312 else
11313 {
11314 name_buf[0] = '<';
11315 name_buf[1] = 't';
11316 name_buf[2] = '_';
11317 name_buf[3] = str[0];
11318 name_buf[4] = str[1];
11319 name_buf[5] = '>';
11320 name_buf[6] = NUL;
11321
11322 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11323 match = TRUE;
11324 }
11325 if (match)
11326 {
11327 if (loop == 0)
11328 num_term++;
11329 else
11330 (*file)[count++] = vim_strsave(name_buf);
11331 }
11332 }
11333
11334 /*
11335 * Check special key names.
11336 */
11337 regmatch->rm_ic = TRUE; /* ignore case here */
11338 for (opt_idx = 0; (str = get_key_name(opt_idx)) != NULL; opt_idx++)
11339 {
11340 name_buf[0] = '<';
11341 STRCPY(name_buf + 1, str);
11342 STRCAT(name_buf, ">");
11343
11344 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11345 {
11346 if (loop == 0)
11347 num_term++;
11348 else
11349 (*file)[count++] = vim_strsave(name_buf);
11350 }
11351 }
11352 }
11353 if (loop == 0)
11354 {
11355 if (num_normal > 0)
11356 *num_file = num_normal;
11357 else if (num_term > 0)
11358 *num_file = num_term;
11359 else
11360 return OK;
11361 *file = (char_u **)alloc((unsigned)(*num_file * sizeof(char_u *)));
11362 if (*file == NULL)
11363 {
11364 *file = (char_u **)"";
11365 return FAIL;
11366 }
11367 }
11368 }
11369 return OK;
11370}
11371
11372 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011373ExpandOldSetting(int *num_file, char_u ***file)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011374{
11375 char_u *var = NULL; /* init for GCC */
11376 char_u *buf;
11377
11378 *num_file = 0;
11379 *file = (char_u **)alloc((unsigned)sizeof(char_u *));
11380 if (*file == NULL)
11381 return FAIL;
11382
11383 /*
11384 * For a terminal key code expand_option_idx is < 0.
11385 */
11386 if (expand_option_idx < 0)
11387 {
11388 var = find_termcode(expand_option_name + 2);
11389 if (var == NULL)
11390 expand_option_idx = findoption(expand_option_name);
11391 }
11392
11393 if (expand_option_idx >= 0)
11394 {
11395 /* put string of option value in NameBuff */
11396 option_value2string(&options[expand_option_idx], expand_option_flags);
11397 var = NameBuff;
11398 }
11399 else if (var == NULL)
11400 var = (char_u *)"";
11401
11402 /* A backslash is required before some characters. This is the reverse of
11403 * what happens in do_set(). */
11404 buf = vim_strsave_escaped(var, escape_chars);
11405
11406 if (buf == NULL)
11407 {
11408 vim_free(*file);
11409 *file = NULL;
11410 return FAIL;
11411 }
11412
11413#ifdef BACKSLASH_IN_FILENAME
11414 /* For MS-Windows et al. we don't double backslashes at the start and
11415 * before a file name character. */
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011416 for (var = buf; *var != NUL; mb_ptr_adv(var))
Bram Moolenaar071d4272004-06-13 20:20:40 +000011417 if (var[0] == '\\' && var[1] == '\\'
11418 && expand_option_idx >= 0
11419 && (options[expand_option_idx].flags & P_EXPAND)
11420 && vim_isfilec(var[2])
11421 && (var[2] != '\\' || (var == buf && var[4] != '\\')))
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +000011422 STRMOVE(var, var + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011423#endif
11424
11425 *file[0] = buf;
11426 *num_file = 1;
11427 return OK;
11428}
11429#endif
11430
11431/*
11432 * Get the value for the numeric or string option *opp in a nice format into
11433 * NameBuff[]. Must not be called with a hidden option!
11434 */
11435 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011436option_value2string(
11437 struct vimoption *opp,
11438 int opt_flags) /* OPT_GLOBAL and/or OPT_LOCAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011439{
11440 char_u *varp;
11441
11442 varp = get_varp_scope(opp, opt_flags);
11443
11444 if (opp->flags & P_NUM)
11445 {
11446 long wc = 0;
11447
11448 if (wc_use_keyname(varp, &wc))
11449 STRCPY(NameBuff, get_special_key_name((int)wc, 0));
11450 else if (wc != 0)
11451 STRCPY(NameBuff, transchar((int)wc));
11452 else
11453 sprintf((char *)NameBuff, "%ld", *(long *)varp);
11454 }
11455 else /* P_STRING */
11456 {
11457 varp = *(char_u **)(varp);
11458 if (varp == NULL) /* just in case */
11459 NameBuff[0] = NUL;
11460#ifdef FEAT_CRYPT
11461 /* don't show the actual value of 'key', only that it's set */
Bram Moolenaareb3593b2006-04-22 22:33:57 +000011462 else if (opp->var == (char_u *)&p_key && *varp)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011463 STRCPY(NameBuff, "*****");
11464#endif
11465 else if (opp->flags & P_EXPAND)
11466 home_replace(NULL, varp, NameBuff, MAXPATHL, FALSE);
11467 /* Translate 'pastetoggle' into special key names */
11468 else if ((char_u **)opp->var == &p_pt)
11469 str2specialbuf(p_pt, NameBuff, MAXPATHL);
11470 else
Bram Moolenaarce0842a2005-07-18 21:58:11 +000011471 vim_strncpy(NameBuff, varp, MAXPATHL - 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011472 }
11473}
11474
11475/*
11476 * Return TRUE if "varp" points to 'wildchar' or 'wildcharm' and it can be
11477 * printed as a keyname.
11478 * "*wcp" is set to the value of the option if it's 'wildchar' or 'wildcharm'.
11479 */
11480 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011481wc_use_keyname(char_u *varp, long *wcp)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011482{
11483 if (((long *)varp == &p_wc) || ((long *)varp == &p_wcm))
11484 {
11485 *wcp = *(long *)varp;
11486 if (IS_SPECIAL(*wcp) || find_special_key_in_table((int)*wcp) >= 0)
11487 return TRUE;
11488 }
11489 return FALSE;
11490}
11491
Bram Moolenaar01615492015-02-03 13:00:38 +010011492#if defined(FEAT_LANGMAP) || defined(PROTO)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011493/*
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011494 * Any character has an equivalent 'langmap' character. This is used for
11495 * keyboards that have a special language mode that sends characters above
11496 * 128 (although other characters can be translated too). The "to" field is a
11497 * Vim command character. This avoids having to switch the keyboard back to
11498 * ASCII mode when leaving Insert mode.
11499 *
11500 * langmap_mapchar[] maps any of 256 chars to an ASCII char used for Vim
11501 * commands.
11502 * When FEAT_MBYTE is defined langmap_mapga.ga_data is a sorted table of
11503 * langmap_entry_T. This does the same as langmap_mapchar[] for characters >=
11504 * 256.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011505 */
Bram Moolenaar01615492015-02-03 13:00:38 +010011506# if defined(FEAT_MBYTE) || defined(PROTO)
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011507/*
11508 * With multi-byte support use growarray for 'langmap' chars >= 256
11509 */
11510typedef struct
11511{
11512 int from;
11513 int to;
11514} langmap_entry_T;
11515
11516static garray_T langmap_mapga;
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +010011517static void langmap_set_entry(int from, int to);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011518
11519/*
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011520 * Search for an entry in "langmap_mapga" for "from". If found set the "to"
11521 * field. If not found insert a new entry at the appropriate location.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011522 */
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011523 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011524langmap_set_entry(int from, int to)
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011525{
11526 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
Bram Moolenaarcc448b32010-07-14 16:52:17 +020011527 int a = 0;
11528 int b = langmap_mapga.ga_len;
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011529
11530 /* Do a binary search for an existing entry. */
11531 while (a != b)
11532 {
11533 int i = (a + b) / 2;
11534 int d = entries[i].from - from;
11535
11536 if (d == 0)
11537 {
11538 entries[i].to = to;
11539 return;
11540 }
11541 if (d < 0)
11542 a = i + 1;
11543 else
11544 b = i;
11545 }
11546
11547 if (ga_grow(&langmap_mapga, 1) != OK)
11548 return; /* out of memory */
11549
11550 /* insert new entry at position "a" */
11551 entries = (langmap_entry_T *)(langmap_mapga.ga_data) + a;
11552 mch_memmove(entries + 1, entries,
11553 (langmap_mapga.ga_len - a) * sizeof(langmap_entry_T));
11554 ++langmap_mapga.ga_len;
11555 entries[0].from = from;
11556 entries[0].to = to;
11557}
11558
11559/*
11560 * Apply 'langmap' to multi-byte character "c" and return the result.
11561 */
11562 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011563langmap_adjust_mb(int c)
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011564{
11565 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
11566 int a = 0;
11567 int b = langmap_mapga.ga_len;
11568
11569 while (a != b)
11570 {
11571 int i = (a + b) / 2;
11572 int d = entries[i].from - c;
11573
11574 if (d == 0)
11575 return entries[i].to; /* found matching entry */
11576 if (d < 0)
11577 a = i + 1;
11578 else
11579 b = i;
11580 }
11581 return c; /* no entry found, return "c" unmodified */
11582}
11583# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011584
11585 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011586langmap_init(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011587{
11588 int i;
11589
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011590 for (i = 0; i < 256; i++)
11591 langmap_mapchar[i] = i; /* we init with a one-to-one map */
11592# ifdef FEAT_MBYTE
11593 ga_init2(&langmap_mapga, sizeof(langmap_entry_T), 8);
11594# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011595}
11596
11597/*
11598 * Called when langmap option is set; the language map can be
11599 * changed at any time!
11600 */
11601 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011602langmap_set(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011603{
11604 char_u *p;
11605 char_u *p2;
11606 int from, to;
11607
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011608#ifdef FEAT_MBYTE
11609 ga_clear(&langmap_mapga); /* clear the previous map first */
11610#endif
11611 langmap_init(); /* back to one-to-one map */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011612
11613 for (p = p_langmap; p[0] != NUL; )
11614 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011615 for (p2 = p; p2[0] != NUL && p2[0] != ',' && p2[0] != ';';
11616 mb_ptr_adv(p2))
Bram Moolenaar071d4272004-06-13 20:20:40 +000011617 {
11618 if (p2[0] == '\\' && p2[1] != NUL)
11619 ++p2;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011620 }
11621 if (p2[0] == ';')
11622 ++p2; /* abcd;ABCD form, p2 points to A */
11623 else
11624 p2 = NULL; /* aAbBcCdD form, p2 is NULL */
11625 while (p[0])
11626 {
Bram Moolenaar6af05062010-05-14 17:32:58 +020011627 if (p[0] == ',')
11628 {
11629 ++p;
11630 break;
11631 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011632 if (p[0] == '\\' && p[1] != NUL)
11633 ++p;
11634#ifdef FEAT_MBYTE
11635 from = (*mb_ptr2char)(p);
11636#else
11637 from = p[0];
11638#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011639 to = NUL;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011640 if (p2 == NULL)
11641 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011642 mb_ptr_adv(p);
Bram Moolenaar6af05062010-05-14 17:32:58 +020011643 if (p[0] != ',')
11644 {
11645 if (p[0] == '\\')
11646 ++p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011647#ifdef FEAT_MBYTE
Bram Moolenaar6af05062010-05-14 17:32:58 +020011648 to = (*mb_ptr2char)(p);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011649#else
Bram Moolenaar6af05062010-05-14 17:32:58 +020011650 to = p[0];
Bram Moolenaar071d4272004-06-13 20:20:40 +000011651#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011652 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011653 }
11654 else
11655 {
Bram Moolenaar6af05062010-05-14 17:32:58 +020011656 if (p2[0] != ',')
11657 {
11658 if (p2[0] == '\\')
11659 ++p2;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011660#ifdef FEAT_MBYTE
Bram Moolenaar6af05062010-05-14 17:32:58 +020011661 to = (*mb_ptr2char)(p2);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011662#else
Bram Moolenaar6af05062010-05-14 17:32:58 +020011663 to = p2[0];
Bram Moolenaar071d4272004-06-13 20:20:40 +000011664#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011665 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011666 }
11667 if (to == NUL)
11668 {
11669 EMSG2(_("E357: 'langmap': Matching character missing for %s"),
11670 transchar(from));
11671 return;
11672 }
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011673
11674#ifdef FEAT_MBYTE
11675 if (from >= 256)
11676 langmap_set_entry(from, to);
11677 else
11678#endif
11679 langmap_mapchar[from & 255] = to;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011680
11681 /* Advance to next pair */
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011682 mb_ptr_adv(p);
Bram Moolenaar6af05062010-05-14 17:32:58 +020011683 if (p2 != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011684 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011685 mb_ptr_adv(p2);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011686 if (*p == ';')
11687 {
11688 p = p2;
11689 if (p[0] != NUL)
11690 {
11691 if (p[0] != ',')
11692 {
11693 EMSG2(_("E358: 'langmap': Extra characters after semicolon: %s"), p);
11694 return;
11695 }
11696 ++p;
11697 }
11698 break;
11699 }
11700 }
11701 }
11702 }
11703}
11704#endif
11705
11706/*
11707 * Return TRUE if format option 'x' is in effect.
11708 * Take care of no formatting when 'paste' is set.
11709 */
11710 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011711has_format_option(int x)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011712{
11713 if (p_paste)
11714 return FALSE;
11715 return (vim_strchr(curbuf->b_p_fo, x) != NULL);
11716}
11717
11718/*
11719 * Return TRUE if "x" is present in 'shortmess' option, or
11720 * 'shortmess' contains 'a' and "x" is present in SHM_A.
11721 */
11722 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011723shortmess(int x)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011724{
Bram Moolenaar7f29f7a2012-02-29 13:51:37 +010011725 return p_shm != NULL &&
11726 ( vim_strchr(p_shm, x) != NULL
Bram Moolenaar071d4272004-06-13 20:20:40 +000011727 || (vim_strchr(p_shm, 'a') != NULL
11728 && vim_strchr((char_u *)SHM_A, x) != NULL));
11729}
11730
11731/*
11732 * paste_option_changed() - Called after p_paste was set or reset.
11733 */
11734 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011735paste_option_changed(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011736{
11737 static int old_p_paste = FALSE;
11738 static int save_sm = 0;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020011739 static int save_sta = 0;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011740#ifdef FEAT_CMDL_INFO
11741 static int save_ru = 0;
11742#endif
11743#ifdef FEAT_RIGHTLEFT
11744 static int save_ri = 0;
11745 static int save_hkmap = 0;
11746#endif
11747 buf_T *buf;
11748
11749 if (p_paste)
11750 {
11751 /*
11752 * Paste switched from off to on.
11753 * Save the current values, so they can be restored later.
11754 */
11755 if (!old_p_paste)
11756 {
11757 /* save options for each buffer */
Bram Moolenaar29323592016-07-24 22:04:11 +020011758 FOR_ALL_BUFFERS(buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011759 {
11760 buf->b_p_tw_nopaste = buf->b_p_tw;
11761 buf->b_p_wm_nopaste = buf->b_p_wm;
11762 buf->b_p_sts_nopaste = buf->b_p_sts;
11763 buf->b_p_ai_nopaste = buf->b_p_ai;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020011764 buf->b_p_et_nopaste = buf->b_p_et;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011765 }
11766
11767 /* save global options */
11768 save_sm = p_sm;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020011769 save_sta = p_sta;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011770#ifdef FEAT_CMDL_INFO
11771 save_ru = p_ru;
11772#endif
11773#ifdef FEAT_RIGHTLEFT
11774 save_ri = p_ri;
11775 save_hkmap = p_hkmap;
11776#endif
11777 /* save global values for local buffer options */
Bram Moolenaar54f018c2015-09-15 17:30:40 +020011778 p_ai_nopaste = p_ai;
11779 p_et_nopaste = p_et;
11780 p_sts_nopaste = p_sts;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011781 p_tw_nopaste = p_tw;
11782 p_wm_nopaste = p_wm;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011783 }
11784
11785 /*
11786 * Always set the option values, also when 'paste' is set when it is
11787 * already on.
11788 */
11789 /* set options for each buffer */
Bram Moolenaar29323592016-07-24 22:04:11 +020011790 FOR_ALL_BUFFERS(buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011791 {
11792 buf->b_p_tw = 0; /* textwidth is 0 */
11793 buf->b_p_wm = 0; /* wrapmargin is 0 */
11794 buf->b_p_sts = 0; /* softtabstop is 0 */
11795 buf->b_p_ai = 0; /* no auto-indent */
Bram Moolenaar54f018c2015-09-15 17:30:40 +020011796 buf->b_p_et = 0; /* no expandtab */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011797 }
11798
11799 /* set global options */
11800 p_sm = 0; /* no showmatch */
Bram Moolenaar54f018c2015-09-15 17:30:40 +020011801 p_sta = 0; /* no smarttab */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011802#ifdef FEAT_CMDL_INFO
11803# ifdef FEAT_WINDOWS
11804 if (p_ru)
11805 status_redraw_all(); /* redraw to remove the ruler */
11806# endif
11807 p_ru = 0; /* no ruler */
11808#endif
11809#ifdef FEAT_RIGHTLEFT
11810 p_ri = 0; /* no reverse insert */
11811 p_hkmap = 0; /* no Hebrew keyboard */
11812#endif
11813 /* set global values for local buffer options */
11814 p_tw = 0;
11815 p_wm = 0;
11816 p_sts = 0;
11817 p_ai = 0;
11818 }
11819
11820 /*
11821 * Paste switched from on to off: Restore saved values.
11822 */
11823 else if (old_p_paste)
11824 {
11825 /* restore options for each buffer */
Bram Moolenaar29323592016-07-24 22:04:11 +020011826 FOR_ALL_BUFFERS(buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011827 {
11828 buf->b_p_tw = buf->b_p_tw_nopaste;
11829 buf->b_p_wm = buf->b_p_wm_nopaste;
11830 buf->b_p_sts = buf->b_p_sts_nopaste;
11831 buf->b_p_ai = buf->b_p_ai_nopaste;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020011832 buf->b_p_et = buf->b_p_et_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011833 }
11834
11835 /* restore global options */
11836 p_sm = save_sm;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020011837 p_sta = save_sta;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011838#ifdef FEAT_CMDL_INFO
11839# ifdef FEAT_WINDOWS
11840 if (p_ru != save_ru)
11841 status_redraw_all(); /* redraw to draw the ruler */
11842# endif
11843 p_ru = save_ru;
11844#endif
11845#ifdef FEAT_RIGHTLEFT
11846 p_ri = save_ri;
11847 p_hkmap = save_hkmap;
11848#endif
11849 /* set global values for local buffer options */
Bram Moolenaar54f018c2015-09-15 17:30:40 +020011850 p_ai = p_ai_nopaste;
11851 p_et = p_et_nopaste;
11852 p_sts = p_sts_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011853 p_tw = p_tw_nopaste;
11854 p_wm = p_wm_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011855 }
11856
11857 old_p_paste = p_paste;
11858}
11859
11860/*
11861 * vimrc_found() - Called when a ".vimrc" or "VIMINIT" has been found.
11862 *
11863 * Reset 'compatible' and set the values for options that didn't get set yet
11864 * to the Vim defaults.
11865 * Don't do this if the 'compatible' option has been set or reset before.
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011866 * When "fname" is not NULL, use it to set $"envname" when it wasn't set yet.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011867 */
11868 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011869vimrc_found(char_u *fname, char_u *envname)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011870{
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011871 int opt_idx;
Bram Moolenaar4c3f5362006-04-11 21:38:50 +000011872 int dofree = FALSE;
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011873 char_u *p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011874
11875 if (!option_was_set((char_u *)"cp"))
11876 {
11877 p_cp = FALSE;
11878 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
11879 if (!(options[opt_idx].flags & (P_WAS_SET|P_VI_DEF)))
11880 set_option_default(opt_idx, OPT_FREE, FALSE);
11881 didset_options();
Bram Moolenaare68c25c2015-08-25 15:39:55 +020011882 didset_options2();
Bram Moolenaar071d4272004-06-13 20:20:40 +000011883 }
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011884
11885 if (fname != NULL)
11886 {
11887 p = vim_getenv(envname, &dofree);
11888 if (p == NULL)
11889 {
11890 /* Set $MYVIMRC to the first vimrc file found. */
11891 p = FullName_save(fname, FALSE);
11892 if (p != NULL)
11893 {
11894 vim_setenv(envname, p);
11895 vim_free(p);
11896 }
11897 }
11898 else if (dofree)
11899 vim_free(p);
11900 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011901}
11902
11903/*
11904 * Set 'compatible' on or off. Called for "-C" and "-N" command line arg.
11905 */
11906 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011907change_compatible(int on)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011908{
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000011909 int opt_idx;
11910
Bram Moolenaar071d4272004-06-13 20:20:40 +000011911 if (p_cp != on)
11912 {
11913 p_cp = on;
11914 compatible_set();
11915 }
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000011916 opt_idx = findoption((char_u *)"cp");
11917 if (opt_idx >= 0)
11918 options[opt_idx].flags |= P_WAS_SET;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011919}
11920
11921/*
11922 * Return TRUE when option "name" has been set.
Bram Moolenaar1a4a75c2013-07-28 16:03:06 +020011923 * Only works correctly for global options.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011924 */
11925 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011926option_was_set(char_u *name)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011927{
11928 int idx;
11929
11930 idx = findoption(name);
11931 if (idx < 0) /* unknown option */
11932 return FALSE;
11933 if (options[idx].flags & P_WAS_SET)
11934 return TRUE;
11935 return FALSE;
11936}
11937
11938/*
Bram Moolenaar15d55de2012-12-05 14:43:02 +010011939 * Reset the flag indicating option "name" was set.
11940 */
11941 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011942reset_option_was_set(char_u *name)
Bram Moolenaar15d55de2012-12-05 14:43:02 +010011943{
11944 int idx = findoption(name);
11945
11946 if (idx >= 0)
11947 options[idx].flags &= ~P_WAS_SET;
11948}
11949
11950/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000011951 * compatible_set() - Called when 'compatible' has been set or unset.
11952 *
11953 * When 'compatible' set: Set all relevant options (those that have the P_VIM)
11954 * flag) to a Vi compatible value.
11955 * When 'compatible' is unset: Set all options that have a different default
11956 * for Vim (without the P_VI_DEF flag) to that default.
11957 */
11958 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011959compatible_set(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011960{
11961 int opt_idx;
11962
11963 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
11964 if ( ((options[opt_idx].flags & P_VIM) && p_cp)
11965 || (!(options[opt_idx].flags & P_VI_DEF) && !p_cp))
11966 set_option_default(opt_idx, OPT_FREE, p_cp);
11967 didset_options();
Bram Moolenaare68c25c2015-08-25 15:39:55 +020011968 didset_options2();
Bram Moolenaar071d4272004-06-13 20:20:40 +000011969}
11970
11971#ifdef FEAT_LINEBREAK
11972
11973# if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
11974 /* Borland C++ screws up loop optimisation here (negri) */
Bram Moolenaar8f999f12005-01-25 22:12:55 +000011975 #pragma option -O-l
Bram Moolenaar071d4272004-06-13 20:20:40 +000011976# endif
11977
11978/*
11979 * fill_breakat_flags() -- called when 'breakat' changes value.
11980 */
11981 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011982fill_breakat_flags(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011983{
Bram Moolenaarac6e65f2005-08-29 22:25:38 +000011984 char_u *p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011985 int i;
11986
11987 for (i = 0; i < 256; i++)
11988 breakat_flags[i] = FALSE;
11989
11990 if (p_breakat != NULL)
Bram Moolenaarac6e65f2005-08-29 22:25:38 +000011991 for (p = p_breakat; *p; p++)
11992 breakat_flags[*p] = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011993}
11994
11995# if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
Bram Moolenaar8f999f12005-01-25 22:12:55 +000011996 #pragma option -O.l
Bram Moolenaar071d4272004-06-13 20:20:40 +000011997# endif
11998
11999#endif
12000
12001/*
12002 * Check an option that can be a range of string values.
12003 *
12004 * Return OK for correct value, FAIL otherwise.
12005 * Empty is always OK.
12006 */
12007 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012008check_opt_strings(
12009 char_u *val,
12010 char **values,
12011 int list) /* when TRUE: accept a list of values */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012012{
12013 return opt_strings_flags(val, values, NULL, list);
12014}
12015
12016/*
12017 * Handle an option that can be a range of string values.
12018 * Set a flag in "*flagp" for each string present.
12019 *
12020 * Return OK for correct value, FAIL otherwise.
12021 * Empty is always OK.
12022 */
12023 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012024opt_strings_flags(
12025 char_u *val, /* new value */
12026 char **values, /* array of valid string values */
12027 unsigned *flagp,
12028 int list) /* when TRUE: accept a list of values */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012029{
12030 int i;
12031 int len;
12032 unsigned new_flags = 0;
12033
12034 while (*val)
12035 {
12036 for (i = 0; ; ++i)
12037 {
12038 if (values[i] == NULL) /* val not found in values[] */
12039 return FAIL;
12040
12041 len = (int)STRLEN(values[i]);
12042 if (STRNCMP(values[i], val, len) == 0
12043 && ((list && val[len] == ',') || val[len] == NUL))
12044 {
12045 val += len + (val[len] == ',');
12046 new_flags |= (1 << i);
12047 break; /* check next item in val list */
12048 }
12049 }
12050 }
12051 if (flagp != NULL)
12052 *flagp = new_flags;
12053
12054 return OK;
12055}
12056
12057/*
12058 * Read the 'wildmode' option, fill wim_flags[].
12059 */
12060 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012061check_opt_wim(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012062{
12063 char_u new_wim_flags[4];
12064 char_u *p;
12065 int i;
12066 int idx = 0;
12067
12068 for (i = 0; i < 4; ++i)
12069 new_wim_flags[i] = 0;
12070
12071 for (p = p_wim; *p; ++p)
12072 {
12073 for (i = 0; ASCII_ISALPHA(p[i]); ++i)
12074 ;
12075 if (p[i] != NUL && p[i] != ',' && p[i] != ':')
12076 return FAIL;
12077 if (i == 7 && STRNCMP(p, "longest", 7) == 0)
12078 new_wim_flags[idx] |= WIM_LONGEST;
12079 else if (i == 4 && STRNCMP(p, "full", 4) == 0)
12080 new_wim_flags[idx] |= WIM_FULL;
12081 else if (i == 4 && STRNCMP(p, "list", 4) == 0)
12082 new_wim_flags[idx] |= WIM_LIST;
12083 else
12084 return FAIL;
12085 p += i;
12086 if (*p == NUL)
12087 break;
12088 if (*p == ',')
12089 {
12090 if (idx == 3)
12091 return FAIL;
12092 ++idx;
12093 }
12094 }
12095
12096 /* fill remaining entries with last flag */
12097 while (idx < 3)
12098 {
12099 new_wim_flags[idx + 1] = new_wim_flags[idx];
12100 ++idx;
12101 }
12102
12103 /* only when there are no errors, wim_flags[] is changed */
12104 for (i = 0; i < 4; ++i)
12105 wim_flags[i] = new_wim_flags[i];
12106 return OK;
12107}
12108
12109/*
12110 * Check if backspacing over something is allowed.
12111 */
12112 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012113can_bs(
12114 int what) /* BS_INDENT, BS_EOL or BS_START */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012115{
12116 switch (*p_bs)
12117 {
12118 case '2': return TRUE;
12119 case '1': return (what != BS_START);
12120 case '0': return FALSE;
12121 }
12122 return vim_strchr(p_bs, what) != NULL;
12123}
12124
12125/*
12126 * Save the current values of 'fileformat' and 'fileencoding', so that we know
12127 * the file must be considered changed when the value is different.
12128 */
12129 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012130save_file_ff(buf_T *buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012131{
12132 buf->b_start_ffc = *buf->b_p_ff;
12133 buf->b_start_eol = buf->b_p_eol;
12134#ifdef FEAT_MBYTE
Bram Moolenaar83eb8852007-08-12 13:51:26 +000012135 buf->b_start_bomb = buf->b_p_bomb;
12136
Bram Moolenaar071d4272004-06-13 20:20:40 +000012137 /* Only use free/alloc when necessary, they take time. */
12138 if (buf->b_start_fenc == NULL
12139 || STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0)
12140 {
12141 vim_free(buf->b_start_fenc);
12142 buf->b_start_fenc = vim_strsave(buf->b_p_fenc);
12143 }
12144#endif
12145}
12146
12147/*
12148 * Return TRUE if 'fileformat' and/or 'fileencoding' has a different value
12149 * from when editing started (save_file_ff() called).
Bram Moolenaar83eb8852007-08-12 13:51:26 +000012150 * Also when 'endofline' was changed and 'binary' is set, or when 'bomb' was
12151 * changed and 'binary' is not set.
Bram Moolenaar34d72d42015-07-17 14:18:08 +020012152 * Also when 'endofline' was changed and 'fixeol' is not set.
Bram Moolenaar164c60f2011-01-22 00:11:50 +010012153 * When "ignore_empty" is true don't consider a new, empty buffer to be
12154 * changed.
Bram Moolenaar071d4272004-06-13 20:20:40 +000012155 */
12156 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012157file_ff_differs(buf_T *buf, int ignore_empty)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012158{
Bram Moolenaar9cffde92007-07-24 07:51:18 +000012159 /* In a buffer that was never loaded the options are not valid. */
12160 if (buf->b_flags & BF_NEVERLOADED)
12161 return FALSE;
Bram Moolenaar164c60f2011-01-22 00:11:50 +010012162 if (ignore_empty
12163 && (buf->b_flags & BF_NEW)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012164 && buf->b_ml.ml_line_count == 1
12165 && *ml_get_buf(buf, (linenr_T)1, FALSE) == NUL)
12166 return FALSE;
12167 if (buf->b_start_ffc != *buf->b_p_ff)
12168 return TRUE;
Bram Moolenaar34d72d42015-07-17 14:18:08 +020012169 if ((buf->b_p_bin || !buf->b_p_fixeol) && buf->b_start_eol != buf->b_p_eol)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012170 return TRUE;
12171#ifdef FEAT_MBYTE
Bram Moolenaar83eb8852007-08-12 13:51:26 +000012172 if (!buf->b_p_bin && buf->b_start_bomb != buf->b_p_bomb)
12173 return TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012174 if (buf->b_start_fenc == NULL)
12175 return (*buf->b_p_fenc != NUL);
12176 return (STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0);
12177#else
12178 return FALSE;
12179#endif
12180}
12181
12182/*
12183 * return OK if "p" is a valid fileformat name, FAIL otherwise.
12184 */
12185 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012186check_ff_value(char_u *p)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012187{
12188 return check_opt_strings(p, p_ff_values, FALSE);
12189}
Bram Moolenaar14f24742012-08-08 18:01:05 +020012190
12191/*
12192 * Return the effective shiftwidth value for current buffer, using the
12193 * 'tabstop' value when 'shiftwidth' is zero.
12194 */
12195 long
Bram Moolenaar9b578142016-01-30 19:39:49 +010012196get_sw_value(buf_T *buf)
Bram Moolenaar14f24742012-08-08 18:01:05 +020012197{
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +010012198 return buf->b_p_sw ? buf->b_p_sw : buf->b_p_ts;
Bram Moolenaar14f24742012-08-08 18:01:05 +020012199}
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020012200
12201/*
12202 * Return the effective softtabstop value for the current buffer, using the
12203 * 'tabstop' value when 'softtabstop' is negative.
12204 */
12205 long
Bram Moolenaar9b578142016-01-30 19:39:49 +010012206get_sts_value(void)
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020012207{
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +010012208 return curbuf->b_p_sts < 0 ? get_sw_value(curbuf) : curbuf->b_p_sts;
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020012209}
Bram Moolenaar8c7694a2013-01-17 17:02:05 +010012210
12211/*
12212 * Check matchpairs option for "*initc".
12213 * If there is a match set "*initc" to the matching character and "*findc" to
12214 * the opposite character. Set "*backwards" to the direction.
12215 * When "switchit" is TRUE swap the direction.
12216 */
12217 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012218find_mps_values(
12219 int *initc,
12220 int *findc,
12221 int *backwards,
12222 int switchit)
Bram Moolenaar8c7694a2013-01-17 17:02:05 +010012223{
12224 char_u *ptr;
12225
12226 ptr = curbuf->b_p_mps;
12227 while (*ptr != NUL)
12228 {
12229#ifdef FEAT_MBYTE
12230 if (has_mbyte)
12231 {
12232 char_u *prev;
12233
12234 if (mb_ptr2char(ptr) == *initc)
12235 {
12236 if (switchit)
12237 {
12238 *findc = *initc;
12239 *initc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1);
12240 *backwards = TRUE;
12241 }
12242 else
12243 {
12244 *findc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1);
12245 *backwards = FALSE;
12246 }
12247 return;
12248 }
12249 prev = ptr;
12250 ptr += mb_ptr2len(ptr) + 1;
12251 if (mb_ptr2char(ptr) == *initc)
12252 {
12253 if (switchit)
12254 {
12255 *findc = *initc;
12256 *initc = mb_ptr2char(prev);
12257 *backwards = FALSE;
12258 }
12259 else
12260 {
12261 *findc = mb_ptr2char(prev);
12262 *backwards = TRUE;
12263 }
12264 return;
12265 }
12266 ptr += mb_ptr2len(ptr);
12267 }
12268 else
12269#endif
12270 {
12271 if (*ptr == *initc)
12272 {
12273 if (switchit)
12274 {
12275 *backwards = TRUE;
12276 *findc = *initc;
12277 *initc = ptr[2];
12278 }
12279 else
12280 {
12281 *backwards = FALSE;
12282 *findc = ptr[2];
12283 }
12284 return;
12285 }
12286 ptr += 2;
12287 if (*ptr == *initc)
12288 {
12289 if (switchit)
12290 {
12291 *backwards = FALSE;
12292 *findc = *initc;
12293 *initc = ptr[-2];
12294 }
12295 else
12296 {
12297 *backwards = TRUE;
12298 *findc = ptr[-2];
12299 }
12300 return;
12301 }
12302 ++ptr;
12303 }
12304 if (*ptr == ',')
12305 ++ptr;
12306 }
12307}
Bram Moolenaar597a4222014-06-25 14:39:50 +020012308
12309#if defined(FEAT_LINEBREAK) || defined(PROTO)
12310/*
12311 * This is called when 'breakindentopt' is changed and when a window is
12312 * initialized.
12313 */
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012314 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012315briopt_check(win_T *wp)
Bram Moolenaar597a4222014-06-25 14:39:50 +020012316{
12317 char_u *p;
12318 int bri_shift = 0;
12319 long bri_min = 20;
12320 int bri_sbr = FALSE;
12321
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012322 p = wp->w_p_briopt;
Bram Moolenaar597a4222014-06-25 14:39:50 +020012323 while (*p != NUL)
12324 {
12325 if (STRNCMP(p, "shift:", 6) == 0
12326 && ((p[6] == '-' && VIM_ISDIGIT(p[7])) || VIM_ISDIGIT(p[6])))
12327 {
12328 p += 6;
12329 bri_shift = getdigits(&p);
12330 }
12331 else if (STRNCMP(p, "min:", 4) == 0 && VIM_ISDIGIT(p[4]))
12332 {
12333 p += 4;
12334 bri_min = getdigits(&p);
12335 }
12336 else if (STRNCMP(p, "sbr", 3) == 0)
12337 {
12338 p += 3;
12339 bri_sbr = TRUE;
12340 }
12341 if (*p != ',' && *p != NUL)
12342 return FAIL;
12343 if (*p == ',')
12344 ++p;
12345 }
12346
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012347 wp->w_p_brishift = bri_shift;
12348 wp->w_p_brimin = bri_min;
12349 wp->w_p_brisbr = bri_sbr;
Bram Moolenaar597a4222014-06-25 14:39:50 +020012350
12351 return OK;
12352}
12353#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020012354
12355/*
12356 * Get the local or global value of 'backupcopy'.
12357 */
12358 unsigned int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012359get_bkc_value(buf_T *buf)
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020012360{
12361 return buf->b_bkc_flags ? buf->b_bkc_flags : bkc_flags;
12362}
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020012363
12364#if defined(FEAT_SIGNS) || defined(PROTO)
12365/*
12366 * Return TRUE when window "wp" has a column to draw signs in.
12367 */
12368 int
12369signcolumn_on(win_T *wp)
12370{
12371 if (*wp->w_p_scl == 'n')
12372 return FALSE;
12373 if (*wp->w_p_scl == 'y')
12374 return TRUE;
12375 return (wp->w_buffer->b_signlist != NULL
12376# ifdef FEAT_NETBEANS_INTG
12377 || wp->w_buffer->b_has_sign_column
12378# endif
12379 );
12380}
12381#endif
Bram Moolenaarb5ae48e2016-08-12 22:23:25 +020012382
12383#if defined(FEAT_EVAL) || defined(PROTO)
12384/*
12385 * Get window or buffer local options.
12386 */
12387 dict_T *
12388get_winbuf_options(int bufopt)
12389{
12390 dict_T *d;
12391 int opt_idx;
12392
12393 d = dict_alloc();
12394 if (d == NULL)
12395 return NULL;
12396
12397 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
12398 {
12399 struct vimoption *opt = &options[opt_idx];
12400
12401 if ((bufopt && (opt->indir & PV_BUF))
12402 || (!bufopt && (opt->indir & PV_WIN)))
12403 {
12404 char_u *varp = get_varp(opt);
12405
12406 if (varp != NULL)
12407 {
12408 if (opt->flags & P_STRING)
12409 dict_add_nr_str(d, opt->fullname, 0L, *(char_u **)varp);
Bram Moolenaar789a5c02016-09-12 19:51:11 +020012410 else if (opt->flags & P_NUM)
12411 dict_add_nr_str(d, opt->fullname, *(long *)varp, NULL);
Bram Moolenaarb5ae48e2016-08-12 22:23:25 +020012412 else
Bram Moolenaar789a5c02016-09-12 19:51:11 +020012413 dict_add_nr_str(d, opt->fullname, *(int *)varp, NULL);
Bram Moolenaarb5ae48e2016-08-12 22:23:25 +020012414 }
12415 }
12416 }
12417
12418 return d;
12419}
12420#endif