blob: 920f163a5fa30f6a93ba7c2d192035768c9f5da7 [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 */
Bram Moolenaara2477fd2016-12-03 15:13:20 +0100438#define P_RWIN 0x2000 /* redraw current window and recompute text */
439#define P_RBUF 0x4000 /* redraw current buffer and recompute text */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000440#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 Moolenaar7554da42016-11-25 22:04:13 +0100455 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 Moolenaar7554da42016-11-25 22:04:13 +0100459#define P_NDNAME 0x8000000L /* only normal dir name chars allowed */
Bram Moolenaara2477fd2016-12-03 15:13:20 +0100460#define P_RWINONLY 0x10000000L /* only redraw current window */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000461
Bram Moolenaar362e1a32006-03-06 23:29:24 +0000462#define ISK_LATIN1 (char_u *)"@,48-57,_,192-255"
463
Bram Moolenaar910f66f2006-04-05 20:41:53 +0000464/* 'isprint' for latin1 is also used for MS-Windows cp1252, where 0x80 is used
465 * for the currency sign. */
Bram Moolenaar48e330a2016-02-23 14:53:34 +0100466#if defined(MSWIN)
Bram Moolenaare2f98b92006-03-29 21:18:24 +0000467# define ISP_LATIN1 (char_u *)"@,~-255"
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +0000468#else
469# define ISP_LATIN1 (char_u *)"@,161-255"
470#endif
471
Bram Moolenaar44a2f922016-03-19 22:11:51 +0100472/* Make the string as short as possible when compiling with few features. */
Bram Moolenaar3991dab2006-03-27 17:01:56 +0000473#if defined(FEAT_DIFF) || defined(FEAT_FOLDING) || defined(FEAT_SPELL) \
Bram Moolenaar44a2f922016-03-19 22:11:51 +0100474 || defined(FEAT_WINDOWS) || defined(FEAT_CLIPBOARD) \
Bram Moolenaar860cae12010-06-05 23:22:07 +0200475 || defined(FEAT_INS_EXPAND) || defined(FEAT_SYN_HL) || defined(FEAT_CONCEAL)
Bram Moolenaar58b85342016-08-14 19:54:54 +0200476# 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 +0000477#else
Bram Moolenaar06ca5132012-03-23 16:25:17 +0100478# 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 +0000479#endif
480
Bram Moolenaar071d4272004-06-13 20:20:40 +0000481/*
482 * options[] is initialized here.
483 * The order of the options MUST be alphabetic for ":set all" and findoption().
484 * All option names MUST start with a lowercase letter (for findoption()).
485 * Exception: "t_" options are at the end.
486 * The options with a NULL variable are 'hidden': a set command for them is
487 * ignored and they are not printed.
488 */
Bram Moolenaare89ff042016-02-20 22:17:05 +0100489static struct vimoption options[] =
Bram Moolenaar071d4272004-06-13 20:20:40 +0000490{
Bram Moolenaar913077c2012-03-28 19:59:04 +0200491 {"aleph", "al", P_NUM|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000492#ifdef FEAT_RIGHTLEFT
493 (char_u *)&p_aleph, PV_NONE,
494#else
495 (char_u *)NULL, PV_NONE,
496#endif
497 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +0100498#if (defined(WIN3264)) && !defined(FEAT_GUI_W32)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000499 (char_u *)128L,
500#else
501 (char_u *)224L,
502#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000503 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000504 {"antialias", "anti", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
505#if defined(FEAT_GUI) && defined(MACOS_X)
506 (char_u *)&p_antialias, PV_NONE,
507 {(char_u *)FALSE, (char_u *)FALSE}
508#else
509 (char_u *)NULL, PV_NONE,
510 {(char_u *)FALSE, (char_u *)FALSE}
511#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000512 SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +0200513 {"arabic", "arab", P_BOOL|P_VI_DEF|P_VIM|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000514#ifdef FEAT_ARABIC
515 (char_u *)VAR_WIN, PV_ARAB,
516#else
517 (char_u *)NULL, PV_NONE,
518#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000519 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000520 {"arabicshape", "arshape", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
521#ifdef FEAT_ARABIC
522 (char_u *)&p_arshape, PV_NONE,
523#else
524 (char_u *)NULL, PV_NONE,
525#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000526 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000527 {"allowrevins", "ari", P_BOOL|P_VI_DEF|P_VIM,
528#ifdef FEAT_RIGHTLEFT
529 (char_u *)&p_ari, PV_NONE,
530#else
531 (char_u *)NULL, PV_NONE,
532#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000533 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000534 {"altkeymap", "akm", P_BOOL|P_VI_DEF,
535#ifdef FEAT_FKMAP
536 (char_u *)&p_altkeymap, PV_NONE,
537#else
538 (char_u *)NULL, PV_NONE,
539#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000540 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000541 {"ambiwidth", "ambw", P_STRING|P_VI_DEF|P_RCLR,
542#if defined(FEAT_MBYTE)
543 (char_u *)&p_ambw, PV_NONE,
544 {(char_u *)"single", (char_u *)0L}
545#else
546 (char_u *)NULL, PV_NONE,
547 {(char_u *)0L, (char_u *)0L}
548#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000549 SCRIPTID_INIT},
Bram Moolenaar8dff8182006-04-06 20:18:50 +0000550#ifdef FEAT_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +0000551 {"autochdir", "acd", P_BOOL|P_VI_DEF,
552 (char_u *)&p_acd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000553 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000554#endif
555 {"autoindent", "ai", P_BOOL|P_VI_DEF,
556 (char_u *)&p_ai, PV_AI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000557 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000558 {"autoprint", "ap", P_BOOL|P_VI_DEF,
559 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000560 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000561 {"autoread", "ar", P_BOOL|P_VI_DEF,
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000562 (char_u *)&p_ar, PV_AR,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000563 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000564 {"autowrite", "aw", P_BOOL|P_VI_DEF,
565 (char_u *)&p_aw, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000566 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000567 {"autowriteall","awa", P_BOOL|P_VI_DEF,
568 (char_u *)&p_awa, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000569 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000570 {"background", "bg", P_STRING|P_VI_DEF|P_RCLR,
571 (char_u *)&p_bg, PV_NONE,
572 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +0100573#if (defined(WIN3264)) && !defined(FEAT_GUI)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000574 (char_u *)"dark",
575#else
576 (char_u *)"light",
577#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000578 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200579 {"backspace", "bs", P_STRING|P_VI_DEF|P_VIM|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000580 (char_u *)&p_bs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000581 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000582 {"backup", "bk", P_BOOL|P_VI_DEF|P_VIM,
583 (char_u *)&p_bk, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000584 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200585 {"backupcopy", "bkc", P_STRING|P_VIM|P_ONECOMMA|P_NODUP,
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +0200586 (char_u *)&p_bkc, PV_BKC,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000587#ifdef UNIX
588 {(char_u *)"yes", (char_u *)"auto"}
589#else
590 {(char_u *)"auto", (char_u *)"auto"}
591#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000592 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200593 {"backupdir", "bdir", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA
594 |P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000595 (char_u *)&p_bdir, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000596 {(char_u *)DFLT_BDIR, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +0000597 {"backupext", "bex", P_STRING|P_VI_DEF|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000598 (char_u *)&p_bex, PV_NONE,
599 {
600#ifdef VMS
601 (char_u *)"_",
602#else
603 (char_u *)"~",
604#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000605 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200606 {"backupskip", "bsk", P_STRING|P_VI_DEF|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000607#ifdef FEAT_WILDIGN
608 (char_u *)&p_bsk, PV_NONE,
609 {(char_u *)"", (char_u *)0L}
610#else
611 (char_u *)NULL, PV_NONE,
612 {(char_u *)0L, (char_u *)0L}
613#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000614 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000615#ifdef FEAT_BEVAL
616 {"balloondelay","bdlay",P_NUM|P_VI_DEF,
617 (char_u *)&p_bdlay, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000618 {(char_u *)600L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000619 {"ballooneval", "beval",P_BOOL|P_VI_DEF|P_NO_MKRC,
620 (char_u *)&p_beval, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000621 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +0000622# ifdef FEAT_EVAL
Bram Moolenaar39f05632006-03-19 22:15:26 +0000623 {"balloonexpr", "bexpr", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
Bram Moolenaar9b2200a2006-03-20 21:55:45 +0000624 (char_u *)&p_bexpr, PV_BEXPR,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000625 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +0000626# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000627#endif
628 {"beautify", "bf", P_BOOL|P_VI_DEF,
629 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000630 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar165bc692015-07-21 17:53:25 +0200631 {"belloff", "bo", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
632 (char_u *)&p_bo, PV_NONE,
633 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000634 {"binary", "bin", P_BOOL|P_VI_DEF|P_RSTAT,
635 (char_u *)&p_bin, PV_BIN,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000636 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000637 {"bioskey", "biosk",P_BOOL|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000638 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000639 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000640 {"bomb", NULL, P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
641#ifdef FEAT_MBYTE
642 (char_u *)&p_bomb, PV_BOMB,
643#else
644 (char_u *)NULL, PV_NONE,
645#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000646 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000647 {"breakat", "brk", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST,
648#ifdef FEAT_LINEBREAK
649 (char_u *)&p_breakat, PV_NONE,
650 {(char_u *)" \t!@*-+;:,./?", (char_u *)0L}
651#else
652 (char_u *)NULL, PV_NONE,
653 {(char_u *)0L, (char_u *)0L}
654#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000655 SCRIPTID_INIT},
Bram Moolenaar597a4222014-06-25 14:39:50 +0200656 {"breakindent", "bri", P_BOOL|P_VI_DEF|P_VIM|P_RWIN,
657#ifdef FEAT_LINEBREAK
658 (char_u *)VAR_WIN, PV_BRI,
659 {(char_u *)FALSE, (char_u *)0L}
660#else
661 (char_u *)NULL, PV_NONE,
662 {(char_u *)0L, (char_u *)0L}
663#endif
664 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200665 {"breakindentopt", "briopt", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF
666 |P_ONECOMMA|P_NODUP,
Bram Moolenaar597a4222014-06-25 14:39:50 +0200667#ifdef FEAT_LINEBREAK
668 (char_u *)VAR_WIN, PV_BRIOPT,
669 {(char_u *)"", (char_u *)NULL}
670#else
671 (char_u *)NULL, PV_NONE,
672 {(char_u *)"", (char_u *)NULL}
673#endif
674 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000675 {"browsedir", "bsdir",P_STRING|P_VI_DEF,
676#ifdef FEAT_BROWSE
677 (char_u *)&p_bsdir, PV_NONE,
678 {(char_u *)"last", (char_u *)0L}
679#else
680 (char_u *)NULL, PV_NONE,
681 {(char_u *)0L, (char_u *)0L}
682#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000683 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000684 {"bufhidden", "bh", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB,
685#if defined(FEAT_QUICKFIX)
686 (char_u *)&p_bh, PV_BH,
687 {(char_u *)"", (char_u *)0L}
688#else
689 (char_u *)NULL, PV_NONE,
690 {(char_u *)0L, (char_u *)0L}
691#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000692 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000693 {"buflisted", "bl", P_BOOL|P_VI_DEF|P_NOGLOB,
694 (char_u *)&p_bl, PV_BL,
695 {(char_u *)1L, (char_u *)0L}
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000696 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000697 {"buftype", "bt", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB,
698#if defined(FEAT_QUICKFIX)
699 (char_u *)&p_bt, PV_BT,
700 {(char_u *)"", (char_u *)0L}
701#else
702 (char_u *)NULL, PV_NONE,
703 {(char_u *)0L, (char_u *)0L}
704#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000705 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200706 {"casemap", "cmp", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaarfa1d1402006-03-25 21:59:56 +0000707#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +0000708 (char_u *)&p_cmp, PV_NONE,
709 {(char_u *)"internal,keepascii", (char_u *)0L}
Bram Moolenaarfa1d1402006-03-25 21:59:56 +0000710#else
711 (char_u *)NULL, PV_NONE,
712 {(char_u *)0L, (char_u *)0L}
713#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000714 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000715 {"cdpath", "cd", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
716#ifdef FEAT_SEARCHPATH
717 (char_u *)&p_cdpath, PV_NONE,
718 {(char_u *)",,", (char_u *)0L}
719#else
720 (char_u *)NULL, PV_NONE,
721 {(char_u *)0L, (char_u *)0L}
722#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000723 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000724 {"cedit", NULL, P_STRING,
725#ifdef FEAT_CMDWIN
726 (char_u *)&p_cedit, PV_NONE,
727 {(char_u *)"", (char_u *)CTRL_F_STR}
728#else
729 (char_u *)NULL, PV_NONE,
730 {(char_u *)0L, (char_u *)0L}
731#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000732 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000733 {"charconvert", "ccv", P_STRING|P_VI_DEF|P_SECURE,
734#if defined(FEAT_MBYTE) && defined(FEAT_EVAL)
735 (char_u *)&p_ccv, PV_NONE,
736 {(char_u *)"", (char_u *)0L}
737#else
738 (char_u *)NULL, PV_NONE,
739 {(char_u *)0L, (char_u *)0L}
740#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000741 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000742 {"cindent", "cin", P_BOOL|P_VI_DEF|P_VIM,
743#ifdef FEAT_CINDENT
744 (char_u *)&p_cin, PV_CIN,
745#else
746 (char_u *)NULL, PV_NONE,
747#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000748 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200749 {"cinkeys", "cink", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000750#ifdef FEAT_CINDENT
751 (char_u *)&p_cink, PV_CINK,
752 {(char_u *)"0{,0},0),:,0#,!^F,o,O,e", (char_u *)0L}
753#else
754 (char_u *)NULL, PV_NONE,
755 {(char_u *)0L, (char_u *)0L}
756#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000757 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200758 {"cinoptions", "cino", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000759#ifdef FEAT_CINDENT
760 (char_u *)&p_cino, PV_CINO,
761#else
762 (char_u *)NULL, PV_NONE,
763#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000764 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200765 {"cinwords", "cinw", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000766#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
767 (char_u *)&p_cinw, PV_CINW,
768 {(char_u *)"if,else,while,do,for,switch",
769 (char_u *)0L}
770#else
771 (char_u *)NULL, PV_NONE,
772 {(char_u *)0L, (char_u *)0L}
773#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000774 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200775 {"clipboard", "cb", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000776#ifdef FEAT_CLIPBOARD
777 (char_u *)&p_cb, PV_NONE,
778# ifdef FEAT_XCLIPBOARD
779 {(char_u *)"autoselect,exclude:cons\\|linux",
780 (char_u *)0L}
781# else
782 {(char_u *)"", (char_u *)0L}
783# endif
784#else
785 (char_u *)NULL, PV_NONE,
786 {(char_u *)"", (char_u *)0L}
787#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000788 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000789 {"cmdheight", "ch", P_NUM|P_VI_DEF|P_RALL,
790 (char_u *)&p_ch, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000791 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000792 {"cmdwinheight", "cwh", P_NUM|P_VI_DEF,
793#ifdef FEAT_CMDWIN
794 (char_u *)&p_cwh, PV_NONE,
795#else
796 (char_u *)NULL, PV_NONE,
797#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000798 {(char_u *)7L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200799 {"colorcolumn", "cc", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_RWIN,
Bram Moolenaar1a384422010-07-14 19:53:30 +0200800#ifdef FEAT_SYN_HL
801 (char_u *)VAR_WIN, PV_CC,
802#else
803 (char_u *)NULL, PV_NONE,
804#endif
805 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000806 {"columns", "co", P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR,
807 (char_u *)&Columns, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000808 {(char_u *)80L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200809 {"comments", "com", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA
810 |P_NODUP|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000811#ifdef FEAT_COMMENTS
812 (char_u *)&p_com, PV_COM,
813 {(char_u *)"s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-",
814 (char_u *)0L}
815#else
816 (char_u *)NULL, PV_NONE,
817 {(char_u *)0L, (char_u *)0L}
818#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000819 SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +0200820 {"commentstring", "cms", P_STRING|P_ALLOCED|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000821#ifdef FEAT_FOLDING
822 (char_u *)&p_cms, PV_CMS,
823 {(char_u *)"/*%s*/", (char_u *)0L}
824#else
825 (char_u *)NULL, PV_NONE,
826 {(char_u *)0L, (char_u *)0L}
827#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000828 SCRIPTID_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +0000829 /* P_PRI_MKRC isn't needed here, optval_default()
830 * always returns TRUE for 'compatible' */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000831 {"compatible", "cp", P_BOOL|P_RALL,
832 (char_u *)&p_cp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000833 {(char_u *)TRUE, (char_u *)FALSE} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200834 {"complete", "cpt", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000835#ifdef FEAT_INS_EXPAND
836 (char_u *)&p_cpt, PV_CPT,
837 {(char_u *)".,w,b,u,t,i", (char_u *)0L}
838#else
839 (char_u *)NULL, PV_NONE,
840 {(char_u *)0L, (char_u *)0L}
841#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000842 SCRIPTID_INIT},
Bram Moolenaarf5963f72010-07-23 22:10:27 +0200843 {"concealcursor","cocu", P_STRING|P_ALLOCED|P_RWIN|P_VI_DEF,
Bram Moolenaar860cae12010-06-05 23:22:07 +0200844#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +0200845 (char_u *)VAR_WIN, PV_COCU,
846 {(char_u *)"", (char_u *)NULL}
847#else
848 (char_u *)NULL, PV_NONE,
849 {(char_u *)NULL, (char_u *)0L}
850#endif
851 SCRIPTID_INIT},
852 {"conceallevel","cole", P_NUM|P_RWIN|P_VI_DEF,
853#ifdef FEAT_CONCEAL
854 (char_u *)VAR_WIN, PV_COLE,
Bram Moolenaar860cae12010-06-05 23:22:07 +0200855#else
856 (char_u *)NULL, PV_NONE,
857#endif
858 {(char_u *)0L, (char_u *)0L}
859 SCRIPTID_INIT},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000860 {"completefunc", "cfu", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE,
861#ifdef FEAT_COMPL_FUNC
862 (char_u *)&p_cfu, PV_CFU,
863 {(char_u *)"", (char_u *)0L}
864#else
865 (char_u *)NULL, PV_NONE,
866 {(char_u *)0L, (char_u *)0L}
867#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000868 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200869 {"completeopt", "cot", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar1c7715d2005-10-03 22:02:18 +0000870#ifdef FEAT_INS_EXPAND
871 (char_u *)&p_cot, PV_NONE,
Bram Moolenaarc270d802006-03-11 21:29:41 +0000872 {(char_u *)"menu,preview", (char_u *)0L}
Bram Moolenaar1c7715d2005-10-03 22:02:18 +0000873#else
874 (char_u *)NULL, PV_NONE,
875 {(char_u *)0L, (char_u *)0L}
876#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000877 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000878 {"confirm", "cf", P_BOOL|P_VI_DEF,
879#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
880 (char_u *)&p_confirm, PV_NONE,
881#else
882 (char_u *)NULL, PV_NONE,
883#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000884 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000885 {"conskey", "consk",P_BOOL|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000886 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000887 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000888 {"copyindent", "ci", P_BOOL|P_VI_DEF|P_VIM,
889 (char_u *)&p_ci, PV_CI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000890 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000891 {"cpoptions", "cpo", P_STRING|P_VIM|P_RALL|P_FLAGLIST,
892 (char_u *)&p_cpo, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000893 {(char_u *)CPO_VI, (char_u *)CPO_VIM}
894 SCRIPTID_INIT},
Bram Moolenaar49771f42010-07-20 17:32:38 +0200895 {"cryptmethod", "cm", P_STRING|P_ALLOCED|P_VI_DEF,
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200896#ifdef FEAT_CRYPT
Bram Moolenaar40e6a712010-05-16 22:32:54 +0200897 (char_u *)&p_cm, PV_CM,
Bram Moolenaar49771f42010-07-20 17:32:38 +0200898 {(char_u *)"zip", (char_u *)0L}
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200899#else
900 (char_u *)NULL, PV_NONE,
Bram Moolenaar49771f42010-07-20 17:32:38 +0200901 {(char_u *)0L, (char_u *)0L}
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200902#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +0200903 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000904 {"cscopepathcomp", "cspc", P_NUM|P_VI_DEF|P_VIM,
905#ifdef FEAT_CSCOPE
906 (char_u *)&p_cspc, PV_NONE,
907#else
908 (char_u *)NULL, PV_NONE,
909#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000910 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000911 {"cscopeprg", "csprg", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
912#ifdef FEAT_CSCOPE
913 (char_u *)&p_csprg, PV_NONE,
914 {(char_u *)"cscope", (char_u *)0L}
915#else
916 (char_u *)NULL, PV_NONE,
917 {(char_u *)0L, (char_u *)0L}
918#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000919 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200920 {"cscopequickfix", "csqf", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000921#if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX)
922 (char_u *)&p_csqf, PV_NONE,
923 {(char_u *)"", (char_u *)0L}
924#else
925 (char_u *)NULL, PV_NONE,
926 {(char_u *)0L, (char_u *)0L}
927#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000928 SCRIPTID_INIT},
Bram Moolenaarf7befa92011-06-12 22:13:40 +0200929 {"cscoperelative", "csre", P_BOOL|P_VI_DEF|P_VIM,
930#ifdef FEAT_CSCOPE
931 (char_u *)&p_csre, PV_NONE,
932#else
933 (char_u *)NULL, PV_NONE,
934#endif
935 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000936 {"cscopetag", "cst", P_BOOL|P_VI_DEF|P_VIM,
937#ifdef FEAT_CSCOPE
938 (char_u *)&p_cst, PV_NONE,
939#else
940 (char_u *)NULL, PV_NONE,
941#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000942 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000943 {"cscopetagorder", "csto", P_NUM|P_VI_DEF|P_VIM,
944#ifdef FEAT_CSCOPE
945 (char_u *)&p_csto, PV_NONE,
946#else
947 (char_u *)NULL, PV_NONE,
948#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000949 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000950 {"cscopeverbose", "csverb", P_BOOL|P_VI_DEF|P_VIM,
951#ifdef FEAT_CSCOPE
952 (char_u *)&p_csverbose, PV_NONE,
953#else
954 (char_u *)NULL, PV_NONE,
955#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000956 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar860cae12010-06-05 23:22:07 +0200957 {"cursorbind", "crb", P_BOOL|P_VI_DEF,
958#ifdef FEAT_CURSORBIND
959 (char_u *)VAR_WIN, PV_CRBIND,
960#else
961 (char_u *)NULL, PV_NONE,
962#endif
963 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000964 {"cursorcolumn", "cuc", P_BOOL|P_VI_DEF|P_RWIN,
965#ifdef FEAT_SYN_HL
966 (char_u *)VAR_WIN, PV_CUC,
967#else
968 (char_u *)NULL, PV_NONE,
969#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000970 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaara2477fd2016-12-03 15:13:20 +0100971 {"cursorline", "cul", P_BOOL|P_VI_DEF|P_RWINONLY,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000972#ifdef FEAT_SYN_HL
973 (char_u *)VAR_WIN, PV_CUL,
974#else
975 (char_u *)NULL, PV_NONE,
976#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000977 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000978 {"debug", NULL, P_STRING|P_VI_DEF,
979 (char_u *)&p_debug, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000980 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +0200981 {"define", "def", P_STRING|P_ALLOCED|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000982#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000983 (char_u *)&p_def, PV_DEF,
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000984 {(char_u *)"^\\s*#\\s*define", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000985#else
986 (char_u *)NULL, PV_NONE,
987 {(char_u *)NULL, (char_u *)0L}
988#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000989 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000990 {"delcombine", "deco", P_BOOL|P_VI_DEF|P_VIM,
991#ifdef FEAT_MBYTE
992 (char_u *)&p_deco, PV_NONE,
993#else
994 (char_u *)NULL, PV_NONE,
995#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000996 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar7554da42016-11-25 22:04:13 +0100997 {"dictionary", "dict", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP|P_NDNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000998#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000999 (char_u *)&p_dict, PV_DICT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001000#else
1001 (char_u *)NULL, PV_NONE,
1002#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001003 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001004 {"diff", NULL, P_BOOL|P_VI_DEF|P_RWIN|P_NOGLOB,
1005#ifdef FEAT_DIFF
1006 (char_u *)VAR_WIN, PV_DIFF,
1007#else
1008 (char_u *)NULL, PV_NONE,
1009#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001010 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001011 {"diffexpr", "dex", P_STRING|P_VI_DEF|P_SECURE|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001012#if defined(FEAT_DIFF) && defined(FEAT_EVAL)
1013 (char_u *)&p_dex, PV_NONE,
1014 {(char_u *)"", (char_u *)0L}
1015#else
1016 (char_u *)NULL, PV_NONE,
1017 {(char_u *)0L, (char_u *)0L}
1018#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001019 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001020 {"diffopt", "dip", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN|P_ONECOMMA
1021 |P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001022#ifdef FEAT_DIFF
1023 (char_u *)&p_dip, PV_NONE,
1024 {(char_u *)"filler", (char_u *)NULL}
1025#else
1026 (char_u *)NULL, PV_NONE,
1027 {(char_u *)"", (char_u *)NULL}
1028#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001029 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001030 {"digraph", "dg", P_BOOL|P_VI_DEF|P_VIM,
1031#ifdef FEAT_DIGRAPHS
1032 (char_u *)&p_dg, PV_NONE,
1033#else
1034 (char_u *)NULL, PV_NONE,
1035#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001036 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001037 {"directory", "dir", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA
1038 |P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001039 (char_u *)&p_dir, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001040 {(char_u *)DFLT_DIR, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001041 {"display", "dy", P_STRING|P_VI_DEF|P_ONECOMMA|P_RALL|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001042 (char_u *)&p_dy, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001043 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001044 {"eadirection", "ead", P_STRING|P_VI_DEF,
Bram Moolenaar44a2f922016-03-19 22:11:51 +01001045#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00001046 (char_u *)&p_ead, PV_NONE,
1047 {(char_u *)"both", (char_u *)0L}
1048#else
1049 (char_u *)NULL, PV_NONE,
1050 {(char_u *)NULL, (char_u *)0L}
1051#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001052 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001053 {"edcompatible","ed", P_BOOL|P_VI_DEF,
1054 (char_u *)&p_ed, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001055 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar3848e002016-03-19 18:42:29 +01001056 {"emoji", "emo", P_BOOL|P_VI_DEF|P_RCLR,
1057#if defined(FEAT_MBYTE)
1058 (char_u *)&p_emoji, PV_NONE,
1059 {(char_u *)TRUE, (char_u *)0L}
1060#else
1061 (char_u *)NULL, PV_NONE,
1062 {(char_u *)0L, (char_u *)0L}
1063#endif
1064 SCRIPTID_INIT},
Bram Moolenaar865242e2010-07-14 21:12:05 +02001065 {"encoding", "enc", P_STRING|P_VI_DEF|P_RCLR|P_NO_ML,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001066#ifdef FEAT_MBYTE
1067 (char_u *)&p_enc, PV_NONE,
1068 {(char_u *)ENC_DFLT, (char_u *)0L}
1069#else
1070 (char_u *)NULL, PV_NONE,
1071 {(char_u *)0L, (char_u *)0L}
1072#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001073 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001074 {"endofline", "eol", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
1075 (char_u *)&p_eol, PV_EOL,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001076 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001077 {"equalalways", "ea", P_BOOL|P_VI_DEF|P_RALL,
1078 (char_u *)&p_ea, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001079 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001080 {"equalprg", "ep", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001081 (char_u *)&p_ep, PV_EP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001082 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001083 {"errorbells", "eb", P_BOOL|P_VI_DEF,
1084 (char_u *)&p_eb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001085 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001086 {"errorfile", "ef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1087#ifdef FEAT_QUICKFIX
1088 (char_u *)&p_ef, PV_NONE,
1089 {(char_u *)DFLT_ERRORFILE, (char_u *)0L}
1090#else
1091 (char_u *)NULL, PV_NONE,
1092 {(char_u *)NULL, (char_u *)0L}
1093#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001094 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001095 {"errorformat", "efm", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001096#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001097 (char_u *)&p_efm, PV_EFM,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001098 {(char_u *)DFLT_EFM, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001099#else
1100 (char_u *)NULL, PV_NONE,
1101 {(char_u *)NULL, (char_u *)0L}
1102#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001103 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001104 {"esckeys", "ek", P_BOOL|P_VIM,
1105 (char_u *)&p_ek, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001106 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001107 {"eventignore", "ei", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001108#ifdef FEAT_AUTOCMD
1109 (char_u *)&p_ei, PV_NONE,
1110#else
1111 (char_u *)NULL, PV_NONE,
1112#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001113 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001114 {"expandtab", "et", P_BOOL|P_VI_DEF|P_VIM,
1115 (char_u *)&p_et, PV_ET,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001116 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001117 {"exrc", "ex", P_BOOL|P_VI_DEF|P_SECURE,
1118 (char_u *)&p_exrc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001119 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001120 {"fileencoding","fenc", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_RBUF
1121 |P_NO_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001122#ifdef FEAT_MBYTE
1123 (char_u *)&p_fenc, PV_FENC,
1124 {(char_u *)"", (char_u *)0L}
1125#else
1126 (char_u *)NULL, PV_NONE,
1127 {(char_u *)0L, (char_u *)0L}
1128#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001129 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001130 {"fileencodings","fencs", P_STRING|P_VI_DEF|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001131#ifdef FEAT_MBYTE
1132 (char_u *)&p_fencs, PV_NONE,
1133 {(char_u *)"ucs-bom", (char_u *)0L}
1134#else
1135 (char_u *)NULL, PV_NONE,
1136 {(char_u *)0L, (char_u *)0L}
1137#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001138 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001139 {"fileformat", "ff", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_NO_MKRC
1140 |P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001141 (char_u *)&p_ff, PV_FF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001142 {(char_u *)DFLT_FF, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001143 {"fileformats", "ffs", P_STRING|P_VIM|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001144 (char_u *)&p_ffs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001145 {(char_u *)DFLT_FFS_VI, (char_u *)DFLT_FFS_VIM}
1146 SCRIPTID_INIT},
Bram Moolenaar71afbfe2013-03-19 16:49:16 +01001147 {"fileignorecase", "fic", P_BOOL|P_VI_DEF,
1148 (char_u *)&p_fic, PV_NONE,
1149 {
1150#ifdef CASE_INSENSITIVE_FILENAME
1151 (char_u *)TRUE,
1152#else
1153 (char_u *)FALSE,
1154#endif
1155 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001156 {"filetype", "ft", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001157#ifdef FEAT_AUTOCMD
1158 (char_u *)&p_ft, PV_FT,
1159 {(char_u *)"", (char_u *)0L}
1160#else
1161 (char_u *)NULL, PV_NONE,
1162 {(char_u *)0L, (char_u *)0L}
1163#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001164 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001165 {"fillchars", "fcs", P_STRING|P_VI_DEF|P_RALL|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001166#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
1167 (char_u *)&p_fcs, PV_NONE,
1168 {(char_u *)"vert:|,fold:-", (char_u *)0L}
1169#else
1170 (char_u *)NULL, PV_NONE,
1171 {(char_u *)"", (char_u *)0L}
1172#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001173 SCRIPTID_INIT},
Bram Moolenaar34d72d42015-07-17 14:18:08 +02001174 {"fixendofline", "fixeol", P_BOOL|P_VI_DEF|P_RSTAT,
1175 (char_u *)&p_fixeol, PV_FIXEOL,
1176 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001177 {"fkmap", "fk", P_BOOL|P_VI_DEF,
1178#ifdef FEAT_FKMAP
1179 (char_u *)&p_fkmap, PV_NONE,
1180#else
1181 (char_u *)NULL, PV_NONE,
1182#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001183 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001184 {"flash", "fl", P_BOOL|P_VI_DEF,
1185 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001186 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001187#ifdef FEAT_FOLDING
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001188 {"foldclose", "fcl", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_RWIN,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001189 (char_u *)&p_fcl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001190 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001191 {"foldcolumn", "fdc", P_NUM|P_VI_DEF|P_RWIN,
1192 (char_u *)VAR_WIN, PV_FDC,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001193 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001194 {"foldenable", "fen", P_BOOL|P_VI_DEF|P_RWIN,
1195 (char_u *)VAR_WIN, PV_FEN,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001196 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001197 {"foldexpr", "fde", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1198# ifdef FEAT_EVAL
1199 (char_u *)VAR_WIN, PV_FDE,
1200 {(char_u *)"0", (char_u *)NULL}
1201# else
1202 (char_u *)NULL, PV_NONE,
1203 {(char_u *)NULL, (char_u *)0L}
1204# endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001205 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001206 {"foldignore", "fdi", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1207 (char_u *)VAR_WIN, PV_FDI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001208 {(char_u *)"#", (char_u *)NULL} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001209 {"foldlevel", "fdl", P_NUM|P_VI_DEF|P_RWIN,
1210 (char_u *)VAR_WIN, PV_FDL,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001211 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001212 {"foldlevelstart","fdls", P_NUM|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001213 (char_u *)&p_fdls, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001214 {(char_u *)-1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001215 {"foldmarker", "fmr", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001216 P_RWIN|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001217 (char_u *)VAR_WIN, PV_FMR,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001218 {(char_u *)"{{{,}}}", (char_u *)NULL}
1219 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001220 {"foldmethod", "fdm", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1221 (char_u *)VAR_WIN, PV_FDM,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001222 {(char_u *)"manual", (char_u *)NULL} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001223 {"foldminlines","fml", P_NUM|P_VI_DEF|P_RWIN,
1224 (char_u *)VAR_WIN, PV_FML,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001225 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001226 {"foldnestmax", "fdn", P_NUM|P_VI_DEF|P_RWIN,
1227 (char_u *)VAR_WIN, PV_FDN,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001228 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001229 {"foldopen", "fdo", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001230 (char_u *)&p_fdo, PV_NONE,
1231 {(char_u *)"block,hor,mark,percent,quickfix,search,tag,undo",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001232 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001233 {"foldtext", "fdt", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1234# ifdef FEAT_EVAL
1235 (char_u *)VAR_WIN, PV_FDT,
1236 {(char_u *)"foldtext()", (char_u *)NULL}
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00001237# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00001238 (char_u *)NULL, PV_NONE,
1239 {(char_u *)NULL, (char_u *)0L}
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00001240# endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001241 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001242#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00001243 {"formatexpr", "fex", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001244#ifdef FEAT_EVAL
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00001245 (char_u *)&p_fex, PV_FEX,
1246 {(char_u *)"", (char_u *)0L}
1247#else
1248 (char_u *)NULL, PV_NONE,
1249 {(char_u *)0L, (char_u *)0L}
1250#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001251 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001252 {"formatoptions","fo", P_STRING|P_ALLOCED|P_VIM|P_FLAGLIST,
1253 (char_u *)&p_fo, PV_FO,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001254 {(char_u *)DFLT_FO_VI, (char_u *)DFLT_FO_VIM}
1255 SCRIPTID_INIT},
Bram Moolenaar86b68352004-12-27 21:59:20 +00001256 {"formatlistpat","flp", P_STRING|P_ALLOCED|P_VI_DEF,
1257 (char_u *)&p_flp, PV_FLP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001258 {(char_u *)"^\\s*\\d\\+[\\]:.)}\\t ]\\s*",
1259 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001260 {"formatprg", "fp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1261 (char_u *)&p_fp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001262 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001263 {"fsync", "fs", P_BOOL|P_SECURE|P_VI_DEF,
1264#ifdef HAVE_FSYNC
1265 (char_u *)&p_fs, PV_NONE,
1266 {(char_u *)TRUE, (char_u *)0L}
1267#else
1268 (char_u *)NULL, PV_NONE,
1269 {(char_u *)FALSE, (char_u *)0L}
1270#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001271 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001272 {"gdefault", "gd", P_BOOL|P_VI_DEF|P_VIM,
1273 (char_u *)&p_gd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001274 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001275 {"graphic", "gr", P_BOOL|P_VI_DEF,
1276 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001277 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001278 {"grepformat", "gfm", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001279#ifdef FEAT_QUICKFIX
1280 (char_u *)&p_gefm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001281 {(char_u *)DFLT_GREPFORMAT, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001282#else
1283 (char_u *)NULL, PV_NONE,
1284 {(char_u *)NULL, (char_u *)0L}
1285#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001286 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001287 {"grepprg", "gp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1288#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001289 (char_u *)&p_gp, PV_GP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001290 {
1291# ifdef WIN3264
1292 /* may be changed to "grep -n" in os_win32.c */
1293 (char_u *)"findstr /n",
1294# else
1295# ifdef UNIX
1296 /* Add an extra file name so that grep will always
1297 * insert a file name in the match line. */
1298 (char_u *)"grep -n $* /dev/null",
1299# else
1300# ifdef VMS
1301 (char_u *)"SEARCH/NUMBERS ",
1302# else
1303 (char_u *)"grep -n ",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001304# endif
1305# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00001306# endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001307 (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001308#else
1309 (char_u *)NULL, PV_NONE,
1310 {(char_u *)NULL, (char_u *)0L}
1311#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001312 SCRIPTID_INIT},
Bram Moolenaar8a633e32016-04-21 21:10:14 +02001313 {"guicursor", "gcr", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001314#ifdef CURSOR_SHAPE
1315 (char_u *)&p_guicursor, PV_NONE,
1316 {
1317# ifdef FEAT_GUI
1318 (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 +01001319# else /* Win32 console */
Bram Moolenaar071d4272004-06-13 20:20:40 +00001320 (char_u *)"n-v-c:block,o:hor50,i-ci:hor15,r-cr:hor30,sm:block",
1321# endif
1322 (char_u *)0L}
1323#else
1324 (char_u *)NULL, PV_NONE,
1325 {(char_u *)NULL, (char_u *)0L}
1326#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001327 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001328 {"guifont", "gfn", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001329#ifdef FEAT_GUI
1330 (char_u *)&p_guifont, PV_NONE,
1331 {(char_u *)"", (char_u *)0L}
1332#else
1333 (char_u *)NULL, PV_NONE,
1334 {(char_u *)NULL, (char_u *)0L}
1335#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001336 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001337 {"guifontset", "gfs", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001338#if defined(FEAT_GUI) && defined(FEAT_XFONTSET)
1339 (char_u *)&p_guifontset, PV_NONE,
1340 {(char_u *)"", (char_u *)0L}
1341#else
1342 (char_u *)NULL, PV_NONE,
1343 {(char_u *)NULL, (char_u *)0L}
1344#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001345 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001346 {"guifontwide", "gfw", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001347#if defined(FEAT_GUI) && defined(FEAT_MBYTE)
1348 (char_u *)&p_guifontwide, PV_NONE,
1349 {(char_u *)"", (char_u *)0L}
1350#else
1351 (char_u *)NULL, PV_NONE,
1352 {(char_u *)NULL, (char_u *)0L}
1353#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001354 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001355 {"guiheadroom", "ghr", P_NUM|P_VI_DEF,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001356#if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001357 (char_u *)&p_ghr, PV_NONE,
1358#else
1359 (char_u *)NULL, PV_NONE,
1360#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001361 {(char_u *)50L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001362 {"guioptions", "go", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001363#if defined(FEAT_GUI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001364 (char_u *)&p_go, PV_NONE,
1365# if defined(UNIX) && !defined(MACOS)
Bram Moolenaar32466aa2006-02-24 23:53:04 +00001366 {(char_u *)"aegimrLtT", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001367# else
Bram Moolenaar32466aa2006-02-24 23:53:04 +00001368 {(char_u *)"egmrLtT", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001369# endif
1370#else
1371 (char_u *)NULL, PV_NONE,
1372 {(char_u *)NULL, (char_u *)0L}
1373#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001374 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001375 {"guipty", NULL, P_BOOL|P_VI_DEF,
1376#if defined(FEAT_GUI)
1377 (char_u *)&p_guipty, PV_NONE,
1378#else
1379 (char_u *)NULL, PV_NONE,
1380#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001381 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar18144c82006-04-12 21:52:12 +00001382 {"guitablabel", "gtl", P_STRING|P_VI_DEF|P_RWIN,
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00001383#if defined(FEAT_GUI_TABLINE)
1384 (char_u *)&p_gtl, PV_NONE,
1385 {(char_u *)"", (char_u *)0L}
1386#else
1387 (char_u *)NULL, PV_NONE,
1388 {(char_u *)NULL, (char_u *)0L}
1389#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001390 SCRIPTID_INIT},
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001391 {"guitabtooltip", "gtt", P_STRING|P_VI_DEF|P_RWIN,
Bram Moolenaar57657d82006-04-21 22:12:41 +00001392#if defined(FEAT_GUI_TABLINE)
1393 (char_u *)&p_gtt, PV_NONE,
1394 {(char_u *)"", (char_u *)0L}
1395#else
1396 (char_u *)NULL, PV_NONE,
1397 {(char_u *)NULL, (char_u *)0L}
1398#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001399 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001400 {"hardtabs", "ht", P_NUM|P_VI_DEF,
1401 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001402 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001403 {"helpfile", "hf", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1404 (char_u *)&p_hf, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001405 {(char_u *)DFLT_HELPFILE, (char_u *)0L}
1406 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001407 {"helpheight", "hh", P_NUM|P_VI_DEF,
1408#ifdef FEAT_WINDOWS
1409 (char_u *)&p_hh, PV_NONE,
1410#else
1411 (char_u *)NULL, PV_NONE,
1412#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001413 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001414 {"helplang", "hlg", P_STRING|P_VI_DEF|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001415#ifdef FEAT_MULTI_LANG
1416 (char_u *)&p_hlg, PV_NONE,
1417 {(char_u *)"", (char_u *)0L}
1418#else
1419 (char_u *)NULL, PV_NONE,
1420 {(char_u *)0L, (char_u *)0L}
1421#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001422 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001423 {"hidden", "hid", P_BOOL|P_VI_DEF,
1424 (char_u *)&p_hid, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001425 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001426 {"highlight", "hl", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001427 (char_u *)&p_hl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001428 {(char_u *)HIGHLIGHT_INIT, (char_u *)0L}
1429 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001430 {"history", "hi", P_NUM|P_VIM,
1431 (char_u *)&p_hi, PV_NONE,
Bram Moolenaar78159bb2014-06-25 11:48:54 +02001432 {(char_u *)0L, (char_u *)50L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001433 {"hkmap", "hk", P_BOOL|P_VI_DEF|P_VIM,
1434#ifdef FEAT_RIGHTLEFT
1435 (char_u *)&p_hkmap, PV_NONE,
1436#else
1437 (char_u *)NULL, PV_NONE,
1438#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001439 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001440 {"hkmapp", "hkp", P_BOOL|P_VI_DEF|P_VIM,
1441#ifdef FEAT_RIGHTLEFT
1442 (char_u *)&p_hkmapp, PV_NONE,
1443#else
1444 (char_u *)NULL, PV_NONE,
1445#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001446 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001447 {"hlsearch", "hls", P_BOOL|P_VI_DEF|P_VIM|P_RALL,
1448 (char_u *)&p_hls, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001449 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001450 {"icon", NULL, P_BOOL|P_VI_DEF,
1451#ifdef FEAT_TITLE
1452 (char_u *)&p_icon, PV_NONE,
1453#else
1454 (char_u *)NULL, PV_NONE,
1455#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001456 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001457 {"iconstring", NULL, P_STRING|P_VI_DEF,
1458#ifdef FEAT_TITLE
1459 (char_u *)&p_iconstring, PV_NONE,
1460#else
1461 (char_u *)NULL, PV_NONE,
1462#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001463 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001464 {"ignorecase", "ic", P_BOOL|P_VI_DEF,
1465 (char_u *)&p_ic, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001466 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarabab85a2013-06-26 19:18:05 +02001467 {"imactivatefunc","imaf",P_STRING|P_VI_DEF|P_SECURE,
1468# if defined(FEAT_EVAL) && defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
1469 (char_u *)&p_imaf, PV_NONE,
1470 {(char_u *)"", (char_u *)NULL}
1471# else
1472 (char_u *)NULL, PV_NONE,
1473 {(char_u *)NULL, (char_u *)0L}
1474# endif
1475 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001476 {"imactivatekey","imak",P_STRING|P_VI_DEF,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001477#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001478 (char_u *)&p_imak, PV_NONE,
1479#else
1480 (char_u *)NULL, PV_NONE,
1481#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001482 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001483 {"imcmdline", "imc", P_BOOL|P_VI_DEF,
1484#ifdef USE_IM_CONTROL
1485 (char_u *)&p_imcmdline, PV_NONE,
1486#else
1487 (char_u *)NULL, PV_NONE,
1488#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001489 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001490 {"imdisable", "imd", P_BOOL|P_VI_DEF,
1491#ifdef USE_IM_CONTROL
1492 (char_u *)&p_imdisable, PV_NONE,
1493#else
1494 (char_u *)NULL, PV_NONE,
1495#endif
1496#ifdef __sgi
1497 {(char_u *)TRUE, (char_u *)0L}
1498#else
1499 {(char_u *)FALSE, (char_u *)0L}
1500#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001501 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001502 {"iminsert", "imi", P_NUM|P_VI_DEF,
1503 (char_u *)&p_iminsert, PV_IMI,
1504#ifdef B_IMODE_IM
1505 {(char_u *)B_IMODE_IM, (char_u *)0L}
1506#else
1507 {(char_u *)B_IMODE_NONE, (char_u *)0L}
1508#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001509 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001510 {"imsearch", "ims", P_NUM|P_VI_DEF,
1511 (char_u *)&p_imsearch, PV_IMS,
1512#ifdef B_IMODE_IM
1513 {(char_u *)B_IMODE_IM, (char_u *)0L}
1514#else
1515 {(char_u *)B_IMODE_NONE, (char_u *)0L}
1516#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001517 SCRIPTID_INIT},
Bram Moolenaar4a460702013-06-29 14:42:26 +02001518 {"imstatusfunc","imsf",P_STRING|P_VI_DEF|P_SECURE,
Bram Moolenaarabab85a2013-06-26 19:18:05 +02001519# if defined(FEAT_EVAL) && defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
1520 (char_u *)&p_imsf, PV_NONE,
1521 {(char_u *)"", (char_u *)NULL}
1522# else
1523 (char_u *)NULL, PV_NONE,
1524 {(char_u *)NULL, (char_u *)0L}
1525# endif
1526 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001527 {"include", "inc", P_STRING|P_ALLOCED|P_VI_DEF,
1528#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001529 (char_u *)&p_inc, PV_INC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001530 {(char_u *)"^\\s*#\\s*include", (char_u *)0L}
1531#else
1532 (char_u *)NULL, PV_NONE,
1533 {(char_u *)0L, (char_u *)0L}
1534#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001535 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001536 {"includeexpr", "inex", P_STRING|P_ALLOCED|P_VI_DEF,
1537#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
1538 (char_u *)&p_inex, PV_INEX,
1539 {(char_u *)"", (char_u *)0L}
1540#else
1541 (char_u *)NULL, PV_NONE,
1542 {(char_u *)0L, (char_u *)0L}
1543#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001544 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001545 {"incsearch", "is", P_BOOL|P_VI_DEF|P_VIM,
1546 (char_u *)&p_is, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001547 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001548 {"indentexpr", "inde", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
1549#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
1550 (char_u *)&p_inde, PV_INDE,
1551 {(char_u *)"", (char_u *)0L}
1552#else
1553 (char_u *)NULL, PV_NONE,
1554 {(char_u *)0L, (char_u *)0L}
1555#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001556 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001557 {"indentkeys", "indk", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001558#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
1559 (char_u *)&p_indk, PV_INDK,
1560 {(char_u *)"0{,0},:,0#,!^F,o,O,e", (char_u *)0L}
1561#else
1562 (char_u *)NULL, PV_NONE,
1563 {(char_u *)0L, (char_u *)0L}
1564#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001565 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001566 {"infercase", "inf", P_BOOL|P_VI_DEF,
1567 (char_u *)&p_inf, PV_INF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001568 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001569 {"insertmode", "im", P_BOOL|P_VI_DEF|P_VIM,
1570 (char_u *)&p_im, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001571 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001572 {"isfname", "isf", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1573 (char_u *)&p_isf, PV_NONE,
1574 {
1575#ifdef BACKSLASH_IN_FILENAME
1576 /* Excluded are: & and ^ are special in cmd.exe
1577 * ( and ) are used in text separating fnames */
1578 (char_u *)"@,48-57,/,\\,.,-,_,+,,,#,$,%,{,},[,],:,@-@,!,~,=",
1579#else
1580# ifdef AMIGA
1581 (char_u *)"@,48-57,/,.,-,_,+,,,$,:",
1582# else
1583# ifdef VMS
1584 (char_u *)"@,48-57,/,.,-,_,+,,,#,$,%,<,>,[,],:,;,~",
1585# else /* UNIX et al. */
1586# ifdef EBCDIC
1587 (char_u *)"@,240-249,/,.,-,_,+,,,#,$,%,~,=",
1588# else
1589 (char_u *)"@,48-57,/,.,-,_,+,,,#,$,%,~,=",
1590# endif
1591# endif
1592# endif
1593#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001594 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001595 {"isident", "isi", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1596 (char_u *)&p_isi, PV_NONE,
1597 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001598#if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001599 (char_u *)"@,48-57,_,128-167,224-235",
1600#else
1601# ifdef EBCDIC
1602 /* TODO: EBCDIC Check this! @ == isalpha()*/
1603 (char_u *)"@,240-249,_,66-73,81-89,98-105,"
1604 "112-120,128,140-142,156,158,172,"
1605 "174,186,191,203-207,219-225,235-239,"
1606 "251-254",
1607# else
1608 (char_u *)"@,48-57,_,192-255",
1609# endif
1610#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001611 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001612 {"iskeyword", "isk", P_STRING|P_ALLOCED|P_VIM|P_COMMA|P_NODUP,
1613 (char_u *)&p_isk, PV_ISK,
1614 {
1615#ifdef EBCDIC
1616 (char_u *)"@,240-249,_",
1617 /* TODO: EBCDIC Check this! @ == isalpha()*/
1618 (char_u *)"@,240-249,_,66-73,81-89,98-105,"
1619 "112-120,128,140-142,156,158,172,"
1620 "174,186,191,203-207,219-225,235-239,"
1621 "251-254",
1622#else
1623 (char_u *)"@,48-57,_",
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001624# if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001625 (char_u *)"@,48-57,_,128-167,224-235"
1626# else
Bram Moolenaar362e1a32006-03-06 23:29:24 +00001627 ISK_LATIN1
Bram Moolenaar071d4272004-06-13 20:20:40 +00001628# endif
1629#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001630 } SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001631 {"isprint", "isp", P_STRING|P_VI_DEF|P_RALL|P_COMMA|P_NODUP,
1632 (char_u *)&p_isp, PV_NONE,
1633 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001634#if defined(MSWIN) || (defined(MACOS) && !defined(MACOS_X)) \
Bram Moolenaar071d4272004-06-13 20:20:40 +00001635 || defined(VMS)
1636 (char_u *)"@,~-255",
1637#else
1638# ifdef EBCDIC
1639 /* all chars above 63 are printable */
1640 (char_u *)"63-255",
1641# else
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +00001642 ISP_LATIN1,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001643# endif
1644#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001645 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001646 {"joinspaces", "js", P_BOOL|P_VI_DEF|P_VIM,
1647 (char_u *)&p_js, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001648 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001649 {"key", NULL, P_STRING|P_ALLOCED|P_VI_DEF|P_NO_MKRC,
1650#ifdef FEAT_CRYPT
1651 (char_u *)&p_key, PV_KEY,
1652 {(char_u *)"", (char_u *)0L}
1653#else
1654 (char_u *)NULL, PV_NONE,
1655 {(char_u *)0L, (char_u *)0L}
1656#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001657 SCRIPTID_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +00001658 {"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 +00001659#ifdef FEAT_KEYMAP
1660 (char_u *)&p_keymap, PV_KMAP,
1661 {(char_u *)"", (char_u *)0L}
1662#else
1663 (char_u *)NULL, PV_NONE,
1664 {(char_u *)"", (char_u *)0L}
1665#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001666 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001667 {"keymodel", "km", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001668 (char_u *)&p_km, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001669 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001670 {"keywordprg", "kp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001671 (char_u *)&p_kp, PV_KP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001672 {
Bram Moolenaarfd89d7e2016-06-04 20:25:05 +02001673#ifdef MSWIN
Bram Moolenaar071d4272004-06-13 20:20:40 +00001674 (char_u *)":help",
1675#else
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001676# ifdef VMS
Bram Moolenaar071d4272004-06-13 20:20:40 +00001677 (char_u *)"help",
Bram Moolenaare7fedb62015-12-31 19:07:19 +01001678# else
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001679# ifdef USEMAN_S
1680 (char_u *)"man -s",
1681# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00001682 (char_u *)"man",
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001683# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00001684# endif
1685#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001686 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001687 {"langmap", "lmap", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001688#ifdef FEAT_LANGMAP
1689 (char_u *)&p_langmap, PV_NONE,
1690 {(char_u *)"", /* unmatched } */
1691#else
1692 (char_u *)NULL, PV_NONE,
1693 {(char_u *)NULL,
1694#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001695 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001696 {"langmenu", "lm", P_STRING|P_VI_DEF|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001697#if defined(FEAT_MENU) && defined(FEAT_MULTI_LANG)
1698 (char_u *)&p_lm, PV_NONE,
1699#else
1700 (char_u *)NULL, PV_NONE,
1701#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001702 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar4391cf92014-11-05 17:44:52 +01001703 {"langnoremap", "lnr", P_BOOL|P_VI_DEF,
1704#ifdef FEAT_LANGMAP
1705 (char_u *)&p_lnr, PV_NONE,
1706#else
1707 (char_u *)NULL, PV_NONE,
1708#endif
1709 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar920694c2016-08-21 17:45:02 +02001710 {"langremap", "lrm", P_BOOL|P_VI_DEF,
1711#ifdef FEAT_LANGMAP
1712 (char_u *)&p_lrm, PV_NONE,
1713#else
1714 (char_u *)NULL, PV_NONE,
1715#endif
Bram Moolenaarda9ce2c2016-09-02 19:34:10 +02001716 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001717 {"laststatus", "ls", P_NUM|P_VI_DEF|P_RALL,
1718#ifdef FEAT_WINDOWS
1719 (char_u *)&p_ls, PV_NONE,
1720#else
1721 (char_u *)NULL, PV_NONE,
1722#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001723 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001724 {"lazyredraw", "lz", P_BOOL|P_VI_DEF,
1725 (char_u *)&p_lz, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001726 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001727 {"linebreak", "lbr", P_BOOL|P_VI_DEF|P_RWIN,
1728#ifdef FEAT_LINEBREAK
1729 (char_u *)VAR_WIN, PV_LBR,
1730#else
1731 (char_u *)NULL, PV_NONE,
1732#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001733 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001734 {"lines", NULL, P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR,
1735 (char_u *)&Rows, PV_NONE,
1736 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001737#if defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001738 (char_u *)25L,
1739#else
1740 (char_u *)24L,
1741#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001742 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001743 {"linespace", "lsp", P_NUM|P_VI_DEF|P_RCLR,
1744#ifdef FEAT_GUI
1745 (char_u *)&p_linespace, PV_NONE,
1746#else
1747 (char_u *)NULL, PV_NONE,
1748#endif
1749#ifdef FEAT_GUI_W32
1750 {(char_u *)1L, (char_u *)0L}
1751#else
1752 {(char_u *)0L, (char_u *)0L}
1753#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001754 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001755 {"lisp", NULL, P_BOOL|P_VI_DEF,
1756#ifdef FEAT_LISP
1757 (char_u *)&p_lisp, PV_LISP,
1758#else
1759 (char_u *)NULL, PV_NONE,
1760#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001761 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001762 {"lispwords", "lw", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001763#ifdef FEAT_LISP
Bram Moolenaaraf6c1312014-03-12 18:55:58 +01001764 (char_u *)&p_lispwords, PV_LW,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001765 {(char_u *)LISPWORD_VALUE, (char_u *)0L}
1766#else
1767 (char_u *)NULL, PV_NONE,
1768 {(char_u *)"", (char_u *)0L}
1769#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001770 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001771 {"list", NULL, P_BOOL|P_VI_DEF|P_RWIN,
1772 (char_u *)VAR_WIN, PV_LIST,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001773 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001774 {"listchars", "lcs", P_STRING|P_VI_DEF|P_RALL|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001775 (char_u *)&p_lcs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001776 {(char_u *)"eol:$", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001777 {"loadplugins", "lpl", P_BOOL|P_VI_DEF,
1778 (char_u *)&p_lpl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001779 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01001780#if defined(DYNAMIC_LUA)
Bram Moolenaara6e42502016-04-20 16:19:52 +02001781 {"luadll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaard94464e2015-11-02 15:28:18 +01001782 (char_u *)&p_luadll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01001783 {(char_u *)DYNAMIC_LUA_DLL, (char_u *)0L}
1784 SCRIPTID_INIT},
Bram Moolenaard94464e2015-11-02 15:28:18 +01001785#endif
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001786#ifdef FEAT_GUI_MAC
1787 {"macatsui", NULL, P_BOOL|P_VI_DEF|P_RCLR,
1788 (char_u *)&p_macatsui, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001789 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001790#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00001791 {"magic", NULL, P_BOOL|P_VI_DEF,
1792 (char_u *)&p_magic, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001793 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00001794 {"makeef", "mef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001795#ifdef FEAT_QUICKFIX
1796 (char_u *)&p_mef, PV_NONE,
1797 {(char_u *)"", (char_u *)0L}
1798#else
1799 (char_u *)NULL, PV_NONE,
1800 {(char_u *)NULL, (char_u *)0L}
1801#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001802 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001803 {"makeprg", "mp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1804#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001805 (char_u *)&p_mp, PV_MP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001806# ifdef VMS
1807 {(char_u *)"MMS", (char_u *)0L}
1808# else
1809 {(char_u *)"make", (char_u *)0L}
1810# endif
1811#else
1812 (char_u *)NULL, PV_NONE,
1813 {(char_u *)NULL, (char_u *)0L}
1814#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001815 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001816 {"matchpairs", "mps", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001817 (char_u *)&p_mps, PV_MPS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001818 {(char_u *)"(:),{:},[:]", (char_u *)0L}
1819 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001820 {"matchtime", "mat", P_NUM|P_VI_DEF,
1821 (char_u *)&p_mat, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001822 {(char_u *)5L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001823 {"maxcombine", "mco", P_NUM|P_VI_DEF|P_CURSWANT,
Bram Moolenaar362e1a32006-03-06 23:29:24 +00001824#ifdef FEAT_MBYTE
1825 (char_u *)&p_mco, PV_NONE,
1826#else
1827 (char_u *)NULL, PV_NONE,
1828#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001829 {(char_u *)2, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001830 {"maxfuncdepth", "mfd", P_NUM|P_VI_DEF,
1831#ifdef FEAT_EVAL
1832 (char_u *)&p_mfd, PV_NONE,
1833#else
1834 (char_u *)NULL, PV_NONE,
1835#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001836 {(char_u *)100L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001837 {"maxmapdepth", "mmd", P_NUM|P_VI_DEF,
1838 (char_u *)&p_mmd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001839 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001840 {"maxmem", "mm", P_NUM|P_VI_DEF,
1841 (char_u *)&p_mm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001842 {(char_u *)DFLT_MAXMEM, (char_u *)0L}
1843 SCRIPTID_INIT},
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00001844 {"maxmempattern","mmp", P_NUM|P_VI_DEF,
1845 (char_u *)&p_mmp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001846 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001847 {"maxmemtot", "mmt", P_NUM|P_VI_DEF,
1848 (char_u *)&p_mmt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001849 {(char_u *)DFLT_MAXMEMTOT, (char_u *)0L}
1850 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001851 {"menuitems", "mis", P_NUM|P_VI_DEF,
1852#ifdef FEAT_MENU
1853 (char_u *)&p_mis, PV_NONE,
1854#else
1855 (char_u *)NULL, PV_NONE,
1856#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001857 {(char_u *)25L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001858 {"mesg", NULL, P_BOOL|P_VI_DEF,
1859 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001860 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001861 {"mkspellmem", "msm", P_STRING|P_VI_DEF|P_EXPAND|P_SECURE,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00001862#ifdef FEAT_SPELL
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001863 (char_u *)&p_msm, PV_NONE,
1864 {(char_u *)"460000,2000,500", (char_u *)0L}
1865#else
1866 (char_u *)NULL, PV_NONE,
1867 {(char_u *)0L, (char_u *)0L}
1868#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001869 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001870 {"modeline", "ml", P_BOOL|P_VIM,
1871 (char_u *)&p_ml, PV_ML,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001872 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001873 {"modelines", "mls", P_NUM|P_VI_DEF,
1874 (char_u *)&p_mls, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001875 {(char_u *)5L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001876 {"modifiable", "ma", P_BOOL|P_VI_DEF|P_NOGLOB,
1877 (char_u *)&p_ma, PV_MA,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001878 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001879 {"modified", "mod", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
1880 (char_u *)&p_mod, PV_MOD,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001881 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001882 {"more", NULL, P_BOOL|P_VIM,
1883 (char_u *)&p_more, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001884 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001885 {"mouse", NULL, P_STRING|P_VI_DEF|P_FLAGLIST,
1886 (char_u *)&p_mouse, PV_NONE,
1887 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001888#if defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001889 (char_u *)"a",
1890#else
1891 (char_u *)"",
1892#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001893 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001894 {"mousefocus", "mousef", P_BOOL|P_VI_DEF,
1895#ifdef FEAT_GUI
1896 (char_u *)&p_mousef, PV_NONE,
1897#else
1898 (char_u *)NULL, PV_NONE,
1899#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001900 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001901 {"mousehide", "mh", P_BOOL|P_VI_DEF,
1902#ifdef FEAT_GUI
1903 (char_u *)&p_mh, PV_NONE,
1904#else
1905 (char_u *)NULL, PV_NONE,
1906#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001907 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001908 {"mousemodel", "mousem", P_STRING|P_VI_DEF,
1909 (char_u *)&p_mousem, PV_NONE,
1910 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001911#if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001912 (char_u *)"popup",
1913#else
1914# if defined(MACOS)
1915 (char_u *)"popup_setpos",
1916# else
1917 (char_u *)"extend",
1918# endif
1919#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001920 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001921 {"mouseshape", "mouses", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001922#ifdef FEAT_MOUSESHAPE
1923 (char_u *)&p_mouseshape, PV_NONE,
1924 {(char_u *)"i-r:beam,s:updown,sd:udsizing,vs:leftright,vd:lrsizing,m:no,ml:up-arrow,v:rightup-arrow", (char_u *)0L}
1925#else
1926 (char_u *)NULL, PV_NONE,
1927 {(char_u *)NULL, (char_u *)0L}
1928#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001929 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001930 {"mousetime", "mouset", P_NUM|P_VI_DEF,
1931 (char_u *)&p_mouset, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001932 {(char_u *)500L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar325b7a22004-07-05 15:58:32 +00001933 {"mzquantum", "mzq", P_NUM,
1934#ifdef FEAT_MZSCHEME
1935 (char_u *)&p_mzq, PV_NONE,
1936#else
1937 (char_u *)NULL, PV_NONE,
1938#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001939 {(char_u *)100L, (char_u *)100L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001940 {"novice", NULL, P_BOOL|P_VI_DEF,
1941 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001942 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001943 {"nrformats", "nf", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001944 (char_u *)&p_nf, PV_NF,
Bram Moolenaar887c1fe2016-01-02 17:56:35 +01001945 {(char_u *)"bin,octal,hex", (char_u *)0L}
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001946 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001947 {"number", "nu", P_BOOL|P_VI_DEF|P_RWIN,
1948 (char_u *)VAR_WIN, PV_NU,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001949 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar592e0a22004-07-03 16:05:59 +00001950 {"numberwidth", "nuw", P_NUM|P_RWIN|P_VIM,
1951#ifdef FEAT_LINEBREAK
1952 (char_u *)VAR_WIN, PV_NUW,
1953#else
1954 (char_u *)NULL, PV_NONE,
1955#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001956 {(char_u *)8L, (char_u *)4L} SCRIPTID_INIT},
Bram Moolenaarf75a9632005-09-13 21:20:47 +00001957 {"omnifunc", "ofu", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE,
Bram Moolenaare344bea2005-09-01 20:46:49 +00001958#ifdef FEAT_COMPL_FUNC
1959 (char_u *)&p_ofu, PV_OFU,
1960 {(char_u *)"", (char_u *)0L}
1961#else
1962 (char_u *)NULL, PV_NONE,
1963 {(char_u *)0L, (char_u *)0L}
1964#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001965 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001966 {"open", NULL, P_BOOL|P_VI_DEF,
1967 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001968 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar043545e2006-10-10 16:44:07 +00001969 {"opendevice", "odev", P_BOOL|P_VI_DEF,
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001970#if defined(MSWIN)
Bram Moolenaar043545e2006-10-10 16:44:07 +00001971 (char_u *)&p_odev, PV_NONE,
1972#else
1973 (char_u *)NULL, PV_NONE,
1974#endif
1975 {(char_u *)FALSE, (char_u *)FALSE}
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001976 SCRIPTID_INIT},
Bram Moolenaar2c7a29c2005-12-12 22:02:31 +00001977 {"operatorfunc", "opfunc", P_STRING|P_VI_DEF|P_SECURE,
1978 (char_u *)&p_opfunc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001979 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001980 {"optimize", "opt", P_BOOL|P_VI_DEF,
1981 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001982 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001983 {"osfiletype", "oft", P_STRING|P_ALLOCED|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001984 (char_u *)NULL, PV_NONE,
Bram Moolenaarb07269a2011-05-19 13:41:14 +02001985 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf6fee0e2016-02-21 23:02:49 +01001986 {"packpath", "pp", P_STRING|P_VI_DEF|P_EXPAND|P_ONECOMMA|P_NODUP
1987 |P_SECURE,
1988 (char_u *)&p_pp, PV_NONE,
1989 {(char_u *)DFLT_RUNTIMEPATH, (char_u *)0L}
1990 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001991 {"paragraphs", "para", P_STRING|P_VI_DEF,
1992 (char_u *)&p_para, PV_NONE,
Bram Moolenaar57e48462008-03-12 16:38:55 +00001993 {(char_u *)"IPLPPPQPP TPHPLIPpLpItpplpipbp",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001994 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +00001995 {"paste", NULL, P_BOOL|P_VI_DEF|P_PRI_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001996 (char_u *)&p_paste, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001997 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001998 {"pastetoggle", "pt", P_STRING|P_VI_DEF,
1999 (char_u *)&p_pt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002000 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002001 {"patchexpr", "pex", P_STRING|P_VI_DEF|P_SECURE,
2002#if defined(FEAT_DIFF) && defined(FEAT_EVAL)
2003 (char_u *)&p_pex, PV_NONE,
2004 {(char_u *)"", (char_u *)0L}
2005#else
2006 (char_u *)NULL, PV_NONE,
2007 {(char_u *)0L, (char_u *)0L}
2008#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002009 SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002010 {"patchmode", "pm", P_STRING|P_VI_DEF|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002011 (char_u *)&p_pm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002012 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002013 {"path", "pa", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002014 (char_u *)&p_path, PV_PATH,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002015 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002016#if defined(AMIGA) || defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002017 (char_u *)".,,",
2018#else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002019 (char_u *)".,/usr/include,,",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002020#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002021 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002022#if defined(DYNAMIC_PERL)
Bram Moolenaara6e42502016-04-20 16:19:52 +02002023 {"perldll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaard94464e2015-11-02 15:28:18 +01002024 (char_u *)&p_perldll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002025 {(char_u *)DYNAMIC_PERL_DLL, (char_u *)0L}
2026 SCRIPTID_INIT},
Bram Moolenaard94464e2015-11-02 15:28:18 +01002027#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002028 {"preserveindent", "pi", P_BOOL|P_VI_DEF|P_VIM,
2029 (char_u *)&p_pi, PV_PI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002030 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar592e0a22004-07-03 16:05:59 +00002031 {"previewheight", "pvh", P_NUM|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002032#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
2033 (char_u *)&p_pvh, PV_NONE,
2034#else
2035 (char_u *)NULL, PV_NONE,
2036#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002037 {(char_u *)12L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002038 {"previewwindow", "pvw", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB,
2039#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
2040 (char_u *)VAR_WIN, PV_PVW,
2041#else
2042 (char_u *)NULL, PV_NONE,
2043#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002044 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002045 {"printdevice", "pdev", P_STRING|P_VI_DEF|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002046#ifdef FEAT_PRINTER
2047 (char_u *)&p_pdev, PV_NONE,
2048 {(char_u *)"", (char_u *)0L}
2049#else
2050 (char_u *)NULL, PV_NONE,
2051 {(char_u *)NULL, (char_u *)0L}
2052#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002053 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002054 {"printencoding", "penc", P_STRING|P_VI_DEF,
2055#ifdef FEAT_POSTSCRIPT
2056 (char_u *)&p_penc, PV_NONE,
2057 {(char_u *)"", (char_u *)0L}
2058#else
2059 (char_u *)NULL, PV_NONE,
2060 {(char_u *)NULL, (char_u *)0L}
2061#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002062 SCRIPTID_INIT},
Bram Moolenaar031cb742016-11-24 21:46:19 +01002063 {"printexpr", "pexpr", P_STRING|P_VI_DEF|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002064#ifdef FEAT_POSTSCRIPT
2065 (char_u *)&p_pexpr, PV_NONE,
2066 {(char_u *)"", (char_u *)0L}
2067#else
2068 (char_u *)NULL, PV_NONE,
2069 {(char_u *)NULL, (char_u *)0L}
2070#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002071 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002072 {"printfont", "pfn", P_STRING|P_VI_DEF,
2073#ifdef FEAT_PRINTER
2074 (char_u *)&p_pfn, PV_NONE,
2075 {
2076# ifdef MSWIN
2077 (char_u *)"Courier_New:h10",
2078# else
2079 (char_u *)"courier",
2080# endif
2081 (char_u *)0L}
2082#else
2083 (char_u *)NULL, PV_NONE,
2084 {(char_u *)NULL, (char_u *)0L}
2085#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002086 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002087 {"printheader", "pheader", P_STRING|P_VI_DEF|P_GETTEXT,
2088#ifdef FEAT_PRINTER
2089 (char_u *)&p_header, PV_NONE,
2090 {(char_u *)N_("%<%f%h%m%=Page %N"), (char_u *)0L}
2091#else
2092 (char_u *)NULL, PV_NONE,
2093 {(char_u *)NULL, (char_u *)0L}
2094#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002095 SCRIPTID_INIT},
Bram Moolenaar8299df92004-07-10 09:47:34 +00002096 {"printmbcharset", "pmbcs", P_STRING|P_VI_DEF,
2097#if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE)
2098 (char_u *)&p_pmcs, PV_NONE,
2099 {(char_u *)"", (char_u *)0L}
2100#else
2101 (char_u *)NULL, PV_NONE,
2102 {(char_u *)NULL, (char_u *)0L}
2103#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002104 SCRIPTID_INIT},
Bram Moolenaar8299df92004-07-10 09:47:34 +00002105 {"printmbfont", "pmbfn", P_STRING|P_VI_DEF,
2106#if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE)
2107 (char_u *)&p_pmfn, PV_NONE,
2108 {(char_u *)"", (char_u *)0L}
2109#else
2110 (char_u *)NULL, PV_NONE,
2111 {(char_u *)NULL, (char_u *)0L}
2112#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002113 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002114 {"printoptions", "popt", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002115#ifdef FEAT_PRINTER
2116 (char_u *)&p_popt, PV_NONE,
2117 {(char_u *)"", (char_u *)0L}
2118#else
2119 (char_u *)NULL, PV_NONE,
2120 {(char_u *)NULL, (char_u *)0L}
2121#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002122 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002123 {"prompt", NULL, P_BOOL|P_VI_DEF,
Bram Moolenaar26a60b42005-02-22 08:49:11 +00002124 (char_u *)&p_prompt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002125 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar9d47f172006-03-15 23:03:01 +00002126 {"pumheight", "ph", P_NUM|P_VI_DEF,
2127#ifdef FEAT_INS_EXPAND
2128 (char_u *)&p_ph, PV_NONE,
2129#else
2130 (char_u *)NULL, PV_NONE,
2131#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002132 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002133#if defined(DYNAMIC_PYTHON3)
Bram Moolenaara6e42502016-04-20 16:19:52 +02002134 {"pythonthreedll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaard94464e2015-11-02 15:28:18 +01002135 (char_u *)&p_py3dll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002136 {(char_u *)DYNAMIC_PYTHON3_DLL, (char_u *)0L}
2137 SCRIPTID_INIT},
Bram Moolenaard94464e2015-11-02 15:28:18 +01002138#endif
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002139#if defined(DYNAMIC_PYTHON)
Bram Moolenaara6e42502016-04-20 16:19:52 +02002140 {"pythondll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaard94464e2015-11-02 15:28:18 +01002141 (char_u *)&p_pydll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002142 {(char_u *)DYNAMIC_PYTHON_DLL, (char_u *)0L}
2143 SCRIPTID_INIT},
Bram Moolenaard94464e2015-11-02 15:28:18 +01002144#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00002145 {"quoteescape", "qe", P_STRING|P_ALLOCED|P_VI_DEF,
2146#ifdef FEAT_TEXTOBJ
2147 (char_u *)&p_qe, PV_QE,
2148 {(char_u *)"\\", (char_u *)0L}
2149#else
2150 (char_u *)NULL, PV_NONE,
2151 {(char_u *)NULL, (char_u *)0L}
2152#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002153 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002154 {"readonly", "ro", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB,
2155 (char_u *)&p_ro, PV_RO,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002156 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002157 {"redraw", NULL, P_BOOL|P_VI_DEF,
2158 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002159 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar91a4e822008-01-19 14:59:58 +00002160 {"redrawtime", "rdt", P_NUM|P_VI_DEF,
2161#ifdef FEAT_RELTIME
2162 (char_u *)&p_rdt, PV_NONE,
2163#else
2164 (char_u *)NULL, PV_NONE,
2165#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002166 {(char_u *)2000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarfbc0d2e2013-05-19 19:40:29 +02002167 {"regexpengine", "re", P_NUM|P_VI_DEF,
2168 (char_u *)&p_re, PV_NONE,
2169 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar64486672010-05-16 15:46:46 +02002170 {"relativenumber", "rnu", P_BOOL|P_VI_DEF|P_RWIN,
2171 (char_u *)VAR_WIN, PV_RNU,
2172 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002173 {"remap", NULL, P_BOOL|P_VI_DEF,
2174 (char_u *)&p_remap, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002175 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002176 {"renderoptions", "rop", P_STRING|P_ONECOMMA|P_RCLR|P_VI_DEF,
Bram Moolenaarb5a7a8b2014-08-06 14:52:30 +02002177#ifdef FEAT_RENDER_OPTIONS
2178 (char_u *)&p_rop, PV_NONE,
2179 {(char_u *)"", (char_u *)0L}
2180#else
2181 (char_u *)NULL, PV_NONE,
2182 {(char_u *)NULL, (char_u *)0L}
2183#endif
2184 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002185 {"report", NULL, P_NUM|P_VI_DEF,
2186 (char_u *)&p_report, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002187 {(char_u *)2L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002188 {"restorescreen", "rs", P_BOOL|P_VI_DEF,
2189#ifdef WIN3264
2190 (char_u *)&p_rs, PV_NONE,
2191#else
2192 (char_u *)NULL, PV_NONE,
2193#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002194 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002195 {"revins", "ri", P_BOOL|P_VI_DEF|P_VIM,
2196#ifdef FEAT_RIGHTLEFT
2197 (char_u *)&p_ri, PV_NONE,
2198#else
2199 (char_u *)NULL, PV_NONE,
2200#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002201 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002202 {"rightleft", "rl", P_BOOL|P_VI_DEF|P_RWIN,
2203#ifdef FEAT_RIGHTLEFT
2204 (char_u *)VAR_WIN, PV_RL,
2205#else
2206 (char_u *)NULL, PV_NONE,
2207#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002208 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002209 {"rightleftcmd", "rlc", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN,
2210#ifdef FEAT_RIGHTLEFT
2211 (char_u *)VAR_WIN, PV_RLC,
2212 {(char_u *)"search", (char_u *)NULL}
2213#else
2214 (char_u *)NULL, PV_NONE,
2215 {(char_u *)NULL, (char_u *)0L}
2216#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002217 SCRIPTID_INIT},
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002218#if defined(DYNAMIC_RUBY)
Bram Moolenaara6e42502016-04-20 16:19:52 +02002219 {"rubydll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaard94464e2015-11-02 15:28:18 +01002220 (char_u *)&p_rubydll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002221 {(char_u *)DYNAMIC_RUBY_DLL, (char_u *)0L}
2222 SCRIPTID_INIT},
Bram Moolenaard94464e2015-11-02 15:28:18 +01002223#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002224 {"ruler", "ru", P_BOOL|P_VI_DEF|P_VIM|P_RSTAT,
2225#ifdef FEAT_CMDL_INFO
2226 (char_u *)&p_ru, PV_NONE,
2227#else
2228 (char_u *)NULL, PV_NONE,
2229#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002230 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002231 {"rulerformat", "ruf", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT,
2232#ifdef FEAT_STL_OPT
2233 (char_u *)&p_ruf, PV_NONE,
2234#else
2235 (char_u *)NULL, PV_NONE,
2236#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002237 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002238 {"runtimepath", "rtp", P_STRING|P_VI_DEF|P_EXPAND|P_ONECOMMA|P_NODUP
2239 |P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002240 (char_u *)&p_rtp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002241 {(char_u *)DFLT_RUNTIMEPATH, (char_u *)0L}
2242 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002243 {"scroll", "scr", P_NUM|P_NO_MKRC|P_VI_DEF,
2244 (char_u *)VAR_WIN, PV_SCROLL,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002245 {(char_u *)12L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002246 {"scrollbind", "scb", P_BOOL|P_VI_DEF,
2247#ifdef FEAT_SCROLLBIND
2248 (char_u *)VAR_WIN, PV_SCBIND,
2249#else
2250 (char_u *)NULL, PV_NONE,
2251#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002252 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002253 {"scrolljump", "sj", P_NUM|P_VI_DEF|P_VIM,
2254 (char_u *)&p_sj, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002255 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002256 {"scrolloff", "so", P_NUM|P_VI_DEF|P_VIM|P_RALL,
2257 (char_u *)&p_so, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002258 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002259 {"scrollopt", "sbo", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002260#ifdef FEAT_SCROLLBIND
2261 (char_u *)&p_sbo, PV_NONE,
2262 {(char_u *)"ver,jump", (char_u *)0L}
2263#else
2264 (char_u *)NULL, PV_NONE,
2265 {(char_u *)0L, (char_u *)0L}
2266#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002267 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002268 {"sections", "sect", P_STRING|P_VI_DEF,
2269 (char_u *)&p_sections, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002270 {(char_u *)"SHNHH HUnhsh", (char_u *)0L}
2271 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002272 {"secure", NULL, P_BOOL|P_VI_DEF|P_SECURE,
2273 (char_u *)&p_secure, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002274 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002275 {"selection", "sel", P_STRING|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002276 (char_u *)&p_sel, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002277 {(char_u *)"inclusive", (char_u *)0L}
2278 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002279 {"selectmode", "slm", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002280 (char_u *)&p_slm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002281 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002282 {"sessionoptions", "ssop", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002283#ifdef FEAT_SESSION
2284 (char_u *)&p_ssop, PV_NONE,
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00002285 {(char_u *)"blank,buffers,curdir,folds,help,options,tabpages,winsize",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002286 (char_u *)0L}
2287#else
2288 (char_u *)NULL, PV_NONE,
2289 {(char_u *)0L, (char_u *)0L}
2290#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002291 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002292 {"shell", "sh", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2293 (char_u *)&p_sh, PV_NONE,
2294 {
2295#ifdef VMS
2296 (char_u *)"-",
2297#else
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002298# if defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002299 (char_u *)"", /* set in set_init_1() */
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002300# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002301 (char_u *)"sh",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002302# endif
2303#endif /* VMS */
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002304 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002305 {"shellcmdflag","shcf", P_STRING|P_VI_DEF|P_SECURE,
2306 (char_u *)&p_shcf, PV_NONE,
2307 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002308#if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002309 (char_u *)"/c",
2310#else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002311 (char_u *)"-c",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002312#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002313 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002314 {"shellpipe", "sp", P_STRING|P_VI_DEF|P_SECURE,
2315#ifdef FEAT_QUICKFIX
2316 (char_u *)&p_sp, PV_NONE,
2317 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01002318#if defined(UNIX)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002319 (char_u *)"| tee",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002320#else
2321 (char_u *)">",
2322#endif
2323 (char_u *)0L}
2324#else
2325 (char_u *)NULL, PV_NONE,
2326 {(char_u *)0L, (char_u *)0L}
2327#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002328 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002329 {"shellquote", "shq", P_STRING|P_VI_DEF|P_SECURE,
2330 (char_u *)&p_shq, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002331 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002332 {"shellredir", "srr", P_STRING|P_VI_DEF|P_SECURE,
2333 (char_u *)&p_srr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002334 {(char_u *)">", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002335 {"shellslash", "ssl", P_BOOL|P_VI_DEF,
2336#ifdef BACKSLASH_IN_FILENAME
2337 (char_u *)&p_ssl, PV_NONE,
2338#else
2339 (char_u *)NULL, PV_NONE,
2340#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002341 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar26a60b42005-02-22 08:49:11 +00002342 {"shelltemp", "stmp", P_BOOL,
2343 (char_u *)&p_stmp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002344 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002345 {"shelltype", "st", P_NUM|P_VI_DEF,
2346#ifdef AMIGA
2347 (char_u *)&p_st, PV_NONE,
2348#else
2349 (char_u *)NULL, PV_NONE,
2350#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002351 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002352 {"shellxquote", "sxq", P_STRING|P_VI_DEF|P_SECURE,
2353 (char_u *)&p_sxq, PV_NONE,
2354 {
Bram Moolenaara06ecab2016-07-16 14:47:36 +02002355#if defined(UNIX) && defined(USE_SYSTEM)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002356 (char_u *)"\"",
2357#else
2358 (char_u *)"",
2359#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002360 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf66b3fc2012-02-20 22:18:30 +01002361 {"shellxescape", "sxe", P_STRING|P_VI_DEF|P_SECURE,
2362 (char_u *)&p_sxe, PV_NONE,
2363 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002364#if defined(WIN3264)
Bram Moolenaarf66b3fc2012-02-20 22:18:30 +01002365 (char_u *)"\"&|<>()@^",
2366#else
2367 (char_u *)"",
2368#endif
2369 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002370 {"shiftround", "sr", P_BOOL|P_VI_DEF|P_VIM,
2371 (char_u *)&p_sr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002372 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002373 {"shiftwidth", "sw", P_NUM|P_VI_DEF,
2374 (char_u *)&p_sw, PV_SW,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002375 {(char_u *)8L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002376 {"shortmess", "shm", P_STRING|P_VIM|P_FLAGLIST,
2377 (char_u *)&p_shm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002378 {(char_u *)"", (char_u *)"filnxtToO"}
2379 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002380 {"shortname", "sn", P_BOOL|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002381 (char_u *)&p_sn, PV_SN,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002382 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002383 {"showbreak", "sbr", P_STRING|P_VI_DEF|P_RALL,
2384#ifdef FEAT_LINEBREAK
2385 (char_u *)&p_sbr, PV_NONE,
2386#else
2387 (char_u *)NULL, PV_NONE,
2388#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002389 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002390 {"showcmd", "sc", P_BOOL|P_VIM,
2391#ifdef FEAT_CMDL_INFO
2392 (char_u *)&p_sc, PV_NONE,
2393#else
2394 (char_u *)NULL, PV_NONE,
2395#endif
2396 {(char_u *)FALSE,
2397#ifdef UNIX
2398 (char_u *)FALSE
2399#else
2400 (char_u *)TRUE
2401#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002402 } SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002403 {"showfulltag", "sft", P_BOOL|P_VI_DEF,
2404 (char_u *)&p_sft, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002405 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002406 {"showmatch", "sm", P_BOOL|P_VI_DEF,
2407 (char_u *)&p_sm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002408 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002409 {"showmode", "smd", P_BOOL|P_VIM,
2410 (char_u *)&p_smd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002411 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00002412 {"showtabline", "stal", P_NUM|P_VI_DEF|P_RALL,
2413#ifdef FEAT_WINDOWS
2414 (char_u *)&p_stal, PV_NONE,
2415#else
2416 (char_u *)NULL, PV_NONE,
2417#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002418 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002419 {"sidescroll", "ss", P_NUM|P_VI_DEF,
2420 (char_u *)&p_ss, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002421 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002422 {"sidescrolloff", "siso", P_NUM|P_VI_DEF|P_VIM|P_RBUF,
2423 (char_u *)&p_siso, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002424 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar95ec9d62016-08-12 18:29:59 +02002425 {"signcolumn", "scl", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN,
2426#ifdef FEAT_SIGNS
2427 (char_u *)VAR_WIN, PV_SCL,
Bram Moolenaarb3384832016-08-12 18:51:58 +02002428 {(char_u *)"auto", (char_u *)0L}
Bram Moolenaar95ec9d62016-08-12 18:29:59 +02002429#else
2430 (char_u *)NULL, PV_NONE,
2431 {(char_u *)NULL, (char_u *)0L}
2432#endif
Bram Moolenaarb3384832016-08-12 18:51:58 +02002433 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002434 {"slowopen", "slow", P_BOOL|P_VI_DEF,
2435 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002436 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002437 {"smartcase", "scs", P_BOOL|P_VI_DEF|P_VIM,
2438 (char_u *)&p_scs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002439 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002440 {"smartindent", "si", P_BOOL|P_VI_DEF|P_VIM,
2441#ifdef FEAT_SMARTINDENT
2442 (char_u *)&p_si, PV_SI,
2443#else
2444 (char_u *)NULL, PV_NONE,
2445#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002446 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002447 {"smarttab", "sta", P_BOOL|P_VI_DEF|P_VIM,
2448 (char_u *)&p_sta, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002449 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002450 {"softtabstop", "sts", P_NUM|P_VI_DEF|P_VIM,
2451 (char_u *)&p_sts, PV_STS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002452 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002453 {"sourceany", NULL, P_BOOL|P_VI_DEF,
2454 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002455 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar217ad922005-03-20 22:37:15 +00002456 {"spell", NULL, P_BOOL|P_VI_DEF|P_RWIN,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002457#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +00002458 (char_u *)VAR_WIN, PV_SPELL,
2459#else
2460 (char_u *)NULL, PV_NONE,
2461#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002462 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar488c6512005-08-11 20:09:58 +00002463 {"spellcapcheck", "spc", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002464#ifdef FEAT_SPELL
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00002465 (char_u *)&p_spc, PV_SPC,
Bram Moolenaar0dc065e2005-07-04 22:49:24 +00002466 {(char_u *)"[.?!]\\_[\\])'\" ]\\+", (char_u *)0L}
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00002467#else
2468 (char_u *)NULL, PV_NONE,
2469 {(char_u *)0L, (char_u *)0L}
2470#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002471 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002472 {"spellfile", "spf", P_STRING|P_EXPAND|P_ALLOCED|P_VI_DEF|P_SECURE
2473 |P_ONECOMMA,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002474#ifdef FEAT_SPELL
Bram Moolenaar82cf9b62005-06-07 21:09:25 +00002475 (char_u *)&p_spf, PV_SPF,
2476 {(char_u *)"", (char_u *)0L}
2477#else
2478 (char_u *)NULL, PV_NONE,
2479 {(char_u *)0L, (char_u *)0L}
2480#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002481 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002482 {"spelllang", "spl", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA
2483 |P_RBUF|P_EXPAND,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002484#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +00002485 (char_u *)&p_spl, PV_SPL,
Bram Moolenaar82cf9b62005-06-07 21:09:25 +00002486 {(char_u *)"en", (char_u *)0L}
Bram Moolenaar217ad922005-03-20 22:37:15 +00002487#else
2488 (char_u *)NULL, PV_NONE,
2489 {(char_u *)0L, (char_u *)0L}
2490#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002491 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002492 {"spellsuggest", "sps", P_STRING|P_VI_DEF|P_EXPAND|P_SECURE|P_ONECOMMA,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002493#ifdef FEAT_SPELL
Bram Moolenaard857f0e2005-06-21 22:37:39 +00002494 (char_u *)&p_sps, PV_NONE,
2495 {(char_u *)"best", (char_u *)0L}
2496#else
2497 (char_u *)NULL, PV_NONE,
2498 {(char_u *)0L, (char_u *)0L}
2499#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002500 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002501 {"splitbelow", "sb", P_BOOL|P_VI_DEF,
2502#ifdef FEAT_WINDOWS
2503 (char_u *)&p_sb, PV_NONE,
2504#else
2505 (char_u *)NULL, PV_NONE,
2506#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002507 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002508 {"splitright", "spr", P_BOOL|P_VI_DEF,
Bram Moolenaar44a2f922016-03-19 22:11:51 +01002509#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002510 (char_u *)&p_spr, PV_NONE,
2511#else
2512 (char_u *)NULL, PV_NONE,
2513#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002514 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002515 {"startofline", "sol", P_BOOL|P_VI_DEF|P_VIM,
2516 (char_u *)&p_sol, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002517 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002518 {"statusline" ,"stl", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT,
2519#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002520 (char_u *)&p_stl, PV_STL,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002521#else
2522 (char_u *)NULL, PV_NONE,
2523#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002524 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002525 {"suffixes", "su", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002526 (char_u *)&p_su, PV_NONE,
2527 {(char_u *)".bak,~,.o,.h,.info,.swp,.obj",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002528 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002529 {"suffixesadd", "sua", P_STRING|P_VI_DEF|P_ALLOCED|P_ONECOMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002530#ifdef FEAT_SEARCHPATH
Bram Moolenaar071d4272004-06-13 20:20:40 +00002531 (char_u *)&p_sua, PV_SUA,
2532 {(char_u *)"", (char_u *)0L}
2533#else
2534 (char_u *)NULL, PV_NONE,
2535 {(char_u *)0L, (char_u *)0L}
2536#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002537 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002538 {"swapfile", "swf", P_BOOL|P_VI_DEF|P_RSTAT,
2539 (char_u *)&p_swf, PV_SWF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002540 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002541 {"swapsync", "sws", P_STRING|P_VI_DEF,
2542 (char_u *)&p_sws, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002543 {(char_u *)"fsync", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002544 {"switchbuf", "swb", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002545 (char_u *)&p_swb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002546 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar3b56eb32005-07-11 22:40:32 +00002547 {"synmaxcol", "smc", P_NUM|P_VI_DEF|P_RBUF,
2548#ifdef FEAT_SYN_HL
2549 (char_u *)&p_smc, PV_SMC,
2550 {(char_u *)3000L, (char_u *)0L}
2551#else
2552 (char_u *)NULL, PV_NONE,
2553 {(char_u *)0L, (char_u *)0L}
2554#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002555 SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002556 {"syntax", "syn", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002557#ifdef FEAT_SYN_HL
2558 (char_u *)&p_syn, PV_SYN,
2559 {(char_u *)"", (char_u *)0L}
2560#else
2561 (char_u *)NULL, PV_NONE,
2562 {(char_u *)0L, (char_u *)0L}
2563#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002564 SCRIPTID_INIT},
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00002565 {"tabline", "tal", P_STRING|P_VI_DEF|P_RALL,
2566#ifdef FEAT_STL_OPT
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00002567 (char_u *)&p_tal, PV_NONE,
2568#else
2569 (char_u *)NULL, PV_NONE,
2570#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002571 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarfd2ac762006-03-01 22:09:21 +00002572 {"tabpagemax", "tpm", P_NUM|P_VI_DEF,
2573#ifdef FEAT_WINDOWS
2574 (char_u *)&p_tpm, PV_NONE,
2575#else
2576 (char_u *)NULL, PV_NONE,
2577#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002578 {(char_u *)10L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002579 {"tabstop", "ts", P_NUM|P_VI_DEF|P_RBUF,
2580 (char_u *)&p_ts, PV_TS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002581 {(char_u *)8L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002582 {"tagbsearch", "tbs", P_BOOL|P_VI_DEF,
2583 (char_u *)&p_tbs, PV_NONE,
2584#ifdef VMS /* binary searching doesn't appear to work on VMS */
2585 {(char_u *)0L, (char_u *)0L}
2586#else
2587 {(char_u *)TRUE, (char_u *)0L}
2588#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002589 SCRIPTID_INIT},
Bram Moolenaar0f6562e2015-11-24 18:48:14 +01002590 {"tagcase", "tc", P_STRING|P_VIM,
2591 (char_u *)&p_tc, PV_TC,
2592 {(char_u *)"followic", (char_u *)"followic"} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002593 {"taglength", "tl", P_NUM|P_VI_DEF,
2594 (char_u *)&p_tl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002595 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002596 {"tagrelative", "tr", P_BOOL|P_VIM,
2597 (char_u *)&p_tr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002598 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002599 {"tags", "tag", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002600 (char_u *)&p_tags, PV_TAGS,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002601 {
2602#if defined(FEAT_EMACS_TAGS) && !defined(CASE_INSENSITIVE_FILENAME)
2603 (char_u *)"./tags,./TAGS,tags,TAGS",
2604#else
2605 (char_u *)"./tags,tags",
2606#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002607 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002608 {"tagstack", "tgst", P_BOOL|P_VI_DEF,
2609 (char_u *)&p_tgst, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002610 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01002611#if defined(DYNAMIC_TCL)
Bram Moolenaara6e42502016-04-20 16:19:52 +02002612 {"tcldll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01002613 (char_u *)&p_tcldll, PV_NONE,
2614 {(char_u *)DYNAMIC_TCL_DLL, (char_u *)0L}
2615 SCRIPTID_INIT},
2616#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002617 {"term", NULL, P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL,
2618 (char_u *)&T_NAME, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002619 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002620 {"termbidi", "tbidi", P_BOOL|P_VI_DEF,
2621#ifdef FEAT_ARABIC
2622 (char_u *)&p_tbidi, PV_NONE,
2623#else
2624 (char_u *)NULL, PV_NONE,
2625#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002626 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002627 {"termencoding", "tenc", P_STRING|P_VI_DEF|P_RCLR,
2628#ifdef FEAT_MBYTE
2629 (char_u *)&p_tenc, PV_NONE,
2630 {(char_u *)"", (char_u *)0L}
2631#else
2632 (char_u *)NULL, PV_NONE,
2633 {(char_u *)0L, (char_u *)0L}
2634#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002635 SCRIPTID_INIT},
Bram Moolenaar61be73b2016-04-29 22:59:22 +02002636 {"termguicolors", "tgc", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
2637#ifdef FEAT_TERMGUICOLORS
2638 (char_u *)&p_tgc, PV_NONE,
2639 {(char_u *)FALSE, (char_u *)FALSE}
2640#else
2641 (char_u*)NULL, PV_NONE,
2642 {(char_u *)FALSE, (char_u *)FALSE}
2643#endif
2644 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002645 {"terse", NULL, P_BOOL|P_VI_DEF,
2646 (char_u *)&p_terse, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002647 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002648 {"textauto", "ta", P_BOOL|P_VIM,
2649 (char_u *)&p_ta, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002650 {(char_u *)DFLT_TEXTAUTO, (char_u *)TRUE}
2651 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002652 {"textmode", "tx", P_BOOL|P_VI_DEF|P_NO_MKRC,
2653 (char_u *)&p_tx, PV_TX,
2654 {
2655#ifdef USE_CRNL
2656 (char_u *)TRUE,
2657#else
2658 (char_u *)FALSE,
2659#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002660 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar1a384422010-07-14 19:53:30 +02002661 {"textwidth", "tw", P_NUM|P_VI_DEF|P_VIM|P_RBUF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002662 (char_u *)&p_tw, PV_TW,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002663 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf422bcc2016-11-26 17:45:53 +01002664 {"thesaurus", "tsr", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP|P_NDNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002665#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002666 (char_u *)&p_tsr, PV_TSR,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002667#else
2668 (char_u *)NULL, PV_NONE,
2669#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002670 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002671 {"tildeop", "top", P_BOOL|P_VI_DEF|P_VIM,
2672 (char_u *)&p_to, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002673 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002674 {"timeout", "to", P_BOOL|P_VI_DEF,
2675 (char_u *)&p_timeout, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002676 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002677 {"timeoutlen", "tm", P_NUM|P_VI_DEF,
2678 (char_u *)&p_tm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002679 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002680 {"title", NULL, P_BOOL|P_VI_DEF,
2681#ifdef FEAT_TITLE
2682 (char_u *)&p_title, PV_NONE,
2683#else
2684 (char_u *)NULL, PV_NONE,
2685#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002686 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002687 {"titlelen", NULL, P_NUM|P_VI_DEF,
2688#ifdef FEAT_TITLE
2689 (char_u *)&p_titlelen, PV_NONE,
2690#else
2691 (char_u *)NULL, PV_NONE,
2692#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002693 {(char_u *)85L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00002694 {"titleold", NULL, P_STRING|P_VI_DEF|P_GETTEXT|P_SECURE|P_NO_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002695#ifdef FEAT_TITLE
2696 (char_u *)&p_titleold, PV_NONE,
2697 {(char_u *)N_("Thanks for flying Vim"),
2698 (char_u *)0L}
2699#else
2700 (char_u *)NULL, PV_NONE,
2701 {(char_u *)0L, (char_u *)0L}
2702#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002703 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002704 {"titlestring", NULL, P_STRING|P_VI_DEF,
2705#ifdef FEAT_TITLE
2706 (char_u *)&p_titlestring, PV_NONE,
2707#else
2708 (char_u *)NULL, PV_NONE,
2709#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002710 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002711#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002712 {"toolbar", "tb", P_STRING|P_ONECOMMA|P_VI_DEF|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002713 (char_u *)&p_toolbar, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002714 {(char_u *)"icons,tooltips", (char_u *)0L}
2715 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002716#endif
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002717#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002718 {"toolbariconsize", "tbis", P_STRING|P_VI_DEF,
2719 (char_u *)&p_tbis, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002720 {(char_u *)"small", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002721#endif
2722 {"ttimeout", NULL, P_BOOL|P_VI_DEF|P_VIM,
2723 (char_u *)&p_ttimeout, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002724 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002725 {"ttimeoutlen", "ttm", P_NUM|P_VI_DEF,
2726 (char_u *)&p_ttm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002727 {(char_u *)-1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002728 {"ttybuiltin", "tbi", P_BOOL|P_VI_DEF,
2729 (char_u *)&p_tbi, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002730 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002731 {"ttyfast", "tf", P_BOOL|P_NO_MKRC|P_VI_DEF,
2732 (char_u *)&p_tf, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002733 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002734 {"ttymouse", "ttym", P_STRING|P_NODEFAULT|P_NO_MKRC|P_VI_DEF,
2735#if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
2736 (char_u *)&p_ttym, PV_NONE,
2737#else
2738 (char_u *)NULL, PV_NONE,
2739#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002740 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002741 {"ttyscroll", "tsl", P_NUM|P_VI_DEF,
2742 (char_u *)&p_ttyscroll, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002743 {(char_u *)999L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002744 {"ttytype", "tty", P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL,
2745 (char_u *)&T_NAME, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002746 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002747 {"undodir", "udir", P_STRING|P_EXPAND|P_ONECOMMA|P_NODUP|P_SECURE
2748 |P_VI_DEF,
Bram Moolenaar55debbe2010-05-23 23:34:36 +02002749#ifdef FEAT_PERSISTENT_UNDO
2750 (char_u *)&p_udir, PV_NONE,
2751 {(char_u *)".", (char_u *)0L}
2752#else
2753 (char_u *)NULL, PV_NONE,
2754 {(char_u *)0L, (char_u *)0L}
2755#endif
2756 SCRIPTID_INIT},
2757 {"undofile", "udf", P_BOOL|P_VI_DEF|P_VIM,
2758#ifdef FEAT_PERSISTENT_UNDO
2759 (char_u *)&p_udf, PV_UDF,
2760#else
2761 (char_u *)NULL, PV_NONE,
2762#endif
2763 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002764 {"undolevels", "ul", P_NUM|P_VI_DEF,
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01002765 (char_u *)&p_ul, PV_UL,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002766 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01002767#if defined(UNIX) || defined(WIN3264) || defined(VMS)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002768 (char_u *)1000L,
2769#else
2770 (char_u *)100L,
2771#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002772 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar59f931e2010-07-24 20:27:03 +02002773 {"undoreload", "ur", P_NUM|P_VI_DEF,
2774 (char_u *)&p_ur, PV_NONE,
2775 { (char_u *)10000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002776 {"updatecount", "uc", P_NUM|P_VI_DEF,
2777 (char_u *)&p_uc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002778 {(char_u *)200L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002779 {"updatetime", "ut", P_NUM|P_VI_DEF,
2780 (char_u *)&p_ut, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002781 {(char_u *)4000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002782 {"verbose", "vbs", P_NUM|P_VI_DEF,
2783 (char_u *)&p_verbose, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002784 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar54ee7752005-05-31 22:22:17 +00002785 {"verbosefile", "vfile", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2786 (char_u *)&p_vfile, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002787 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002788 {"viewdir", "vdir", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2789#ifdef FEAT_SESSION
2790 (char_u *)&p_vdir, PV_NONE,
2791 {(char_u *)DFLT_VDIR, (char_u *)0L}
2792#else
2793 (char_u *)NULL, PV_NONE,
2794 {(char_u *)0L, (char_u *)0L}
2795#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002796 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002797 {"viewoptions", "vop", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002798#ifdef FEAT_SESSION
2799 (char_u *)&p_vop, PV_NONE,
2800 {(char_u *)"folds,options,cursor", (char_u *)0L}
2801#else
2802 (char_u *)NULL, PV_NONE,
2803 {(char_u *)0L, (char_u *)0L}
2804#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002805 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002806 {"viminfo", "vi", P_STRING|P_ONECOMMA|P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002807#ifdef FEAT_VIMINFO
2808 (char_u *)&p_viminfo, PV_NONE,
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002809#if defined(MSWIN)
Bram Moolenaard812df62008-11-09 12:46:09 +00002810 {(char_u *)"", (char_u *)"'100,<50,s10,h,rA:,rB:"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002811#else
2812# ifdef AMIGA
2813 {(char_u *)"",
Bram Moolenaard812df62008-11-09 12:46:09 +00002814 (char_u *)"'100,<50,s10,h,rdf0:,rdf1:,rdf2:"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002815# else
Bram Moolenaard812df62008-11-09 12:46:09 +00002816 {(char_u *)"", (char_u *)"'100,<50,s10,h"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002817# endif
2818#endif
2819#else
2820 (char_u *)NULL, PV_NONE,
2821 {(char_u *)0L, (char_u *)0L}
2822#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002823 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002824 {"virtualedit", "ve", P_STRING|P_ONECOMMA|P_NODUP|P_VI_DEF
2825 |P_VIM|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002826#ifdef FEAT_VIRTUALEDIT
2827 (char_u *)&p_ve, PV_NONE,
2828 {(char_u *)"", (char_u *)""}
2829#else
2830 (char_u *)NULL, PV_NONE,
2831 {(char_u *)0L, (char_u *)0L}
2832#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002833 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002834 {"visualbell", "vb", P_BOOL|P_VI_DEF,
2835 (char_u *)&p_vb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002836 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002837 {"w300", NULL, P_NUM|P_VI_DEF,
2838 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002839 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002840 {"w1200", NULL, P_NUM|P_VI_DEF,
2841 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002842 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002843 {"w9600", NULL, P_NUM|P_VI_DEF,
2844 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002845 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002846 {"warn", NULL, P_BOOL|P_VI_DEF,
2847 (char_u *)&p_warn, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002848 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002849 {"weirdinvert", "wiv", P_BOOL|P_VI_DEF|P_RCLR,
2850 (char_u *)&p_wiv, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002851 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002852 {"whichwrap", "ww", P_STRING|P_VIM|P_ONECOMMA|P_FLAGLIST,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002853 (char_u *)&p_ww, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002854 {(char_u *)"", (char_u *)"b,s"} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002855 {"wildchar", "wc", P_NUM|P_VIM,
2856 (char_u *)&p_wc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002857 {(char_u *)(long)Ctrl_E, (char_u *)(long)TAB}
2858 SCRIPTID_INIT},
Bram Moolenaar94950a92010-12-02 16:01:29 +01002859 {"wildcharm", "wcm", P_NUM|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002860 (char_u *)&p_wcm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002861 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002862 {"wildignore", "wig", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002863#ifdef FEAT_WILDIGN
2864 (char_u *)&p_wig, PV_NONE,
2865#else
2866 (char_u *)NULL, PV_NONE,
2867#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002868 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar94950a92010-12-02 16:01:29 +01002869 {"wildignorecase", "wic", P_BOOL|P_VI_DEF,
2870 (char_u *)&p_wic, PV_NONE,
2871 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002872 {"wildmenu", "wmnu", P_BOOL|P_VI_DEF,
2873#ifdef FEAT_WILDMENU
2874 (char_u *)&p_wmnu, PV_NONE,
2875#else
2876 (char_u *)NULL, PV_NONE,
2877#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002878 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002879 {"wildmode", "wim", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002880 (char_u *)&p_wim, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002881 {(char_u *)"full", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00002882 {"wildoptions", "wop", P_STRING|P_VI_DEF,
2883#ifdef FEAT_CMDL_COMPL
2884 (char_u *)&p_wop, PV_NONE,
2885 {(char_u *)"", (char_u *)0L}
2886#else
2887 (char_u *)NULL, PV_NONE,
2888 {(char_u *)NULL, (char_u *)0L}
2889#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002890 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002891 {"winaltkeys", "wak", P_STRING|P_VI_DEF,
2892#ifdef FEAT_WAK
2893 (char_u *)&p_wak, PV_NONE,
2894 {(char_u *)"menu", (char_u *)0L}
2895#else
2896 (char_u *)NULL, PV_NONE,
2897 {(char_u *)NULL, (char_u *)0L}
2898#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002899 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002900 {"window", "wi", P_NUM|P_VI_DEF,
Bram Moolenaar4399ef42005-02-12 14:29:27 +00002901 (char_u *)&p_window, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002902 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002903 {"winheight", "wh", P_NUM|P_VI_DEF,
2904#ifdef FEAT_WINDOWS
2905 (char_u *)&p_wh, PV_NONE,
2906#else
2907 (char_u *)NULL, PV_NONE,
2908#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002909 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002910 {"winfixheight", "wfh", P_BOOL|P_VI_DEF|P_RSTAT,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002911#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002912 (char_u *)VAR_WIN, PV_WFH,
2913#else
2914 (char_u *)NULL, PV_NONE,
2915#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002916 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002917 {"winfixwidth", "wfw", P_BOOL|P_VI_DEF|P_RSTAT,
Bram Moolenaar44a2f922016-03-19 22:11:51 +01002918#ifdef FEAT_WINDOWS
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002919 (char_u *)VAR_WIN, PV_WFW,
2920#else
2921 (char_u *)NULL, PV_NONE,
2922#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002923 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002924 {"winminheight", "wmh", P_NUM|P_VI_DEF,
2925#ifdef FEAT_WINDOWS
2926 (char_u *)&p_wmh, PV_NONE,
2927#else
2928 (char_u *)NULL, PV_NONE,
2929#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002930 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002931 {"winminwidth", "wmw", P_NUM|P_VI_DEF,
Bram Moolenaar44a2f922016-03-19 22:11:51 +01002932#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002933 (char_u *)&p_wmw, PV_NONE,
2934#else
2935 (char_u *)NULL, PV_NONE,
2936#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002937 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002938 {"winwidth", "wiw", P_NUM|P_VI_DEF,
Bram Moolenaar44a2f922016-03-19 22:11:51 +01002939#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002940 (char_u *)&p_wiw, PV_NONE,
2941#else
2942 (char_u *)NULL, PV_NONE,
2943#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002944 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002945 {"wrap", NULL, P_BOOL|P_VI_DEF|P_RWIN,
2946 (char_u *)VAR_WIN, PV_WRAP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002947 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002948 {"wrapmargin", "wm", P_NUM|P_VI_DEF,
2949 (char_u *)&p_wm, PV_WM,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002950 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002951 {"wrapscan", "ws", P_BOOL|P_VI_DEF,
2952 (char_u *)&p_ws, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002953 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002954 {"write", NULL, P_BOOL|P_VI_DEF,
2955 (char_u *)&p_write, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002956 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002957 {"writeany", "wa", P_BOOL|P_VI_DEF,
2958 (char_u *)&p_wa, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002959 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002960 {"writebackup", "wb", P_BOOL|P_VI_DEF|P_VIM,
2961 (char_u *)&p_wb, PV_NONE,
2962 {
2963#ifdef FEAT_WRITEBACKUP
2964 (char_u *)TRUE,
2965#else
2966 (char_u *)FALSE,
2967#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002968 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002969 {"writedelay", "wd", P_NUM|P_VI_DEF,
2970 (char_u *)&p_wd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002971 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002972
2973/* terminal output codes */
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002974#define p_term(sss, vvv) {sss, NULL, P_STRING|P_VI_DEF|P_RALL|P_SECURE, \
Bram Moolenaar071d4272004-06-13 20:20:40 +00002975 (char_u *)&vvv, PV_NONE, \
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002976 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002977
2978 p_term("t_AB", T_CAB)
2979 p_term("t_AF", T_CAF)
2980 p_term("t_AL", T_CAL)
2981 p_term("t_al", T_AL)
2982 p_term("t_bc", T_BC)
2983 p_term("t_cd", T_CD)
2984 p_term("t_ce", T_CE)
2985 p_term("t_cl", T_CL)
2986 p_term("t_cm", T_CM)
Bram Moolenaar450ca432015-11-10 13:30:39 +01002987 p_term("t_Ce", T_UCE)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002988 p_term("t_Co", T_CCO)
2989 p_term("t_CS", T_CCS)
Bram Moolenaar450ca432015-11-10 13:30:39 +01002990 p_term("t_Cs", T_UCS)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002991 p_term("t_cs", T_CS)
Bram Moolenaar44a2f922016-03-19 22:11:51 +01002992#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002993 p_term("t_CV", T_CSV)
2994#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002995 p_term("t_da", T_DA)
2996 p_term("t_db", T_DB)
2997 p_term("t_DL", T_CDL)
2998 p_term("t_dl", T_DL)
Bram Moolenaare5401222015-06-25 19:16:56 +02002999 p_term("t_EI", T_CEI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003000 p_term("t_fs", T_FS)
3001 p_term("t_IE", T_CIE)
3002 p_term("t_IS", T_CIS)
3003 p_term("t_ke", T_KE)
3004 p_term("t_ks", T_KS)
3005 p_term("t_le", T_LE)
3006 p_term("t_mb", T_MB)
3007 p_term("t_md", T_MD)
3008 p_term("t_me", T_ME)
3009 p_term("t_mr", T_MR)
3010 p_term("t_ms", T_MS)
3011 p_term("t_nd", T_ND)
3012 p_term("t_op", T_OP)
Bram Moolenaare5401222015-06-25 19:16:56 +02003013 p_term("t_RB", T_RBG)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003014 p_term("t_RI", T_CRI)
3015 p_term("t_RV", T_CRV)
3016 p_term("t_Sb", T_CSB)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003017 p_term("t_se", T_SE)
Bram Moolenaare5401222015-06-25 19:16:56 +02003018 p_term("t_Sf", T_CSF)
3019 p_term("t_SI", T_CSI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003020 p_term("t_so", T_SO)
Bram Moolenaare5401222015-06-25 19:16:56 +02003021 p_term("t_SR", T_CSR)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003022 p_term("t_sr", T_SR)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003023 p_term("t_te", T_TE)
3024 p_term("t_ti", T_TI)
Bram Moolenaare5401222015-06-25 19:16:56 +02003025 p_term("t_ts", T_TS)
3026 p_term("t_u7", T_U7)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003027 p_term("t_ue", T_UE)
3028 p_term("t_us", T_US)
Bram Moolenaare5401222015-06-25 19:16:56 +02003029 p_term("t_ut", T_UT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003030 p_term("t_vb", T_VB)
3031 p_term("t_ve", T_VE)
3032 p_term("t_vi", T_VI)
3033 p_term("t_vs", T_VS)
3034 p_term("t_WP", T_CWP)
3035 p_term("t_WS", T_CWS)
Bram Moolenaar494838a2015-02-10 19:20:37 +01003036 p_term("t_xn", T_XN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003037 p_term("t_xs", T_XS)
3038 p_term("t_ZH", T_CZH)
3039 p_term("t_ZR", T_CZR)
Bram Moolenaar8a633e32016-04-21 21:10:14 +02003040 p_term("t_8f", T_8F)
3041 p_term("t_8b", T_8B)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003042
3043/* terminal key codes are not in here */
3044
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003045 /* end marker */
3046 {NULL, NULL, 0, NULL, PV_NONE, {NULL, NULL} SCRIPTID_INIT}
Bram Moolenaar071d4272004-06-13 20:20:40 +00003047};
3048
3049#define PARAM_COUNT (sizeof(options) / sizeof(struct vimoption))
3050
3051#ifdef FEAT_MBYTE
3052static char *(p_ambw_values[]) = {"single", "double", NULL};
3053#endif
3054static char *(p_bg_values[]) = {"light", "dark", NULL};
Bram Moolenaar887c1fe2016-01-02 17:56:35 +01003055static char *(p_nf_values[]) = {"bin", "octal", "hex", "alpha", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003056static char *(p_ff_values[]) = {FF_UNIX, FF_DOS, FF_MAC, NULL};
Bram Moolenaar49771f42010-07-20 17:32:38 +02003057#ifdef FEAT_CRYPT
Bram Moolenaar8f4ac012014-08-10 13:38:34 +02003058static char *(p_cm_values[]) = {"zip", "blowfish", "blowfish2", NULL};
Bram Moolenaar49771f42010-07-20 17:32:38 +02003059#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00003060#ifdef FEAT_CMDL_COMPL
3061static char *(p_wop_values[]) = {"tagfile", NULL};
3062#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003063#ifdef FEAT_WAK
3064static char *(p_wak_values[]) = {"yes", "menu", "no", NULL};
3065#endif
3066static char *(p_mousem_values[]) = {"extend", "popup", "popup_setpos", "mac", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003067static char *(p_sel_values[]) = {"inclusive", "exclusive", "old", NULL};
3068static char *(p_slm_values[]) = {"mouse", "key", "cmd", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003069static char *(p_km_values[]) = {"startsel", "stopsel", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003070#ifdef FEAT_BROWSE
3071static char *(p_bsdir_values[]) = {"current", "last", "buffer", NULL};
3072#endif
3073#ifdef FEAT_SCROLLBIND
3074static char *(p_scbopt_values[]) = {"ver", "hor", "jump", NULL};
3075#endif
Bram Moolenaar57657d82006-04-21 22:12:41 +00003076static char *(p_debug_values[]) = {"msg", "throw", "beep", NULL};
Bram Moolenaar44a2f922016-03-19 22:11:51 +01003077#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00003078static char *(p_ead_values[]) = {"both", "ver", "hor", NULL};
3079#endif
3080#if defined(FEAT_QUICKFIX)
Bram Moolenaar21cf8232004-07-16 20:18:37 +00003081# ifdef FEAT_AUTOCMD
3082static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", "acwrite", NULL};
3083# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00003084static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", NULL};
Bram Moolenaar21cf8232004-07-16 20:18:37 +00003085# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003086static char *(p_bufhidden_values[]) = {"hide", "unload", "delete", "wipe", NULL};
3087#endif
3088static char *(p_bs_values[]) = {"indent", "eol", "start", NULL};
3089#ifdef FEAT_FOLDING
3090static char *(p_fdm_values[]) = {"manual", "expr", "marker", "indent", "syntax",
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003091# ifdef FEAT_DIFF
Bram Moolenaar071d4272004-06-13 20:20:40 +00003092 "diff",
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003093# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003094 NULL};
3095static char *(p_fcl_values[]) = {"all", NULL};
3096#endif
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003097#ifdef FEAT_INS_EXPAND
Bram Moolenaarb6be1e22015-07-10 18:18:40 +02003098static char *(p_cot_values[]) = {"menu", "menuone", "longest", "preview", "noinsert", "noselect", NULL};
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003099#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +02003100#ifdef FEAT_SIGNS
3101static char *(p_scl_values[]) = {"yes", "no", "auto", NULL};
3102#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003103
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003104static void set_option_default(int, int opt_flags, int compatible);
3105static void set_options_default(int opt_flags);
3106static char_u *term_bg_default(void);
3107static void did_set_option(int opt_idx, int opt_flags, int new_value);
3108static char_u *illegal_char(char_u *, int);
3109static int string_to_key(char_u *arg);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003110#ifdef FEAT_CMDWIN
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003111static char_u *check_cedit(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003112#endif
3113#ifdef FEAT_TITLE
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003114static void did_set_title(int icon);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003115#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003116static char_u *option_expand(int opt_idx, char_u *val);
3117static void didset_options(void);
3118static void didset_options2(void);
3119static void check_string_option(char_u **pp);
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003120#if defined(FEAT_EVAL) || defined(PROTO)
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003121static long_u *insecure_flag(int opt_idx, int opt_flags);
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003122#else
3123# define insecure_flag(opt_idx, opt_flags) (&options[opt_idx].flags)
3124#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003125static void set_string_option_global(int opt_idx, char_u **varp);
3126static char_u *set_string_option(int opt_idx, char_u *value, int opt_flags);
3127static 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);
3128static char_u *set_chars_option(char_u **varp);
Bram Moolenaar1a384422010-07-14 19:53:30 +02003129#ifdef FEAT_SYN_HL
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003130static int int_cmp(const void *a, const void *b);
Bram Moolenaar1a384422010-07-14 19:53:30 +02003131#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003132#ifdef FEAT_CLIPBOARD
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003133static char_u *check_clipboard_option(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003134#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00003135#ifdef FEAT_SPELL
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003136static char_u *did_set_spell_option(int is_spellfile);
3137static char_u *compile_cap_prog(synblock_T *synblock);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00003138#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003139#ifdef FEAT_EVAL
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003140static void set_option_scriptID_idx(int opt_idx, int opt_flags, int id);
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003141#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003142static char_u *set_bool_option(int opt_idx, char_u *varp, int value, int opt_flags);
3143static char_u *set_num_option(int opt_idx, char_u *varp, long value, char_u *errbuf, size_t errbuflen, int opt_flags);
3144static void check_redraw(long_u flags);
3145static int findoption(char_u *);
3146static int find_key_option(char_u *);
3147static void showoptions(int all, int opt_flags);
3148static int optval_default(struct vimoption *, char_u *varp);
3149static void showoneopt(struct vimoption *, int opt_flags);
3150static int put_setstring(FILE *fd, char *cmd, char *name, char_u **valuep, int expand);
3151static int put_setnum(FILE *fd, char *cmd, char *name, long *valuep);
3152static int put_setbool(FILE *fd, char *cmd, char *name, int value);
3153static int istermoption(struct vimoption *);
3154static char_u *get_varp_scope(struct vimoption *p, int opt_flags);
3155static char_u *get_varp(struct vimoption *);
3156static void option_value2string(struct vimoption *, int opt_flags);
3157static void check_winopt(winopt_T *wop);
3158static int wc_use_keyname(char_u *varp, long *wcp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003159#ifdef FEAT_LANGMAP
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003160static void langmap_init(void);
3161static void langmap_set(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003162#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003163static void paste_option_changed(void);
3164static void compatible_set(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003165#ifdef FEAT_LINEBREAK
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003166static void fill_breakat_flags(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003167#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003168static int opt_strings_flags(char_u *val, char **values, unsigned *flagp, int list);
3169static int check_opt_strings(char_u *val, char **values, int);
3170static int check_opt_wim(void);
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02003171#ifdef FEAT_LINEBREAK
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003172static int briopt_check(win_T *wp);
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02003173#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003174
3175/*
3176 * Initialize the options, first part.
3177 *
3178 * Called only once from main(), just after creating the first buffer.
3179 */
3180 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003181set_init_1(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003182{
3183 char_u *p;
3184 int opt_idx;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00003185 long_u n;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003186
3187#ifdef FEAT_LANGMAP
3188 langmap_init();
3189#endif
3190
3191 /* Be Vi compatible by default */
3192 p_cp = TRUE;
3193
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003194 /* Use POSIX compatibility when $VIM_POSIX is set. */
3195 if (mch_getenv((char_u *)"VIM_POSIX") != NULL)
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003196 {
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003197 set_string_default("cpo", (char_u *)CPO_ALL);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003198 set_string_default("shm", (char_u *)"A");
3199 }
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003200
Bram Moolenaar071d4272004-06-13 20:20:40 +00003201 /*
3202 * Find default value for 'shell' option.
Bram Moolenaar7c626922005-02-07 22:01:03 +00003203 * Don't use it if it is empty.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003204 */
Bram Moolenaar7c626922005-02-07 22:01:03 +00003205 if (((p = mch_getenv((char_u *)"SHELL")) != NULL && *p != NUL)
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003206#if defined(MSWIN)
Bram Moolenaar7c626922005-02-07 22:01:03 +00003207 || ((p = mch_getenv((char_u *)"COMSPEC")) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003208# ifdef WIN3264
Bram Moolenaar6aa2cd42016-02-16 15:06:59 +01003209 || ((p = (char_u *)default_shell()) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003210# endif
3211#endif
Bram Moolenaar7c626922005-02-07 22:01:03 +00003212 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00003213 set_string_default("sh", p);
3214
3215#ifdef FEAT_WILDIGN
3216 /*
3217 * Set the default for 'backupskip' to include environment variables for
3218 * temp files.
3219 */
3220 {
3221# ifdef UNIX
3222 static char *(names[4]) = {"", "TMPDIR", "TEMP", "TMP"};
3223# else
3224 static char *(names[3]) = {"TMPDIR", "TEMP", "TMP"};
3225# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003226 int len;
3227 garray_T ga;
3228 int mustfree;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003229
3230 ga_init2(&ga, 1, 100);
3231 for (n = 0; n < (long)(sizeof(names) / sizeof(char *)); ++n)
3232 {
Bram Moolenaar05159a02005-02-26 23:04:13 +00003233 mustfree = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003234# ifdef UNIX
3235 if (*names[n] == NUL)
3236 p = (char_u *)"/tmp";
3237 else
3238# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003239 p = vim_getenv((char_u *)names[n], &mustfree);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003240 if (p != NULL && *p != NUL)
3241 {
3242 /* First time count the NUL, otherwise count the ','. */
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00003243 len = (int)STRLEN(p) + 3;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003244 if (ga_grow(&ga, len) == OK)
3245 {
3246 if (ga.ga_len > 0)
3247 STRCAT(ga.ga_data, ",");
3248 STRCAT(ga.ga_data, p);
3249 add_pathsep(ga.ga_data);
3250 STRCAT(ga.ga_data, "*");
Bram Moolenaar071d4272004-06-13 20:20:40 +00003251 ga.ga_len += len;
3252 }
3253 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00003254 if (mustfree)
3255 vim_free(p);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003256 }
3257 if (ga.ga_data != NULL)
3258 {
3259 set_string_default("bsk", ga.ga_data);
3260 vim_free(ga.ga_data);
3261 }
3262 }
3263#endif
3264
3265 /*
3266 * 'maxmemtot' and 'maxmem' may have to be adjusted for available memory
3267 */
3268 opt_idx = findoption((char_u *)"maxmemtot");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003269 if (opt_idx >= 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003270 {
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003271#if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM)
3272 if (options[opt_idx].def_val[VI_DEFAULT] == (char_u *)0L)
3273#endif
3274 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00003275#ifdef HAVE_AVAIL_MEM
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003276 /* Use amount of memory available at this moment. */
Bram Moolenaar11b73d62012-06-29 15:51:30 +02003277 n = (mch_avail_mem(FALSE) >> 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003278#else
3279# ifdef HAVE_TOTAL_MEM
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003280 /* Use amount of memory available to Vim. */
Bram Moolenaar914572a2007-05-01 11:37:47 +00003281 n = (mch_total_mem(FALSE) >> 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003282# else
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003283 n = (0x7fffffff >> 11);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003284# endif
3285#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003286 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n;
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003287 opt_idx = findoption((char_u *)"maxmem");
3288 if (opt_idx >= 0)
3289 {
3290#if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM)
Bram Moolenaar35be4532015-12-11 22:38:36 +01003291 if ((long)(long_i)options[opt_idx].def_val[VI_DEFAULT] > (long)n
3292 || (long)(long_i)options[opt_idx].def_val[VI_DEFAULT] == 0L)
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003293#endif
3294 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n;
3295 }
3296 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003297 }
3298
Bram Moolenaar071d4272004-06-13 20:20:40 +00003299#ifdef FEAT_SEARCHPATH
3300 {
3301 char_u *cdpath;
3302 char_u *buf;
3303 int i;
3304 int j;
Bram Moolenaar05159a02005-02-26 23:04:13 +00003305 int mustfree = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003306
3307 /* Initialize the 'cdpath' option's default value. */
Bram Moolenaar05159a02005-02-26 23:04:13 +00003308 cdpath = vim_getenv((char_u *)"CDPATH", &mustfree);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003309 if (cdpath != NULL)
3310 {
3311 buf = alloc((unsigned)((STRLEN(cdpath) << 1) + 2));
3312 if (buf != NULL)
3313 {
3314 buf[0] = ','; /* start with ",", current dir first */
3315 j = 1;
3316 for (i = 0; cdpath[i] != NUL; ++i)
3317 {
3318 if (vim_ispathlistsep(cdpath[i]))
3319 buf[j++] = ',';
3320 else
3321 {
3322 if (cdpath[i] == ' ' || cdpath[i] == ',')
3323 buf[j++] = '\\';
3324 buf[j++] = cdpath[i];
3325 }
3326 }
3327 buf[j] = NUL;
3328 opt_idx = findoption((char_u *)"cdpath");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003329 if (opt_idx >= 0)
3330 {
3331 options[opt_idx].def_val[VI_DEFAULT] = buf;
3332 options[opt_idx].flags |= P_DEF_ALLOCED;
3333 }
Bram Moolenaara9d52e32010-07-31 16:44:19 +02003334 else
3335 vim_free(buf); /* cannot happen */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003336 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00003337 if (mustfree)
3338 vim_free(cdpath);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003339 }
3340 }
3341#endif
3342
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003343#if defined(FEAT_POSTSCRIPT) && (defined(MSWIN) || defined(VMS) || defined(EBCDIC) || defined(MAC) || defined(hpux))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003344 /* Set print encoding on platforms that don't default to latin1 */
3345 set_string_default("penc",
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003346# if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003347 (char_u *)"cp1252"
3348# else
3349# ifdef VMS
3350 (char_u *)"dec-mcs"
3351# else
3352# ifdef EBCDIC
3353 (char_u *)"ebcdic-uk"
3354# else
3355# ifdef MAC
3356 (char_u *)"mac-roman"
3357# else /* HPUX */
3358 (char_u *)"hp-roman8"
3359# endif
3360# endif
3361# endif
3362# endif
3363 );
3364#endif
3365
3366#ifdef FEAT_POSTSCRIPT
3367 /* 'printexpr' must be allocated to be able to evaluate it. */
3368 set_string_default("pexpr",
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003369# if defined(MSWIN)
Bram Moolenaared203462004-06-16 11:19:22 +00003370 (char_u *)"system('copy' . ' ' . v:fname_in . (&printdevice == '' ? ' LPT1:' : (' \"' . &printdevice . '\"'))) . delete(v:fname_in)"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003371# else
3372# ifdef VMS
3373 (char_u *)"system('print/delete' . (&printdevice == '' ? '' : ' /queue=' . &printdevice) . ' ' . v:fname_in)"
3374
3375# else
3376 (char_u *)"system('lpr' . (&printdevice == '' ? '' : ' -P' . &printdevice) . ' ' . v:fname_in) . delete(v:fname_in) + v:shell_error"
3377# endif
3378# endif
3379 );
3380#endif
3381
3382 /*
3383 * Set all the options (except the terminal options) to their default
3384 * value. Also set the global value for local options.
3385 */
3386 set_options_default(0);
3387
3388#ifdef FEAT_GUI
3389 if (found_reverse_arg)
3390 set_option_value((char_u *)"bg", 0L, (char_u *)"dark", 0);
3391#endif
3392
3393 curbuf->b_p_initialized = TRUE;
3394 curbuf->b_p_ar = -1; /* no local 'autoread' value */
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01003395 curbuf->b_p_ul = NO_LOCAL_UNDOLEVEL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003396 check_buf_options(curbuf);
3397 check_win_options(curwin);
3398 check_options();
3399
3400 /* Must be before option_expand(), because that one needs vim_isIDc() */
3401 didset_options();
3402
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00003403#ifdef FEAT_SPELL
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003404 /* Use the current chartab for the generic chartab. This is not in
3405 * didset_options() because it only depends on 'encoding'. */
Bram Moolenaar6bb68362005-03-22 23:03:44 +00003406 init_spell_chartab();
3407#endif
3408
Bram Moolenaar071d4272004-06-13 20:20:40 +00003409 /*
3410 * Expand environment variables and things like "~" for the defaults.
3411 * If option_expand() returns non-NULL the variable is expanded. This can
3412 * only happen for non-indirect options.
3413 * Also set the default to the expanded value, so ":set" does not list
3414 * them.
3415 * Don't set the P_ALLOCED flag, because we don't want to free the
3416 * default.
3417 */
3418 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
3419 {
3420 if ((options[opt_idx].flags & P_GETTEXT)
3421 && options[opt_idx].var != NULL)
3422 p = (char_u *)_(*(char **)options[opt_idx].var);
3423 else
3424 p = option_expand(opt_idx, NULL);
3425 if (p != NULL && (p = vim_strsave(p)) != NULL)
3426 {
3427 *(char_u **)options[opt_idx].var = p;
3428 /* VIMEXP
3429 * Defaults for all expanded options are currently the same for Vi
3430 * and Vim. When this changes, add some code here! Also need to
3431 * split P_DEF_ALLOCED in two.
3432 */
3433 if (options[opt_idx].flags & P_DEF_ALLOCED)
3434 vim_free(options[opt_idx].def_val[VI_DEFAULT]);
3435 options[opt_idx].def_val[VI_DEFAULT] = p;
3436 options[opt_idx].flags |= P_DEF_ALLOCED;
3437 }
3438 }
3439
Bram Moolenaar071d4272004-06-13 20:20:40 +00003440 save_file_ff(curbuf); /* Buffer is unchanged */
3441
Bram Moolenaar071d4272004-06-13 20:20:40 +00003442#if defined(FEAT_ARABIC)
3443 /* Detect use of mlterm.
3444 * Mlterm is a terminal emulator akin to xterm that has some special
3445 * abilities (bidi namely).
3446 * NOTE: mlterm's author is being asked to 'set' a variable
3447 * instead of an environment variable due to inheritance.
3448 */
3449 if (mch_getenv((char_u *)"MLTERM") != NULL)
3450 set_option_value((char_u *)"tbidi", 1L, NULL, 0);
3451#endif
3452
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003453 didset_options2();
Bram Moolenaar071d4272004-06-13 20:20:40 +00003454
3455#ifdef FEAT_MBYTE
3456# if defined(WIN3264) && defined(FEAT_GETTEXT)
3457 /*
3458 * If $LANG isn't set, try to get a good value for it. This makes the
3459 * right language be used automatically. Don't do this for English.
3460 */
3461 if (mch_getenv((char_u *)"LANG") == NULL)
3462 {
3463 char buf[20];
3464
3465 /* Could use LOCALE_SISO639LANGNAME, but it's not in Win95.
3466 * LOCALE_SABBREVLANGNAME gives us three letters, like "enu", we use
3467 * only the first two. */
3468 n = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME,
3469 (LPTSTR)buf, 20);
3470 if (n >= 2 && STRNICMP(buf, "en", 2) != 0)
3471 {
3472 /* There are a few exceptions (probably more) */
3473 if (STRNICMP(buf, "cht", 3) == 0 || STRNICMP(buf, "zht", 3) == 0)
3474 STRCPY(buf, "zh_TW");
3475 else if (STRNICMP(buf, "chs", 3) == 0
3476 || STRNICMP(buf, "zhc", 3) == 0)
3477 STRCPY(buf, "zh_CN");
3478 else if (STRNICMP(buf, "jp", 2) == 0)
3479 STRCPY(buf, "ja");
3480 else
3481 buf[2] = NUL; /* truncate to two-letter code */
Bram Moolenaar6aa2cd42016-02-16 15:06:59 +01003482 vim_setenv((char_u *)"LANG", (char_u *)buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003483 }
3484 }
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003485# else
Bram Moolenaar9d47f172006-03-15 23:03:01 +00003486# ifdef MACOS_CONVERT
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00003487 /* Moved to os_mac_conv.c to avoid dependency problems. */
3488 mac_lang_init();
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003489# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003490# endif
3491
3492 /* enc_locale() will try to find the encoding of the current locale. */
3493 p = enc_locale();
3494 if (p != NULL)
3495 {
3496 char_u *save_enc;
3497
3498 /* Try setting 'encoding' and check if the value is valid.
3499 * If not, go back to the default "latin1". */
3500 save_enc = p_enc;
3501 p_enc = p;
Bram Moolenaar733f0a22007-03-02 18:56:27 +00003502 if (STRCMP(p_enc, "gb18030") == 0)
3503 {
3504 /* We don't support "gb18030", but "cp936" is a good substitute
3505 * for practical purposes, thus use that. It's not an alias to
3506 * still support conversion between gb18030 and utf-8. */
3507 p_enc = vim_strsave((char_u *)"cp936");
3508 vim_free(p);
3509 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003510 if (mb_init() == NULL)
3511 {
3512 opt_idx = findoption((char_u *)"encoding");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003513 if (opt_idx >= 0)
3514 {
3515 options[opt_idx].def_val[VI_DEFAULT] = p_enc;
3516 options[opt_idx].flags |= P_DEF_ALLOCED;
3517 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003518
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003519#if defined(MSWIN) || defined(MACOS) || defined(VMS)
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003520 if (STRCMP(p_enc, "latin1") == 0
3521# ifdef FEAT_MBYTE
3522 || enc_utf8
3523# endif
3524 )
3525 {
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003526 /* Adjust the default for 'isprint' and 'iskeyword' to match
3527 * latin1. Also set the defaults for when 'nocompatible' is
3528 * set. */
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003529 set_string_option_direct((char_u *)"isp", -1,
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +00003530 ISP_LATIN1, OPT_FREE, SID_NONE);
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003531 set_string_option_direct((char_u *)"isk", -1,
3532 ISK_LATIN1, OPT_FREE, SID_NONE);
3533 opt_idx = findoption((char_u *)"isp");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003534 if (opt_idx >= 0)
3535 options[opt_idx].def_val[VIM_DEFAULT] = ISP_LATIN1;
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003536 opt_idx = findoption((char_u *)"isk");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003537 if (opt_idx >= 0)
3538 options[opt_idx].def_val[VIM_DEFAULT] = ISK_LATIN1;
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003539 (void)init_chartab();
3540 }
3541#endif
3542
Bram Moolenaar071d4272004-06-13 20:20:40 +00003543# if defined(WIN3264) && !defined(FEAT_GUI)
3544 /* Win32 console: When GetACP() returns a different value from
3545 * GetConsoleCP() set 'termencoding'. */
3546 if (GetACP() != GetConsoleCP())
3547 {
3548 char buf[50];
3549
3550 sprintf(buf, "cp%ld", (long)GetConsoleCP());
3551 p_tenc = vim_strsave((char_u *)buf);
3552 if (p_tenc != NULL)
3553 {
3554 opt_idx = findoption((char_u *)"termencoding");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003555 if (opt_idx >= 0)
3556 {
3557 options[opt_idx].def_val[VI_DEFAULT] = p_tenc;
3558 options[opt_idx].flags |= P_DEF_ALLOCED;
3559 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003560 convert_setup(&input_conv, p_tenc, p_enc);
3561 convert_setup(&output_conv, p_enc, p_tenc);
3562 }
3563 else
3564 p_tenc = empty_option;
3565 }
3566# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003567# if defined(WIN3264) && defined(FEAT_MBYTE)
3568 /* $HOME may have characters in active code page. */
3569 init_homedir();
3570# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003571 }
3572 else
3573 {
3574 vim_free(p_enc);
3575 p_enc = save_enc;
3576 }
3577 }
3578#endif
3579
3580#ifdef FEAT_MULTI_LANG
3581 /* Set the default for 'helplang'. */
3582 set_helplang_default(get_mess_lang());
3583#endif
3584}
3585
3586/*
3587 * Set an option to its default value.
3588 * This does not take care of side effects!
3589 */
3590 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003591set_option_default(
3592 int opt_idx,
3593 int opt_flags, /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
3594 int compatible) /* use Vi default value */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003595{
3596 char_u *varp; /* pointer to variable for current option */
3597 int dvi; /* index in def_val[] */
3598 long_u flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003599 long_u *flagsp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003600 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
3601
3602 varp = get_varp_scope(&(options[opt_idx]), both ? OPT_LOCAL : opt_flags);
3603 flags = options[opt_idx].flags;
Bram Moolenaar3638c682005-06-08 22:05:14 +00003604 if (varp != NULL) /* skip hidden option, nothing to do for it */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003605 {
3606 dvi = ((flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT;
3607 if (flags & P_STRING)
3608 {
3609 /* Use set_string_option_direct() for local options to handle
3610 * freeing and allocating the value. */
3611 if (options[opt_idx].indir != PV_NONE)
3612 set_string_option_direct(NULL, opt_idx,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003613 options[opt_idx].def_val[dvi], opt_flags, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003614 else
3615 {
3616 if ((opt_flags & OPT_FREE) && (flags & P_ALLOCED))
3617 free_string_option(*(char_u **)(varp));
3618 *(char_u **)varp = options[opt_idx].def_val[dvi];
3619 options[opt_idx].flags &= ~P_ALLOCED;
3620 }
3621 }
3622 else if (flags & P_NUM)
3623 {
Bram Moolenaar5fc1a8b2006-10-17 16:34:24 +00003624 if (options[opt_idx].indir == PV_SCROLL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003625 win_comp_scroll(curwin);
3626 else
3627 {
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003628 *(long *)varp = (long)(long_i)options[opt_idx].def_val[dvi];
Bram Moolenaar071d4272004-06-13 20:20:40 +00003629 /* May also set global value for local option. */
3630 if (both)
3631 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) =
3632 *(long *)varp;
3633 }
3634 }
3635 else /* P_BOOL */
3636 {
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003637 /* the cast to long is required for Manx C, long_i is needed for
3638 * MSVC */
3639 *(int *)varp = (int)(long)(long_i)options[opt_idx].def_val[dvi];
Bram Moolenaar8243a792007-05-01 17:05:03 +00003640#ifdef UNIX
3641 /* 'modeline' defaults to off for root */
3642 if (options[opt_idx].indir == PV_ML && getuid() == ROOT_UID)
3643 *(int *)varp = FALSE;
3644#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003645 /* May also set global value for local option. */
3646 if (both)
3647 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) =
3648 *(int *)varp;
3649 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00003650
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003651 /* The default value is not insecure. */
3652 flagsp = insecure_flag(opt_idx, opt_flags);
3653 *flagsp = *flagsp & ~P_INSECURE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003654 }
3655
3656#ifdef FEAT_EVAL
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003657 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003658#endif
3659}
3660
3661/*
3662 * Set all options (except terminal options) to their default value.
Bram Moolenaarb341dda2015-08-25 12:56:31 +02003663 * When "opt_flags" is non-zero skip 'encoding'.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003664 */
3665 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003666set_options_default(
3667 int opt_flags) /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003668{
3669 int i;
3670#ifdef FEAT_WINDOWS
3671 win_T *wp;
Bram Moolenaarf740b292006-02-16 22:11:02 +00003672 tabpage_T *tp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003673#endif
3674
3675 for (i = 0; !istermoption(&options[i]); i++)
Bram Moolenaarb341dda2015-08-25 12:56:31 +02003676 if (!(options[i].flags & P_NODEFAULT)
Bram Moolenaar5ea87a02015-08-26 23:24:09 +02003677#if defined(FEAT_MBYTE) || defined(FEAT_CRYPT)
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003678 && (opt_flags == 0
Bram Moolenaar5ea87a02015-08-26 23:24:09 +02003679 || (TRUE
3680# if defined(FEAT_MBYTE)
3681 && options[i].var != (char_u *)&p_enc
3682# endif
3683# if defined(FEAT_CRYPT)
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003684 && options[i].var != (char_u *)&p_cm
Bram Moolenaar80606872015-08-25 21:27:35 +02003685 && options[i].var != (char_u *)&p_key
Bram Moolenaar5ea87a02015-08-26 23:24:09 +02003686# endif
3687 ))
Bram Moolenaar80606872015-08-25 21:27:35 +02003688#endif
Bram Moolenaar5ea87a02015-08-26 23:24:09 +02003689 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00003690 set_option_default(i, opt_flags, p_cp);
3691
3692#ifdef FEAT_WINDOWS
3693 /* The 'scroll' option must be computed for all windows. */
Bram Moolenaarf740b292006-02-16 22:11:02 +00003694 FOR_ALL_TAB_WINDOWS(tp, wp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003695 win_comp_scroll(wp);
3696#else
3697 win_comp_scroll(curwin);
3698#endif
Bram Moolenaar5a4eceb2014-09-09 17:33:07 +02003699#ifdef FEAT_CINDENT
3700 parse_cino(curbuf);
3701#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003702}
3703
3704/*
3705 * Set the Vi-default value of a string option.
3706 * Used for 'sh', 'backupskip' and 'term'.
3707 */
3708 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003709set_string_default(char *name, char_u *val)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003710{
3711 char_u *p;
3712 int opt_idx;
3713
3714 p = vim_strsave(val);
3715 if (p != NULL) /* we don't want a NULL */
3716 {
3717 opt_idx = findoption((char_u *)name);
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003718 if (opt_idx >= 0)
3719 {
3720 if (options[opt_idx].flags & P_DEF_ALLOCED)
3721 vim_free(options[opt_idx].def_val[VI_DEFAULT]);
3722 options[opt_idx].def_val[VI_DEFAULT] = p;
3723 options[opt_idx].flags |= P_DEF_ALLOCED;
3724 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003725 }
3726}
3727
3728/*
3729 * Set the Vi-default value of a number option.
3730 * Used for 'lines' and 'columns'.
3731 */
3732 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003733set_number_default(char *name, long val)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003734{
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003735 int opt_idx;
3736
3737 opt_idx = findoption((char_u *)name);
3738 if (opt_idx >= 0)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003739 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003740}
3741
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00003742#if defined(EXITFREE) || defined(PROTO)
3743/*
3744 * Free all options.
3745 */
3746 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003747free_all_options(void)
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00003748{
3749 int i;
3750
3751 for (i = 0; !istermoption(&options[i]); i++)
3752 {
3753 if (options[i].indir == PV_NONE)
3754 {
3755 /* global option: free value and default value. */
3756 if (options[i].flags & P_ALLOCED && options[i].var != NULL)
3757 free_string_option(*(char_u **)options[i].var);
3758 if (options[i].flags & P_DEF_ALLOCED)
3759 free_string_option(options[i].def_val[VI_DEFAULT]);
3760 }
3761 else if (options[i].var != VAR_WIN
3762 && (options[i].flags & P_STRING))
3763 /* buffer-local option: free global value */
3764 free_string_option(*(char_u **)options[i].var);
3765 }
3766}
3767#endif
3768
3769
Bram Moolenaar071d4272004-06-13 20:20:40 +00003770/*
3771 * Initialize the options, part two: After getting Rows and Columns and
3772 * setting 'term'.
3773 */
3774 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003775set_init_2(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003776{
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003777 int idx;
3778
Bram Moolenaar071d4272004-06-13 20:20:40 +00003779 /*
3780 * 'scroll' defaults to half the window height. Note that this default is
3781 * wrong when the window height changes.
3782 */
Bram Moolenaarc1e37902006-04-18 21:55:01 +00003783 set_number_default("scroll", (long)((long_u)Rows >> 1));
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003784 idx = findoption((char_u *)"scroll");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003785 if (idx >= 0 && !(options[idx].flags & P_WAS_SET))
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003786 set_option_default(idx, OPT_LOCAL, p_cp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003787 comp_col();
3788
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003789 /*
3790 * 'window' is only for backwards compatibility with Vi.
3791 * Default is Rows - 1.
3792 */
Bram Moolenaard68071d2006-05-02 22:08:30 +00003793 if (!option_was_set((char_u *)"window"))
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003794 p_window = Rows - 1;
3795 set_number_default("window", Rows - 1);
3796
Bram Moolenaarf740b292006-02-16 22:11:02 +00003797 /* For DOS console the default is always black. */
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003798#if !((defined(WIN3264)) && !defined(FEAT_GUI))
Bram Moolenaarf740b292006-02-16 22:11:02 +00003799 /*
3800 * If 'background' wasn't set by the user, try guessing the value,
3801 * depending on the terminal name. Only need to check for terminals
3802 * with a dark background, that can handle color.
3803 */
3804 idx = findoption((char_u *)"bg");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003805 if (idx >= 0 && !(options[idx].flags & P_WAS_SET)
3806 && *term_bg_default() == 'd')
Bram Moolenaar071d4272004-06-13 20:20:40 +00003807 {
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003808 set_string_option_direct(NULL, idx, (char_u *)"dark", OPT_FREE, 0);
Bram Moolenaarf740b292006-02-16 22:11:02 +00003809 /* don't mark it as set, when starting the GUI it may be
3810 * changed again */
3811 options[idx].flags &= ~P_WAS_SET;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003812 }
3813#endif
Bram Moolenaar58d98232005-07-23 22:25:46 +00003814
3815#ifdef CURSOR_SHAPE
3816 parse_shape_opt(SHAPE_CURSOR); /* set cursor shapes from 'guicursor' */
3817#endif
3818#ifdef FEAT_MOUSESHAPE
3819 parse_shape_opt(SHAPE_MOUSE); /* set mouse shapes from 'mouseshape' */
3820#endif
3821#ifdef FEAT_PRINTER
3822 (void)parse_printoptions(); /* parse 'printoptions' default value */
3823#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003824}
3825
3826/*
Bram Moolenaarf740b292006-02-16 22:11:02 +00003827 * Return "dark" or "light" depending on the kind of terminal.
3828 * This is just guessing! Recognized are:
3829 * "linux" Linux console
3830 * "screen.linux" Linux console with screen
3831 * "cygwin" Cygwin shell
3832 * "putty" Putty program
3833 * We also check the COLORFGBG environment variable, which is set by
3834 * rxvt and derivatives. This variable contains either two or three
3835 * values separated by semicolons; we want the last value in either
3836 * case. If this value is 0-6 or 8, our background is dark.
3837 */
3838 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01003839term_bg_default(void)
Bram Moolenaarf740b292006-02-16 22:11:02 +00003840{
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003841#if defined(WIN3264)
Bram Moolenaarf740b292006-02-16 22:11:02 +00003842 /* DOS console nearly always black */
3843 return (char_u *)"dark";
3844#else
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00003845 char_u *p;
3846
Bram Moolenaarf740b292006-02-16 22:11:02 +00003847 if (STRCMP(T_NAME, "linux") == 0
3848 || STRCMP(T_NAME, "screen.linux") == 0
3849 || STRCMP(T_NAME, "cygwin") == 0
3850 || STRCMP(T_NAME, "putty") == 0
3851 || ((p = mch_getenv((char_u *)"COLORFGBG")) != NULL
3852 && (p = vim_strrchr(p, ';')) != NULL
3853 && ((p[1] >= '0' && p[1] <= '6') || p[1] == '8')
3854 && p[2] == NUL))
3855 return (char_u *)"dark";
3856 return (char_u *)"light";
3857#endif
3858}
3859
3860/*
Bram Moolenaar071d4272004-06-13 20:20:40 +00003861 * Initialize the options, part three: After reading the .vimrc
3862 */
3863 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003864set_init_3(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003865{
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003866#if defined(UNIX) || defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003867/*
3868 * Set 'shellpipe' and 'shellredir', depending on the 'shell' option.
3869 * This is done after other initializations, where 'shell' might have been
3870 * set, but only if they have not been set before.
3871 */
3872 char_u *p;
3873 int idx_srr;
3874 int do_srr;
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003875# ifdef FEAT_QUICKFIX
Bram Moolenaar071d4272004-06-13 20:20:40 +00003876 int idx_sp;
3877 int do_sp;
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003878# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003879
3880 idx_srr = findoption((char_u *)"srr");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003881 if (idx_srr < 0)
3882 do_srr = FALSE;
3883 else
3884 do_srr = !(options[idx_srr].flags & P_WAS_SET);
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003885# ifdef FEAT_QUICKFIX
Bram Moolenaar071d4272004-06-13 20:20:40 +00003886 idx_sp = findoption((char_u *)"sp");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003887 if (idx_sp < 0)
3888 do_sp = FALSE;
3889 else
3890 do_sp = !(options[idx_sp].flags & P_WAS_SET);
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003891# endif
Bram Moolenaar75a8d742014-05-07 15:10:21 +02003892 p = get_isolated_shell_name();
Bram Moolenaar071d4272004-06-13 20:20:40 +00003893 if (p != NULL)
3894 {
3895 /*
3896 * Default for p_sp is "| tee", for p_srr is ">".
3897 * For known shells it is changed here to include stderr.
3898 */
3899 if ( fnamecmp(p, "csh") == 0
3900 || fnamecmp(p, "tcsh") == 0
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003901# if defined(WIN3264) /* also check with .exe extension */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003902 || fnamecmp(p, "csh.exe") == 0
3903 || fnamecmp(p, "tcsh.exe") == 0
3904# endif
3905 )
3906 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003907# if defined(FEAT_QUICKFIX)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003908 if (do_sp)
3909 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003910# ifdef WIN3264
Bram Moolenaar071d4272004-06-13 20:20:40 +00003911 p_sp = (char_u *)">&";
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003912# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00003913 p_sp = (char_u *)"|& tee";
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003914# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003915 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
3916 }
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003917# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003918 if (do_srr)
3919 {
3920 p_srr = (char_u *)">&";
3921 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
3922 }
3923 }
3924 else
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003925 /* Always use bourne shell style redirection if we reach this */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003926 if ( fnamecmp(p, "sh") == 0
3927 || fnamecmp(p, "ksh") == 0
Bram Moolenaarf1fda2d2011-04-28 12:57:36 +02003928 || fnamecmp(p, "mksh") == 0
3929 || fnamecmp(p, "pdksh") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003930 || fnamecmp(p, "zsh") == 0
Bram Moolenaarc1e37902006-04-18 21:55:01 +00003931 || fnamecmp(p, "zsh-beta") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003932 || fnamecmp(p, "bash") == 0
Bram Moolenaar75a8d742014-05-07 15:10:21 +02003933 || fnamecmp(p, "fish") == 0
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003934# ifdef WIN3264
Bram Moolenaar071d4272004-06-13 20:20:40 +00003935 || fnamecmp(p, "cmd") == 0
3936 || fnamecmp(p, "sh.exe") == 0
3937 || fnamecmp(p, "ksh.exe") == 0
Bram Moolenaarf1fda2d2011-04-28 12:57:36 +02003938 || fnamecmp(p, "mksh.exe") == 0
3939 || fnamecmp(p, "pdksh.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003940 || fnamecmp(p, "zsh.exe") == 0
Bram Moolenaarc1e37902006-04-18 21:55:01 +00003941 || fnamecmp(p, "zsh-beta.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003942 || fnamecmp(p, "bash.exe") == 0
3943 || fnamecmp(p, "cmd.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003944# endif
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003945 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00003946 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003947# if defined(FEAT_QUICKFIX)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003948 if (do_sp)
3949 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003950# ifdef WIN3264
Bram Moolenaar071d4272004-06-13 20:20:40 +00003951 p_sp = (char_u *)">%s 2>&1";
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003952# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00003953 p_sp = (char_u *)"2>&1| tee";
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003954# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003955 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
3956 }
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003957# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003958 if (do_srr)
3959 {
3960 p_srr = (char_u *)">%s 2>&1";
3961 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
3962 }
3963 }
3964 vim_free(p);
3965 }
3966#endif
3967
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003968#if defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003969 /*
Bram Moolenaara64ba222012-02-12 23:23:31 +01003970 * Set 'shellcmdflag', 'shellxquote', and 'shellquote' depending on the
3971 * 'shell' option.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003972 * This is done after other initializations, where 'shell' might have been
3973 * set, but only if they have not been set before. Default for p_shcf is
3974 * "/c", for p_shq is "". For "sh" like shells it is changed here to
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003975 * "-c" and "\"". And for Win32 we need to set p_sxq instead.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003976 */
Bram Moolenaarf4b8e572004-06-24 15:53:16 +00003977 if (strstr((char *)gettail(p_sh), "sh") != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003978 {
3979 int idx3;
3980
3981 idx3 = findoption((char_u *)"shcf");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003982 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003983 {
3984 p_shcf = (char_u *)"-c";
3985 options[idx3].def_val[VI_DEFAULT] = p_shcf;
3986 }
3987
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003988# ifdef WIN3264
Bram Moolenaar071d4272004-06-13 20:20:40 +00003989 /* Somehow Win32 requires the quotes around the redirection too */
3990 idx3 = findoption((char_u *)"sxq");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003991 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003992 {
3993 p_sxq = (char_u *)"\"";
3994 options[idx3].def_val[VI_DEFAULT] = p_sxq;
3995 }
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003996# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00003997 idx3 = findoption((char_u *)"shq");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003998 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003999 {
4000 p_shq = (char_u *)"\"";
4001 options[idx3].def_val[VI_DEFAULT] = p_shq;
4002 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004003# endif
4004 }
Bram Moolenaara64ba222012-02-12 23:23:31 +01004005 else if (strstr((char *)gettail(p_sh), "cmd.exe") != NULL)
4006 {
4007 int idx3;
4008
4009 /*
4010 * cmd.exe on Windows will strip the first and last double quote given
4011 * on the command line, e.g. most of the time things like:
4012 * cmd /c "my path/to/echo" "my args to echo"
4013 * become:
4014 * my path/to/echo" "my args to echo
4015 * when executed.
4016 *
Bram Moolenaar034b1152012-02-19 18:19:30 +01004017 * To avoid this, set shellxquote to surround the command in
4018 * parenthesis. This appears to make most commands work, without
4019 * breaking commands that worked previously, such as
4020 * '"path with spaces/cmd" "a&b"'.
Bram Moolenaara64ba222012-02-12 23:23:31 +01004021 */
Bram Moolenaara64ba222012-02-12 23:23:31 +01004022 idx3 = findoption((char_u *)"sxq");
4023 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
4024 {
Bram Moolenaar034b1152012-02-19 18:19:30 +01004025 p_sxq = (char_u *)"(";
Bram Moolenaara64ba222012-02-12 23:23:31 +01004026 options[idx3].def_val[VI_DEFAULT] = p_sxq;
4027 }
4028
Bram Moolenaara64ba222012-02-12 23:23:31 +01004029 idx3 = findoption((char_u *)"shcf");
4030 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
4031 {
Bram Moolenaar034b1152012-02-19 18:19:30 +01004032 p_shcf = (char_u *)"/c";
Bram Moolenaara64ba222012-02-12 23:23:31 +01004033 options[idx3].def_val[VI_DEFAULT] = p_shcf;
4034 }
4035 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004036#endif
4037
Bram Moolenaar364fa5c2016-03-20 17:53:25 +01004038 if (bufempty())
4039 {
4040 int idx_ffs = findoption((char_u *)"ffs");
4041
4042 /* Apply the first entry of 'fileformats' to the initial buffer. */
4043 if (idx_ffs >= 0 && (options[idx_ffs].flags & P_WAS_SET))
4044 set_fileformat(default_fileformat(), OPT_LOCAL);
4045 }
4046
Bram Moolenaar071d4272004-06-13 20:20:40 +00004047#ifdef FEAT_TITLE
4048 set_title_defaults();
4049#endif
4050}
4051
4052#if defined(FEAT_MULTI_LANG) || defined(PROTO)
4053/*
4054 * When 'helplang' is still at its default value, set it to "lang".
4055 * Only the first two characters of "lang" are used.
4056 */
4057 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01004058set_helplang_default(char_u *lang)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004059{
4060 int idx;
4061
4062 if (lang == NULL || STRLEN(lang) < 2) /* safety check */
4063 return;
4064 idx = findoption((char_u *)"hlg");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004065 if (idx >= 0 && !(options[idx].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004066 {
4067 if (options[idx].flags & P_ALLOCED)
4068 free_string_option(p_hlg);
4069 p_hlg = vim_strsave(lang);
4070 if (p_hlg == NULL)
4071 p_hlg = empty_option;
4072 else
Bram Moolenaarab79bcb2004-07-18 21:34:53 +00004073 {
4074 /* zh_CN becomes "cn", zh_TW becomes "tw". */
4075 if (STRNICMP(p_hlg, "zh_", 3) == 0 && STRLEN(p_hlg) >= 5)
4076 {
4077 p_hlg[0] = TOLOWER_ASC(p_hlg[3]);
4078 p_hlg[1] = TOLOWER_ASC(p_hlg[4]);
4079 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004080 p_hlg[2] = NUL;
Bram Moolenaarab79bcb2004-07-18 21:34:53 +00004081 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004082 options[idx].flags |= P_ALLOCED;
4083 }
4084}
4085#endif
4086
4087#ifdef FEAT_GUI
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01004088static char_u *gui_bg_default(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004089
4090 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01004091gui_bg_default(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004092{
4093 if (gui_get_lightness(gui.back_pixel) < 127)
4094 return (char_u *)"dark";
4095 return (char_u *)"light";
4096}
4097
4098/*
4099 * Option initializations that can only be done after opening the GUI window.
4100 */
4101 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01004102init_gui_options(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004103{
4104 /* Set the 'background' option according to the lightness of the
4105 * background color, unless the user has set it already. */
4106 if (!option_was_set((char_u *)"bg") && STRCMP(p_bg, gui_bg_default()) != 0)
4107 {
4108 set_option_value((char_u *)"bg", 0L, gui_bg_default(), 0);
4109 highlight_changed();
4110 }
4111}
4112#endif
4113
4114#ifdef FEAT_TITLE
4115/*
4116 * 'title' and 'icon' only default to true if they have not been set or reset
4117 * in .vimrc and we can read the old value.
4118 * When 'title' and 'icon' have been reset in .vimrc, we won't even check if
4119 * they can be reset. This reduces startup time when using X on a remote
4120 * machine.
4121 */
4122 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01004123set_title_defaults(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004124{
4125 int idx1;
4126 long val;
4127
4128 /*
4129 * If GUI is (going to be) used, we can always set the window title and
4130 * icon name. Saves a bit of time, because the X11 display server does
4131 * not need to be contacted.
4132 */
4133 idx1 = findoption((char_u *)"title");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004134 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004135 {
4136#ifdef FEAT_GUI
4137 if (gui.starting || gui.in_use)
4138 val = TRUE;
4139 else
4140#endif
4141 val = mch_can_restore_title();
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004142 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004143 p_title = val;
4144 }
4145 idx1 = findoption((char_u *)"icon");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004146 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004147 {
4148#ifdef FEAT_GUI
4149 if (gui.starting || gui.in_use)
4150 val = TRUE;
4151 else
4152#endif
4153 val = mch_can_restore_icon();
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004154 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004155 p_icon = val;
4156 }
4157}
4158#endif
4159
4160/*
4161 * Parse 'arg' for option settings.
4162 *
4163 * 'arg' may be IObuff, but only when no errors can be present and option
4164 * does not need to be expanded with option_expand().
4165 * "opt_flags":
4166 * 0 for ":set"
Bram Moolenaara3227e22006-03-08 21:32:40 +00004167 * OPT_GLOBAL for ":setglobal"
4168 * OPT_LOCAL for ":setlocal" and a modeline
Bram Moolenaar071d4272004-06-13 20:20:40 +00004169 * OPT_MODELINE for a modeline
Bram Moolenaara3227e22006-03-08 21:32:40 +00004170 * OPT_WINONLY to only set window-local options
4171 * OPT_NOWIN to skip setting window-local options
Bram Moolenaar071d4272004-06-13 20:20:40 +00004172 *
4173 * returns FAIL if an error is detected, OK otherwise
4174 */
4175 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01004176do_set(
4177 char_u *arg, /* option string (may be written to!) */
4178 int opt_flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004179{
4180 int opt_idx;
4181 char_u *errmsg;
4182 char_u errbuf[80];
4183 char_u *startarg;
4184 int prefix; /* 1: nothing, 0: "no", 2: "inv" in front of name */
4185 int nextchar; /* next non-white char after option name */
4186 int afterchar; /* character just after option name */
4187 int len;
4188 int i;
Bram Moolenaar22fcfad2016-07-01 18:17:26 +02004189 varnumber_T value;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004190 int key;
4191 long_u flags; /* flags for current option */
4192 char_u *varp = NULL; /* pointer to variable for current option */
4193 int did_show = FALSE; /* already showed one value */
4194 int adding; /* "opt+=arg" */
4195 int prepending; /* "opt^=arg" */
4196 int removing; /* "opt-=arg" */
4197 int cp_val = 0;
4198 char_u key_name[2];
4199
4200 if (*arg == NUL)
4201 {
4202 showoptions(0, opt_flags);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004203 did_show = TRUE;
4204 goto theend;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004205 }
4206
4207 while (*arg != NUL) /* loop to process all options */
4208 {
4209 errmsg = NULL;
4210 startarg = arg; /* remember for error message */
4211
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00004212 if (STRNCMP(arg, "all", 3) == 0 && !isalpha(arg[3])
4213 && !(opt_flags & OPT_MODELINE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004214 {
4215 /*
4216 * ":set all" show all options.
4217 * ":set all&" set all options to their default value.
4218 */
4219 arg += 3;
4220 if (*arg == '&')
4221 {
4222 ++arg;
4223 /* Only for :set command set global value of local options. */
4224 set_options_default(OPT_FREE | opt_flags);
Bram Moolenaare68c25c2015-08-25 15:39:55 +02004225 didset_options();
4226 didset_options2();
Bram Moolenaarb341dda2015-08-25 12:56:31 +02004227 redraw_all_later(CLEAR);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004228 }
4229 else
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004230 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00004231 showoptions(1, opt_flags);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004232 did_show = TRUE;
4233 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004234 }
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00004235 else if (STRNCMP(arg, "termcap", 7) == 0 && !(opt_flags & OPT_MODELINE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004236 {
4237 showoptions(2, opt_flags);
4238 show_termcodes();
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004239 did_show = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004240 arg += 7;
4241 }
4242 else
4243 {
4244 prefix = 1;
Bram Moolenaar2a7b9ee2009-06-16 15:50:33 +00004245 if (STRNCMP(arg, "no", 2) == 0 && STRNCMP(arg, "novice", 6) != 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004246 {
4247 prefix = 0;
4248 arg += 2;
4249 }
4250 else if (STRNCMP(arg, "inv", 3) == 0)
4251 {
4252 prefix = 2;
4253 arg += 3;
4254 }
4255
4256 /* find end of name */
4257 key = 0;
4258 if (*arg == '<')
4259 {
4260 nextchar = 0;
4261 opt_idx = -1;
4262 /* look out for <t_>;> */
4263 if (arg[1] == 't' && arg[2] == '_' && arg[3] && arg[4])
4264 len = 5;
4265 else
4266 {
4267 len = 1;
4268 while (arg[len] != NUL && arg[len] != '>')
4269 ++len;
4270 }
4271 if (arg[len] != '>')
4272 {
4273 errmsg = e_invarg;
4274 goto skip;
4275 }
4276 arg[len] = NUL; /* put NUL after name */
4277 if (arg[1] == 't' && arg[2] == '_') /* could be term code */
4278 opt_idx = findoption(arg + 1);
4279 arg[len++] = '>'; /* restore '>' */
4280 if (opt_idx == -1)
4281 key = find_key_option(arg + 1);
4282 }
4283 else
4284 {
4285 len = 0;
4286 /*
4287 * The two characters after "t_" may not be alphanumeric.
4288 */
4289 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
4290 len = 4;
4291 else
4292 while (ASCII_ISALNUM(arg[len]) || arg[len] == '_')
4293 ++len;
4294 nextchar = arg[len];
4295 arg[len] = NUL; /* put NUL after name */
4296 opt_idx = findoption(arg);
4297 arg[len] = nextchar; /* restore nextchar */
4298 if (opt_idx == -1)
4299 key = find_key_option(arg);
4300 }
4301
4302 /* remember character after option name */
4303 afterchar = arg[len];
4304
4305 /* skip white space, allow ":set ai ?" */
4306 while (vim_iswhite(arg[len]))
4307 ++len;
4308
4309 adding = FALSE;
4310 prepending = FALSE;
4311 removing = FALSE;
4312 if (arg[len] != NUL && arg[len + 1] == '=')
4313 {
4314 if (arg[len] == '+')
4315 {
4316 adding = TRUE; /* "+=" */
4317 ++len;
4318 }
4319 else if (arg[len] == '^')
4320 {
4321 prepending = TRUE; /* "^=" */
4322 ++len;
4323 }
4324 else if (arg[len] == '-')
4325 {
4326 removing = TRUE; /* "-=" */
4327 ++len;
4328 }
4329 }
4330 nextchar = arg[len];
4331
4332 if (opt_idx == -1 && key == 0) /* found a mismatch: skip */
4333 {
4334 errmsg = (char_u *)N_("E518: Unknown option");
4335 goto skip;
4336 }
4337
4338 if (opt_idx >= 0)
4339 {
4340 if (options[opt_idx].var == NULL) /* hidden option: skip */
4341 {
4342 /* Only give an error message when requesting the value of
4343 * a hidden option, ignore setting it. */
4344 if (vim_strchr((char_u *)"=:!&<", nextchar) == NULL
4345 && (!(options[opt_idx].flags & P_BOOL)
4346 || nextchar == '?'))
4347 errmsg = (char_u *)N_("E519: Option not supported");
4348 goto skip;
4349 }
4350
4351 flags = options[opt_idx].flags;
4352 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
4353 }
4354 else
4355 {
4356 flags = P_STRING;
4357 if (key < 0)
4358 {
4359 key_name[0] = KEY2TERMCAP0(key);
4360 key_name[1] = KEY2TERMCAP1(key);
4361 }
4362 else
4363 {
4364 key_name[0] = KS_KEY;
4365 key_name[1] = (key & 0xff);
4366 }
4367 }
4368
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004369 /* Skip all options that are not window-local (used when showing
4370 * an already loaded buffer in a window). */
4371 if ((opt_flags & OPT_WINONLY)
4372 && (opt_idx < 0 || options[opt_idx].var != VAR_WIN))
4373 goto skip;
4374
Bram Moolenaara3227e22006-03-08 21:32:40 +00004375 /* Skip all options that are window-local (used for :vimgrep). */
4376 if ((opt_flags & OPT_NOWIN) && opt_idx >= 0
4377 && options[opt_idx].var == VAR_WIN)
4378 goto skip;
4379
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004380 /* Disallow changing some options from modelines. */
4381 if (opt_flags & OPT_MODELINE)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004382 {
Bram Moolenaar865242e2010-07-14 21:12:05 +02004383 if (flags & (P_SECURE | P_NO_ML))
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004384 {
4385 errmsg = (char_u *)_("E520: Not allowed in a modeline");
4386 goto skip;
4387 }
Bram Moolenaarf69d9a32009-02-11 21:48:40 +00004388#ifdef FEAT_DIFF
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004389 /* In diff mode some options are overruled. This avoids that
4390 * 'foldmethod' becomes "marker" instead of "diff" and that
4391 * "wrap" gets set. */
4392 if (curwin->w_p_diff
Bram Moolenaara9d52e32010-07-31 16:44:19 +02004393 && opt_idx >= 0 /* shut up coverity warning */
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004394 && (options[opt_idx].indir == PV_FDM
4395 || options[opt_idx].indir == PV_WRAP))
4396 goto skip;
Bram Moolenaarf69d9a32009-02-11 21:48:40 +00004397#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004398 }
4399
4400#ifdef HAVE_SANDBOX
4401 /* Disallow changing some options in the sandbox */
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004402 if (sandbox != 0 && (flags & P_SECURE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004403 {
4404 errmsg = (char_u *)_(e_sandbox);
4405 goto skip;
4406 }
4407#endif
4408
4409 if (vim_strchr((char_u *)"?=:!&<", nextchar) != NULL)
4410 {
4411 arg += len;
4412 cp_val = p_cp;
4413 if (nextchar == '&' && arg[1] == 'v' && arg[2] == 'i')
4414 {
4415 if (arg[3] == 'm') /* "opt&vim": set to Vim default */
4416 {
4417 cp_val = FALSE;
4418 arg += 3;
4419 }
4420 else /* "opt&vi": set to Vi default */
4421 {
4422 cp_val = TRUE;
4423 arg += 2;
4424 }
4425 }
4426 if (vim_strchr((char_u *)"?!&<", nextchar) != NULL
4427 && arg[1] != NUL && !vim_iswhite(arg[1]))
4428 {
4429 errmsg = e_trailing;
4430 goto skip;
4431 }
4432 }
4433
4434 /*
Bram Moolenaar48e330a2016-02-23 14:53:34 +01004435 * allow '=' and ':' for hystorical reasons (MSDOS command.com
4436 * allows only one '=' character per "set" command line. grrr. (jw)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004437 */
4438 if (nextchar == '?'
4439 || (prefix == 1
4440 && vim_strchr((char_u *)"=:&<", nextchar) == NULL
4441 && !(flags & P_BOOL)))
4442 {
4443 /*
4444 * print value
4445 */
4446 if (did_show)
4447 msg_putchar('\n'); /* cursor below last one */
4448 else
4449 {
4450 gotocmdline(TRUE); /* cursor at status line */
4451 did_show = TRUE; /* remember that we did a line */
4452 }
4453 if (opt_idx >= 0)
4454 {
4455 showoneopt(&options[opt_idx], opt_flags);
4456#ifdef FEAT_EVAL
4457 if (p_verbose > 0)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00004458 {
4459 /* Mention where the option was last set. */
4460 if (varp == options[opt_idx].var)
4461 last_set_msg(options[opt_idx].scriptID);
4462 else if ((int)options[opt_idx].indir & PV_WIN)
4463 last_set_msg(curwin->w_p_scriptID[
4464 (int)options[opt_idx].indir & PV_MASK]);
4465 else if ((int)options[opt_idx].indir & PV_BUF)
4466 last_set_msg(curbuf->b_p_scriptID[
4467 (int)options[opt_idx].indir & PV_MASK]);
4468 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004469#endif
4470 }
4471 else
4472 {
4473 char_u *p;
4474
4475 p = find_termcode(key_name);
4476 if (p == NULL)
4477 {
Bram Moolenaar0b2f94d2011-03-22 14:35:05 +01004478 errmsg = (char_u *)N_("E846: Key code not set");
Bram Moolenaar071d4272004-06-13 20:20:40 +00004479 goto skip;
4480 }
4481 else
4482 (void)show_one_termcode(key_name, p, TRUE);
4483 }
4484 if (nextchar != '?'
4485 && nextchar != NUL && !vim_iswhite(afterchar))
4486 errmsg = e_trailing;
4487 }
4488 else
4489 {
4490 if (flags & P_BOOL) /* boolean */
4491 {
4492 if (nextchar == '=' || nextchar == ':')
4493 {
4494 errmsg = e_invarg;
4495 goto skip;
4496 }
4497
4498 /*
4499 * ":set opt!": invert
4500 * ":set opt&": reset to default value
4501 * ":set opt<": reset to global value
4502 */
4503 if (nextchar == '!')
4504 value = *(int *)(varp) ^ 1;
4505 else if (nextchar == '&')
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004506 value = (int)(long)(long_i)options[opt_idx].def_val[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004507 ((flags & P_VI_DEF) || cp_val)
4508 ? VI_DEFAULT : VIM_DEFAULT];
4509 else if (nextchar == '<')
4510 {
4511 /* For 'autoread' -1 means to use global value. */
4512 if ((int *)varp == &curbuf->b_p_ar
4513 && opt_flags == OPT_LOCAL)
4514 value = -1;
4515 else
4516 value = *(int *)get_varp_scope(&(options[opt_idx]),
4517 OPT_GLOBAL);
4518 }
4519 else
4520 {
4521 /*
4522 * ":set invopt": invert
4523 * ":set opt" or ":set noopt": set or reset
4524 */
4525 if (nextchar != NUL && !vim_iswhite(afterchar))
4526 {
4527 errmsg = e_trailing;
4528 goto skip;
4529 }
4530 if (prefix == 2) /* inv */
4531 value = *(int *)(varp) ^ 1;
4532 else
4533 value = prefix;
4534 }
4535
4536 errmsg = set_bool_option(opt_idx, varp, (int)value,
4537 opt_flags);
4538 }
4539 else /* numeric or string */
4540 {
4541 if (vim_strchr((char_u *)"=:&<", nextchar) == NULL
4542 || prefix != 1)
4543 {
4544 errmsg = e_invarg;
4545 goto skip;
4546 }
4547
4548 if (flags & P_NUM) /* numeric */
4549 {
4550 /*
4551 * Different ways to set a number option:
4552 * & set to default value
4553 * < set to global value
4554 * <xx> accept special key codes for 'wildchar'
4555 * c accept any non-digit for 'wildchar'
4556 * [-]0-9 set number
4557 * other error
4558 */
4559 ++arg;
4560 if (nextchar == '&')
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004561 value = (long)(long_i)options[opt_idx].def_val[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004562 ((flags & P_VI_DEF) || cp_val)
4563 ? VI_DEFAULT : VIM_DEFAULT];
4564 else if (nextchar == '<')
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01004565 {
4566 /* For 'undolevels' NO_LOCAL_UNDOLEVEL means to
4567 * use the global value. */
4568 if ((long *)varp == &curbuf->b_p_ul
4569 && opt_flags == OPT_LOCAL)
4570 value = NO_LOCAL_UNDOLEVEL;
4571 else
4572 value = *(long *)get_varp_scope(
4573 &(options[opt_idx]), OPT_GLOBAL);
4574 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004575 else if (((long *)varp == &p_wc
4576 || (long *)varp == &p_wcm)
4577 && (*arg == '<'
4578 || *arg == '^'
4579 || ((!arg[1] || vim_iswhite(arg[1]))
4580 && !VIM_ISDIGIT(*arg))))
4581 {
4582 value = string_to_key(arg);
4583 if (value == 0 && (long *)varp != &p_wcm)
4584 {
4585 errmsg = e_invarg;
4586 goto skip;
4587 }
4588 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004589 else if (*arg == '-' || VIM_ISDIGIT(*arg))
4590 {
Bram Moolenaar18400e62015-01-27 15:58:40 +01004591 /* Allow negative (for 'undolevels'), octal and
4592 * hex numbers. */
Bram Moolenaar887c1fe2016-01-02 17:56:35 +01004593 vim_str2nr(arg, NULL, &i, STR2NR_ALL,
4594 &value, NULL, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004595 if (arg[i] != NUL && !vim_iswhite(arg[i]))
4596 {
4597 errmsg = e_invarg;
4598 goto skip;
4599 }
4600 }
4601 else
4602 {
4603 errmsg = (char_u *)N_("E521: Number required after =");
4604 goto skip;
4605 }
4606
4607 if (adding)
4608 value = *(long *)varp + value;
4609 if (prepending)
4610 value = *(long *)varp * value;
4611 if (removing)
4612 value = *(long *)varp - value;
4613 errmsg = set_num_option(opt_idx, varp, value,
Bram Moolenaar555b2802005-05-19 21:08:39 +00004614 errbuf, sizeof(errbuf), opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004615 }
4616 else if (opt_idx >= 0) /* string */
4617 {
4618 char_u *save_arg = NULL;
4619 char_u *s = NULL;
Bram Moolenaar53744302015-07-17 17:38:22 +02004620 char_u *oldval = NULL; /* previous value if *varp */
Bram Moolenaar071d4272004-06-13 20:20:40 +00004621 char_u *newval;
Bram Moolenaar53744302015-07-17 17:38:22 +02004622 char_u *origval = NULL;
4623#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
4624 char_u *saved_origval = NULL;
4625#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004626 unsigned newlen;
4627 int comma;
4628 int bs;
4629 int new_value_alloced; /* new string option
4630 was allocated */
4631
4632 /* When using ":set opt=val" for a global option
4633 * with a local value the local value will be
4634 * reset, use the global value here. */
4635 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00004636 && ((int)options[opt_idx].indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004637 varp = options[opt_idx].var;
4638
4639 /* The old value is kept until we are sure that the
4640 * new value is valid. */
4641 oldval = *(char_u **)varp;
4642 if (nextchar == '&') /* set to default val */
4643 {
4644 newval = options[opt_idx].def_val[
4645 ((flags & P_VI_DEF) || cp_val)
4646 ? VI_DEFAULT : VIM_DEFAULT];
4647 if ((char_u **)varp == &p_bg)
4648 {
4649 /* guess the value of 'background' */
4650#ifdef FEAT_GUI
4651 if (gui.in_use)
4652 newval = gui_bg_default();
4653 else
4654#endif
Bram Moolenaarf740b292006-02-16 22:11:02 +00004655 newval = term_bg_default();
Bram Moolenaar071d4272004-06-13 20:20:40 +00004656 }
4657
4658 /* expand environment variables and ~ (since the
4659 * default value was already expanded, only
4660 * required when an environment variable was set
4661 * later */
4662 if (newval == NULL)
4663 newval = empty_option;
4664 else
4665 {
4666 s = option_expand(opt_idx, newval);
4667 if (s == NULL)
4668 s = newval;
4669 newval = vim_strsave(s);
4670 }
4671 new_value_alloced = TRUE;
4672 }
4673 else if (nextchar == '<') /* set to global val */
4674 {
4675 newval = vim_strsave(*(char_u **)get_varp_scope(
4676 &(options[opt_idx]), OPT_GLOBAL));
4677 new_value_alloced = TRUE;
4678 }
4679 else
4680 {
4681 ++arg; /* jump to after the '=' or ':' */
4682
4683 /*
4684 * Set 'keywordprg' to ":help" if an empty
4685 * value was passed to :set by the user.
4686 * Misuse errbuf[] for the resulting string.
4687 */
4688 if (varp == (char_u *)&p_kp
4689 && (*arg == NUL || *arg == ' '))
4690 {
4691 STRCPY(errbuf, ":help");
4692 save_arg = arg;
4693 arg = errbuf;
4694 }
4695 /*
Bram Moolenaar4e5ccfa2011-11-30 11:15:47 +01004696 * Convert 'backspace' number to string, for
4697 * adding, prepending and removing string.
4698 */
4699 else if (varp == (char_u *)&p_bs
4700 && VIM_ISDIGIT(**(char_u **)varp))
4701 {
4702 i = getdigits((char_u **)varp);
4703 switch (i)
4704 {
4705 case 0:
4706 *(char_u **)varp = empty_option;
4707 break;
4708 case 1:
4709 *(char_u **)varp = vim_strsave(
4710 (char_u *)"indent,eol");
4711 break;
4712 case 2:
4713 *(char_u **)varp = vim_strsave(
4714 (char_u *)"indent,eol,start");
4715 break;
4716 }
4717 vim_free(oldval);
4718 oldval = *(char_u **)varp;
4719 }
4720 /*
Bram Moolenaar071d4272004-06-13 20:20:40 +00004721 * Convert 'whichwrap' number to string, for
4722 * backwards compatibility with Vim 3.0.
4723 * Misuse errbuf[] for the resulting string.
4724 */
4725 else if (varp == (char_u *)&p_ww
4726 && VIM_ISDIGIT(*arg))
4727 {
4728 *errbuf = NUL;
4729 i = getdigits(&arg);
4730 if (i & 1)
4731 STRCAT(errbuf, "b,");
4732 if (i & 2)
4733 STRCAT(errbuf, "s,");
4734 if (i & 4)
4735 STRCAT(errbuf, "h,l,");
4736 if (i & 8)
4737 STRCAT(errbuf, "<,>,");
4738 if (i & 16)
4739 STRCAT(errbuf, "[,],");
4740 if (*errbuf != NUL) /* remove trailing , */
4741 errbuf[STRLEN(errbuf) - 1] = NUL;
4742 save_arg = arg;
4743 arg = errbuf;
4744 }
4745 /*
4746 * Remove '>' before 'dir' and 'bdir', for
4747 * backwards compatibility with version 3.0
4748 */
4749 else if ( *arg == '>'
4750 && (varp == (char_u *)&p_dir
4751 || varp == (char_u *)&p_bdir))
4752 {
4753 ++arg;
4754 }
4755
4756 /* When setting the local value of a global
4757 * option, the old value may be the global value. */
Bram Moolenaara23ccb82006-02-27 00:08:02 +00004758 if (((int)options[opt_idx].indir & PV_BOTH)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004759 && (opt_flags & OPT_LOCAL))
4760 origval = *(char_u **)get_varp(
4761 &options[opt_idx]);
4762 else
4763 origval = oldval;
4764
4765 /*
4766 * Copy the new string into allocated memory.
4767 * Can't use set_string_option_direct(), because
4768 * we need to remove the backslashes.
4769 */
4770 /* get a bit too much */
4771 newlen = (unsigned)STRLEN(arg) + 1;
4772 if (adding || prepending || removing)
4773 newlen += (unsigned)STRLEN(origval) + 1;
4774 newval = alloc(newlen);
4775 if (newval == NULL) /* out of mem, don't change */
4776 break;
4777 s = newval;
4778
4779 /*
4780 * Copy the string, skip over escaped chars.
4781 * For MS-DOS and WIN32 backslashes before normal
4782 * file name characters are not removed, and keep
4783 * backslash at start, for "\\machine\path", but
4784 * do remove it for "\\\\machine\\path".
4785 * The reverse is found in ExpandOldSetting().
4786 */
4787 while (*arg && !vim_iswhite(*arg))
4788 {
4789 if (*arg == '\\' && arg[1] != NUL
4790#ifdef BACKSLASH_IN_FILENAME
4791 && !((flags & P_EXPAND)
4792 && vim_isfilec(arg[1])
4793 && (arg[1] != '\\'
4794 || (s == newval
4795 && arg[2] != '\\')))
4796#endif
4797 )
4798 ++arg; /* remove backslash */
4799#ifdef FEAT_MBYTE
4800 if (has_mbyte
Bram Moolenaar0fa313a2005-08-10 21:07:57 +00004801 && (i = (*mb_ptr2len)(arg)) > 1)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004802 {
4803 /* copy multibyte char */
4804 mch_memmove(s, arg, (size_t)i);
4805 arg += i;
4806 s += i;
4807 }
4808 else
4809#endif
4810 *s++ = *arg++;
4811 }
4812 *s = NUL;
4813
4814 /*
4815 * Expand environment variables and ~.
4816 * Don't do it when adding without inserting a
4817 * comma.
4818 */
4819 if (!(adding || prepending || removing)
4820 || (flags & P_COMMA))
4821 {
4822 s = option_expand(opt_idx, newval);
4823 if (s != NULL)
4824 {
4825 vim_free(newval);
4826 newlen = (unsigned)STRLEN(s) + 1;
4827 if (adding || prepending || removing)
4828 newlen += (unsigned)STRLEN(origval) + 1;
4829 newval = alloc(newlen);
4830 if (newval == NULL)
4831 break;
4832 STRCPY(newval, s);
4833 }
4834 }
4835
4836 /* locate newval[] in origval[] when removing it
4837 * and when adding to avoid duplicates */
4838 i = 0; /* init for GCC */
4839 if (removing || (flags & P_NODUP))
4840 {
4841 i = (int)STRLEN(newval);
4842 bs = 0;
4843 for (s = origval; *s; ++s)
4844 {
4845 if ((!(flags & P_COMMA)
4846 || s == origval
4847 || (s[-1] == ',' && !(bs & 1)))
4848 && STRNCMP(s, newval, i) == 0
4849 && (!(flags & P_COMMA)
4850 || s[i] == ','
4851 || s[i] == NUL))
4852 break;
Bram Moolenaar0b2f94d2011-03-22 14:35:05 +01004853 /* Count backslashes. Only a comma with an
Bram Moolenaar8f79acd2016-01-01 14:48:20 +01004854 * even number of backslashes or a single
4855 * backslash preceded by a comma before it
4856 * is recognized as a separator */
4857 if ((s > origval + 1
4858 && s[-1] == '\\'
4859 && s[-2] != ',')
4860 || (s == origval + 1
4861 && s[-1] == '\\'))
4862
Bram Moolenaar071d4272004-06-13 20:20:40 +00004863 ++bs;
4864 else
4865 bs = 0;
4866 }
4867
4868 /* do not add if already there */
4869 if ((adding || prepending) && *s)
4870 {
4871 prepending = FALSE;
4872 adding = FALSE;
4873 STRCPY(newval, origval);
4874 }
4875 }
4876
4877 /* concatenate the two strings; add a ',' if
4878 * needed */
4879 if (adding || prepending)
4880 {
4881 comma = ((flags & P_COMMA) && *origval != NUL
4882 && *newval != NUL);
4883 if (adding)
4884 {
4885 i = (int)STRLEN(origval);
Bram Moolenaara7b7b1c2015-06-19 14:06:43 +02004886 /* strip a trailing comma, would get 2 */
Bram Moolenaar17467472015-11-10 17:50:24 +01004887 if (comma && i > 1
4888 && (flags & P_ONECOMMA) == P_ONECOMMA
4889 && origval[i - 1] == ','
4890 && origval[i - 2] != '\\')
Bram Moolenaara7b7b1c2015-06-19 14:06:43 +02004891 i--;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004892 mch_memmove(newval + i + comma, newval,
4893 STRLEN(newval) + 1);
4894 mch_memmove(newval, origval, (size_t)i);
4895 }
4896 else
4897 {
4898 i = (int)STRLEN(newval);
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00004899 STRMOVE(newval + i + comma, origval);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004900 }
4901 if (comma)
4902 newval[i] = ',';
4903 }
4904
4905 /* Remove newval[] from origval[]. (Note: "i" has
4906 * been set above and is used here). */
4907 if (removing)
4908 {
4909 STRCPY(newval, origval);
4910 if (*s)
4911 {
4912 /* may need to remove a comma */
4913 if (flags & P_COMMA)
4914 {
4915 if (s == origval)
4916 {
4917 /* include comma after string */
4918 if (s[i] == ',')
4919 ++i;
4920 }
4921 else
4922 {
4923 /* include comma before string */
4924 --s;
4925 ++i;
4926 }
4927 }
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00004928 STRMOVE(newval + (s - origval), s + i);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004929 }
4930 }
4931
4932 if (flags & P_FLAGLIST)
4933 {
4934 /* Remove flags that appear twice. */
4935 for (s = newval; *s; ++s)
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02004936 {
4937 /* if options have P_FLAGLIST and
4938 * P_ONECOMMA such as 'whichwrap' */
4939 if (flags & P_ONECOMMA)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004940 {
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02004941 if (*s != ',' && *(s + 1) == ','
4942 && vim_strchr(s + 2, *s) != NULL)
4943 {
4944 /* Remove the duplicated value and
4945 * the next comma. */
4946 STRMOVE(s, s + 2);
4947 s -= 2;
4948 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004949 }
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02004950 else
4951 {
4952 if ((!(flags & P_COMMA) || *s != ',')
4953 && vim_strchr(s + 1, *s) != NULL)
4954 {
4955 STRMOVE(s, s + 1);
4956 --s;
4957 }
4958 }
4959 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004960 }
4961
4962 if (save_arg != NULL) /* number for 'whichwrap' */
4963 arg = save_arg;
4964 new_value_alloced = TRUE;
4965 }
4966
4967 /* Set the new value. */
4968 *(char_u **)(varp) = newval;
4969
Bram Moolenaar53744302015-07-17 17:38:22 +02004970#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
Bram Moolenaar5cbb8db2015-07-17 23:08:29 +02004971 if (!starting
4972# ifdef FEAT_CRYPT
4973 && options[opt_idx].indir != PV_KEY
4974# endif
Bram Moolenaar53744302015-07-17 17:38:22 +02004975 && origval != NULL)
4976 /* origval may be freed by
4977 * did_set_string_option(), make a copy. */
4978 saved_origval = vim_strsave(origval);
4979#endif
4980
Bram Moolenaar071d4272004-06-13 20:20:40 +00004981 /* Handle side effects, and set the global value for
4982 * ":set" on local options. */
4983 errmsg = did_set_string_option(opt_idx, (char_u **)varp,
4984 new_value_alloced, oldval, errbuf, opt_flags);
4985
4986 /* If error detected, print the error message. */
4987 if (errmsg != NULL)
Bram Moolenaara9884962015-12-13 15:08:56 +01004988 {
4989#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
4990 vim_free(saved_origval);
4991#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004992 goto skip;
Bram Moolenaara9884962015-12-13 15:08:56 +01004993 }
Bram Moolenaar53744302015-07-17 17:38:22 +02004994#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
4995 if (saved_origval != NULL)
4996 {
4997 char_u buf_type[7];
4998
4999 sprintf((char *)buf_type, "%s",
5000 (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar9cac4242015-07-19 14:42:23 +02005001 set_vim_var_string(VV_OPTION_NEW,
5002 *(char_u **)varp, -1);
Bram Moolenaar53744302015-07-17 17:38:22 +02005003 set_vim_var_string(VV_OPTION_OLD, saved_origval, -1);
5004 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
5005 apply_autocmds(EVENT_OPTIONSET,
5006 (char_u *)options[opt_idx].fullname,
5007 NULL, FALSE, NULL);
5008 reset_v_option_vars();
5009 vim_free(saved_origval);
5010 }
5011#endif
5012
Bram Moolenaar071d4272004-06-13 20:20:40 +00005013 }
5014 else /* key code option */
5015 {
5016 char_u *p;
5017
5018 if (nextchar == '&')
5019 {
5020 if (add_termcap_entry(key_name, TRUE) == FAIL)
5021 errmsg = (char_u *)N_("E522: Not found in termcap");
5022 }
5023 else
5024 {
5025 ++arg; /* jump to after the '=' or ':' */
5026 for (p = arg; *p && !vim_iswhite(*p); ++p)
5027 if (*p == '\\' && p[1] != NUL)
5028 ++p;
5029 nextchar = *p;
5030 *p = NUL;
5031 add_termcode(key_name, arg, FALSE);
5032 *p = nextchar;
5033 }
5034 if (full_screen)
5035 ttest(FALSE);
5036 redraw_all_later(CLEAR);
5037 }
5038 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005039
Bram Moolenaar071d4272004-06-13 20:20:40 +00005040 if (opt_idx >= 0)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005041 did_set_option(opt_idx, opt_flags,
5042 !prepending && !adding && !removing);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005043 }
5044
5045skip:
5046 /*
5047 * Advance to next argument.
5048 * - skip until a blank found, taking care of backslashes
5049 * - skip blanks
5050 * - skip one "=val" argument (for hidden options ":set gfn =xx")
5051 */
5052 for (i = 0; i < 2 ; ++i)
5053 {
5054 while (*arg != NUL && !vim_iswhite(*arg))
5055 if (*arg++ == '\\' && *arg != NUL)
5056 ++arg;
5057 arg = skipwhite(arg);
5058 if (*arg != '=')
5059 break;
5060 }
5061 }
5062
5063 if (errmsg != NULL)
5064 {
Bram Moolenaarce0842a2005-07-18 21:58:11 +00005065 vim_strncpy(IObuff, (char_u *)_(errmsg), IOSIZE - 1);
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00005066 i = (int)STRLEN(IObuff) + 2;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005067 if (i + (arg - startarg) < IOSIZE)
5068 {
5069 /* append the argument with the error */
5070 STRCAT(IObuff, ": ");
5071 mch_memmove(IObuff + i, startarg, (arg - startarg));
5072 IObuff[i + (arg - startarg)] = NUL;
5073 }
5074 /* make sure all characters are printable */
5075 trans_characters(IObuff, IOSIZE);
5076
5077 ++no_wait_return; /* wait_return done later */
5078 emsg(IObuff); /* show error highlighted */
5079 --no_wait_return;
5080
5081 return FAIL;
5082 }
5083
5084 arg = skipwhite(arg);
5085 }
5086
Bram Moolenaar26a60b42005-02-22 08:49:11 +00005087theend:
5088 if (silent_mode && did_show)
5089 {
5090 /* After displaying option values in silent mode. */
5091 silent_mode = FALSE;
5092 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
5093 msg_putchar('\n');
5094 cursor_on(); /* msg_start() switches it off */
5095 out_flush();
5096 silent_mode = TRUE;
5097 info_message = FALSE; /* use mch_msg(), not mch_errmsg() */
5098 }
5099
Bram Moolenaar071d4272004-06-13 20:20:40 +00005100 return OK;
5101}
5102
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005103/*
5104 * Call this when an option has been given a new value through a user command.
5105 * Sets the P_WAS_SET flag and takes care of the P_INSECURE flag.
5106 */
5107 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005108did_set_option(
5109 int opt_idx,
5110 int opt_flags, /* possibly with OPT_MODELINE */
5111 int new_value) /* value was replaced completely */
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005112{
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005113 long_u *p;
5114
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005115 options[opt_idx].flags |= P_WAS_SET;
5116
5117 /* When an option is set in the sandbox, from a modeline or in secure mode
5118 * set the P_INSECURE flag. Otherwise, if a new value is stored reset the
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005119 * flag. */
5120 p = insecure_flag(opt_idx, opt_flags);
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005121 if (secure
5122#ifdef HAVE_SANDBOX
5123 || sandbox != 0
5124#endif
5125 || (opt_flags & OPT_MODELINE))
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005126 *p = *p | P_INSECURE;
5127 else if (new_value)
5128 *p = *p & ~P_INSECURE;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005129}
5130
Bram Moolenaar071d4272004-06-13 20:20:40 +00005131 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005132illegal_char(char_u *errbuf, int c)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005133{
5134 if (errbuf == NULL)
5135 return (char_u *)"";
5136 sprintf((char *)errbuf, _("E539: Illegal character <%s>"),
Bram Moolenaar555b2802005-05-19 21:08:39 +00005137 (char *)transchar(c));
Bram Moolenaar071d4272004-06-13 20:20:40 +00005138 return errbuf;
5139}
5140
5141/*
5142 * Convert a key name or string into a key value.
5143 * Used for 'wildchar' and 'cedit' options.
5144 */
5145 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01005146string_to_key(char_u *arg)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005147{
5148 if (*arg == '<')
5149 return find_key_option(arg + 1);
5150 if (*arg == '^')
5151 return Ctrl_chr(arg[1]);
5152 return *arg;
5153}
5154
5155#ifdef FEAT_CMDWIN
5156/*
5157 * Check value of 'cedit' and set cedit_key.
5158 * Returns NULL if value is OK, error message otherwise.
5159 */
5160 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005161check_cedit(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005162{
5163 int n;
5164
5165 if (*p_cedit == NUL)
5166 cedit_key = -1;
5167 else
5168 {
5169 n = string_to_key(p_cedit);
5170 if (vim_isprintc(n))
5171 return e_invarg;
5172 cedit_key = n;
5173 }
5174 return NULL;
5175}
5176#endif
5177
5178#ifdef FEAT_TITLE
5179/*
5180 * When changing 'title', 'titlestring', 'icon' or 'iconstring', call
5181 * maketitle() to create and display it.
5182 * When switching the title or icon off, call mch_restore_title() to get
5183 * the old value back.
5184 */
5185 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005186did_set_title(
5187 int icon) /* Did set icon instead of title */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005188{
5189 if (starting != NO_SCREEN
5190#ifdef FEAT_GUI
5191 && !gui.starting
5192#endif
5193 )
5194 {
5195 maketitle();
5196 if (icon)
5197 {
5198 if (!p_icon)
5199 mch_restore_title(2);
5200 }
5201 else
5202 {
5203 if (!p_title)
5204 mch_restore_title(1);
5205 }
5206 }
5207}
5208#endif
5209
5210/*
5211 * set_options_bin - called when 'bin' changes value.
5212 */
5213 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005214set_options_bin(
5215 int oldval,
5216 int newval,
5217 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005218{
5219 /*
5220 * The option values that are changed when 'bin' changes are
5221 * copied when 'bin is set and restored when 'bin' is reset.
5222 */
5223 if (newval)
5224 {
5225 if (!oldval) /* switched on */
5226 {
5227 if (!(opt_flags & OPT_GLOBAL))
5228 {
5229 curbuf->b_p_tw_nobin = curbuf->b_p_tw;
5230 curbuf->b_p_wm_nobin = curbuf->b_p_wm;
5231 curbuf->b_p_ml_nobin = curbuf->b_p_ml;
5232 curbuf->b_p_et_nobin = curbuf->b_p_et;
5233 }
5234 if (!(opt_flags & OPT_LOCAL))
5235 {
5236 p_tw_nobin = p_tw;
5237 p_wm_nobin = p_wm;
5238 p_ml_nobin = p_ml;
5239 p_et_nobin = p_et;
5240 }
5241 }
5242
5243 if (!(opt_flags & OPT_GLOBAL))
5244 {
5245 curbuf->b_p_tw = 0; /* no automatic line wrap */
5246 curbuf->b_p_wm = 0; /* no automatic line wrap */
5247 curbuf->b_p_ml = 0; /* no modelines */
5248 curbuf->b_p_et = 0; /* no expandtab */
5249 }
5250 if (!(opt_flags & OPT_LOCAL))
5251 {
5252 p_tw = 0;
5253 p_wm = 0;
5254 p_ml = FALSE;
5255 p_et = FALSE;
5256 p_bin = TRUE; /* needed when called for the "-b" argument */
5257 }
5258 }
5259 else if (oldval) /* switched off */
5260 {
5261 if (!(opt_flags & OPT_GLOBAL))
5262 {
5263 curbuf->b_p_tw = curbuf->b_p_tw_nobin;
5264 curbuf->b_p_wm = curbuf->b_p_wm_nobin;
5265 curbuf->b_p_ml = curbuf->b_p_ml_nobin;
5266 curbuf->b_p_et = curbuf->b_p_et_nobin;
5267 }
5268 if (!(opt_flags & OPT_LOCAL))
5269 {
5270 p_tw = p_tw_nobin;
5271 p_wm = p_wm_nobin;
5272 p_ml = p_ml_nobin;
5273 p_et = p_et_nobin;
5274 }
5275 }
5276}
5277
5278#ifdef FEAT_VIMINFO
5279/*
5280 * Find the parameter represented by the given character (eg ', :, ", or /),
5281 * and return its associated value in the 'viminfo' string.
5282 * Only works for number parameters, not for 'r' or 'n'.
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +00005283 * If the parameter is not specified in the string or there is no following
5284 * number, return -1.
Bram Moolenaar071d4272004-06-13 20:20:40 +00005285 */
5286 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01005287get_viminfo_parameter(int type)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005288{
5289 char_u *p;
5290
5291 p = find_viminfo_parameter(type);
5292 if (p != NULL && VIM_ISDIGIT(*p))
5293 return atoi((char *)p);
5294 return -1;
5295}
5296
5297/*
5298 * Find the parameter represented by the given character (eg ''', ':', '"', or
5299 * '/') in the 'viminfo' option and return a pointer to the string after it.
5300 * Return NULL if the parameter is not specified in the string.
5301 */
5302 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005303find_viminfo_parameter(int type)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005304{
5305 char_u *p;
5306
5307 for (p = p_viminfo; *p; ++p)
5308 {
5309 if (*p == type)
5310 return p + 1;
5311 if (*p == 'n') /* 'n' is always the last one */
5312 break;
5313 p = vim_strchr(p, ','); /* skip until next ',' */
5314 if (p == NULL) /* hit the end without finding parameter */
5315 break;
5316 }
5317 return NULL;
5318}
5319#endif
5320
5321/*
5322 * Expand environment variables for some string options.
5323 * These string options cannot be indirect!
5324 * If "val" is NULL expand the current value of the option.
5325 * Return pointer to NameBuff, or NULL when not expanded.
5326 */
5327 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005328option_expand(int opt_idx, char_u *val)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005329{
5330 /* if option doesn't need expansion nothing to do */
5331 if (!(options[opt_idx].flags & P_EXPAND) || options[opt_idx].var == NULL)
5332 return NULL;
5333
5334 /* If val is longer than MAXPATHL no meaningful expansion can be done,
5335 * expand_env() would truncate the string. */
5336 if (val != NULL && STRLEN(val) > MAXPATHL)
5337 return NULL;
5338
5339 if (val == NULL)
5340 val = *(char_u **)options[opt_idx].var;
5341
5342 /*
5343 * Expanding this with NameBuff, expand_env() must not be passed IObuff.
5344 * Escape spaces when expanding 'tags', they are used to separate file
5345 * names.
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005346 * For 'spellsuggest' expand after "file:".
Bram Moolenaar071d4272004-06-13 20:20:40 +00005347 */
5348 expand_env_esc(val, NameBuff, MAXPATHL,
Bram Moolenaar9f0545d2007-09-26 20:36:32 +00005349 (char_u **)options[opt_idx].var == &p_tags, FALSE,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005350#ifdef FEAT_SPELL
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005351 (char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" :
5352#endif
5353 NULL);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005354 if (STRCMP(NameBuff, val) == 0) /* they are the same */
5355 return NULL;
5356
5357 return NameBuff;
5358}
5359
5360/*
5361 * After setting various option values: recompute variables that depend on
5362 * option values.
5363 */
5364 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005365didset_options(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005366{
5367 /* initialize the table for 'iskeyword' et.al. */
5368 (void)init_chartab();
5369
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00005370#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +00005371 (void)opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE);
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00005372#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005373 (void)opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, TRUE);
Bram Moolenaar165bc692015-07-21 17:53:25 +02005374 (void)opt_strings_flags(p_bo, p_bo_values, &bo_flags, TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005375#ifdef FEAT_SESSION
5376 (void)opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE);
5377 (void)opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE);
5378#endif
5379#ifdef FEAT_FOLDING
5380 (void)opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE);
5381#endif
5382 (void)opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE);
Bram Moolenaar0f6562e2015-11-24 18:48:14 +01005383 (void)opt_strings_flags(p_tc, p_tc_values, &tc_flags, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005384#ifdef FEAT_VIRTUALEDIT
5385 (void)opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE);
5386#endif
5387#if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
5388 (void)opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE);
5389#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005390#ifdef FEAT_SPELL
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00005391 (void)spell_check_msm();
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005392 (void)spell_check_sps();
Bram Moolenaar860cae12010-06-05 23:22:07 +02005393 (void)compile_cap_prog(curwin->w_s);
Bram Moolenaare68c25c2015-08-25 15:39:55 +02005394 (void)did_set_spell_option(TRUE);
Bram Moolenaard857f0e2005-06-21 22:37:39 +00005395#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005396#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
5397 (void)opt_strings_flags(p_toolbar, p_toolbar_values, &toolbar_flags, TRUE);
5398#endif
Bram Moolenaar182c5be2010-06-25 05:37:59 +02005399#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005400 (void)opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE);
5401#endif
5402#ifdef FEAT_CMDWIN
5403 /* set cedit_key */
5404 (void)check_cedit();
5405#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +02005406#ifdef FEAT_LINEBREAK
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02005407 briopt_check(curwin);
Bram Moolenaar597a4222014-06-25 14:39:50 +02005408#endif
Bram Moolenaare68c25c2015-08-25 15:39:55 +02005409#ifdef FEAT_LINEBREAK
5410 /* initialize the table for 'breakat'. */
5411 fill_breakat_flags();
5412#endif
5413
5414}
5415
5416/*
5417 * More side effects of setting options.
5418 */
5419 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005420didset_options2(void)
Bram Moolenaare68c25c2015-08-25 15:39:55 +02005421{
5422 /* Initialize the highlight_attr[] table. */
5423 (void)highlight_changed();
5424
5425 /* Parse default for 'wildmode' */
5426 check_opt_wim();
5427
5428 (void)set_chars_option(&p_lcs);
5429#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
5430 /* Parse default for 'fillchars'. */
5431 (void)set_chars_option(&p_fcs);
5432#endif
5433
5434#ifdef FEAT_CLIPBOARD
5435 /* Parse default for 'clipboard' */
5436 (void)check_clipboard_option();
5437#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005438}
5439
5440/*
5441 * Check for string options that are NULL (normally only termcap options).
5442 */
5443 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005444check_options(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005445{
5446 int opt_idx;
5447
5448 for (opt_idx = 0; options[opt_idx].fullname != NULL; opt_idx++)
5449 if ((options[opt_idx].flags & P_STRING) && options[opt_idx].var != NULL)
5450 check_string_option((char_u **)get_varp(&(options[opt_idx])));
5451}
5452
5453/*
5454 * Check string options in a buffer for NULL value.
5455 */
5456 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005457check_buf_options(buf_T *buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005458{
5459#if defined(FEAT_QUICKFIX)
5460 check_string_option(&buf->b_p_bh);
5461 check_string_option(&buf->b_p_bt);
5462#endif
5463#ifdef FEAT_MBYTE
5464 check_string_option(&buf->b_p_fenc);
5465#endif
5466 check_string_option(&buf->b_p_ff);
5467#ifdef FEAT_FIND_ID
5468 check_string_option(&buf->b_p_def);
5469 check_string_option(&buf->b_p_inc);
5470# ifdef FEAT_EVAL
5471 check_string_option(&buf->b_p_inex);
5472# endif
5473#endif
5474#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
5475 check_string_option(&buf->b_p_inde);
5476 check_string_option(&buf->b_p_indk);
5477#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00005478#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
5479 check_string_option(&buf->b_p_bexpr);
5480#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +02005481#if defined(FEAT_CRYPT)
5482 check_string_option(&buf->b_p_cm);
5483#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00005484#if defined(FEAT_EVAL)
5485 check_string_option(&buf->b_p_fex);
5486#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005487#ifdef FEAT_CRYPT
5488 check_string_option(&buf->b_p_key);
5489#endif
5490 check_string_option(&buf->b_p_kp);
5491 check_string_option(&buf->b_p_mps);
5492 check_string_option(&buf->b_p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +00005493 check_string_option(&buf->b_p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005494 check_string_option(&buf->b_p_isk);
5495#ifdef FEAT_COMMENTS
5496 check_string_option(&buf->b_p_com);
5497#endif
5498#ifdef FEAT_FOLDING
5499 check_string_option(&buf->b_p_cms);
5500#endif
5501 check_string_option(&buf->b_p_nf);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005502#ifdef FEAT_TEXTOBJ
5503 check_string_option(&buf->b_p_qe);
5504#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005505#ifdef FEAT_SYN_HL
5506 check_string_option(&buf->b_p_syn);
Bram Moolenaarb8060fe2016-01-19 22:29:28 +01005507 check_string_option(&buf->b_s.b_syn_isk);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005508#endif
5509#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02005510 check_string_option(&buf->b_s.b_p_spc);
5511 check_string_option(&buf->b_s.b_p_spf);
5512 check_string_option(&buf->b_s.b_p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005513#endif
5514#ifdef FEAT_SEARCHPATH
5515 check_string_option(&buf->b_p_sua);
5516#endif
5517#ifdef FEAT_CINDENT
5518 check_string_option(&buf->b_p_cink);
5519 check_string_option(&buf->b_p_cino);
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01005520 parse_cino(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005521#endif
5522#ifdef FEAT_AUTOCMD
5523 check_string_option(&buf->b_p_ft);
5524#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005525#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
5526 check_string_option(&buf->b_p_cinw);
5527#endif
5528#ifdef FEAT_INS_EXPAND
5529 check_string_option(&buf->b_p_cpt);
5530#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005531#ifdef FEAT_COMPL_FUNC
5532 check_string_option(&buf->b_p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +00005533 check_string_option(&buf->b_p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005534#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005535#ifdef FEAT_KEYMAP
5536 check_string_option(&buf->b_p_keymap);
5537#endif
5538#ifdef FEAT_QUICKFIX
5539 check_string_option(&buf->b_p_gp);
5540 check_string_option(&buf->b_p_mp);
5541 check_string_option(&buf->b_p_efm);
5542#endif
5543 check_string_option(&buf->b_p_ep);
5544 check_string_option(&buf->b_p_path);
5545 check_string_option(&buf->b_p_tags);
Bram Moolenaar0f6562e2015-11-24 18:48:14 +01005546 check_string_option(&buf->b_p_tc);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005547#ifdef FEAT_INS_EXPAND
5548 check_string_option(&buf->b_p_dict);
5549 check_string_option(&buf->b_p_tsr);
5550#endif
Bram Moolenaaraf6c1312014-03-12 18:55:58 +01005551#ifdef FEAT_LISP
5552 check_string_option(&buf->b_p_lw);
5553#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02005554 check_string_option(&buf->b_p_bkc);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005555}
5556
5557/*
5558 * Free the string allocated for an option.
5559 * Checks for the string being empty_option. This may happen if we're out of
5560 * memory, vim_strsave() returned NULL, which was replaced by empty_option by
5561 * check_options().
5562 * Does NOT check for P_ALLOCED flag!
5563 */
5564 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005565free_string_option(char_u *p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005566{
5567 if (p != empty_option)
5568 vim_free(p);
5569}
5570
5571 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005572clear_string_option(char_u **pp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005573{
5574 if (*pp != empty_option)
5575 vim_free(*pp);
5576 *pp = empty_option;
5577}
5578
5579 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005580check_string_option(char_u **pp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005581{
5582 if (*pp == NULL)
5583 *pp = empty_option;
5584}
5585
5586/*
5587 * Mark a terminal option as allocated, found by a pointer into term_strings[].
5588 */
5589 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005590set_term_option_alloced(char_u **p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005591{
5592 int opt_idx;
5593
5594 for (opt_idx = 1; options[opt_idx].fullname != NULL; opt_idx++)
5595 if (options[opt_idx].var == (char_u *)p)
5596 {
5597 options[opt_idx].flags |= P_ALLOCED;
5598 return;
5599 }
5600 return; /* cannot happen: didn't find it! */
5601}
5602
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005603#if defined(FEAT_EVAL) || defined(PROTO)
5604/*
5605 * Return TRUE when option "opt" was set from a modeline or in secure mode.
5606 * Return FALSE when it wasn't.
5607 * Return -1 for an unknown option.
5608 */
5609 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01005610was_set_insecurely(char_u *opt, int opt_flags)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005611{
5612 int idx = findoption(opt);
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005613 long_u *flagp;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005614
5615 if (idx >= 0)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005616 {
5617 flagp = insecure_flag(idx, opt_flags);
5618 return (*flagp & P_INSECURE) != 0;
5619 }
Bram Moolenaar95f09602016-11-10 20:01:45 +01005620 internal_error("was_set_insecurely()");
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005621 return -1;
5622}
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005623
5624/*
5625 * Get a pointer to the flags used for the P_INSECURE flag of option
5626 * "opt_idx". For some local options a local flags field is used.
5627 */
5628 static long_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005629insecure_flag(int opt_idx, int opt_flags)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005630{
5631 if (opt_flags & OPT_LOCAL)
5632 switch ((int)options[opt_idx].indir)
5633 {
5634#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005635 case PV_STL: return &curwin->w_p_stl_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005636#endif
5637#ifdef FEAT_EVAL
Bram Moolenaar2e978902006-05-13 12:37:50 +00005638# ifdef FEAT_FOLDING
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005639 case PV_FDE: return &curwin->w_p_fde_flags;
5640 case PV_FDT: return &curwin->w_p_fdt_flags;
Bram Moolenaar2e978902006-05-13 12:37:50 +00005641# endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00005642# ifdef FEAT_BEVAL
5643 case PV_BEXPR: return &curbuf->b_p_bexpr_flags;
5644# endif
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005645# if defined(FEAT_CINDENT)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005646 case PV_INDE: return &curbuf->b_p_inde_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005647# endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005648 case PV_FEX: return &curbuf->b_p_fex_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005649# ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005650 case PV_INEX: return &curbuf->b_p_inex_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005651# endif
5652#endif
5653 }
5654
5655 /* Nothing special, return global flags field. */
5656 return &options[opt_idx].flags;
5657}
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005658#endif
5659
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005660#ifdef FEAT_TITLE
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01005661static void redraw_titles(void);
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005662
5663/*
5664 * Redraw the window title and/or tab page text later.
5665 */
Bram Moolenaar9b578142016-01-30 19:39:49 +01005666static void redraw_titles(void)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005667{
5668 need_maketitle = TRUE;
5669# ifdef FEAT_WINDOWS
5670 redraw_tabline = TRUE;
5671# endif
5672}
5673#endif
5674
Bram Moolenaar071d4272004-06-13 20:20:40 +00005675/*
5676 * Set a string option to a new value (without checking the effect).
5677 * The string is copied into allocated memory.
5678 * if ("opt_idx" == -1) "name" is used, otherwise "opt_idx" is used.
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005679 * When "set_sid" is zero set the scriptID to current_SID. When "set_sid" is
Bram Moolenaard55de222007-05-06 13:38:48 +00005680 * SID_NONE don't set the scriptID. Otherwise set the scriptID to "set_sid".
Bram Moolenaar071d4272004-06-13 20:20:40 +00005681 */
5682 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005683set_string_option_direct(
5684 char_u *name,
5685 int opt_idx,
5686 char_u *val,
5687 int opt_flags, /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
5688 int set_sid UNUSED)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005689{
5690 char_u *s;
5691 char_u **varp;
5692 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
Bram Moolenaar89d40322006-08-29 15:30:07 +00005693 int idx = opt_idx;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005694
Bram Moolenaar89d40322006-08-29 15:30:07 +00005695 if (idx == -1) /* use name */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005696 {
Bram Moolenaar89d40322006-08-29 15:30:07 +00005697 idx = findoption(name);
5698 if (idx < 0) /* not found (should not happen) */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005699 {
5700 EMSG2(_(e_intern2), "set_string_option_direct()");
Bram Moolenaar95f09602016-11-10 20:01:45 +01005701 IEMSG2(_("For option %s"), name);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005702 return;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005703 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005704 }
5705
Bram Moolenaar89d40322006-08-29 15:30:07 +00005706 if (options[idx].var == NULL) /* can't set hidden option */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005707 return;
5708
5709 s = vim_strsave(val);
5710 if (s != NULL)
5711 {
Bram Moolenaar89d40322006-08-29 15:30:07 +00005712 varp = (char_u **)get_varp_scope(&(options[idx]),
Bram Moolenaar071d4272004-06-13 20:20:40 +00005713 both ? OPT_LOCAL : opt_flags);
Bram Moolenaar89d40322006-08-29 15:30:07 +00005714 if ((opt_flags & OPT_FREE) && (options[idx].flags & P_ALLOCED))
Bram Moolenaar071d4272004-06-13 20:20:40 +00005715 free_string_option(*varp);
5716 *varp = s;
5717
5718 /* For buffer/window local option may also set the global value. */
5719 if (both)
Bram Moolenaar89d40322006-08-29 15:30:07 +00005720 set_string_option_global(idx, varp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005721
Bram Moolenaar89d40322006-08-29 15:30:07 +00005722 options[idx].flags |= P_ALLOCED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005723
5724 /* When setting both values of a global option with a local value,
5725 * make the local value empty, so that the global value is used. */
Bram Moolenaar89d40322006-08-29 15:30:07 +00005726 if (((int)options[idx].indir & PV_BOTH) && both)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005727 {
5728 free_string_option(*varp);
5729 *varp = empty_option;
5730 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005731# ifdef FEAT_EVAL
5732 if (set_sid != SID_NONE)
Bram Moolenaar89d40322006-08-29 15:30:07 +00005733 set_option_scriptID_idx(idx, opt_flags,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005734 set_sid == 0 ? current_SID : set_sid);
5735# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005736 }
5737}
5738
5739/*
5740 * Set global value for string option when it's a local option.
5741 */
5742 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005743set_string_option_global(
5744 int opt_idx, /* option index */
5745 char_u **varp) /* pointer to option variable */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005746{
5747 char_u **p, *s;
5748
5749 /* the global value is always allocated */
5750 if (options[opt_idx].var == VAR_WIN)
5751 p = (char_u **)GLOBAL_WO(varp);
5752 else
5753 p = (char_u **)options[opt_idx].var;
5754 if (options[opt_idx].indir != PV_NONE
5755 && p != varp
5756 && (s = vim_strsave(*varp)) != NULL)
5757 {
5758 free_string_option(*p);
5759 *p = s;
5760 }
5761}
5762
5763/*
5764 * Set a string option to a new value, and handle the effects.
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005765 *
5766 * Returns NULL on success or error message on error.
Bram Moolenaar071d4272004-06-13 20:20:40 +00005767 */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005768 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005769set_string_option(
5770 int opt_idx,
5771 char_u *value,
5772 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005773{
5774 char_u *s;
5775 char_u **varp;
5776 char_u *oldval;
Bram Moolenaar53744302015-07-17 17:38:22 +02005777#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
5778 char_u *saved_oldval = NULL;
5779#endif
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005780 char_u *r = NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005781
5782 if (options[opt_idx].var == NULL) /* don't set hidden option */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005783 return NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005784
5785 s = vim_strsave(value);
5786 if (s != NULL)
5787 {
5788 varp = (char_u **)get_varp_scope(&(options[opt_idx]),
5789 (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00005790 ? (((int)options[opt_idx].indir & PV_BOTH)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005791 ? OPT_GLOBAL : OPT_LOCAL)
5792 : opt_flags);
5793 oldval = *varp;
5794 *varp = s;
Bram Moolenaar53744302015-07-17 17:38:22 +02005795
5796#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
Bram Moolenaar5cbb8db2015-07-17 23:08:29 +02005797 if (!starting
5798# ifdef FEAT_CRYPT
5799 && options[opt_idx].indir != PV_KEY
5800# endif
5801 )
Bram Moolenaar53744302015-07-17 17:38:22 +02005802 saved_oldval = vim_strsave(oldval);
5803#endif
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005804 if ((r = did_set_string_option(opt_idx, varp, TRUE, oldval, NULL,
5805 opt_flags)) == NULL)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005806 did_set_option(opt_idx, opt_flags, TRUE);
Bram Moolenaar53744302015-07-17 17:38:22 +02005807
5808 /* call autocomamnd after handling side effects */
5809#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
5810 if (saved_oldval != NULL)
5811 {
5812 char_u buf_type[7];
5813 sprintf((char *)buf_type, "%s",
5814 (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar9cac4242015-07-19 14:42:23 +02005815 set_vim_var_string(VV_OPTION_NEW, *varp, -1);
5816 set_vim_var_string(VV_OPTION_OLD, saved_oldval, -1);
Bram Moolenaar53744302015-07-17 17:38:22 +02005817 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
5818 apply_autocmds(EVENT_OPTIONSET, (char_u *)options[opt_idx].fullname, NULL, FALSE, NULL);
5819 reset_v_option_vars();
5820 vim_free(saved_oldval);
5821 }
5822#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005823 }
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005824 return r;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005825}
5826
Bram Moolenaar40d3f132016-11-05 20:13:35 +01005827#if defined(FEAT_KEYMAP) || defined(FEAT_AUTOCMD) || defined(FEAT_SYN_HL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005828/*
Bram Moolenaard0b51382016-11-04 15:23:45 +01005829 * Return TRUE if "val" is a valid 'filetype' name.
5830 * Also used for 'syntax' and 'keymap'.
5831 */
5832 static int
5833valid_filetype(char_u *val)
5834{
5835 char_u *s;
5836
5837 for (s = val; *s != NUL; ++s)
5838 if (!ASCII_ISALNUM(*s) && vim_strchr((char_u *)".-_", *s) == NULL)
5839 return FALSE;
5840 return TRUE;
5841}
Bram Moolenaar40d3f132016-11-05 20:13:35 +01005842#endif
Bram Moolenaard0b51382016-11-04 15:23:45 +01005843
5844/*
Bram Moolenaar071d4272004-06-13 20:20:40 +00005845 * Handle string options that need some action to perform when changed.
5846 * Returns NULL for success, or an error message for an error.
5847 */
5848 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005849did_set_string_option(
5850 int opt_idx, /* index in options[] table */
5851 char_u **varp, /* pointer to the option variable */
5852 int new_value_alloced, /* new value was allocated */
5853 char_u *oldval, /* previous value of the option */
5854 char_u *errbuf, /* buffer for errors, or NULL */
5855 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005856{
5857 char_u *errmsg = NULL;
5858 char_u *s, *p;
5859 int did_chartab = FALSE;
5860 char_u **gvarp;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00005861 long_u free_oldval = (options[opt_idx].flags & P_ALLOCED);
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00005862#ifdef FEAT_GUI
5863 /* set when changing an option that only requires a redraw in the GUI */
5864 int redraw_gui_only = FALSE;
5865#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005866
5867 /* Get the global option to compare with, otherwise we would have to check
5868 * two values for all local options. */
5869 gvarp = (char_u **)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL);
5870
5871 /* Disallow changing some options from secure mode */
5872 if ((secure
5873#ifdef HAVE_SANDBOX
5874 || sandbox != 0
5875#endif
5876 ) && (options[opt_idx].flags & P_SECURE))
5877 {
5878 errmsg = e_secure;
5879 }
5880
Bram Moolenaar7554da42016-11-25 22:04:13 +01005881 /* Check for a "normal" directory or file name in some options. Disallow a
5882 * path separator (slash and/or backslash), wildcards and characters that
Bram Moolenaar0945eaf2016-11-29 22:10:48 +01005883 * are often illegal in a file name. Be more permissive if "secure" is off.
5884 */
Bram Moolenaar7554da42016-11-25 22:04:13 +01005885 else if (((options[opt_idx].flags & P_NFNAME)
Bram Moolenaar0945eaf2016-11-29 22:10:48 +01005886 && vim_strpbrk(*varp, (char_u *)(secure
5887 ? "/\\*?[|;&<>\r\n" : "/\\*?[<>\r\n")) != NULL)
Bram Moolenaar7554da42016-11-25 22:04:13 +01005888 || ((options[opt_idx].flags & P_NDNAME)
5889 && vim_strpbrk(*varp, (char_u *)"*?[|;&<>\r\n") != NULL))
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00005890 {
5891 errmsg = e_invarg;
5892 }
5893
Bram Moolenaar071d4272004-06-13 20:20:40 +00005894 /* 'term' */
5895 else if (varp == &T_NAME)
5896 {
5897 if (T_NAME[0] == NUL)
5898 errmsg = (char_u *)N_("E529: Cannot set 'term' to empty string");
5899#ifdef FEAT_GUI
5900 if (gui.in_use)
5901 errmsg = (char_u *)N_("E530: Cannot change term in GUI");
5902 else if (term_is_gui(T_NAME))
5903 errmsg = (char_u *)N_("E531: Use \":gui\" to start the GUI");
5904#endif
5905 else if (set_termname(T_NAME) == FAIL)
5906 errmsg = (char_u *)N_("E522: Not found in termcap");
5907 else
5908 /* Screen colors may have changed. */
5909 redraw_later_clear();
5910 }
5911
5912 /* 'backupcopy' */
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02005913 else if (gvarp == &p_bkc)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005914 {
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02005915 char_u *bkc = p_bkc;
5916 unsigned int *flags = &bkc_flags;
5917
5918 if (opt_flags & OPT_LOCAL)
5919 {
5920 bkc = curbuf->b_p_bkc;
5921 flags = &curbuf->b_bkc_flags;
5922 }
5923
Bram Moolenaar84d17a62014-09-29 17:15:18 +02005924 if ((opt_flags & OPT_LOCAL) && *bkc == NUL)
5925 /* make the local value empty: use the global value */
5926 *flags = 0;
5927 else
Bram Moolenaar071d4272004-06-13 20:20:40 +00005928 {
Bram Moolenaar84d17a62014-09-29 17:15:18 +02005929 if (opt_strings_flags(bkc, p_bkc_values, flags, TRUE) != OK)
5930 errmsg = e_invarg;
5931 if ((((int)*flags & BKC_AUTO) != 0)
5932 + (((int)*flags & BKC_YES) != 0)
5933 + (((int)*flags & BKC_NO) != 0) != 1)
5934 {
5935 /* Must have exactly one of "auto", "yes" and "no". */
5936 (void)opt_strings_flags(oldval, p_bkc_values, flags, TRUE);
5937 errmsg = e_invarg;
5938 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005939 }
5940 }
5941
5942 /* 'backupext' and 'patchmode' */
5943 else if (varp == &p_bex || varp == &p_pm)
5944 {
5945 if (STRCMP(*p_bex == '.' ? p_bex + 1 : p_bex,
5946 *p_pm == '.' ? p_pm + 1 : p_pm) == 0)
5947 errmsg = (char_u *)N_("E589: 'backupext' and 'patchmode' are equal");
5948 }
Bram Moolenaar597a4222014-06-25 14:39:50 +02005949#ifdef FEAT_LINEBREAK
5950 /* 'breakindentopt' */
5951 else if (varp == &curwin->w_p_briopt)
5952 {
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02005953 if (briopt_check(curwin) == FAIL)
Bram Moolenaar597a4222014-06-25 14:39:50 +02005954 errmsg = e_invarg;
5955 }
5956#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005957
5958 /*
Bram Moolenaar88e8f9f2016-01-20 22:48:02 +01005959 * 'isident', 'iskeyword', 'isprint or 'isfname' option: refill g_chartab[]
Bram Moolenaar071d4272004-06-13 20:20:40 +00005960 * If the new option is invalid, use old value. 'lisp' option: refill
Bram Moolenaar88e8f9f2016-01-20 22:48:02 +01005961 * g_chartab[] for '-' char
Bram Moolenaar071d4272004-06-13 20:20:40 +00005962 */
5963 else if ( varp == &p_isi
5964 || varp == &(curbuf->b_p_isk)
5965 || varp == &p_isp
5966 || varp == &p_isf)
5967 {
5968 if (init_chartab() == FAIL)
5969 {
5970 did_chartab = TRUE; /* need to restore it below */
5971 errmsg = e_invarg; /* error in value */
5972 }
5973 }
5974
5975 /* 'helpfile' */
5976 else if (varp == &p_hf)
5977 {
5978 /* May compute new values for $VIM and $VIMRUNTIME */
5979 if (didset_vim)
5980 {
5981 vim_setenv((char_u *)"VIM", (char_u *)"");
5982 didset_vim = FALSE;
5983 }
5984 if (didset_vimruntime)
5985 {
5986 vim_setenv((char_u *)"VIMRUNTIME", (char_u *)"");
5987 didset_vimruntime = FALSE;
5988 }
5989 }
5990
Bram Moolenaar1a384422010-07-14 19:53:30 +02005991#ifdef FEAT_SYN_HL
5992 /* 'colorcolumn' */
5993 else if (varp == &curwin->w_p_cc)
5994 errmsg = check_colorcolumn(curwin);
5995#endif
5996
Bram Moolenaar071d4272004-06-13 20:20:40 +00005997#ifdef FEAT_MULTI_LANG
5998 /* 'helplang' */
5999 else if (varp == &p_hlg)
6000 {
6001 /* Check for "", "ab", "ab,cd", etc. */
6002 for (s = p_hlg; *s != NUL; s += 3)
6003 {
6004 if (s[1] == NUL || ((s[2] != ',' || s[3] == NUL) && s[2] != NUL))
6005 {
6006 errmsg = e_invarg;
6007 break;
6008 }
6009 if (s[2] == NUL)
6010 break;
6011 }
6012 }
6013#endif
6014
6015 /* 'highlight' */
6016 else if (varp == &p_hl)
6017 {
6018 if (highlight_changed() == FAIL)
6019 errmsg = e_invarg; /* invalid flags */
6020 }
6021
6022 /* 'nrformats' */
6023 else if (gvarp == &p_nf)
6024 {
6025 if (check_opt_strings(*varp, p_nf_values, TRUE) != OK)
6026 errmsg = e_invarg;
6027 }
6028
6029#ifdef FEAT_SESSION
6030 /* 'sessionoptions' */
6031 else if (varp == &p_ssop)
6032 {
6033 if (opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE) != OK)
6034 errmsg = e_invarg;
6035 if ((ssop_flags & SSOP_CURDIR) && (ssop_flags & SSOP_SESDIR))
6036 {
6037 /* Don't allow both "sesdir" and "curdir". */
6038 (void)opt_strings_flags(oldval, p_ssop_values, &ssop_flags, TRUE);
6039 errmsg = e_invarg;
6040 }
6041 }
6042 /* 'viewoptions' */
6043 else if (varp == &p_vop)
6044 {
6045 if (opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE) != OK)
6046 errmsg = e_invarg;
6047 }
6048#endif
6049
6050 /* 'scrollopt' */
6051#ifdef FEAT_SCROLLBIND
6052 else if (varp == &p_sbo)
6053 {
6054 if (check_opt_strings(p_sbo, p_scbopt_values, TRUE) != OK)
6055 errmsg = e_invarg;
6056 }
6057#endif
6058
6059 /* 'ambiwidth' */
6060#ifdef FEAT_MBYTE
Bram Moolenaar3848e002016-03-19 18:42:29 +01006061 else if (varp == &p_ambw || varp == &p_emoji)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006062 {
6063 if (check_opt_strings(p_ambw, p_ambw_values, FALSE) != OK)
6064 errmsg = e_invarg;
Bram Moolenaar5c3bd0a2010-08-04 20:55:44 +02006065 else if (set_chars_option(&p_lcs) != NULL)
6066 errmsg = (char_u *)_("E834: Conflicts with value of 'listchars'");
6067# if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
6068 else if (set_chars_option(&p_fcs) != NULL)
6069 errmsg = (char_u *)_("E835: Conflicts with value of 'fillchars'");
6070# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006071 }
6072#endif
6073
6074 /* 'background' */
6075 else if (varp == &p_bg)
6076 {
6077 if (check_opt_strings(p_bg, p_bg_values, FALSE) == OK)
6078 {
6079#ifdef FEAT_EVAL
6080 int dark = (*p_bg == 'd');
6081#endif
6082
6083 init_highlight(FALSE, FALSE);
6084
6085#ifdef FEAT_EVAL
6086 if (dark != (*p_bg == 'd')
6087 && get_var_value((char_u *)"g:colors_name") != NULL)
6088 {
6089 /* The color scheme must have set 'background' back to another
6090 * value, that's not what we want here. Disable the color
6091 * scheme and set the colors again. */
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00006092 do_unlet((char_u *)"g:colors_name", TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006093 free_string_option(p_bg);
6094 p_bg = vim_strsave((char_u *)(dark ? "dark" : "light"));
6095 check_string_option(&p_bg);
6096 init_highlight(FALSE, FALSE);
6097 }
6098#endif
6099 }
6100 else
6101 errmsg = e_invarg;
6102 }
6103
6104 /* 'wildmode' */
6105 else if (varp == &p_wim)
6106 {
6107 if (check_opt_wim() == FAIL)
6108 errmsg = e_invarg;
6109 }
6110
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00006111#ifdef FEAT_CMDL_COMPL
6112 /* 'wildoptions' */
6113 else if (varp == &p_wop)
6114 {
6115 if (check_opt_strings(p_wop, p_wop_values, TRUE) != OK)
6116 errmsg = e_invarg;
6117 }
6118#endif
6119
Bram Moolenaar071d4272004-06-13 20:20:40 +00006120#ifdef FEAT_WAK
6121 /* 'winaltkeys' */
6122 else if (varp == &p_wak)
6123 {
6124 if (*p_wak == NUL
6125 || check_opt_strings(p_wak, p_wak_values, FALSE) != OK)
6126 errmsg = e_invarg;
6127# ifdef FEAT_MENU
6128# ifdef FEAT_GUI_MOTIF
6129 else if (gui.in_use)
6130 gui_motif_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
6131# else
6132# ifdef FEAT_GUI_GTK
6133 else if (gui.in_use)
6134 gui_gtk_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
6135# endif
6136# endif
6137# endif
6138 }
6139#endif
6140
6141#ifdef FEAT_AUTOCMD
6142 /* 'eventignore' */
6143 else if (varp == &p_ei)
6144 {
6145 if (check_ei() == FAIL)
6146 errmsg = e_invarg;
6147 }
6148#endif
6149
6150#ifdef FEAT_MBYTE
6151 /* 'encoding' and 'fileencoding' */
6152 else if (varp == &p_enc || gvarp == &p_fenc || varp == &p_tenc)
6153 {
6154 if (gvarp == &p_fenc)
6155 {
Bram Moolenaarf2f70252008-02-13 17:36:06 +00006156 if (!curbuf->b_p_ma && opt_flags != OPT_GLOBAL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006157 errmsg = e_modifiable;
6158 else if (vim_strchr(*varp, ',') != NULL)
6159 /* No comma allowed in 'fileencoding'; catches confusing it
6160 * with 'fileencodings'. */
6161 errmsg = e_invarg;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006162 else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006163 {
6164# ifdef FEAT_TITLE
Bram Moolenaar071d4272004-06-13 20:20:40 +00006165 /* May show a "+" in the title now. */
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006166 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006167# endif
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006168 /* Add 'fileencoding' to the swap file. */
6169 ml_setflags(curbuf);
6170 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006171 }
6172 if (errmsg == NULL)
6173 {
6174 /* canonize the value, so that STRCMP() can be used on it */
6175 p = enc_canonize(*varp);
6176 if (p != NULL)
6177 {
6178 vim_free(*varp);
6179 *varp = p;
6180 }
6181 if (varp == &p_enc)
6182 {
6183 errmsg = mb_init();
6184# ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006185 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006186# endif
6187 }
6188 }
6189
Bram Moolenaar182c5be2010-06-25 05:37:59 +02006190# if defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006191 if (errmsg == NULL && varp == &p_tenc && gui.in_use)
6192 {
6193 /* GTK+ 2 uses only a single encoding, and that is UTF-8. */
6194 if (STRCMP(p_tenc, "utf-8") != 0)
6195 errmsg = (char_u *)N_("E617: Cannot be changed in the GTK+ 2 GUI");
6196 }
6197# endif
6198
6199 if (errmsg == NULL)
6200 {
6201# ifdef FEAT_KEYMAP
6202 /* When 'keymap' is used and 'encoding' changes, reload the keymap
6203 * (with another encoding). */
6204 if (varp == &p_enc && *curbuf->b_p_keymap != NUL)
6205 (void)keymap_init();
6206# endif
6207
6208 /* When 'termencoding' is not empty and 'encoding' changes or when
6209 * 'termencoding' changes, need to setup for keyboard input and
6210 * display output conversion. */
6211 if (((varp == &p_enc && *p_tenc != NUL) || varp == &p_tenc))
6212 {
6213 convert_setup(&input_conv, p_tenc, p_enc);
6214 convert_setup(&output_conv, p_enc, p_tenc);
6215 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00006216
6217# if defined(WIN3264) && defined(FEAT_MBYTE)
6218 /* $HOME may have characters in active code page. */
6219 if (varp == &p_enc)
6220 init_homedir();
6221# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006222 }
6223 }
6224#endif
6225
6226#if defined(FEAT_POSTSCRIPT)
6227 else if (varp == &p_penc)
6228 {
6229 /* Canonize printencoding if VIM standard one */
6230 p = enc_canonize(p_penc);
6231 if (p != NULL)
6232 {
6233 vim_free(p_penc);
6234 p_penc = p;
6235 }
6236 else
6237 {
6238 /* Ensure lower case and '-' for '_' */
6239 for (s = p_penc; *s != NUL; s++)
6240 {
6241 if (*s == '_')
6242 *s = '-';
6243 else
6244 *s = TOLOWER_ASC(*s);
6245 }
6246 }
6247 }
6248#endif
6249
Bram Moolenaar9372a112005-12-06 19:59:18 +00006250#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006251 else if (varp == &p_imak)
6252 {
6253 if (gui.in_use && !im_xim_isvalid_imactivate())
6254 errmsg = e_invarg;
6255 }
6256#endif
6257
6258#ifdef FEAT_KEYMAP
6259 else if (varp == &curbuf->b_p_keymap)
6260 {
Bram Moolenaard0b51382016-11-04 15:23:45 +01006261 if (!valid_filetype(*varp))
6262 errmsg = e_invarg;
6263 else
6264 /* load or unload key mapping tables */
6265 errmsg = keymap_init();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006266
Bram Moolenaarfab06232009-03-04 03:13:35 +00006267 if (errmsg == NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006268 {
Bram Moolenaarfab06232009-03-04 03:13:35 +00006269 if (*curbuf->b_p_keymap != NUL)
6270 {
6271 /* Installed a new keymap, switch on using it. */
6272 curbuf->b_p_iminsert = B_IMODE_LMAP;
6273 if (curbuf->b_p_imsearch != B_IMODE_USE_INSERT)
6274 curbuf->b_p_imsearch = B_IMODE_LMAP;
6275 }
6276 else
6277 {
6278 /* Cleared the keymap, may reset 'iminsert' and 'imsearch'. */
6279 if (curbuf->b_p_iminsert == B_IMODE_LMAP)
6280 curbuf->b_p_iminsert = B_IMODE_NONE;
6281 if (curbuf->b_p_imsearch == B_IMODE_LMAP)
6282 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
6283 }
6284 if ((opt_flags & OPT_LOCAL) == 0)
6285 {
6286 set_iminsert_global();
6287 set_imsearch_global();
6288 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006289# ifdef FEAT_WINDOWS
6290 status_redraw_curbuf();
6291# endif
6292 }
6293 }
6294#endif
6295
6296 /* 'fileformat' */
6297 else if (gvarp == &p_ff)
6298 {
6299 if (!curbuf->b_p_ma && !(opt_flags & OPT_GLOBAL))
6300 errmsg = e_modifiable;
6301 else if (check_opt_strings(*varp, p_ff_values, FALSE) != OK)
6302 errmsg = e_invarg;
6303 else
6304 {
6305 /* may also change 'textmode' */
6306 if (get_fileformat(curbuf) == EOL_DOS)
6307 curbuf->b_p_tx = TRUE;
6308 else
6309 curbuf->b_p_tx = FALSE;
6310#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006311 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006312#endif
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006313 /* update flag in swap file */
6314 ml_setflags(curbuf);
Bram Moolenaar0413d482010-02-11 17:02:11 +01006315 /* Redraw needed when switching to/from "mac": a CR in the text
6316 * will be displayed differently. */
6317 if (get_fileformat(curbuf) == EOL_MAC || *oldval == 'm')
6318 redraw_curbuf_later(NOT_VALID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006319 }
6320 }
6321
6322 /* 'fileformats' */
6323 else if (varp == &p_ffs)
6324 {
6325 if (check_opt_strings(p_ffs, p_ff_values, TRUE) != OK)
6326 errmsg = e_invarg;
6327 else
6328 {
6329 /* also change 'textauto' */
6330 if (*p_ffs == NUL)
6331 p_ta = FALSE;
6332 else
6333 p_ta = TRUE;
6334 }
6335 }
6336
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006337#if defined(FEAT_CRYPT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006338 /* 'cryptkey' */
6339 else if (gvarp == &p_key)
6340 {
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006341# if defined(FEAT_CMDHIST)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006342 /* Make sure the ":set" command doesn't show the new value in the
6343 * history. */
6344 remove_key_from_history();
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006345# endif
6346 if (STRCMP(curbuf->b_p_key, oldval) != 0)
6347 /* Need to update the swapfile. */
Bram Moolenaarbc563362015-06-09 18:35:25 +02006348 ml_set_crypt_key(curbuf, oldval,
6349 *curbuf->b_p_cm == NUL ? p_cm : curbuf->b_p_cm);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006350 }
6351
6352 else if (gvarp == &p_cm)
6353 {
6354 if (opt_flags & OPT_LOCAL)
6355 p = curbuf->b_p_cm;
6356 else
6357 p = p_cm;
6358 if (check_opt_strings(p, p_cm_values, TRUE) != OK)
6359 errmsg = e_invarg;
Bram Moolenaar8f4ac012014-08-10 13:38:34 +02006360 else if (crypt_self_test() == FAIL)
Bram Moolenaar49771f42010-07-20 17:32:38 +02006361 errmsg = e_invarg;
6362 else
6363 {
6364 /* When setting the global value to empty, make it "zip". */
6365 if (*p_cm == NUL)
6366 {
6367 if (new_value_alloced)
6368 free_string_option(p_cm);
6369 p_cm = vim_strsave((char_u *)"zip");
6370 new_value_alloced = TRUE;
6371 }
Bram Moolenaar2be79502014-08-13 21:58:28 +02006372 /* When using ":set cm=name" the local value is going to be empty.
6373 * Do that here, otherwise the crypt functions will still use the
6374 * local value. */
6375 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
6376 {
6377 free_string_option(curbuf->b_p_cm);
6378 curbuf->b_p_cm = empty_option;
6379 }
Bram Moolenaar49771f42010-07-20 17:32:38 +02006380
6381 /* Need to update the swapfile when the effective method changed.
6382 * Set "s" to the effective old value, "p" to the effective new
6383 * method and compare. */
6384 if ((opt_flags & OPT_LOCAL) && *oldval == NUL)
6385 s = p_cm; /* was previously using the global value */
6386 else
6387 s = oldval;
6388 if (*curbuf->b_p_cm == NUL)
6389 p = p_cm; /* is now using the global value */
6390 else
6391 p = curbuf->b_p_cm;
6392 if (STRCMP(s, p) != 0)
Bram Moolenaarbc563362015-06-09 18:35:25 +02006393 ml_set_crypt_key(curbuf, curbuf->b_p_key, s);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006394
6395 /* If the global value changes need to update the swapfile for all
6396 * buffers using that value. */
6397 if ((opt_flags & OPT_GLOBAL) && STRCMP(p_cm, oldval) != 0)
6398 {
6399 buf_T *buf;
6400
Bram Moolenaar29323592016-07-24 22:04:11 +02006401 FOR_ALL_BUFFERS(buf)
Bram Moolenaar49771f42010-07-20 17:32:38 +02006402 if (buf != curbuf && *buf->b_p_cm == NUL)
Bram Moolenaarbc563362015-06-09 18:35:25 +02006403 ml_set_crypt_key(buf, buf->b_p_key, oldval);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006404 }
6405 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006406 }
6407#endif
6408
6409 /* 'matchpairs' */
6410 else if (gvarp == &p_mps)
6411 {
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006412#ifdef FEAT_MBYTE
6413 if (has_mbyte)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006414 {
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006415 for (p = *varp; *p != NUL; ++p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006416 {
Bram Moolenaar09365022013-01-17 17:37:35 +01006417 int x2 = -1;
6418 int x3 = -1;
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006419
6420 if (*p != NUL)
6421 p += mb_ptr2len(p);
6422 if (*p != NUL)
6423 x2 = *p++;
6424 if (*p != NUL)
6425 {
6426 x3 = mb_ptr2char(p);
6427 p += mb_ptr2len(p);
6428 }
Bram Moolenaar09365022013-01-17 17:37:35 +01006429 if (x2 != ':' || x3 == -1 || (*p != NUL && *p != ','))
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006430 {
6431 errmsg = e_invarg;
6432 break;
6433 }
6434 if (*p == NUL)
6435 break;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006436 }
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006437 }
6438 else
6439#endif
6440 {
6441 /* Check for "x:y,x:y" */
6442 for (p = *varp; *p != NUL; p += 4)
6443 {
6444 if (p[1] != ':' || p[2] == NUL || (p[3] != NUL && p[3] != ','))
6445 {
6446 errmsg = e_invarg;
6447 break;
6448 }
6449 if (p[3] == NUL)
6450 break;
6451 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006452 }
6453 }
6454
6455#ifdef FEAT_COMMENTS
6456 /* 'comments' */
6457 else if (gvarp == &p_com)
6458 {
6459 for (s = *varp; *s; )
6460 {
6461 while (*s && *s != ':')
6462 {
6463 if (vim_strchr((char_u *)COM_ALL, *s) == NULL
6464 && !VIM_ISDIGIT(*s) && *s != '-')
6465 {
6466 errmsg = illegal_char(errbuf, *s);
6467 break;
6468 }
6469 ++s;
6470 }
6471 if (*s++ == NUL)
6472 errmsg = (char_u *)N_("E524: Missing colon");
6473 else if (*s == ',' || *s == NUL)
6474 errmsg = (char_u *)N_("E525: Zero length string");
6475 if (errmsg != NULL)
6476 break;
6477 while (*s && *s != ',')
6478 {
6479 if (*s == '\\' && s[1] != NUL)
6480 ++s;
6481 ++s;
6482 }
6483 s = skip_to_option_part(s);
6484 }
6485 }
6486#endif
6487
6488 /* 'listchars' */
6489 else if (varp == &p_lcs)
6490 {
6491 errmsg = set_chars_option(varp);
6492 }
6493
6494#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
6495 /* 'fillchars' */
6496 else if (varp == &p_fcs)
6497 {
6498 errmsg = set_chars_option(varp);
6499 }
6500#endif
6501
6502#ifdef FEAT_CMDWIN
6503 /* 'cedit' */
6504 else if (varp == &p_cedit)
6505 {
6506 errmsg = check_cedit();
6507 }
6508#endif
6509
Bram Moolenaar54ee7752005-05-31 22:22:17 +00006510 /* 'verbosefile' */
6511 else if (varp == &p_vfile)
6512 {
6513 verbose_stop();
6514 if (*p_vfile != NUL && verbose_open() == FAIL)
6515 errmsg = e_invarg;
6516 }
6517
Bram Moolenaar071d4272004-06-13 20:20:40 +00006518#ifdef FEAT_VIMINFO
6519 /* 'viminfo' */
6520 else if (varp == &p_viminfo)
6521 {
6522 for (s = p_viminfo; *s;)
6523 {
6524 /* Check it's a valid character */
6525 if (vim_strchr((char_u *)"!\"%'/:<@cfhnrs", *s) == NULL)
6526 {
6527 errmsg = illegal_char(errbuf, *s);
6528 break;
6529 }
6530 if (*s == 'n') /* name is always last one */
6531 {
6532 break;
6533 }
6534 else if (*s == 'r') /* skip until next ',' */
6535 {
6536 while (*++s && *s != ',')
6537 ;
6538 }
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +00006539 else if (*s == '%')
6540 {
6541 /* optional number */
6542 while (vim_isdigit(*++s))
6543 ;
6544 }
6545 else if (*s == '!' || *s == 'h' || *s == 'c')
Bram Moolenaar071d4272004-06-13 20:20:40 +00006546 ++s; /* no extra chars */
6547 else /* must have a number */
6548 {
6549 while (vim_isdigit(*++s))
6550 ;
6551
6552 if (!VIM_ISDIGIT(*(s - 1)))
6553 {
6554 if (errbuf != NULL)
6555 {
Bram Moolenaar8f999f12005-01-25 22:12:55 +00006556 sprintf((char *)errbuf,
6557 _("E526: Missing number after <%s>"),
Bram Moolenaar071d4272004-06-13 20:20:40 +00006558 transchar_byte(*(s - 1)));
6559 errmsg = errbuf;
6560 }
6561 else
6562 errmsg = (char_u *)"";
6563 break;
6564 }
6565 }
6566 if (*s == ',')
6567 ++s;
6568 else if (*s)
6569 {
6570 if (errbuf != NULL)
6571 errmsg = (char_u *)N_("E527: Missing comma");
6572 else
6573 errmsg = (char_u *)"";
6574 break;
6575 }
6576 }
6577 if (*p_viminfo && errmsg == NULL && get_viminfo_parameter('\'') < 0)
6578 errmsg = (char_u *)N_("E528: Must specify a ' value");
6579 }
6580#endif /* FEAT_VIMINFO */
6581
6582 /* terminal options */
6583 else if (istermoption(&options[opt_idx]) && full_screen)
6584 {
6585 /* ":set t_Co=0" and ":set t_Co=1" do ":set t_Co=" */
6586 if (varp == &T_CCO)
6587 {
Bram Moolenaarc84e8952009-03-18 13:21:18 +00006588 int colors = atoi((char *)T_CCO);
6589
6590 /* Only reinitialize colors if t_Co value has really changed to
6591 * avoid expensive reload of colorscheme if t_Co is set to the
6592 * same value multiple times. */
6593 if (colors != t_colors)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006594 {
Bram Moolenaarc84e8952009-03-18 13:21:18 +00006595 t_colors = colors;
6596 if (t_colors <= 1)
6597 {
6598 if (new_value_alloced)
6599 vim_free(T_CCO);
6600 T_CCO = empty_option;
6601 }
6602 /* We now have a different color setup, initialize it again. */
6603 init_highlight(TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006604 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006605 }
6606 ttest(FALSE);
6607 if (varp == &T_ME)
6608 {
6609 out_str(T_ME);
6610 redraw_later(CLEAR);
Bram Moolenaar48e330a2016-02-23 14:53:34 +01006611#if defined(WIN3264) && !defined(FEAT_GUI_W32)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006612 /* Since t_me has been set, this probably means that the user
6613 * wants to use this as default colors. Need to reset default
6614 * background/foreground colors. */
6615 mch_set_normal_colors();
6616#endif
6617 }
6618 }
6619
6620#ifdef FEAT_LINEBREAK
6621 /* 'showbreak' */
6622 else if (varp == &p_sbr)
6623 {
6624 for (s = p_sbr; *s; )
6625 {
6626 if (ptr2cells(s) != 1)
6627 errmsg = (char_u *)N_("E595: contains unprintable or wide character");
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006628 mb_ptr_adv(s);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006629 }
6630 }
6631#endif
6632
6633#ifdef FEAT_GUI
6634 /* 'guifont' */
6635 else if (varp == &p_guifont)
6636 {
6637 if (gui.in_use)
6638 {
6639 p = p_guifont;
Bram Moolenaar9372a112005-12-06 19:59:18 +00006640# if defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006641 /*
6642 * Put up a font dialog and let the user select a new value.
6643 * If this is cancelled go back to the old value but don't
6644 * give an error message.
6645 */
6646 if (STRCMP(p, "*") == 0)
6647 {
6648 p = gui_mch_font_dialog(oldval);
6649
6650 if (new_value_alloced)
6651 free_string_option(p_guifont);
6652
6653 p_guifont = (p != NULL) ? p : vim_strsave(oldval);
6654 new_value_alloced = TRUE;
6655 }
6656# endif
6657 if (p != NULL && gui_init_font(p_guifont, FALSE) != OK)
6658 {
6659# if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_PHOTON)
6660 if (STRCMP(p_guifont, "*") == 0)
6661 {
6662 /* Dialog was cancelled: Keep the old value without giving
6663 * an error message. */
6664 if (new_value_alloced)
6665 free_string_option(p_guifont);
6666 p_guifont = vim_strsave(oldval);
6667 new_value_alloced = TRUE;
6668 }
6669 else
6670# endif
6671 errmsg = (char_u *)N_("E596: Invalid font(s)");
6672 }
6673 }
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006674 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006675 }
6676# ifdef FEAT_XFONTSET
6677 else if (varp == &p_guifontset)
6678 {
6679 if (STRCMP(p_guifontset, "*") == 0)
6680 errmsg = (char_u *)N_("E597: can't select fontset");
6681 else if (gui.in_use && gui_init_font(p_guifontset, TRUE) != OK)
6682 errmsg = (char_u *)N_("E598: Invalid fontset");
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006683 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006684 }
6685# endif
6686# ifdef FEAT_MBYTE
6687 else if (varp == &p_guifontwide)
6688 {
6689 if (STRCMP(p_guifontwide, "*") == 0)
6690 errmsg = (char_u *)N_("E533: can't select wide font");
6691 else if (gui_get_wide_font() == FAIL)
6692 errmsg = (char_u *)N_("E534: Invalid wide font");
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006693 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006694 }
6695# endif
6696#endif
6697
6698#ifdef CURSOR_SHAPE
6699 /* 'guicursor' */
6700 else if (varp == &p_guicursor)
6701 errmsg = parse_shape_opt(SHAPE_CURSOR);
6702#endif
6703
6704#ifdef FEAT_MOUSESHAPE
6705 /* 'mouseshape' */
6706 else if (varp == &p_mouseshape)
6707 {
6708 errmsg = parse_shape_opt(SHAPE_MOUSE);
6709 update_mouseshape(-1);
6710 }
6711#endif
6712
6713#ifdef FEAT_PRINTER
6714 else if (varp == &p_popt)
Bram Moolenaar58d98232005-07-23 22:25:46 +00006715 errmsg = parse_printoptions();
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00006716# if defined(FEAT_MBYTE) && defined(FEAT_POSTSCRIPT)
Bram Moolenaar8299df92004-07-10 09:47:34 +00006717 else if (varp == &p_pmfn)
Bram Moolenaar58d98232005-07-23 22:25:46 +00006718 errmsg = parse_printmbfont();
Bram Moolenaar8299df92004-07-10 09:47:34 +00006719# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006720#endif
6721
6722#ifdef FEAT_LANGMAP
6723 /* 'langmap' */
6724 else if (varp == &p_langmap)
6725 langmap_set();
6726#endif
6727
6728#ifdef FEAT_LINEBREAK
6729 /* 'breakat' */
6730 else if (varp == &p_breakat)
6731 fill_breakat_flags();
6732#endif
6733
6734#ifdef FEAT_TITLE
6735 /* 'titlestring' and 'iconstring' */
6736 else if (varp == &p_titlestring || varp == &p_iconstring)
6737 {
6738# ifdef FEAT_STL_OPT
6739 int flagval = (varp == &p_titlestring) ? STL_IN_TITLE : STL_IN_ICON;
6740
6741 /* NULL => statusline syntax */
6742 if (vim_strchr(*varp, '%') && check_stl_option(*varp) == NULL)
6743 stl_syntax |= flagval;
6744 else
6745 stl_syntax &= ~flagval;
6746# endif
6747 did_set_title(varp == &p_iconstring);
6748
6749 }
6750#endif
6751
6752#ifdef FEAT_GUI
6753 /* 'guioptions' */
6754 else if (varp == &p_go)
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006755 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00006756 gui_init_which_components(oldval);
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006757 redraw_gui_only = TRUE;
6758 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006759#endif
6760
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00006761#if defined(FEAT_GUI_TABLINE)
6762 /* 'guitablabel' */
6763 else if (varp == &p_gtl)
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006764 {
Bram Moolenaar18144c82006-04-12 21:52:12 +00006765 redraw_tabline = TRUE;
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006766 redraw_gui_only = TRUE;
6767 }
6768 /* 'guitabtooltip' */
6769 else if (varp == &p_gtt)
6770 {
6771 redraw_gui_only = TRUE;
6772 }
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00006773#endif
6774
Bram Moolenaar071d4272004-06-13 20:20:40 +00006775#if defined(FEAT_MOUSE_TTY) && (defined(UNIX) || defined(VMS))
6776 /* 'ttymouse' */
6777 else if (varp == &p_ttym)
6778 {
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00006779 /* Switch the mouse off before changing the escape sequences used for
6780 * that. */
6781 mch_setmouse(FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006782 if (opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE) != OK)
6783 errmsg = e_invarg;
6784 else
6785 check_mouse_termcode();
Bram Moolenaar6bb68362005-03-22 23:03:44 +00006786 if (termcap_active)
6787 setmouse(); /* may switch it on again */
Bram Moolenaar071d4272004-06-13 20:20:40 +00006788 }
6789#endif
6790
Bram Moolenaar071d4272004-06-13 20:20:40 +00006791 /* 'selection' */
6792 else if (varp == &p_sel)
6793 {
6794 if (*p_sel == NUL
6795 || check_opt_strings(p_sel, p_sel_values, FALSE) != OK)
6796 errmsg = e_invarg;
6797 }
6798
6799 /* 'selectmode' */
6800 else if (varp == &p_slm)
6801 {
6802 if (check_opt_strings(p_slm, p_slm_values, TRUE) != OK)
6803 errmsg = e_invarg;
6804 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006805
6806#ifdef FEAT_BROWSE
6807 /* 'browsedir' */
6808 else if (varp == &p_bsdir)
6809 {
6810 if (check_opt_strings(p_bsdir, p_bsdir_values, FALSE) != OK
6811 && !mch_isdir(p_bsdir))
6812 errmsg = e_invarg;
6813 }
6814#endif
6815
Bram Moolenaar071d4272004-06-13 20:20:40 +00006816 /* 'keymodel' */
6817 else if (varp == &p_km)
6818 {
6819 if (check_opt_strings(p_km, p_km_values, TRUE) != OK)
6820 errmsg = e_invarg;
6821 else
6822 {
6823 km_stopsel = (vim_strchr(p_km, 'o') != NULL);
6824 km_startsel = (vim_strchr(p_km, 'a') != NULL);
6825 }
6826 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006827
6828 /* 'mousemodel' */
6829 else if (varp == &p_mousem)
6830 {
6831 if (check_opt_strings(p_mousem, p_mousem_values, FALSE) != OK)
6832 errmsg = e_invarg;
6833#if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU) && (XmVersion <= 1002)
6834 else if (*p_mousem != *oldval)
6835 /* Changed from "extend" to "popup" or "popup_setpos" or vv: need
6836 * to create or delete the popup menus. */
6837 gui_motif_update_mousemodel(root_menu);
6838#endif
6839 }
6840
6841 /* 'switchbuf' */
6842 else if (varp == &p_swb)
6843 {
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00006844 if (opt_strings_flags(p_swb, p_swb_values, &swb_flags, TRUE) != OK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006845 errmsg = e_invarg;
6846 }
6847
6848 /* 'debug' */
6849 else if (varp == &p_debug)
6850 {
Bram Moolenaar57657d82006-04-21 22:12:41 +00006851 if (check_opt_strings(p_debug, p_debug_values, TRUE) != OK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006852 errmsg = e_invarg;
6853 }
6854
6855 /* 'display' */
6856 else if (varp == &p_dy)
6857 {
6858 if (opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE) != OK)
6859 errmsg = e_invarg;
6860 else
6861 (void)init_chartab();
6862
6863 }
6864
Bram Moolenaar44a2f922016-03-19 22:11:51 +01006865#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00006866 /* 'eadirection' */
6867 else if (varp == &p_ead)
6868 {
6869 if (check_opt_strings(p_ead, p_ead_values, FALSE) != OK)
6870 errmsg = e_invarg;
6871 }
6872#endif
6873
6874#ifdef FEAT_CLIPBOARD
6875 /* 'clipboard' */
6876 else if (varp == &p_cb)
6877 errmsg = check_clipboard_option();
6878#endif
6879
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00006880#ifdef FEAT_SPELL
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006881 /* When 'spelllang' or 'spellfile' is set and there is a window for this
6882 * buffer in which 'spell' is set load the wordlists. */
Bram Moolenaar2683c8e2014-11-19 19:33:16 +01006883 else if (varp == &(curwin->w_s->b_p_spl)
6884 || varp == &(curwin->w_s->b_p_spf))
Bram Moolenaar217ad922005-03-20 22:37:15 +00006885 {
Bram Moolenaare68c25c2015-08-25 15:39:55 +02006886 errmsg = did_set_spell_option(varp == &(curwin->w_s->b_p_spf));
Bram Moolenaar217ad922005-03-20 22:37:15 +00006887 }
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00006888 /* When 'spellcapcheck' is set compile the regexp program. */
Bram Moolenaar860cae12010-06-05 23:22:07 +02006889 else if (varp == &(curwin->w_s->b_p_spc))
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00006890 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02006891 errmsg = compile_cap_prog(curwin->w_s);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00006892 }
Bram Moolenaard857f0e2005-06-21 22:37:39 +00006893 /* 'spellsuggest' */
6894 else if (varp == &p_sps)
6895 {
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00006896 if (spell_check_sps() != OK)
Bram Moolenaard857f0e2005-06-21 22:37:39 +00006897 errmsg = e_invarg;
6898 }
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00006899 /* 'mkspellmem' */
6900 else if (varp == &p_msm)
6901 {
6902 if (spell_check_msm() != OK)
6903 errmsg = e_invarg;
6904 }
Bram Moolenaar217ad922005-03-20 22:37:15 +00006905#endif
6906
Bram Moolenaar071d4272004-06-13 20:20:40 +00006907#ifdef FEAT_QUICKFIX
6908 /* When 'bufhidden' is set, check for valid value. */
6909 else if (gvarp == &p_bh)
6910 {
6911 if (check_opt_strings(curbuf->b_p_bh, p_bufhidden_values, FALSE) != OK)
6912 errmsg = e_invarg;
6913 }
6914
6915 /* When 'buftype' is set, check for valid value. */
6916 else if (gvarp == &p_bt)
6917 {
6918 if (check_opt_strings(curbuf->b_p_bt, p_buftype_values, FALSE) != OK)
6919 errmsg = e_invarg;
6920 else
6921 {
6922# ifdef FEAT_WINDOWS
6923 if (curwin->w_status_height)
6924 {
6925 curwin->w_redr_status = TRUE;
6926 redraw_later(VALID);
6927 }
6928# endif
6929 curbuf->b_help = (curbuf->b_p_bt[0] == 'h');
Bram Moolenaar5075aad2010-01-27 15:58:13 +01006930# ifdef FEAT_TITLE
6931 redraw_titles();
6932# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006933 }
6934 }
6935#endif
6936
6937#ifdef FEAT_STL_OPT
6938 /* 'statusline' or 'rulerformat' */
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00006939 else if (gvarp == &p_stl || varp == &p_ruf)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006940 {
6941 int wid;
6942
6943 if (varp == &p_ruf) /* reset ru_wid first */
6944 ru_wid = 0;
6945 s = *varp;
6946 if (varp == &p_ruf && *s == '%')
6947 {
6948 /* set ru_wid if 'ruf' starts with "%99(" */
6949 if (*++s == '-') /* ignore a '-' */
6950 s++;
6951 wid = getdigits(&s);
6952 if (wid && *s == '(' && (errmsg = check_stl_option(p_ruf)) == NULL)
6953 ru_wid = wid;
6954 else
6955 errmsg = check_stl_option(p_ruf);
6956 }
Bram Moolenaar3709e7c2006-08-08 14:29:16 +00006957 /* check 'statusline' only if it doesn't start with "%!" */
Bram Moolenaar177d8c62007-09-06 11:33:37 +00006958 else if (varp == &p_ruf || s[0] != '%' || s[1] != '!')
Bram Moolenaar071d4272004-06-13 20:20:40 +00006959 errmsg = check_stl_option(s);
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00006960 if (varp == &p_ruf && errmsg == NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006961 comp_col();
6962 }
6963#endif
6964
6965#ifdef FEAT_INS_EXPAND
6966 /* check if it is a valid value for 'complete' -- Acevedo */
6967 else if (gvarp == &p_cpt)
6968 {
6969 for (s = *varp; *s;)
6970 {
Bram Moolenaar11b73d62012-06-29 15:51:30 +02006971 while (*s == ',' || *s == ' ')
Bram Moolenaar071d4272004-06-13 20:20:40 +00006972 s++;
6973 if (!*s)
6974 break;
6975 if (vim_strchr((char_u *)".wbuksid]tU", *s) == NULL)
6976 {
6977 errmsg = illegal_char(errbuf, *s);
6978 break;
6979 }
6980 if (*++s != NUL && *s != ',' && *s != ' ')
6981 {
6982 if (s[-1] == 'k' || s[-1] == 's')
6983 {
6984 /* skip optional filename after 'k' and 's' */
6985 while (*s && *s != ',' && *s != ' ')
6986 {
6987 if (*s == '\\')
6988 ++s;
6989 ++s;
6990 }
6991 }
6992 else
6993 {
6994 if (errbuf != NULL)
6995 {
6996 sprintf((char *)errbuf,
6997 _("E535: Illegal character after <%c>"),
6998 *--s);
6999 errmsg = errbuf;
7000 }
7001 else
7002 errmsg = (char_u *)"";
7003 break;
7004 }
7005 }
7006 }
7007 }
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00007008
7009 /* 'completeopt' */
7010 else if (varp == &p_cot)
7011 {
7012 if (check_opt_strings(p_cot, p_cot_values, TRUE) != OK)
7013 errmsg = e_invarg;
Bram Moolenaarc0200422016-04-20 12:02:02 +02007014 else
7015 completeopt_was_set();
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00007016 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007017#endif /* FEAT_INS_EXPAND */
7018
Bram Moolenaar95ec9d62016-08-12 18:29:59 +02007019#ifdef FEAT_SIGNS
7020 /* 'signcolumn' */
7021 else if (varp == &curwin->w_p_scl)
7022 {
7023 if (check_opt_strings(*varp, p_scl_values, FALSE) != OK)
7024 errmsg = e_invarg;
7025 }
7026#endif
7027
Bram Moolenaar071d4272004-06-13 20:20:40 +00007028
7029#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
Bram Moolenaar031cb742016-11-24 21:46:19 +01007030 /* 'toolbar' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007031 else if (varp == &p_toolbar)
7032 {
7033 if (opt_strings_flags(p_toolbar, p_toolbar_values,
7034 &toolbar_flags, TRUE) != OK)
7035 errmsg = e_invarg;
7036 else
7037 {
7038 out_flush();
7039 gui_mch_show_toolbar((toolbar_flags &
7040 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
7041 }
7042 }
7043#endif
7044
Bram Moolenaar182c5be2010-06-25 05:37:59 +02007045#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007046 /* 'toolbariconsize': GTK+ 2 only */
7047 else if (varp == &p_tbis)
7048 {
7049 if (opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE) != OK)
7050 errmsg = e_invarg;
7051 else
7052 {
7053 out_flush();
7054 gui_mch_show_toolbar((toolbar_flags &
7055 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
7056 }
7057 }
7058#endif
7059
7060 /* 'pastetoggle': translate key codes like in a mapping */
7061 else if (varp == &p_pt)
7062 {
7063 if (*p_pt)
7064 {
Bram Moolenaar9c102382006-05-03 21:26:49 +00007065 (void)replace_termcodes(p_pt, &p, TRUE, TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007066 if (p != NULL)
7067 {
7068 if (new_value_alloced)
7069 free_string_option(p_pt);
7070 p_pt = p;
7071 new_value_alloced = TRUE;
7072 }
7073 }
7074 }
7075
7076 /* 'backspace' */
7077 else if (varp == &p_bs)
7078 {
7079 if (VIM_ISDIGIT(*p_bs))
7080 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01007081 if (*p_bs > '2' || p_bs[1] != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007082 errmsg = e_invarg;
7083 }
7084 else if (check_opt_strings(p_bs, p_bs_values, TRUE) != OK)
7085 errmsg = e_invarg;
7086 }
Bram Moolenaar165bc692015-07-21 17:53:25 +02007087 else if (varp == &p_bo)
7088 {
7089 if (opt_strings_flags(p_bo, p_bo_values, &bo_flags, TRUE) != OK)
7090 errmsg = e_invarg;
7091 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007092
Bram Moolenaar0f6562e2015-11-24 18:48:14 +01007093 /* 'tagcase' */
7094 else if (gvarp == &p_tc)
7095 {
7096 unsigned int *flags;
7097
7098 if (opt_flags & OPT_LOCAL)
7099 {
7100 p = curbuf->b_p_tc;
7101 flags = &curbuf->b_tc_flags;
7102 }
7103 else
7104 {
7105 p = p_tc;
7106 flags = &tc_flags;
7107 }
7108
7109 if ((opt_flags & OPT_LOCAL) && *p == NUL)
7110 /* make the local value empty: use the global value */
7111 *flags = 0;
7112 else if (*p == NUL
7113 || opt_strings_flags(p, p_tc_values, flags, FALSE) != OK)
7114 errmsg = e_invarg;
7115 }
7116
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00007117#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +00007118 /* 'casemap' */
7119 else if (varp == &p_cmp)
7120 {
7121 if (opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE) != OK)
7122 errmsg = e_invarg;
7123 }
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00007124#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007125
7126#ifdef FEAT_DIFF
7127 /* 'diffopt' */
7128 else if (varp == &p_dip)
7129 {
7130 if (diffopt_changed() == FAIL)
7131 errmsg = e_invarg;
7132 }
7133#endif
7134
7135#ifdef FEAT_FOLDING
7136 /* 'foldmethod' */
7137 else if (gvarp == &curwin->w_allbuf_opt.wo_fdm)
7138 {
7139 if (check_opt_strings(*varp, p_fdm_values, FALSE) != OK
7140 || *curwin->w_p_fdm == NUL)
7141 errmsg = e_invarg;
7142 else
Bram Moolenaarf4d7f942010-02-24 14:34:19 +01007143 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00007144 foldUpdateAll(curwin);
Bram Moolenaarf4d7f942010-02-24 14:34:19 +01007145 if (foldmethodIsDiff(curwin))
7146 newFoldLevel();
7147 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007148 }
7149# ifdef FEAT_EVAL
7150 /* 'foldexpr' */
7151 else if (varp == &curwin->w_p_fde)
7152 {
7153 if (foldmethodIsExpr(curwin))
7154 foldUpdateAll(curwin);
7155 }
7156# endif
7157 /* 'foldmarker' */
7158 else if (gvarp == &curwin->w_allbuf_opt.wo_fmr)
7159 {
7160 p = vim_strchr(*varp, ',');
7161 if (p == NULL)
7162 errmsg = (char_u *)N_("E536: comma required");
7163 else if (p == *varp || p[1] == NUL)
7164 errmsg = e_invarg;
7165 else if (foldmethodIsMarker(curwin))
7166 foldUpdateAll(curwin);
7167 }
7168 /* 'commentstring' */
7169 else if (gvarp == &p_cms)
7170 {
7171 if (**varp != NUL && strstr((char *)*varp, "%s") == NULL)
7172 errmsg = (char_u *)N_("E537: 'commentstring' must be empty or contain %s");
7173 }
7174 /* 'foldopen' */
7175 else if (varp == &p_fdo)
7176 {
7177 if (opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE) != OK)
7178 errmsg = e_invarg;
7179 }
7180 /* 'foldclose' */
7181 else if (varp == &p_fcl)
7182 {
7183 if (check_opt_strings(p_fcl, p_fcl_values, TRUE) != OK)
7184 errmsg = e_invarg;
7185 }
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00007186 /* 'foldignore' */
7187 else if (gvarp == &curwin->w_allbuf_opt.wo_fdi)
7188 {
7189 if (foldmethodIsIndent(curwin))
7190 foldUpdateAll(curwin);
7191 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007192#endif
7193
7194#ifdef FEAT_VIRTUALEDIT
7195 /* 'virtualedit' */
7196 else if (varp == &p_ve)
7197 {
7198 if (opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE) != OK)
7199 errmsg = e_invarg;
7200 else if (STRCMP(p_ve, oldval) != 0)
7201 {
7202 /* Recompute cursor position in case the new 've' setting
7203 * changes something. */
7204 validate_virtcol();
7205 coladvance(curwin->w_virtcol);
7206 }
7207 }
7208#endif
7209
7210#if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX)
7211 else if (varp == &p_csqf)
7212 {
7213 if (p_csqf != NULL)
7214 {
7215 p = p_csqf;
7216 while (*p != NUL)
7217 {
7218 if (vim_strchr((char_u *)CSQF_CMDS, *p) == NULL
7219 || p[1] == NUL
7220 || vim_strchr((char_u *)CSQF_FLAGS, p[1]) == NULL
7221 || (p[2] != NUL && p[2] != ','))
7222 {
7223 errmsg = e_invarg;
7224 break;
7225 }
7226 else if (p[2] == NUL)
7227 break;
7228 else
7229 p += 3;
7230 }
7231 }
7232 }
7233#endif
7234
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01007235#ifdef FEAT_CINDENT
7236 /* 'cinoptions' */
7237 else if (gvarp == &p_cino)
7238 {
7239 /* TODO: recognize errors */
7240 parse_cino(curbuf);
7241 }
7242#endif
7243
Bram Moolenaarb5a7a8b2014-08-06 14:52:30 +02007244#if defined(FEAT_RENDER_OPTIONS)
Bram Moolenaar031cb742016-11-24 21:46:19 +01007245 /* 'renderoptions' */
Bram Moolenaarb5a7a8b2014-08-06 14:52:30 +02007246 else if (varp == &p_rop && gui.in_use)
7247 {
7248 if (!gui_mch_set_rendering_options(p_rop))
7249 errmsg = e_invarg;
7250 }
7251#endif
7252
Bram Moolenaard0b51382016-11-04 15:23:45 +01007253#ifdef FEAT_AUTOCMD
7254 else if (gvarp == &p_ft)
7255 {
7256 if (!valid_filetype(*varp))
7257 errmsg = e_invarg;
7258 }
7259#endif
7260
7261#ifdef FEAT_SYN_HL
7262 else if (gvarp == &p_syn)
7263 {
7264 if (!valid_filetype(*varp))
7265 errmsg = e_invarg;
7266 }
7267#endif
7268
Bram Moolenaar071d4272004-06-13 20:20:40 +00007269 /* Options that are a list of flags. */
7270 else
7271 {
7272 p = NULL;
Bram Moolenaar031cb742016-11-24 21:46:19 +01007273 if (varp == &p_ww) /* 'whichwrap' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007274 p = (char_u *)WW_ALL;
Bram Moolenaar031cb742016-11-24 21:46:19 +01007275 if (varp == &p_shm) /* 'shortmess' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007276 p = (char_u *)SHM_ALL;
Bram Moolenaar031cb742016-11-24 21:46:19 +01007277 else if (varp == &(p_cpo)) /* 'cpoptions' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007278 p = (char_u *)CPO_ALL;
Bram Moolenaar031cb742016-11-24 21:46:19 +01007279 else if (varp == &(curbuf->b_p_fo)) /* 'formatoptions' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007280 p = (char_u *)FO_ALL;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02007281#ifdef FEAT_CONCEAL
Bram Moolenaar031cb742016-11-24 21:46:19 +01007282 else if (varp == &curwin->w_p_cocu) /* 'concealcursor' */
Bram Moolenaarf5963f72010-07-23 22:10:27 +02007283 p = (char_u *)COCU_ALL;
7284#endif
Bram Moolenaar031cb742016-11-24 21:46:19 +01007285 else if (varp == &p_mouse) /* 'mouse' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007286 {
7287#ifdef FEAT_MOUSE
7288 p = (char_u *)MOUSE_ALL;
7289#else
7290 if (*p_mouse != NUL)
7291 errmsg = (char_u *)N_("E538: No mouse support");
7292#endif
7293 }
7294#if defined(FEAT_GUI)
Bram Moolenaar031cb742016-11-24 21:46:19 +01007295 else if (varp == &p_go) /* 'guioptions' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007296 p = (char_u *)GO_ALL;
7297#endif
7298 if (p != NULL)
7299 {
7300 for (s = *varp; *s; ++s)
7301 if (vim_strchr(p, *s) == NULL)
7302 {
7303 errmsg = illegal_char(errbuf, *s);
7304 break;
7305 }
7306 }
7307 }
7308
7309 /*
7310 * If error detected, restore the previous value.
7311 */
7312 if (errmsg != NULL)
7313 {
7314 if (new_value_alloced)
7315 free_string_option(*varp);
7316 *varp = oldval;
7317 /*
7318 * When resetting some values, need to act on it.
7319 */
7320 if (did_chartab)
7321 (void)init_chartab();
7322 if (varp == &p_hl)
7323 (void)highlight_changed();
7324 }
7325 else
7326 {
7327#ifdef FEAT_EVAL
7328 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007329 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007330#endif
7331 /*
7332 * Free string options that are in allocated memory.
Bram Moolenaarc0197e22004-09-13 20:26:32 +00007333 * Use "free_oldval", because recursiveness may change the flags under
7334 * our fingers (esp. init_highlight()).
Bram Moolenaar071d4272004-06-13 20:20:40 +00007335 */
Bram Moolenaarc0197e22004-09-13 20:26:32 +00007336 if (free_oldval)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007337 free_string_option(oldval);
7338 if (new_value_alloced)
7339 options[opt_idx].flags |= P_ALLOCED;
7340 else
7341 options[opt_idx].flags &= ~P_ALLOCED;
7342
7343 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00007344 && ((int)options[opt_idx].indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007345 {
7346 /* global option with local value set to use global value; free
7347 * the local value and make it empty */
7348 p = get_varp_scope(&(options[opt_idx]), OPT_LOCAL);
7349 free_string_option(*(char_u **)p);
7350 *(char_u **)p = empty_option;
7351 }
7352
7353 /* May set global value for local option. */
7354 else if (!(opt_flags & OPT_LOCAL) && opt_flags != OPT_GLOBAL)
7355 set_string_option_global(opt_idx, varp);
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007356
7357#ifdef FEAT_AUTOCMD
7358 /*
7359 * Trigger the autocommand only after setting the flags.
7360 */
7361# ifdef FEAT_SYN_HL
7362 /* When 'syntax' is set, load the syntax of that name */
7363 if (varp == &(curbuf->b_p_syn))
7364 {
7365 apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn,
7366 curbuf->b_fname, TRUE, curbuf);
7367 }
7368# endif
7369 else if (varp == &(curbuf->b_p_ft))
7370 {
7371 /* 'filetype' is set, trigger the FileType autocommand */
7372 did_filetype = TRUE;
7373 apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft,
7374 curbuf->b_fname, TRUE, curbuf);
7375 }
7376#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007377#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02007378 if (varp == &(curwin->w_s->b_p_spl))
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007379 {
7380 char_u fname[200];
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007381 char_u *q = curwin->w_s->b_p_spl;
7382
7383 /* Skip the first name if it is "cjk". */
7384 if (STRNCMP(q, "cjk,", 4) == 0)
7385 q += 4;
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007386
7387 /*
7388 * Source the spell/LANG.vim in 'runtimepath'.
7389 * They could set 'spellcapcheck' depending on the language.
7390 * Use the first name in 'spelllang' up to '_region' or
7391 * '.encoding'.
7392 */
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007393 for (p = q; *p != NUL; ++p)
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007394 if (vim_strchr((char_u *)"_.,", *p) != NULL)
7395 break;
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007396 vim_snprintf((char *)fname, 200, "spell/%.*s.vim", (int)(p - q), q);
Bram Moolenaar7f8989d2016-03-12 22:11:39 +01007397 source_runtime(fname, DIP_ALL);
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007398 }
7399#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007400 }
7401
7402#ifdef FEAT_MOUSE
7403 if (varp == &p_mouse)
7404 {
7405# ifdef FEAT_MOUSE_TTY
7406 if (*p_mouse == NUL)
7407 mch_setmouse(FALSE); /* switch mouse off */
7408 else
7409# endif
7410 setmouse(); /* in case 'mouse' changed */
7411 }
7412#endif
7413
Bram Moolenaar913077c2012-03-28 19:59:04 +02007414 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01007415 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02007416 curwin->w_set_curswant = TRUE;
7417
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00007418#ifdef FEAT_GUI
7419 /* check redraw when it's not a GUI option or the GUI is active. */
7420 if (!redraw_gui_only || gui.in_use)
7421#endif
7422 check_redraw(options[opt_idx].flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007423
7424 return errmsg;
7425}
7426
Bram Moolenaarf4e5e862013-02-13 15:44:26 +01007427#if defined(FEAT_SYN_HL) || defined(PROTO)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007428/*
7429 * Simple int comparison function for use with qsort()
7430 */
7431 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01007432int_cmp(const void *a, const void *b)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007433{
7434 return *(const int *)a - *(const int *)b;
7435}
7436
7437/*
7438 * Handle setting 'colorcolumn' or 'textwidth' in window "wp".
7439 * Returns error message, NULL if it's OK.
7440 */
7441 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007442check_colorcolumn(win_T *wp)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007443{
7444 char_u *s;
7445 int col;
7446 int count = 0;
7447 int color_cols[256];
7448 int i;
7449 int j = 0;
7450
Bram Moolenaar50f834d2011-09-21 13:40:17 +02007451 if (wp->w_buffer == NULL)
7452 return NULL; /* buffer was closed */
7453
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007454 for (s = wp->w_p_cc; *s != NUL && count < 255;)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007455 {
7456 if (*s == '-' || *s == '+')
7457 {
7458 /* -N and +N: add to 'textwidth' */
7459 col = (*s == '-') ? -1 : 1;
7460 ++s;
7461 if (!VIM_ISDIGIT(*s))
7462 return e_invarg;
7463 col = col * getdigits(&s);
7464 if (wp->w_buffer->b_p_tw == 0)
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007465 goto skip; /* 'textwidth' not set, skip this item */
Bram Moolenaar1a384422010-07-14 19:53:30 +02007466 col += wp->w_buffer->b_p_tw;
7467 if (col < 0)
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007468 goto skip;
Bram Moolenaar1a384422010-07-14 19:53:30 +02007469 }
7470 else if (VIM_ISDIGIT(*s))
7471 col = getdigits(&s);
7472 else
7473 return e_invarg;
7474 color_cols[count++] = col - 1; /* 1-based to 0-based */
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007475skip:
Bram Moolenaar1a384422010-07-14 19:53:30 +02007476 if (*s == NUL)
7477 break;
7478 if (*s != ',')
7479 return e_invarg;
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007480 if (*++s == NUL)
7481 return e_invarg; /* illegal trailing comma as in "set cc=80," */
Bram Moolenaar1a384422010-07-14 19:53:30 +02007482 }
7483
7484 vim_free(wp->w_p_cc_cols);
7485 if (count == 0)
7486 wp->w_p_cc_cols = NULL;
7487 else
7488 {
7489 wp->w_p_cc_cols = (int *)alloc((unsigned)sizeof(int) * (count + 1));
7490 if (wp->w_p_cc_cols != NULL)
7491 {
7492 /* sort the columns for faster usage on screen redraw inside
7493 * win_line() */
7494 qsort(color_cols, count, sizeof(int), int_cmp);
7495
7496 for (i = 0; i < count; ++i)
7497 /* skip duplicates */
7498 if (j == 0 || wp->w_p_cc_cols[j - 1] != color_cols[i])
7499 wp->w_p_cc_cols[j++] = color_cols[i];
7500 wp->w_p_cc_cols[j] = -1; /* end marker */
7501 }
7502 }
7503
7504 return NULL; /* no error */
7505}
7506#endif
7507
Bram Moolenaar071d4272004-06-13 20:20:40 +00007508/*
7509 * Handle setting 'listchars' or 'fillchars'.
7510 * Returns error message, NULL if it's OK.
7511 */
7512 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007513set_chars_option(char_u **varp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007514{
7515 int round, i, len, entries;
7516 char_u *p, *s;
7517 int c1, c2 = 0;
7518 struct charstab
7519 {
7520 int *cp;
7521 char *name;
7522 };
7523#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7524 static struct charstab filltab[] =
7525 {
7526 {&fill_stl, "stl"},
7527 {&fill_stlnc, "stlnc"},
7528 {&fill_vert, "vert"},
7529 {&fill_fold, "fold"},
7530 {&fill_diff, "diff"},
7531 };
7532#endif
7533 static struct charstab lcstab[] =
7534 {
7535 {&lcs_eol, "eol"},
7536 {&lcs_ext, "extends"},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00007537 {&lcs_nbsp, "nbsp"},
Bram Moolenaar071d4272004-06-13 20:20:40 +00007538 {&lcs_prec, "precedes"},
Bram Moolenaar4c6b3b22015-04-21 19:10:48 +02007539 {&lcs_space, "space"},
Bram Moolenaar071d4272004-06-13 20:20:40 +00007540 {&lcs_tab2, "tab"},
7541 {&lcs_trail, "trail"},
Bram Moolenaar860cae12010-06-05 23:22:07 +02007542#ifdef FEAT_CONCEAL
7543 {&lcs_conceal, "conceal"},
7544#else
7545 {NULL, "conceal"},
7546#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007547 };
7548 struct charstab *tab;
7549
7550#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7551 if (varp == &p_lcs)
7552#endif
7553 {
7554 tab = lcstab;
7555 entries = sizeof(lcstab) / sizeof(struct charstab);
7556 }
7557#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7558 else
7559 {
7560 tab = filltab;
7561 entries = sizeof(filltab) / sizeof(struct charstab);
7562 }
7563#endif
7564
7565 /* first round: check for valid value, second round: assign values */
7566 for (round = 0; round <= 1; ++round)
7567 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007568 if (round > 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007569 {
7570 /* After checking that the value is valid: set defaults: space for
7571 * 'fillchars', NUL for 'listchars' */
7572 for (i = 0; i < entries; ++i)
Bram Moolenaar860cae12010-06-05 23:22:07 +02007573 if (tab[i].cp != NULL)
7574 *(tab[i].cp) = (varp == &p_lcs ? NUL : ' ');
Bram Moolenaar071d4272004-06-13 20:20:40 +00007575 if (varp == &p_lcs)
7576 lcs_tab1 = NUL;
7577#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7578 else
7579 fill_diff = '-';
7580#endif
7581 }
7582 p = *varp;
7583 while (*p)
7584 {
7585 for (i = 0; i < entries; ++i)
7586 {
7587 len = (int)STRLEN(tab[i].name);
7588 if (STRNCMP(p, tab[i].name, len) == 0
7589 && p[len] == ':'
7590 && p[len + 1] != NUL)
7591 {
7592 s = p + len + 1;
7593#ifdef FEAT_MBYTE
7594 c1 = mb_ptr2char_adv(&s);
Bram Moolenaar910f66f2006-04-05 20:41:53 +00007595 if (mb_char2cells(c1) > 1)
7596 continue;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007597#else
7598 c1 = *s++;
7599#endif
7600 if (tab[i].cp == &lcs_tab2)
7601 {
7602 if (*s == NUL)
7603 continue;
7604#ifdef FEAT_MBYTE
7605 c2 = mb_ptr2char_adv(&s);
Bram Moolenaar910f66f2006-04-05 20:41:53 +00007606 if (mb_char2cells(c2) > 1)
7607 continue;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007608#else
7609 c2 = *s++;
7610#endif
7611 }
7612 if (*s == ',' || *s == NUL)
7613 {
7614 if (round)
7615 {
7616 if (tab[i].cp == &lcs_tab2)
7617 {
7618 lcs_tab1 = c1;
7619 lcs_tab2 = c2;
7620 }
Bram Moolenaar860cae12010-06-05 23:22:07 +02007621 else if (tab[i].cp != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007622 *(tab[i].cp) = c1;
7623
7624 }
7625 p = s;
7626 break;
7627 }
7628 }
7629 }
7630
7631 if (i == entries)
7632 return e_invarg;
7633 if (*p == ',')
7634 ++p;
7635 }
7636 }
7637
7638 return NULL; /* no error */
7639}
7640
7641#ifdef FEAT_STL_OPT
7642/*
7643 * Check validity of options with the 'statusline' format.
7644 * Return error message or NULL.
7645 */
7646 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007647check_stl_option(char_u *s)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007648{
7649 int itemcnt = 0;
7650 int groupdepth = 0;
7651 static char_u errbuf[80];
7652
7653 while (*s && itemcnt < STL_MAX_ITEM)
7654 {
7655 /* Check for valid keys after % sequences */
7656 while (*s && *s != '%')
7657 s++;
7658 if (!*s)
7659 break;
7660 s++;
7661 if (*s != '%' && *s != ')')
7662 ++itemcnt;
7663 if (*s == '%' || *s == STL_TRUNCMARK || *s == STL_MIDDLEMARK)
7664 {
7665 s++;
7666 continue;
7667 }
7668 if (*s == ')')
7669 {
7670 s++;
7671 if (--groupdepth < 0)
7672 break;
7673 continue;
7674 }
7675 if (*s == '-')
7676 s++;
7677 while (VIM_ISDIGIT(*s))
7678 s++;
Bram Moolenaar238a5642006-02-21 22:12:05 +00007679 if (*s == STL_USER_HL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007680 continue;
7681 if (*s == '.')
7682 {
7683 s++;
7684 while (*s && VIM_ISDIGIT(*s))
7685 s++;
7686 }
7687 if (*s == '(')
7688 {
7689 groupdepth++;
7690 continue;
7691 }
7692 if (vim_strchr(STL_ALL, *s) == NULL)
7693 {
7694 return illegal_char(errbuf, *s);
7695 }
7696 if (*s == '{')
7697 {
7698 s++;
7699 while (*s != '}' && *s)
7700 s++;
7701 if (*s != '}')
7702 return (char_u *)N_("E540: Unclosed expression sequence");
7703 }
7704 }
7705 if (itemcnt >= STL_MAX_ITEM)
7706 return (char_u *)N_("E541: too many items");
7707 if (groupdepth != 0)
7708 return (char_u *)N_("E542: unbalanced groups");
7709 return NULL;
7710}
7711#endif
7712
7713#ifdef FEAT_CLIPBOARD
7714/*
7715 * Extract the items in the 'clipboard' option and set global values.
7716 */
7717 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007718check_clipboard_option(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007719{
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007720 int new_unnamed = 0;
Bram Moolenaar89af4392012-07-10 18:31:54 +02007721 int new_autoselect_star = FALSE;
7722 int new_autoselect_plus = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007723 int new_autoselectml = FALSE;
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007724 int new_html = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007725 regprog_T *new_exclude_prog = NULL;
7726 char_u *errmsg = NULL;
7727 char_u *p;
7728
7729 for (p = p_cb; *p != NUL; )
7730 {
7731 if (STRNCMP(p, "unnamed", 7) == 0 && (p[7] == ',' || p[7] == NUL))
7732 {
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007733 new_unnamed |= CLIP_UNNAMED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007734 p += 7;
7735 }
Bram Moolenaar11b73d62012-06-29 15:51:30 +02007736 else if (STRNCMP(p, "unnamedplus", 11) == 0
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007737 && (p[11] == ',' || p[11] == NUL))
7738 {
7739 new_unnamed |= CLIP_UNNAMED_PLUS;
7740 p += 11;
7741 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007742 else if (STRNCMP(p, "autoselect", 10) == 0
Bram Moolenaar89af4392012-07-10 18:31:54 +02007743 && (p[10] == ',' || p[10] == NUL))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007744 {
Bram Moolenaar89af4392012-07-10 18:31:54 +02007745 new_autoselect_star = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007746 p += 10;
7747 }
Bram Moolenaar89af4392012-07-10 18:31:54 +02007748 else if (STRNCMP(p, "autoselectplus", 14) == 0
7749 && (p[14] == ',' || p[14] == NUL))
7750 {
7751 new_autoselect_plus = TRUE;
7752 p += 14;
7753 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007754 else if (STRNCMP(p, "autoselectml", 12) == 0
Bram Moolenaar89af4392012-07-10 18:31:54 +02007755 && (p[12] == ',' || p[12] == NUL))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007756 {
7757 new_autoselectml = TRUE;
7758 p += 12;
7759 }
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007760 else if (STRNCMP(p, "html", 4) == 0 && (p[4] == ',' || p[4] == NUL))
7761 {
7762 new_html = TRUE;
7763 p += 4;
7764 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007765 else if (STRNCMP(p, "exclude:", 8) == 0 && new_exclude_prog == NULL)
7766 {
7767 p += 8;
7768 new_exclude_prog = vim_regcomp(p, RE_MAGIC);
7769 if (new_exclude_prog == NULL)
7770 errmsg = e_invarg;
7771 break;
7772 }
7773 else
7774 {
7775 errmsg = e_invarg;
7776 break;
7777 }
7778 if (*p == ',')
7779 ++p;
7780 }
7781 if (errmsg == NULL)
7782 {
7783 clip_unnamed = new_unnamed;
Bram Moolenaar89af4392012-07-10 18:31:54 +02007784 clip_autoselect_star = new_autoselect_star;
7785 clip_autoselect_plus = new_autoselect_plus;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007786 clip_autoselectml = new_autoselectml;
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007787 clip_html = new_html;
Bram Moolenaar473de612013-06-08 18:19:48 +02007788 vim_regfree(clip_exclude_prog);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007789 clip_exclude_prog = new_exclude_prog;
Bram Moolenaara76638f2010-06-05 12:49:46 +02007790#ifdef FEAT_GUI_GTK
7791 if (gui.in_use)
7792 {
7793 gui_gtk_set_selection_targets();
7794 gui_gtk_set_dnd_targets();
7795 }
7796#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007797 }
7798 else
Bram Moolenaar473de612013-06-08 18:19:48 +02007799 vim_regfree(new_exclude_prog);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007800
7801 return errmsg;
7802}
7803#endif
7804
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007805#ifdef FEAT_SPELL
Bram Moolenaare68c25c2015-08-25 15:39:55 +02007806 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007807did_set_spell_option(int is_spellfile)
Bram Moolenaare68c25c2015-08-25 15:39:55 +02007808{
7809 char_u *errmsg = NULL;
7810 win_T *wp;
7811 int l;
7812
7813 if (is_spellfile)
7814 {
7815 l = (int)STRLEN(curwin->w_s->b_p_spf);
7816 if (l > 0 && (l < 4
7817 || STRCMP(curwin->w_s->b_p_spf + l - 4, ".add") != 0))
7818 errmsg = e_invarg;
7819 }
7820
7821 if (errmsg == NULL)
7822 {
7823 FOR_ALL_WINDOWS(wp)
7824 if (wp->w_buffer == curbuf && wp->w_p_spell)
7825 {
7826 errmsg = did_set_spelllang(wp);
7827# ifdef FEAT_WINDOWS
7828 break;
7829# endif
7830 }
7831 }
7832 return errmsg;
7833}
7834
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007835/*
7836 * Set curbuf->b_cap_prog to the regexp program for 'spellcapcheck'.
7837 * Return error message when failed, NULL when OK.
7838 */
7839 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007840compile_cap_prog(synblock_T *synblock)
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007841{
Bram Moolenaar860cae12010-06-05 23:22:07 +02007842 regprog_T *rp = synblock->b_cap_prog;
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007843 char_u *re;
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007844
Bram Moolenaar860cae12010-06-05 23:22:07 +02007845 if (*synblock->b_p_spc == NUL)
7846 synblock->b_cap_prog = NULL;
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007847 else
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007848 {
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007849 /* Prepend a ^ so that we only match at one column */
Bram Moolenaar860cae12010-06-05 23:22:07 +02007850 re = concat_str((char_u *)"^", synblock->b_p_spc);
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007851 if (re != NULL)
7852 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007853 synblock->b_cap_prog = vim_regcomp(re, RE_MAGIC);
Bram Moolenaar473de612013-06-08 18:19:48 +02007854 vim_free(re);
Bram Moolenaar860cae12010-06-05 23:22:07 +02007855 if (synblock->b_cap_prog == NULL)
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007856 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007857 synblock->b_cap_prog = rp; /* restore the previous program */
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007858 return e_invarg;
7859 }
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007860 }
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007861 }
7862
Bram Moolenaar473de612013-06-08 18:19:48 +02007863 vim_regfree(rp);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007864 return NULL;
7865}
7866#endif
7867
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007868#if defined(FEAT_EVAL) || defined(PROTO)
7869/*
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007870 * Set the scriptID for an option, taking care of setting the buffer- or
7871 * window-local value.
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007872 */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007873 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01007874set_option_scriptID_idx(int opt_idx, int opt_flags, int id)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007875{
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007876 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
7877 int indir = (int)options[opt_idx].indir;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007878
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007879 /* Remember where the option was set. For local options need to do that
7880 * in the buffer or window structure. */
7881 if (both || (opt_flags & OPT_GLOBAL) || (indir & (PV_BUF|PV_WIN)) == 0)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007882 options[opt_idx].scriptID = id;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007883 if (both || (opt_flags & OPT_LOCAL))
7884 {
7885 if (indir & PV_BUF)
7886 curbuf->b_p_scriptID[indir & PV_MASK] = id;
7887 else if (indir & PV_WIN)
7888 curwin->w_p_scriptID[indir & PV_MASK] = id;
7889 }
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007890}
7891#endif
7892
Bram Moolenaar071d4272004-06-13 20:20:40 +00007893/*
7894 * Set the value of a boolean option, and take care of side effects.
7895 * Returns NULL for success, or an error message for an error.
7896 */
7897 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007898set_bool_option(
7899 int opt_idx, /* index in options[] table */
7900 char_u *varp, /* pointer to the option variable */
7901 int value, /* new value */
7902 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007903{
7904 int old_value = *(int *)varp;
7905
Bram Moolenaar071d4272004-06-13 20:20:40 +00007906 /* Disallow changing some options from secure mode */
7907 if ((secure
7908#ifdef HAVE_SANDBOX
7909 || sandbox != 0
7910#endif
7911 ) && (options[opt_idx].flags & P_SECURE))
7912 return e_secure;
7913
7914 *(int *)varp = value; /* set the new value */
7915#ifdef FEAT_EVAL
7916 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007917 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007918#endif
7919
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00007920#ifdef FEAT_GUI
7921 need_mouse_correct = TRUE;
7922#endif
7923
Bram Moolenaar071d4272004-06-13 20:20:40 +00007924 /* May set global value for local option. */
7925 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
7926 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = value;
7927
7928 /*
7929 * Handle side effects of changing a bool option.
7930 */
7931
7932 /* 'compatible' */
7933 if ((int *)varp == &p_cp)
7934 {
7935 compatible_set();
7936 }
7937
Bram Moolenaar920694c2016-08-21 17:45:02 +02007938#ifdef FEAT_LANGMAP
7939 if ((int *)varp == &p_lrm)
7940 /* 'langremap' -> !'langnoremap' */
7941 p_lnr = !p_lrm;
7942 else if ((int *)varp == &p_lnr)
7943 /* 'langnoremap' -> !'langremap' */
7944 p_lrm = !p_lnr;
7945#endif
7946
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007947#ifdef FEAT_PERSISTENT_UNDO
7948 /* 'undofile' */
7949 else if ((int *)varp == &curbuf->b_p_udf || (int *)varp == &p_udf)
7950 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007951 /* Only take action when the option was set. When reset we do not
7952 * delete the undo file, the option may be set again without making
7953 * any changes in between. */
7954 if (curbuf->b_p_udf || p_udf)
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007955 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007956 char_u hash[UNDO_HASH_SIZE];
7957 buf_T *save_curbuf = curbuf;
7958
Bram Moolenaar29323592016-07-24 22:04:11 +02007959 FOR_ALL_BUFFERS(curbuf)
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007960 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007961 /* When 'undofile' is set globally: for every buffer, otherwise
7962 * only for the current buffer: Try to read in the undofile,
7963 * if one exists, the buffer wasn't changed and the buffer was
7964 * loaded */
7965 if ((curbuf == save_curbuf
7966 || (opt_flags & OPT_GLOBAL) || opt_flags == 0)
7967 && !curbufIsChanged() && curbuf->b_ml.ml_mfp != NULL)
7968 {
7969 u_compute_hash(hash);
7970 u_read_undo(NULL, hash, curbuf->b_fname);
7971 }
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007972 }
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007973 curbuf = save_curbuf;
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007974 }
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007975 }
7976#endif
7977
Bram Moolenaar071d4272004-06-13 20:20:40 +00007978 else if ((int *)varp == &curbuf->b_p_ro)
7979 {
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00007980 /* when 'readonly' is reset globally, also reset readonlymode */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007981 if (!curbuf->b_p_ro && (opt_flags & OPT_LOCAL) == 0)
7982 readonlymode = FALSE;
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00007983
7984 /* when 'readonly' is set may give W10 again */
7985 if (curbuf->b_p_ro)
7986 curbuf->b_did_warn = FALSE;
7987
Bram Moolenaar071d4272004-06-13 20:20:40 +00007988#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007989 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00007990#endif
7991 }
7992
Bram Moolenaar9c449722010-07-20 18:44:27 +02007993#ifdef FEAT_GUI
7994 else if ((int *)varp == &p_mh)
7995 {
7996 if (!p_mh)
7997 gui_mch_mousehide(FALSE);
7998 }
7999#endif
8000
Bram Moolenaara539df02010-08-01 14:35:05 +02008001#ifdef FEAT_TITLE
8002 /* when 'modifiable' is changed, redraw the window title */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008003 else if ((int *)varp == &curbuf->b_p_ma)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008004 {
8005 redraw_titles();
8006 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008007 /* when 'endofline' is changed, redraw the window title */
8008 else if ((int *)varp == &curbuf->b_p_eol)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008009 {
8010 redraw_titles();
8011 }
Bram Moolenaar34d72d42015-07-17 14:18:08 +02008012 /* when 'fixeol' is changed, redraw the window title */
8013 else if ((int *)varp == &curbuf->b_p_fixeol)
8014 {
8015 redraw_titles();
8016 }
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008017# ifdef FEAT_MBYTE
8018 /* when 'bomb' is changed, redraw the window title and tab page text */
Bram Moolenaar83eb8852007-08-12 13:51:26 +00008019 else if ((int *)varp == &curbuf->b_p_bomb)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008020 {
8021 redraw_titles();
8022 }
8023# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008024#endif
8025
8026 /* when 'bin' is set also set some other options */
8027 else if ((int *)varp == &curbuf->b_p_bin)
8028 {
8029 set_options_bin(old_value, curbuf->b_p_bin, opt_flags);
8030#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008031 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008032#endif
8033 }
8034
8035#ifdef FEAT_AUTOCMD
8036 /* when 'buflisted' changes, trigger autocommands */
8037 else if ((int *)varp == &curbuf->b_p_bl && old_value != curbuf->b_p_bl)
8038 {
8039 apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE,
8040 NULL, NULL, TRUE, curbuf);
8041 }
8042#endif
8043
8044 /* when 'swf' is set, create swapfile, when reset remove swapfile */
8045 else if ((int *)varp == &curbuf->b_p_swf)
8046 {
8047 if (curbuf->b_p_swf && p_uc)
8048 ml_open_file(curbuf); /* create the swap file */
8049 else
Bram Moolenaard55de222007-05-06 13:38:48 +00008050 /* no need to reset curbuf->b_may_swap, ml_open_file() will check
8051 * buf->b_p_swf */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008052 mf_close_file(curbuf, TRUE); /* remove the swap file */
8053 }
8054
8055 /* when 'terse' is set change 'shortmess' */
8056 else if ((int *)varp == &p_terse)
8057 {
8058 char_u *p;
8059
8060 p = vim_strchr(p_shm, SHM_SEARCH);
8061
8062 /* insert 's' in p_shm */
8063 if (p_terse && p == NULL)
8064 {
8065 STRCPY(IObuff, p_shm);
8066 STRCAT(IObuff, "s");
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008067 set_string_option_direct((char_u *)"shm", -1, IObuff, OPT_FREE, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008068 }
8069 /* remove 's' from p_shm */
8070 else if (!p_terse && p != NULL)
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00008071 STRMOVE(p, p + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008072 }
8073
8074 /* when 'paste' is set or reset also change other options */
8075 else if ((int *)varp == &p_paste)
8076 {
8077 paste_option_changed();
8078 }
8079
8080 /* when 'insertmode' is set from an autocommand need to do work here */
8081 else if ((int *)varp == &p_im)
8082 {
8083 if (p_im)
8084 {
8085 if ((State & INSERT) == 0)
8086 need_start_insertmode = TRUE;
8087 stop_insert_mode = FALSE;
8088 }
Bram Moolenaar00672e12016-06-26 18:38:13 +02008089 /* only reset if it was set previously */
8090 else if (old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008091 {
8092 need_start_insertmode = FALSE;
8093 stop_insert_mode = TRUE;
Bram Moolenaard12f5c12006-01-25 22:10:52 +00008094 if (restart_edit != 0 && mode_displayed)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008095 clear_cmdline = TRUE; /* remove "(insert)" */
8096 restart_edit = 0;
8097 }
8098 }
8099
8100 /* when 'ignorecase' is set or reset and 'hlsearch' is set, redraw */
8101 else if ((int *)varp == &p_ic && p_hls)
8102 {
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00008103 redraw_all_later(SOME_VALID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008104 }
8105
8106#ifdef FEAT_SEARCH_EXTRA
8107 /* when 'hlsearch' is set or reset: reset no_hlsearch */
8108 else if ((int *)varp == &p_hls)
8109 {
Bram Moolenaar8050efa2013-11-08 04:30:20 +01008110 SET_NO_HLSEARCH(FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008111 }
8112#endif
8113
8114#ifdef FEAT_SCROLLBIND
8115 /* when 'scrollbind' is set: snapshot the current position to avoid a jump
8116 * at the end of normal_cmd() */
8117 else if ((int *)varp == &curwin->w_p_scb)
8118 {
8119 if (curwin->w_p_scb)
Bram Moolenaar04c5c9e2013-07-09 13:44:59 +02008120 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00008121 do_check_scrollbind(FALSE);
Bram Moolenaar04c5c9e2013-07-09 13:44:59 +02008122 curwin->w_scbind_pos = curwin->w_topline;
8123 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008124 }
8125#endif
8126
8127#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
8128 /* There can be only one window with 'previewwindow' set. */
8129 else if ((int *)varp == &curwin->w_p_pvw)
8130 {
8131 if (curwin->w_p_pvw)
8132 {
8133 win_T *win;
8134
Bram Moolenaar29323592016-07-24 22:04:11 +02008135 FOR_ALL_WINDOWS(win)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008136 if (win->w_p_pvw && win != curwin)
8137 {
8138 curwin->w_p_pvw = FALSE;
8139 return (char_u *)N_("E590: A preview window already exists");
8140 }
8141 }
8142 }
8143#endif
8144
8145 /* when 'textmode' is set or reset also change 'fileformat' */
8146 else if ((int *)varp == &curbuf->b_p_tx)
8147 {
8148 set_fileformat(curbuf->b_p_tx ? EOL_DOS : EOL_UNIX, opt_flags);
8149 }
8150
8151 /* when 'textauto' is set or reset also change 'fileformats' */
8152 else if ((int *)varp == &p_ta)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008153 set_string_option_direct((char_u *)"ffs", -1,
8154 p_ta ? (char_u *)DFLT_FFS_VIM : (char_u *)"",
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008155 OPT_FREE | opt_flags, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008156
8157 /*
8158 * When 'lisp' option changes include/exclude '-' in
8159 * keyword characters.
8160 */
8161#ifdef FEAT_LISP
8162 else if (varp == (char_u *)&(curbuf->b_p_lisp))
8163 {
8164 (void)buf_init_chartab(curbuf, FALSE); /* ignore errors */
8165 }
8166#endif
8167
8168#ifdef FEAT_TITLE
8169 /* when 'title' changed, may need to change the title; same for 'icon' */
8170 else if ((int *)varp == &p_title)
8171 {
8172 did_set_title(FALSE);
8173 }
8174
8175 else if ((int *)varp == &p_icon)
8176 {
8177 did_set_title(TRUE);
8178 }
8179#endif
8180
8181 else if ((int *)varp == &curbuf->b_changed)
8182 {
8183 if (!value)
8184 save_file_ff(curbuf); /* Buffer is unchanged */
8185#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008186 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008187#endif
8188#ifdef FEAT_AUTOCMD
8189 modified_was_set = value;
8190#endif
8191 }
8192
8193#ifdef BACKSLASH_IN_FILENAME
8194 else if ((int *)varp == &p_ssl)
8195 {
8196 if (p_ssl)
8197 {
8198 psepc = '/';
8199 psepcN = '\\';
8200 pseps[0] = '/';
Bram Moolenaar071d4272004-06-13 20:20:40 +00008201 }
8202 else
8203 {
8204 psepc = '\\';
8205 psepcN = '/';
8206 pseps[0] = '\\';
Bram Moolenaar071d4272004-06-13 20:20:40 +00008207 }
8208
8209 /* need to adjust the file name arguments and buffer names. */
8210 buflist_slash_adjust();
8211 alist_slash_adjust();
8212# ifdef FEAT_EVAL
8213 scriptnames_slash_adjust();
8214# endif
8215 }
8216#endif
8217
8218 /* If 'wrap' is set, set w_leftcol to zero. */
8219 else if ((int *)varp == &curwin->w_p_wrap)
8220 {
8221 if (curwin->w_p_wrap)
8222 curwin->w_leftcol = 0;
8223 }
8224
8225#ifdef FEAT_WINDOWS
8226 else if ((int *)varp == &p_ea)
8227 {
8228 if (p_ea && !old_value)
8229 win_equal(curwin, FALSE, 0);
8230 }
8231#endif
8232
8233 else if ((int *)varp == &p_wiv)
8234 {
8235 /*
8236 * When 'weirdinvert' changed, set/reset 't_xs'.
8237 * Then set 'weirdinvert' according to value of 't_xs'.
8238 */
8239 if (p_wiv && !old_value)
8240 T_XS = (char_u *)"y";
8241 else if (!p_wiv && old_value)
8242 T_XS = empty_option;
8243 p_wiv = (*T_XS != NUL);
8244 }
8245
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00008246#ifdef FEAT_BEVAL
Bram Moolenaar071d4272004-06-13 20:20:40 +00008247 else if ((int *)varp == &p_beval)
8248 {
Bram Moolenaar49e4ec62011-11-30 11:31:30 +01008249 if (p_beval && !old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008250 gui_mch_enable_beval_area(balloonEval);
Bram Moolenaar49e4ec62011-11-30 11:31:30 +01008251 else if (!p_beval && old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008252 gui_mch_disable_beval_area(balloonEval);
8253 }
Bram Moolenaar8dff8182006-04-06 20:18:50 +00008254#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008255
Bram Moolenaar8dff8182006-04-06 20:18:50 +00008256#ifdef FEAT_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +00008257 else if ((int *)varp == &p_acd)
8258 {
Bram Moolenaar498efdb2006-09-05 14:31:54 +00008259 /* Change directories when the 'acd' option is set now. */
8260 DO_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +00008261 }
8262#endif
8263
8264#ifdef FEAT_DIFF
8265 /* 'diff' */
8266 else if ((int *)varp == &curwin->w_p_diff)
8267 {
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008268 /* May add or remove the buffer from the list of diff buffers. */
8269 diff_buf_adjust(curwin);
8270# ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00008271 if (foldmethodIsDiff(curwin))
8272 foldUpdateAll(curwin);
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008273# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008274 }
8275#endif
8276
8277#ifdef USE_IM_CONTROL
8278 /* 'imdisable' */
8279 else if ((int *)varp == &p_imdisable)
8280 {
8281 /* Only de-activate it here, it will be enabled when changing mode. */
8282 if (p_imdisable)
8283 im_set_active(FALSE);
Bram Moolenaar725a9622011-10-12 16:57:13 +02008284 else if (State & INSERT)
8285 /* When the option is set from an autocommand, it may need to take
8286 * effect right away. */
8287 im_set_active(curbuf->b_p_iminsert == B_IMODE_IM);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008288 }
8289#endif
8290
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00008291#ifdef FEAT_SPELL
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00008292 /* 'spell' */
8293 else if ((int *)varp == &curwin->w_p_spell)
8294 {
8295 if (curwin->w_p_spell)
8296 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02008297 char_u *errmsg = did_set_spelllang(curwin);
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00008298 if (errmsg != NULL)
8299 EMSG(_(errmsg));
8300 }
8301 }
8302#endif
8303
Bram Moolenaar071d4272004-06-13 20:20:40 +00008304#ifdef FEAT_FKMAP
8305 else if ((int *)varp == &p_altkeymap)
8306 {
8307 if (old_value != p_altkeymap)
8308 {
8309 if (!p_altkeymap)
8310 {
8311 p_hkmap = p_fkmap;
8312 p_fkmap = 0;
8313 }
8314 else
8315 {
8316 p_fkmap = p_hkmap;
8317 p_hkmap = 0;
8318 }
8319 (void)init_chartab();
8320 }
8321 }
8322
8323 /*
8324 * In case some second language keymapping options have changed, check
8325 * and correct the setting in a consistent way.
8326 */
8327
8328 /*
8329 * If hkmap or fkmap are set, reset Arabic keymapping.
8330 */
8331 if ((p_hkmap || p_fkmap) && p_altkeymap)
8332 {
8333 p_altkeymap = p_fkmap;
8334# ifdef FEAT_ARABIC
8335 curwin->w_p_arab = FALSE;
8336# endif
8337 (void)init_chartab();
8338 }
8339
8340 /*
8341 * If hkmap set, reset Farsi keymapping.
8342 */
8343 if (p_hkmap && p_altkeymap)
8344 {
8345 p_altkeymap = 0;
8346 p_fkmap = 0;
8347# ifdef FEAT_ARABIC
8348 curwin->w_p_arab = FALSE;
8349# endif
8350 (void)init_chartab();
8351 }
8352
8353 /*
8354 * If fkmap set, reset Hebrew keymapping.
8355 */
8356 if (p_fkmap && !p_altkeymap)
8357 {
8358 p_altkeymap = 1;
8359 p_hkmap = 0;
8360# ifdef FEAT_ARABIC
8361 curwin->w_p_arab = FALSE;
8362# endif
8363 (void)init_chartab();
8364 }
8365#endif
8366
8367#ifdef FEAT_ARABIC
8368 if ((int *)varp == &curwin->w_p_arab)
8369 {
8370 if (curwin->w_p_arab)
8371 {
8372 /*
8373 * 'arabic' is set, handle various sub-settings.
8374 */
8375 if (!p_tbidi)
8376 {
8377 /* set rightleft mode */
8378 if (!curwin->w_p_rl)
8379 {
8380 curwin->w_p_rl = TRUE;
8381 changed_window_setting();
8382 }
8383
8384 /* Enable Arabic shaping (major part of what Arabic requires) */
8385 if (!p_arshape)
8386 {
8387 p_arshape = TRUE;
8388 redraw_later_clear();
8389 }
8390 }
8391
8392 /* Arabic requires a utf-8 encoding, inform the user if its not
8393 * set. */
8394 if (STRCMP(p_enc, "utf-8") != 0)
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008395 {
Bram Moolenaar496c5262009-03-18 14:42:00 +00008396 static char *w_arabic = N_("W17: Arabic requires UTF-8, do ':set encoding=utf-8'");
8397
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008398 msg_source(hl_attr(HLF_W));
Bram Moolenaar496c5262009-03-18 14:42:00 +00008399 MSG_ATTR(_(w_arabic), hl_attr(HLF_W));
8400#ifdef FEAT_EVAL
8401 set_vim_var_string(VV_WARNINGMSG, (char_u *)_(w_arabic), -1);
8402#endif
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008403 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008404
8405# ifdef FEAT_MBYTE
8406 /* set 'delcombine' */
8407 p_deco = TRUE;
8408# endif
8409
8410# ifdef FEAT_KEYMAP
8411 /* Force-set the necessary keymap for arabic */
8412 set_option_value((char_u *)"keymap", 0L, (char_u *)"arabic",
8413 OPT_LOCAL);
8414# endif
8415# ifdef FEAT_FKMAP
8416 p_altkeymap = 0;
8417 p_hkmap = 0;
8418 p_fkmap = 0;
8419 (void)init_chartab();
8420# endif
8421 }
8422 else
8423 {
8424 /*
8425 * 'arabic' is reset, handle various sub-settings.
8426 */
8427 if (!p_tbidi)
8428 {
8429 /* reset rightleft mode */
8430 if (curwin->w_p_rl)
8431 {
8432 curwin->w_p_rl = FALSE;
8433 changed_window_setting();
8434 }
8435
8436 /* 'arabicshape' isn't reset, it is a global option and
8437 * another window may still need it "on". */
8438 }
8439
8440 /* 'delcombine' isn't reset, it is a global option and another
8441 * window may still want it "on". */
8442
8443# ifdef FEAT_KEYMAP
8444 /* Revert to the default keymap */
8445 curbuf->b_p_iminsert = B_IMODE_NONE;
8446 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
8447# endif
8448 }
Bram Moolenaar801f8b82009-07-29 13:42:05 +00008449 }
8450
Bram Moolenaar319bdbd2009-09-11 13:20:33 +00008451#endif
8452
Bram Moolenaar61be73b2016-04-29 22:59:22 +02008453#ifdef FEAT_TERMGUICOLORS
8454 /* 'termguicolors' */
8455 else if ((int *)varp == &p_tgc)
Bram Moolenaar8a633e32016-04-21 21:10:14 +02008456 {
8457# ifdef FEAT_GUI
8458 if (!gui.in_use && !gui.starting)
8459# endif
8460 highlight_gui_started();
8461 }
8462#endif
8463
Bram Moolenaar071d4272004-06-13 20:20:40 +00008464 /*
8465 * End of handling side effects for bool options.
8466 */
8467
Bram Moolenaar53744302015-07-17 17:38:22 +02008468 /* after handling side effects, call autocommand */
8469
Bram Moolenaar071d4272004-06-13 20:20:40 +00008470 options[opt_idx].flags |= P_WAS_SET;
8471
Bram Moolenaar53744302015-07-17 17:38:22 +02008472#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
8473 if (!starting)
8474 {
8475 char_u buf_old[2], buf_new[2], buf_type[7];
Bram Moolenaarfb9bc482015-07-17 22:04:48 +02008476 vim_snprintf((char *)buf_old, 2, "%d", old_value ? TRUE: FALSE);
8477 vim_snprintf((char *)buf_new, 2, "%d", value ? TRUE: FALSE);
8478 vim_snprintf((char *)buf_type, 7, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar53744302015-07-17 17:38:22 +02008479 set_vim_var_string(VV_OPTION_NEW, buf_new, -1);
8480 set_vim_var_string(VV_OPTION_OLD, buf_old, -1);
8481 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
8482 apply_autocmds(EVENT_OPTIONSET, (char_u *) options[opt_idx].fullname, NULL, FALSE, NULL);
8483 reset_v_option_vars();
8484 }
8485#endif
8486
Bram Moolenaar071d4272004-06-13 20:20:40 +00008487 comp_col(); /* in case 'ruler' or 'showcmd' changed */
Bram Moolenaar913077c2012-03-28 19:59:04 +02008488 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01008489 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02008490 curwin->w_set_curswant = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008491 check_redraw(options[opt_idx].flags);
8492
8493 return NULL;
8494}
8495
8496/*
8497 * Set the value of a number option, and take care of side effects.
8498 * Returns NULL for success, or an error message for an error.
8499 */
8500 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01008501set_num_option(
8502 int opt_idx, /* index in options[] table */
8503 char_u *varp, /* pointer to the option variable */
8504 long value, /* new value */
8505 char_u *errbuf, /* buffer for error messages */
8506 size_t errbuflen, /* length of "errbuf" */
8507 int opt_flags) /* OPT_LOCAL, OPT_GLOBAL and
Bram Moolenaar071d4272004-06-13 20:20:40 +00008508 OPT_MODELINE */
8509{
8510 char_u *errmsg = NULL;
8511 long old_value = *(long *)varp;
8512 long old_Rows = Rows; /* remember old Rows */
8513 long old_Columns = Columns; /* remember old Columns */
8514 long *pp = (long *)varp;
8515
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008516 /* Disallow changing some options from secure mode. */
8517 if ((secure
8518#ifdef HAVE_SANDBOX
8519 || sandbox != 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00008520#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008521 ) && (options[opt_idx].flags & P_SECURE))
8522 return e_secure;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008523
8524 *pp = value;
8525#ifdef FEAT_EVAL
8526 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008527 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008528#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008529#ifdef FEAT_GUI
8530 need_mouse_correct = TRUE;
8531#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008532
Bram Moolenaar14f24742012-08-08 18:01:05 +02008533 if (curbuf->b_p_sw < 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008534 {
8535 errmsg = e_positive;
8536 curbuf->b_p_sw = curbuf->b_p_ts;
8537 }
8538
8539 /*
8540 * Number options that need some action when changed
8541 */
8542#ifdef FEAT_WINDOWS
8543 if (pp == &p_wh || pp == &p_hh)
8544 {
8545 if (p_wh < 1)
8546 {
8547 errmsg = e_positive;
8548 p_wh = 1;
8549 }
8550 if (p_wmh > p_wh)
8551 {
8552 errmsg = e_winheight;
8553 p_wh = p_wmh;
8554 }
8555 if (p_hh < 0)
8556 {
8557 errmsg = e_positive;
8558 p_hh = 0;
8559 }
8560
8561 /* Change window height NOW */
Bram Moolenaar459ca562016-11-10 18:16:33 +01008562 if (!ONE_WINDOW)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008563 {
8564 if (pp == &p_wh && curwin->w_height < p_wh)
8565 win_setheight((int)p_wh);
8566 if (pp == &p_hh && curbuf->b_help && curwin->w_height < p_hh)
8567 win_setheight((int)p_hh);
8568 }
8569 }
8570
8571 /* 'winminheight' */
8572 else if (pp == &p_wmh)
8573 {
8574 if (p_wmh < 0)
8575 {
8576 errmsg = e_positive;
8577 p_wmh = 0;
8578 }
8579 if (p_wmh > p_wh)
8580 {
8581 errmsg = e_winheight;
8582 p_wmh = p_wh;
8583 }
8584 win_setminheight();
8585 }
8586
Bram Moolenaar44a2f922016-03-19 22:11:51 +01008587# ifdef FEAT_WINDOWS
Bram Moolenaar592e0a22004-07-03 16:05:59 +00008588 else if (pp == &p_wiw)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008589 {
8590 if (p_wiw < 1)
8591 {
8592 errmsg = e_positive;
8593 p_wiw = 1;
8594 }
8595 if (p_wmw > p_wiw)
8596 {
8597 errmsg = e_winwidth;
8598 p_wiw = p_wmw;
8599 }
8600
8601 /* Change window width NOW */
Bram Moolenaar459ca562016-11-10 18:16:33 +01008602 if (!ONE_WINDOW && curwin->w_width < p_wiw)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008603 win_setwidth((int)p_wiw);
8604 }
8605
8606 /* 'winminwidth' */
8607 else if (pp == &p_wmw)
8608 {
8609 if (p_wmw < 0)
8610 {
8611 errmsg = e_positive;
8612 p_wmw = 0;
8613 }
8614 if (p_wmw > p_wiw)
8615 {
8616 errmsg = e_winwidth;
8617 p_wmw = p_wiw;
8618 }
8619 win_setminheight();
8620 }
8621# endif
8622
8623#endif
8624
8625#ifdef FEAT_WINDOWS
8626 /* (re)set last window status line */
8627 else if (pp == &p_ls)
8628 {
8629 last_status(FALSE);
8630 }
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00008631
8632 /* (re)set tab page line */
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00008633 else if (pp == &p_stal)
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00008634 {
8635 shell_new_rows(); /* recompute window positions and heights */
8636 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008637#endif
8638
8639#ifdef FEAT_GUI
8640 else if (pp == &p_linespace)
8641 {
Bram Moolenaar02743632005-07-25 20:42:36 +00008642 /* Recompute gui.char_height and resize the Vim window to keep the
8643 * same number of lines. */
8644 if (gui.in_use && gui_mch_adjust_charheight() == OK)
Bram Moolenaar3964b7e2006-03-27 20:59:33 +00008645 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008646 }
8647#endif
8648
8649#ifdef FEAT_FOLDING
8650 /* 'foldlevel' */
8651 else if (pp == &curwin->w_p_fdl)
8652 {
8653 if (curwin->w_p_fdl < 0)
8654 curwin->w_p_fdl = 0;
8655 newFoldLevel();
8656 }
8657
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008658 /* 'foldminlines' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008659 else if (pp == &curwin->w_p_fml)
8660 {
8661 foldUpdateAll(curwin);
8662 }
8663
8664 /* 'foldnestmax' */
8665 else if (pp == &curwin->w_p_fdn)
8666 {
8667 if (foldmethodIsSyntax(curwin) || foldmethodIsIndent(curwin))
8668 foldUpdateAll(curwin);
8669 }
8670
8671 /* 'foldcolumn' */
8672 else if (pp == &curwin->w_p_fdc)
8673 {
8674 if (curwin->w_p_fdc < 0)
8675 {
8676 errmsg = e_positive;
8677 curwin->w_p_fdc = 0;
8678 }
8679 else if (curwin->w_p_fdc > 12)
8680 {
8681 errmsg = e_invarg;
8682 curwin->w_p_fdc = 12;
8683 }
8684 }
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008685#endif /* FEAT_FOLDING */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008686
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008687#if defined(FEAT_FOLDING) || defined(FEAT_CINDENT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008688 /* 'shiftwidth' or 'tabstop' */
8689 else if (pp == &curbuf->b_p_sw || pp == &curbuf->b_p_ts)
8690 {
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008691# ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00008692 if (foldmethodIsIndent(curwin))
8693 foldUpdateAll(curwin);
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008694# endif
8695# ifdef FEAT_CINDENT
8696 /* When 'shiftwidth' changes, or it's zero and 'tabstop' changes:
8697 * parse 'cinoptions'. */
8698 if (pp == &curbuf->b_p_sw || curbuf->b_p_sw == 0)
8699 parse_cino(curbuf);
8700# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008701 }
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008702#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008703
Bram Moolenaar362e1a32006-03-06 23:29:24 +00008704#ifdef FEAT_MBYTE
8705 /* 'maxcombine' */
8706 else if (pp == &p_mco)
8707 {
8708 if (p_mco > MAX_MCO)
8709 p_mco = MAX_MCO;
8710 else if (p_mco < 0)
8711 p_mco = 0;
8712 screenclear(); /* will re-allocate the screen */
8713 }
8714#endif
8715
Bram Moolenaar071d4272004-06-13 20:20:40 +00008716 else if (pp == &curbuf->b_p_iminsert)
8717 {
8718 if (curbuf->b_p_iminsert < 0 || curbuf->b_p_iminsert > B_IMODE_LAST)
8719 {
8720 errmsg = e_invarg;
8721 curbuf->b_p_iminsert = B_IMODE_NONE;
8722 }
8723 p_iminsert = curbuf->b_p_iminsert;
8724 if (termcap_active) /* don't do this in the alternate screen */
8725 showmode();
8726#if defined(FEAT_WINDOWS) && defined(FEAT_KEYMAP)
8727 /* Show/unshow value of 'keymap' in status lines. */
8728 status_redraw_curbuf();
8729#endif
8730 }
8731
Bram Moolenaar4399ef42005-02-12 14:29:27 +00008732 else if (pp == &p_window)
8733 {
8734 if (p_window < 1)
8735 p_window = 1;
8736 else if (p_window >= Rows)
8737 p_window = Rows - 1;
8738 }
8739
Bram Moolenaar071d4272004-06-13 20:20:40 +00008740 else if (pp == &curbuf->b_p_imsearch)
8741 {
8742 if (curbuf->b_p_imsearch < -1 || curbuf->b_p_imsearch > B_IMODE_LAST)
8743 {
8744 errmsg = e_invarg;
8745 curbuf->b_p_imsearch = B_IMODE_NONE;
8746 }
8747 p_imsearch = curbuf->b_p_imsearch;
8748 }
8749
8750#ifdef FEAT_TITLE
8751 /* if 'titlelen' has changed, redraw the title */
8752 else if (pp == &p_titlelen)
8753 {
8754 if (p_titlelen < 0)
8755 {
8756 errmsg = e_positive;
8757 p_titlelen = 85;
8758 }
8759 if (starting != NO_SCREEN && old_value != p_titlelen)
8760 need_maketitle = TRUE;
8761 }
8762#endif
8763
8764 /* if p_ch changed value, change the command line height */
8765 else if (pp == &p_ch)
8766 {
8767 if (p_ch < 1)
8768 {
8769 errmsg = e_positive;
8770 p_ch = 1;
8771 }
Bram Moolenaar719939c2007-09-25 12:51:28 +00008772 if (p_ch > Rows - min_rows() + 1)
8773 p_ch = Rows - min_rows() + 1;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008774
8775 /* Only compute the new window layout when startup has been
8776 * completed. Otherwise the frame sizes may be wrong. */
8777 if (p_ch != old_value && full_screen
8778#ifdef FEAT_GUI
8779 && !gui.starting
8780#endif
8781 )
Bram Moolenaarc6fe9192006-04-09 21:54:49 +00008782 command_height();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008783 }
8784
8785 /* when 'updatecount' changes from zero to non-zero, open swap files */
8786 else if (pp == &p_uc)
8787 {
8788 if (p_uc < 0)
8789 {
8790 errmsg = e_positive;
8791 p_uc = 100;
8792 }
8793 if (p_uc && !old_value)
8794 ml_open_files();
8795 }
Bram Moolenaar860cae12010-06-05 23:22:07 +02008796#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008797 else if (pp == &curwin->w_p_cole)
Bram Moolenaar860cae12010-06-05 23:22:07 +02008798 {
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008799 if (curwin->w_p_cole < 0)
Bram Moolenaar860cae12010-06-05 23:22:07 +02008800 {
8801 errmsg = e_positive;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008802 curwin->w_p_cole = 0;
Bram Moolenaar860cae12010-06-05 23:22:07 +02008803 }
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008804 else if (curwin->w_p_cole > 3)
Bram Moolenaar860cae12010-06-05 23:22:07 +02008805 {
8806 errmsg = e_invarg;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008807 curwin->w_p_cole = 3;
Bram Moolenaar860cae12010-06-05 23:22:07 +02008808 }
8809 }
8810#endif
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008811#ifdef MZSCHEME_GUI_THREADS
Bram Moolenaar325b7a22004-07-05 15:58:32 +00008812 else if (pp == &p_mzq)
8813 mzvim_reset_timer();
8814#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008815
8816 /* sync undo before 'undolevels' changes */
8817 else if (pp == &p_ul)
8818 {
8819 /* use the old value, otherwise u_sync() may not work properly */
8820 p_ul = old_value;
Bram Moolenaar779b74b2006-04-10 14:55:34 +00008821 u_sync(TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008822 p_ul = value;
8823 }
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01008824 else if (pp == &curbuf->b_p_ul)
8825 {
8826 /* use the old value, otherwise u_sync() may not work properly */
8827 curbuf->b_p_ul = old_value;
8828 u_sync(TRUE);
8829 curbuf->b_p_ul = value;
8830 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008831
Bram Moolenaar592e0a22004-07-03 16:05:59 +00008832#ifdef FEAT_LINEBREAK
8833 /* 'numberwidth' must be positive */
8834 else if (pp == &curwin->w_p_nuw)
8835 {
8836 if (curwin->w_p_nuw < 1)
8837 {
8838 errmsg = e_positive;
8839 curwin->w_p_nuw = 1;
8840 }
8841 if (curwin->w_p_nuw > 10)
8842 {
8843 errmsg = e_invarg;
8844 curwin->w_p_nuw = 10;
8845 }
Bram Moolenaar1e7813a2015-03-31 18:31:03 +02008846 curwin->w_nrwidth_line_count = 0; /* trigger a redraw */
Bram Moolenaar592e0a22004-07-03 16:05:59 +00008847 }
8848#endif
8849
Bram Moolenaar1a384422010-07-14 19:53:30 +02008850 else if (pp == &curbuf->b_p_tw)
8851 {
8852 if (curbuf->b_p_tw < 0)
8853 {
8854 errmsg = e_positive;
8855 curbuf->b_p_tw = 0;
8856 }
8857#ifdef FEAT_SYN_HL
8858# ifdef FEAT_WINDOWS
8859 {
8860 win_T *wp;
8861 tabpage_T *tp;
8862
8863 FOR_ALL_TAB_WINDOWS(tp, wp)
8864 check_colorcolumn(wp);
8865 }
8866# else
8867 check_colorcolumn(curwin);
8868# endif
8869#endif
8870 }
8871
Bram Moolenaar071d4272004-06-13 20:20:40 +00008872 /*
8873 * Check the bounds for numeric options here
8874 */
8875 if (Rows < min_rows() && full_screen)
8876 {
8877 if (errbuf != NULL)
8878 {
Bram Moolenaar555b2802005-05-19 21:08:39 +00008879 vim_snprintf((char *)errbuf, errbuflen,
8880 _("E593: Need at least %d lines"), min_rows());
Bram Moolenaar071d4272004-06-13 20:20:40 +00008881 errmsg = errbuf;
8882 }
8883 Rows = min_rows();
8884 }
8885 if (Columns < MIN_COLUMNS && full_screen)
8886 {
8887 if (errbuf != NULL)
8888 {
Bram Moolenaar555b2802005-05-19 21:08:39 +00008889 vim_snprintf((char *)errbuf, errbuflen,
8890 _("E594: Need at least %d columns"), MIN_COLUMNS);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008891 errmsg = errbuf;
8892 }
8893 Columns = MIN_COLUMNS;
8894 }
Bram Moolenaare057d402013-06-30 17:51:51 +02008895 limit_screen_size();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008896
Bram Moolenaar071d4272004-06-13 20:20:40 +00008897 /*
8898 * If the screen (shell) height has been changed, assume it is the
8899 * physical screenheight.
8900 */
8901 if (old_Rows != Rows || old_Columns != Columns)
8902 {
8903 /* Changing the screen size is not allowed while updating the screen. */
8904 if (updating_screen)
8905 *pp = old_value;
8906 else if (full_screen
8907#ifdef FEAT_GUI
8908 && !gui.starting
8909#endif
8910 )
8911 set_shellsize((int)Columns, (int)Rows, TRUE);
8912 else
8913 {
8914 /* Postpone the resizing; check the size and cmdline position for
8915 * messages. */
8916 check_shellsize();
8917 if (cmdline_row > Rows - p_ch && Rows > p_ch)
8918 cmdline_row = Rows - p_ch;
8919 }
Bram Moolenaard68071d2006-05-02 22:08:30 +00008920 if (p_window >= Rows || !option_was_set((char_u *)"window"))
Bram Moolenaar4399ef42005-02-12 14:29:27 +00008921 p_window = Rows - 1;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008922 }
8923
Bram Moolenaar071d4272004-06-13 20:20:40 +00008924 if (curbuf->b_p_ts <= 0)
8925 {
8926 errmsg = e_positive;
8927 curbuf->b_p_ts = 8;
8928 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008929 if (p_tm < 0)
8930 {
8931 errmsg = e_positive;
8932 p_tm = 0;
8933 }
8934 if ((curwin->w_p_scr <= 0
8935 || (curwin->w_p_scr > curwin->w_height
8936 && curwin->w_height > 0))
8937 && full_screen)
8938 {
8939 if (pp == &(curwin->w_p_scr))
8940 {
8941 if (curwin->w_p_scr != 0)
8942 errmsg = e_scroll;
8943 win_comp_scroll(curwin);
8944 }
8945 /* If 'scroll' became invalid because of a side effect silently adjust
8946 * it. */
8947 else if (curwin->w_p_scr <= 0)
8948 curwin->w_p_scr = 1;
8949 else /* curwin->w_p_scr > curwin->w_height */
8950 curwin->w_p_scr = curwin->w_height;
8951 }
Bram Moolenaar991e10f2008-10-02 20:48:41 +00008952 if (p_hi < 0)
8953 {
8954 errmsg = e_positive;
8955 p_hi = 0;
8956 }
Bram Moolenaar78159bb2014-06-25 11:48:54 +02008957 else if (p_hi > 10000)
8958 {
8959 errmsg = e_invarg;
8960 p_hi = 10000;
8961 }
Bram Moolenaarfbc0d2e2013-05-19 19:40:29 +02008962 if (p_re < 0 || p_re > 2)
8963 {
8964 errmsg = e_invarg;
8965 p_re = 0;
8966 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008967 if (p_report < 0)
8968 {
8969 errmsg = e_positive;
8970 p_report = 1;
8971 }
Bram Moolenaar1e015462005-09-25 22:16:38 +00008972 if ((p_sj < -100 || p_sj >= Rows) && full_screen)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008973 {
8974 if (Rows != old_Rows) /* Rows changed, just adjust p_sj */
8975 p_sj = Rows / 2;
8976 else
8977 {
8978 errmsg = e_scroll;
8979 p_sj = 1;
8980 }
8981 }
8982 if (p_so < 0 && full_screen)
8983 {
8984 errmsg = e_scroll;
8985 p_so = 0;
8986 }
8987 if (p_siso < 0 && full_screen)
8988 {
8989 errmsg = e_positive;
8990 p_siso = 0;
8991 }
8992#ifdef FEAT_CMDWIN
8993 if (p_cwh < 1)
8994 {
8995 errmsg = e_positive;
8996 p_cwh = 1;
8997 }
8998#endif
8999 if (p_ut < 0)
9000 {
9001 errmsg = e_positive;
9002 p_ut = 2000;
9003 }
9004 if (p_ss < 0)
9005 {
9006 errmsg = e_positive;
9007 p_ss = 0;
9008 }
9009
9010 /* May set global value for local option. */
9011 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
9012 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = *pp;
9013
9014 options[opt_idx].flags |= P_WAS_SET;
9015
Bram Moolenaar53744302015-07-17 17:38:22 +02009016#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
9017 if (!starting && errmsg == NULL)
9018 {
9019 char_u buf_old[11], buf_new[11], buf_type[7];
Bram Moolenaarfb9bc482015-07-17 22:04:48 +02009020 vim_snprintf((char *)buf_old, 10, "%ld", old_value);
9021 vim_snprintf((char *)buf_new, 10, "%ld", value);
9022 vim_snprintf((char *)buf_type, 7, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar53744302015-07-17 17:38:22 +02009023 set_vim_var_string(VV_OPTION_NEW, buf_new, -1);
9024 set_vim_var_string(VV_OPTION_OLD, buf_old, -1);
9025 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
9026 apply_autocmds(EVENT_OPTIONSET, (char_u *) options[opt_idx].fullname, NULL, FALSE, NULL);
9027 reset_v_option_vars();
9028 }
9029#endif
9030
Bram Moolenaar071d4272004-06-13 20:20:40 +00009031 comp_col(); /* in case 'columns' or 'ls' changed */
Bram Moolenaar913077c2012-03-28 19:59:04 +02009032 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01009033 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02009034 curwin->w_set_curswant = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009035 check_redraw(options[opt_idx].flags);
9036
9037 return errmsg;
9038}
9039
9040/*
9041 * Called after an option changed: check if something needs to be redrawn.
9042 */
9043 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01009044check_redraw(long_u flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009045{
9046 /* Careful: P_RCLR and P_RALL are a combination of other P_ flags */
Bram Moolenaar70b2a562012-01-10 22:26:17 +01009047 int doclear = (flags & P_RCLR) == P_RCLR;
9048 int all = ((flags & P_RALL) == P_RALL || doclear);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009049
9050#ifdef FEAT_WINDOWS
9051 if ((flags & P_RSTAT) || all) /* mark all status lines dirty */
9052 status_redraw_all();
9053#endif
9054
9055 if ((flags & P_RBUF) || (flags & P_RWIN) || all)
9056 changed_window_setting();
9057 if (flags & P_RBUF)
9058 redraw_curbuf_later(NOT_VALID);
Bram Moolenaara2477fd2016-12-03 15:13:20 +01009059 if (flags & P_RWINONLY)
9060 redraw_later(NOT_VALID);
Bram Moolenaar70b2a562012-01-10 22:26:17 +01009061 if (doclear)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009062 redraw_all_later(CLEAR);
9063 else if (all)
9064 redraw_all_later(NOT_VALID);
9065}
9066
9067/*
9068 * Find index for option 'arg'.
9069 * Return -1 if not found.
9070 */
9071 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009072findoption(char_u *arg)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009073{
9074 int opt_idx;
9075 char *s, *p;
9076 static short quick_tab[27] = {0, 0}; /* quick access table */
9077 int is_term_opt;
9078
9079 /*
9080 * For first call: Initialize the quick-access table.
9081 * It contains the index for the first option that starts with a certain
9082 * letter. There are 26 letters, plus the first "t_" option.
9083 */
9084 if (quick_tab[1] == 0)
9085 {
9086 p = options[0].fullname;
9087 for (opt_idx = 1; (s = options[opt_idx].fullname) != NULL; opt_idx++)
9088 {
9089 if (s[0] != p[0])
9090 {
9091 if (s[0] == 't' && s[1] == '_')
9092 quick_tab[26] = opt_idx;
9093 else
9094 quick_tab[CharOrdLow(s[0])] = opt_idx;
9095 }
9096 p = s;
9097 }
9098 }
9099
9100 /*
9101 * Check for name starting with an illegal character.
9102 */
9103#ifdef EBCDIC
9104 if (!islower(arg[0]))
9105#else
9106 if (arg[0] < 'a' || arg[0] > 'z')
9107#endif
9108 return -1;
9109
9110 is_term_opt = (arg[0] == 't' && arg[1] == '_');
9111 if (is_term_opt)
9112 opt_idx = quick_tab[26];
9113 else
9114 opt_idx = quick_tab[CharOrdLow(arg[0])];
9115 for ( ; (s = options[opt_idx].fullname) != NULL; opt_idx++)
9116 {
9117 if (STRCMP(arg, s) == 0) /* match full name */
9118 break;
9119 }
9120 if (s == NULL && !is_term_opt)
9121 {
9122 opt_idx = quick_tab[CharOrdLow(arg[0])];
9123 for ( ; options[opt_idx].fullname != NULL; opt_idx++)
9124 {
9125 s = options[opt_idx].shortname;
9126 if (s != NULL && STRCMP(arg, s) == 0) /* match short name */
9127 break;
9128 s = NULL;
9129 }
9130 }
9131 if (s == NULL)
9132 opt_idx = -1;
9133 return opt_idx;
9134}
9135
Bram Moolenaar325b7a22004-07-05 15:58:32 +00009136#if defined(FEAT_EVAL) || defined(FEAT_TCL) || defined(FEAT_MZSCHEME)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009137/*
9138 * Get the value for an option.
9139 *
9140 * Returns:
9141 * Number or Toggle option: 1, *numval gets value.
9142 * String option: 0, *stringval gets allocated string.
9143 * Hidden Number or Toggle option: -1.
9144 * hidden String option: -2.
9145 * unknown option: -3.
9146 */
9147 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009148get_option_value(
9149 char_u *name,
9150 long *numval,
9151 char_u **stringval, /* NULL when only checking existence */
9152 int opt_flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009153{
9154 int opt_idx;
9155 char_u *varp;
9156
9157 opt_idx = findoption(name);
9158 if (opt_idx < 0) /* unknown option */
9159 return -3;
9160
9161 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
9162
9163 if (options[opt_idx].flags & P_STRING)
9164 {
9165 if (varp == NULL) /* hidden option */
9166 return -2;
9167 if (stringval != NULL)
9168 {
9169#ifdef FEAT_CRYPT
9170 /* never return the value of the crypt key */
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00009171 if ((char_u **)varp == &curbuf->b_p_key
9172 && **(char_u **)(varp) != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009173 *stringval = vim_strsave((char_u *)"*****");
9174 else
9175#endif
9176 *stringval = vim_strsave(*(char_u **)(varp));
9177 }
9178 return 0;
9179 }
9180
9181 if (varp == NULL) /* hidden option */
9182 return -1;
9183 if (options[opt_idx].flags & P_NUM)
9184 *numval = *(long *)varp;
9185 else
9186 {
9187 /* Special case: 'modified' is b_changed, but we also want to consider
9188 * it set when 'ff' or 'fenc' changed. */
9189 if ((int *)varp == &curbuf->b_changed)
9190 *numval = curbufIsChanged();
9191 else
Bram Moolenaar2acfbed2016-07-01 23:14:02 +02009192 *numval = (long) *(int *)varp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009193 }
9194 return 1;
9195}
9196#endif
9197
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009198#if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009199/*
9200 * Returns the option attributes and its value. Unlike the above function it
9201 * will return either global value or local value of the option depending on
9202 * what was requested, but it will never return global value if it was
9203 * requested to return local one and vice versa. Neither it will return
9204 * buffer-local value if it was requested to return window-local one.
9205 *
9206 * Pretends that option is absent if it is not present in the requested scope
9207 * (i.e. has no global, window-local or buffer-local value depending on
9208 * opt_type). Uses
9209 *
9210 * Returned flags:
Bram Moolenaar75a8d742014-05-07 15:10:21 +02009211 * 0 hidden or unknown option, also option that does not have requested
9212 * type (see SREQ_* in vim.h)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009213 * see SOPT_* in vim.h for other flags
9214 *
9215 * Possible opt_type values: see SREQ_* in vim.h
9216 */
9217 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009218get_option_value_strict(
9219 char_u *name,
9220 long *numval,
9221 char_u **stringval, /* NULL when only obtaining attributes */
9222 int opt_type,
9223 void *from)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009224{
9225 int opt_idx;
Bram Moolenaar68001862013-05-11 13:45:05 +02009226 char_u *varp = NULL;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009227 struct vimoption *p;
9228 int r = 0;
9229
9230 opt_idx = findoption(name);
9231 if (opt_idx < 0)
9232 return 0;
9233
9234 p = &(options[opt_idx]);
9235
9236 /* Hidden option */
9237 if (p->var == NULL)
9238 return 0;
9239
9240 if (p->flags & P_BOOL)
9241 r |= SOPT_BOOL;
9242 else if (p->flags & P_NUM)
9243 r |= SOPT_NUM;
9244 else if (p->flags & P_STRING)
9245 r |= SOPT_STRING;
9246
9247 if (p->indir == PV_NONE)
9248 {
9249 if (opt_type == SREQ_GLOBAL)
9250 r |= SOPT_GLOBAL;
9251 else
9252 return 0; /* Did not request global-only option */
9253 }
9254 else
9255 {
9256 if (p->indir & PV_BOTH)
9257 r |= SOPT_GLOBAL;
9258 else if (opt_type == SREQ_GLOBAL)
9259 return 0; /* Requested global option */
9260
9261 if (p->indir & PV_WIN)
9262 {
9263 if (opt_type == SREQ_BUF)
9264 return 0; /* Did not request window-local option */
9265 else
9266 r |= SOPT_WIN;
9267 }
9268 else if (p->indir & PV_BUF)
9269 {
9270 if (opt_type == SREQ_WIN)
9271 return 0; /* Did not request buffer-local option */
9272 else
9273 r |= SOPT_BUF;
9274 }
9275 }
9276
9277 if (stringval == NULL)
9278 return r;
9279
9280 if (opt_type == SREQ_GLOBAL)
9281 varp = p->var;
9282 else
9283 {
9284 if (opt_type == SREQ_BUF)
9285 {
9286 /* Special case: 'modified' is b_changed, but we also want to
9287 * consider it set when 'ff' or 'fenc' changed. */
9288 if (p->indir == PV_MOD)
9289 {
9290 *numval = bufIsChanged((buf_T *) from);
9291 varp = NULL;
9292 }
9293#ifdef FEAT_CRYPT
9294 else if (p->indir == PV_KEY)
9295 {
9296 /* never return the value of the crypt key */
9297 *stringval = NULL;
9298 varp = NULL;
9299 }
9300#endif
9301 else
9302 {
9303 aco_save_T aco;
9304 aucmd_prepbuf(&aco, (buf_T *) from);
9305 varp = get_varp(p);
9306 aucmd_restbuf(&aco);
9307 }
9308 }
9309 else if (opt_type == SREQ_WIN)
9310 {
9311 win_T *save_curwin;
9312 save_curwin = curwin;
9313 curwin = (win_T *) from;
9314 curbuf = curwin->w_buffer;
9315 varp = get_varp(p);
9316 curwin = save_curwin;
9317 curbuf = curwin->w_buffer;
9318 }
9319 if (varp == p->var)
9320 return (r | SOPT_UNSET);
9321 }
9322
9323 if (varp != NULL)
9324 {
9325 if (p->flags & P_STRING)
9326 *stringval = vim_strsave(*(char_u **)(varp));
9327 else if (p->flags & P_NUM)
9328 *numval = *(long *) varp;
9329 else
9330 *numval = *(int *)varp;
9331 }
9332
9333 return r;
9334}
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009335
9336/*
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009337 * Iterate over options. First argument is a pointer to a pointer to a
9338 * structure inside options[] array, second is option type like in the above
9339 * function.
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009340 *
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009341 * If first argument points to NULL it is assumed that iteration just started
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009342 * and caller needs the very first value.
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009343 * If first argument points to the end marker function returns NULL and sets
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009344 * first argument to NULL.
9345 *
9346 * Returns full option name for current option on each call.
9347 */
9348 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009349option_iter_next(void **option, int opt_type)
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009350{
9351 struct vimoption *ret = NULL;
9352 do
9353 {
9354 if (*option == NULL)
9355 *option = (void *) options;
9356 else if (((struct vimoption *) (*option))->fullname == NULL)
9357 {
9358 *option = NULL;
9359 return NULL;
9360 }
9361 else
9362 *option = (void *) (((struct vimoption *) (*option)) + 1);
9363
9364 ret = ((struct vimoption *) (*option));
9365
9366 /* Hidden option */
9367 if (ret->var == NULL)
9368 {
9369 ret = NULL;
9370 continue;
9371 }
9372
9373 switch (opt_type)
9374 {
9375 case SREQ_GLOBAL:
9376 if (!(ret->indir == PV_NONE || ret->indir & PV_BOTH))
9377 ret = NULL;
9378 break;
9379 case SREQ_BUF:
9380 if (!(ret->indir & PV_BUF))
9381 ret = NULL;
9382 break;
9383 case SREQ_WIN:
9384 if (!(ret->indir & PV_WIN))
9385 ret = NULL;
9386 break;
9387 default:
Bram Moolenaar95f09602016-11-10 20:01:45 +01009388 internal_error("option_iter_next()");
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009389 return NULL;
9390 }
9391 }
9392 while (ret == NULL);
9393
9394 return (char_u *)ret->fullname;
9395}
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009396#endif
9397
Bram Moolenaar071d4272004-06-13 20:20:40 +00009398/*
9399 * Set the value of option "name".
9400 * Use "string" for string options, use "number" for other options.
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009401 *
9402 * Returns NULL on success or error message on error.
Bram Moolenaar071d4272004-06-13 20:20:40 +00009403 */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009404 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009405set_option_value(
9406 char_u *name,
9407 long number,
9408 char_u *string,
9409 int opt_flags) /* OPT_LOCAL or 0 (both) */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009410{
9411 int opt_idx;
9412 char_u *varp;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00009413 long_u flags;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009414
9415 opt_idx = findoption(name);
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00009416 if (opt_idx < 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009417 EMSG2(_("E355: Unknown option: %s"), name);
9418 else
9419 {
9420 flags = options[opt_idx].flags;
9421#ifdef HAVE_SANDBOX
9422 /* Disallow changing some options in the sandbox */
9423 if (sandbox > 0 && (flags & P_SECURE))
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009424 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00009425 EMSG(_(e_sandbox));
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009426 return NULL;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009427 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009428#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009429 if (flags & P_STRING)
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009430 return set_string_option(opt_idx, string, opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009431 else
9432 {
Bram Moolenaarb3163762008-07-08 15:15:08 +00009433 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009434 if (varp != NULL) /* hidden option is not changed */
9435 {
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009436 if (number == 0 && string != NULL)
9437 {
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009438 int idx;
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009439
9440 /* Either we are given a string or we are setting option
9441 * to zero. */
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009442 for (idx = 0; string[idx] == '0'; ++idx)
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009443 ;
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009444 if (string[idx] != NUL || idx == 0)
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009445 {
9446 /* There's another character after zeros or the string
9447 * is empty. In both cases, we are trying to set a
9448 * num option using a string. */
9449 EMSG3(_("E521: Number required: &%s = '%s'"),
9450 name, string);
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009451 return NULL; /* do nothing as we hit an error */
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009452
9453 }
9454 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009455 if (flags & P_NUM)
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009456 return set_num_option(opt_idx, varp, number,
Bram Moolenaar555b2802005-05-19 21:08:39 +00009457 NULL, 0, opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009458 else
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009459 return set_bool_option(opt_idx, varp, (int)number,
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009460 opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009461 }
9462 }
9463 }
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009464 return NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009465}
9466
9467/*
9468 * Get the terminal code for a terminal option.
9469 * Returns NULL when not found.
9470 */
9471 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009472get_term_code(char_u *tname)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009473{
9474 int opt_idx;
9475 char_u *varp;
9476
9477 if (tname[0] != 't' || tname[1] != '_' ||
9478 tname[2] == NUL || tname[3] == NUL)
9479 return NULL;
9480 if ((opt_idx = findoption(tname)) >= 0)
9481 {
9482 varp = get_varp(&(options[opt_idx]));
9483 if (varp != NULL)
9484 varp = *(char_u **)(varp);
9485 return varp;
9486 }
9487 return find_termcode(tname + 2);
9488}
9489
9490 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009491get_highlight_default(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009492{
9493 int i;
9494
9495 i = findoption((char_u *)"hl");
9496 if (i >= 0)
9497 return options[i].def_val[VI_DEFAULT];
9498 return (char_u *)NULL;
9499}
9500
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00009501#if defined(FEAT_MBYTE) || defined(PROTO)
9502 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009503get_encoding_default(void)
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00009504{
9505 int i;
9506
9507 i = findoption((char_u *)"enc");
9508 if (i >= 0)
9509 return options[i].def_val[VI_DEFAULT];
9510 return (char_u *)NULL;
9511}
9512#endif
9513
Bram Moolenaar071d4272004-06-13 20:20:40 +00009514/*
9515 * Translate a string like "t_xx", "<t_xx>" or "<S-Tab>" to a key number.
9516 */
9517 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009518find_key_option(char_u *arg)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009519{
9520 int key;
9521 int modifiers;
9522
9523 /*
9524 * Don't use get_special_key_code() for t_xx, we don't want it to call
9525 * add_termcap_entry().
9526 */
9527 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
9528 key = TERMCAP2KEY(arg[2], arg[3]);
9529 else
9530 {
9531 --arg; /* put arg at the '<' */
9532 modifiers = 0;
Bram Moolenaar35a4cfa2016-08-14 16:07:48 +02009533 key = find_special_key(&arg, &modifiers, TRUE, TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009534 if (modifiers) /* can't handle modifiers here */
9535 key = 0;
9536 }
9537 return key;
9538}
9539
9540/*
9541 * if 'all' == 0: show changed options
9542 * if 'all' == 1: show all normal options
9543 * if 'all' == 2: show all terminal options
9544 */
9545 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01009546showoptions(
9547 int all,
9548 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009549{
9550 struct vimoption *p;
9551 int col;
9552 int isterm;
9553 char_u *varp;
9554 struct vimoption **items;
9555 int item_count;
9556 int run;
9557 int row, rows;
9558 int cols;
9559 int i;
9560 int len;
9561
9562#define INC 20
9563#define GAP 3
9564
9565 items = (struct vimoption **)alloc((unsigned)(sizeof(struct vimoption *) *
9566 PARAM_COUNT));
9567 if (items == NULL)
9568 return;
9569
9570 /* Highlight title */
9571 if (all == 2)
9572 MSG_PUTS_TITLE(_("\n--- Terminal codes ---"));
9573 else if (opt_flags & OPT_GLOBAL)
9574 MSG_PUTS_TITLE(_("\n--- Global option values ---"));
9575 else if (opt_flags & OPT_LOCAL)
9576 MSG_PUTS_TITLE(_("\n--- Local option values ---"));
9577 else
9578 MSG_PUTS_TITLE(_("\n--- Options ---"));
9579
9580 /*
9581 * do the loop two times:
9582 * 1. display the short items
9583 * 2. display the long items (only strings and numbers)
9584 */
9585 for (run = 1; run <= 2 && !got_int; ++run)
9586 {
9587 /*
9588 * collect the items in items[]
9589 */
9590 item_count = 0;
9591 for (p = &options[0]; p->fullname != NULL; p++)
9592 {
9593 varp = NULL;
9594 isterm = istermoption(p);
9595 if (opt_flags != 0)
9596 {
9597 if (p->indir != PV_NONE && !isterm)
9598 varp = get_varp_scope(p, opt_flags);
9599 }
9600 else
9601 varp = get_varp(p);
9602 if (varp != NULL
9603 && ((all == 2 && isterm)
9604 || (all == 1 && !isterm)
9605 || (all == 0 && !optval_default(p, varp))))
9606 {
9607 if (p->flags & P_BOOL)
9608 len = 1; /* a toggle option fits always */
9609 else
9610 {
9611 option_value2string(p, opt_flags);
9612 len = (int)STRLEN(p->fullname) + vim_strsize(NameBuff) + 1;
9613 }
9614 if ((len <= INC - GAP && run == 1) ||
9615 (len > INC - GAP && run == 2))
9616 items[item_count++] = p;
9617 }
9618 }
9619
9620 /*
9621 * display the items
9622 */
9623 if (run == 1)
9624 {
9625 cols = (Columns + GAP - 3) / INC;
9626 if (cols == 0)
9627 cols = 1;
9628 rows = (item_count + cols - 1) / cols;
9629 }
9630 else /* run == 2 */
9631 rows = item_count;
9632 for (row = 0; row < rows && !got_int; ++row)
9633 {
9634 msg_putchar('\n'); /* go to next line */
9635 if (got_int) /* 'q' typed in more */
9636 break;
9637 col = 0;
9638 for (i = row; i < item_count; i += rows)
9639 {
9640 msg_col = col; /* make columns */
9641 showoneopt(items[i], opt_flags);
9642 col += INC;
9643 }
9644 out_flush();
9645 ui_breakcheck();
9646 }
9647 }
9648 vim_free(items);
9649}
9650
9651/*
9652 * Return TRUE if option "p" has its default value.
9653 */
9654 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009655optval_default(struct vimoption *p, char_u *varp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009656{
9657 int dvi;
9658
9659 if (varp == NULL)
9660 return TRUE; /* hidden option is always at default */
9661 dvi = ((p->flags & P_VI_DEF) || p_cp) ? VI_DEFAULT : VIM_DEFAULT;
9662 if (p->flags & P_NUM)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00009663 return (*(long *)varp == (long)(long_i)p->def_val[dvi]);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009664 if (p->flags & P_BOOL)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00009665 /* the cast to long is required for Manx C, long_i is
9666 * needed for MSVC */
9667 return (*(int *)varp == (int)(long)(long_i)p->def_val[dvi]);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009668 /* P_STRING */
9669 return (STRCMP(*(char_u **)varp, p->def_val[dvi]) == 0);
9670}
9671
9672/*
9673 * showoneopt: show the value of one option
9674 * must not be called with a hidden option!
9675 */
9676 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01009677showoneopt(
9678 struct vimoption *p,
9679 int opt_flags) /* OPT_LOCAL or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009680{
Bram Moolenaar26a60b42005-02-22 08:49:11 +00009681 char_u *varp;
9682 int save_silent = silent_mode;
9683
9684 silent_mode = FALSE;
9685 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009686
9687 varp = get_varp_scope(p, opt_flags);
9688
9689 /* for 'modified' we also need to check if 'ff' or 'fenc' changed. */
9690 if ((p->flags & P_BOOL) && ((int *)varp == &curbuf->b_changed
9691 ? !curbufIsChanged() : !*(int *)varp))
9692 MSG_PUTS("no");
9693 else if ((p->flags & P_BOOL) && *(int *)varp < 0)
9694 MSG_PUTS("--");
9695 else
9696 MSG_PUTS(" ");
9697 MSG_PUTS(p->fullname);
9698 if (!(p->flags & P_BOOL))
9699 {
9700 msg_putchar('=');
9701 /* put value string in NameBuff */
9702 option_value2string(p, opt_flags);
9703 msg_outtrans(NameBuff);
9704 }
Bram Moolenaar26a60b42005-02-22 08:49:11 +00009705
9706 silent_mode = save_silent;
9707 info_message = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009708}
9709
9710/*
9711 * Write modified options as ":set" commands to a file.
9712 *
9713 * There are three values for "opt_flags":
9714 * OPT_GLOBAL: Write global option values and fresh values of
9715 * buffer-local options (used for start of a session
9716 * file).
9717 * OPT_GLOBAL + OPT_LOCAL: Idem, add fresh values of window-local options for
9718 * curwin (used for a vimrc file).
9719 * OPT_LOCAL: Write buffer-local option values for curbuf, fresh
9720 * and local values for window-local options of
9721 * curwin. Local values are also written when at the
9722 * default value, because a modeline or autocommand
9723 * may have set them when doing ":edit file" and the
9724 * user has set them back at the default or fresh
9725 * value.
9726 * When "local_only" is TRUE, don't write fresh
9727 * values, only local values (for ":mkview").
9728 * (fresh value = value used for a new buffer or window for a local option).
9729 *
9730 * Return FAIL on error, OK otherwise.
9731 */
9732 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009733makeset(FILE *fd, int opt_flags, int local_only)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009734{
9735 struct vimoption *p;
9736 char_u *varp; /* currently used value */
9737 char_u *varp_fresh; /* local value */
9738 char_u *varp_local = NULL; /* fresh value */
9739 char *cmd;
9740 int round;
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009741 int pri;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009742
9743 /*
9744 * The options that don't have a default (terminal name, columns, lines)
9745 * are never written. Terminal options are also not written.
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009746 * Do the loop over "options[]" twice: once for options with the
9747 * P_PRI_MKRC flag and once without.
Bram Moolenaar071d4272004-06-13 20:20:40 +00009748 */
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009749 for (pri = 1; pri >= 0; --pri)
9750 {
9751 for (p = &options[0]; !istermoption(p); p++)
9752 if (!(p->flags & P_NO_MKRC)
9753 && !istermoption(p)
9754 && ((pri == 1) == ((p->flags & P_PRI_MKRC) != 0)))
Bram Moolenaar071d4272004-06-13 20:20:40 +00009755 {
9756 /* skip global option when only doing locals */
9757 if (p->indir == PV_NONE && !(opt_flags & OPT_GLOBAL))
9758 continue;
9759
9760 /* Do not store options like 'bufhidden' and 'syntax' in a vimrc
9761 * file, they are always buffer-specific. */
9762 if ((opt_flags & OPT_GLOBAL) && (p->flags & P_NOGLOB))
9763 continue;
9764
9765 /* Global values are only written when not at the default value. */
9766 varp = get_varp_scope(p, opt_flags);
9767 if ((opt_flags & OPT_GLOBAL) && optval_default(p, varp))
9768 continue;
9769
9770 round = 2;
9771 if (p->indir != PV_NONE)
9772 {
9773 if (p->var == VAR_WIN)
9774 {
9775 /* skip window-local option when only doing globals */
9776 if (!(opt_flags & OPT_LOCAL))
9777 continue;
9778 /* When fresh value of window-local option is not at the
9779 * default, need to write it too. */
9780 if (!(opt_flags & OPT_GLOBAL) && !local_only)
9781 {
9782 varp_fresh = get_varp_scope(p, OPT_GLOBAL);
9783 if (!optval_default(p, varp_fresh))
9784 {
9785 round = 1;
9786 varp_local = varp;
9787 varp = varp_fresh;
9788 }
9789 }
9790 }
9791 }
9792
9793 /* Round 1: fresh value for window-local options.
9794 * Round 2: other values */
9795 for ( ; round <= 2; varp = varp_local, ++round)
9796 {
9797 if (round == 1 || (opt_flags & OPT_GLOBAL))
9798 cmd = "set";
9799 else
9800 cmd = "setlocal";
9801
9802 if (p->flags & P_BOOL)
9803 {
9804 if (put_setbool(fd, cmd, p->fullname, *(int *)varp) == FAIL)
9805 return FAIL;
9806 }
9807 else if (p->flags & P_NUM)
9808 {
9809 if (put_setnum(fd, cmd, p->fullname, (long *)varp) == FAIL)
9810 return FAIL;
9811 }
9812 else /* P_STRING */
9813 {
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009814#if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD)
9815 int do_endif = FALSE;
9816
Bram Moolenaar071d4272004-06-13 20:20:40 +00009817 /* Don't set 'syntax' and 'filetype' again if the value is
9818 * already right, avoids reloading the syntax file. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009819 if (
9820# if defined(FEAT_SYN_HL)
9821 p->indir == PV_SYN
9822# if defined(FEAT_AUTOCMD)
9823 ||
9824# endif
9825# endif
9826# if defined(FEAT_AUTOCMD)
Bram Moolenaar15bfa092008-07-24 16:45:38 +00009827 p->indir == PV_FT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009828# endif
Bram Moolenaar15bfa092008-07-24 16:45:38 +00009829 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00009830 {
9831 if (fprintf(fd, "if &%s != '%s'", p->fullname,
9832 *(char_u **)(varp)) < 0
9833 || put_eol(fd) < 0)
9834 return FAIL;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009835 do_endif = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009836 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009837#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009838 if (put_setstring(fd, cmd, p->fullname, (char_u **)varp,
9839 (p->flags & P_EXPAND) != 0) == FAIL)
9840 return FAIL;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009841#if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD)
9842 if (do_endif)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009843 {
9844 if (put_line(fd, "endif") == FAIL)
9845 return FAIL;
9846 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009847#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009848 }
9849 }
9850 }
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009851 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009852 return OK;
9853}
9854
9855#if defined(FEAT_FOLDING) || defined(PROTO)
9856/*
9857 * Generate set commands for the local fold options only. Used when
9858 * 'sessionoptions' or 'viewoptions' contains "folds" but not "options".
9859 */
9860 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009861makefoldset(FILE *fd)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009862{
9863 if (put_setstring(fd, "setlocal", "fdm", &curwin->w_p_fdm, FALSE) == FAIL
9864# ifdef FEAT_EVAL
9865 || put_setstring(fd, "setlocal", "fde", &curwin->w_p_fde, FALSE)
9866 == FAIL
9867# endif
9868 || put_setstring(fd, "setlocal", "fmr", &curwin->w_p_fmr, FALSE)
9869 == FAIL
9870 || put_setstring(fd, "setlocal", "fdi", &curwin->w_p_fdi, FALSE)
9871 == FAIL
9872 || put_setnum(fd, "setlocal", "fdl", &curwin->w_p_fdl) == FAIL
9873 || put_setnum(fd, "setlocal", "fml", &curwin->w_p_fml) == FAIL
9874 || put_setnum(fd, "setlocal", "fdn", &curwin->w_p_fdn) == FAIL
9875 || put_setbool(fd, "setlocal", "fen", curwin->w_p_fen) == FAIL
9876 )
9877 return FAIL;
9878
9879 return OK;
9880}
9881#endif
9882
9883 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009884put_setstring(
9885 FILE *fd,
9886 char *cmd,
9887 char *name,
9888 char_u **valuep,
9889 int expand)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009890{
9891 char_u *s;
Bram Moolenaarf8441472011-04-28 17:24:58 +02009892 char_u *buf;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009893
9894 if (fprintf(fd, "%s %s=", cmd, name) < 0)
9895 return FAIL;
9896 if (*valuep != NULL)
9897 {
9898 /* Output 'pastetoggle' as key names. For other
9899 * options some characters have to be escaped with
9900 * CTRL-V or backslash */
9901 if (valuep == &p_pt)
9902 {
9903 s = *valuep;
9904 while (*s != NUL)
Bram Moolenaar7d96acd2008-06-09 15:07:54 +00009905 if (put_escstr(fd, str2special(&s, FALSE), 2) == FAIL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009906 return FAIL;
9907 }
9908 else if (expand)
9909 {
Bram Moolenaarf8441472011-04-28 17:24:58 +02009910 buf = alloc(MAXPATHL);
9911 if (buf == NULL)
9912 return FAIL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009913 home_replace(NULL, *valuep, buf, MAXPATHL, FALSE);
9914 if (put_escstr(fd, buf, 2) == FAIL)
Bram Moolenaarf8441472011-04-28 17:24:58 +02009915 {
9916 vim_free(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009917 return FAIL;
Bram Moolenaarf8441472011-04-28 17:24:58 +02009918 }
9919 vim_free(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009920 }
9921 else if (put_escstr(fd, *valuep, 2) == FAIL)
9922 return FAIL;
9923 }
9924 if (put_eol(fd) < 0)
9925 return FAIL;
9926 return OK;
9927}
9928
9929 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009930put_setnum(
9931 FILE *fd,
9932 char *cmd,
9933 char *name,
9934 long *valuep)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009935{
9936 long wc;
9937
9938 if (fprintf(fd, "%s %s=", cmd, name) < 0)
9939 return FAIL;
9940 if (wc_use_keyname((char_u *)valuep, &wc))
9941 {
9942 /* print 'wildchar' and 'wildcharm' as a key name */
9943 if (fputs((char *)get_special_key_name((int)wc, 0), fd) < 0)
9944 return FAIL;
9945 }
9946 else if (fprintf(fd, "%ld", *valuep) < 0)
9947 return FAIL;
9948 if (put_eol(fd) < 0)
9949 return FAIL;
9950 return OK;
9951}
9952
9953 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009954put_setbool(
9955 FILE *fd,
9956 char *cmd,
9957 char *name,
9958 int value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009959{
Bram Moolenaar893de922007-10-02 18:40:57 +00009960 if (value < 0) /* global/local option using global value */
9961 return OK;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009962 if (fprintf(fd, "%s %s%s", cmd, value ? "" : "no", name) < 0
9963 || put_eol(fd) < 0)
9964 return FAIL;
9965 return OK;
9966}
9967
9968/*
9969 * Clear all the terminal options.
9970 * If the option has been allocated, free the memory.
9971 * Terminal options are never hidden or indirect.
9972 */
9973 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01009974clear_termoptions(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009975{
Bram Moolenaar071d4272004-06-13 20:20:40 +00009976 /*
9977 * Reset a few things before clearing the old options. This may cause
9978 * outputting a few things that the terminal doesn't understand, but the
9979 * screen will be cleared later, so this is OK.
9980 */
9981#ifdef FEAT_MOUSE_TTY
9982 mch_setmouse(FALSE); /* switch mouse off */
9983#endif
9984#ifdef FEAT_TITLE
9985 mch_restore_title(3); /* restore window titles */
9986#endif
9987#if defined(FEAT_XCLIPBOARD) && defined(FEAT_GUI)
9988 /* When starting the GUI close the display opened for the clipboard.
9989 * After restoring the title, because that will need the display. */
9990 if (gui.starting)
9991 clear_xterm_clip();
9992#endif
Bram Moolenaarcea912a2016-10-12 14:20:24 +02009993 stoptermcap(); /* stop termcap mode */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009994
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00009995 free_termoptions();
9996}
9997
9998 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01009999free_termoptions(void)
Bram Moolenaarf461c8e2005-06-25 23:04:51 +000010000{
10001 struct vimoption *p;
10002
Bram Moolenaar071d4272004-06-13 20:20:40 +000010003 for (p = &options[0]; p->fullname != NULL; p++)
10004 if (istermoption(p))
10005 {
10006 if (p->flags & P_ALLOCED)
10007 free_string_option(*(char_u **)(p->var));
10008 if (p->flags & P_DEF_ALLOCED)
10009 free_string_option(p->def_val[VI_DEFAULT]);
10010 *(char_u **)(p->var) = empty_option;
10011 p->def_val[VI_DEFAULT] = empty_option;
10012 p->flags &= ~(P_ALLOCED|P_DEF_ALLOCED);
10013 }
10014 clear_termcodes();
10015}
10016
10017/*
Bram Moolenaar363cb672009-07-22 12:28:17 +000010018 * Free the string for one term option, if it was allocated.
10019 * Set the string to empty_option and clear allocated flag.
10020 * "var" points to the option value.
10021 */
10022 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010023free_one_termoption(char_u *var)
Bram Moolenaar363cb672009-07-22 12:28:17 +000010024{
10025 struct vimoption *p;
10026
10027 for (p = &options[0]; p->fullname != NULL; p++)
10028 if (p->var == var)
10029 {
10030 if (p->flags & P_ALLOCED)
10031 free_string_option(*(char_u **)(p->var));
10032 *(char_u **)(p->var) = empty_option;
10033 p->flags &= ~P_ALLOCED;
10034 break;
10035 }
10036}
10037
10038/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000010039 * Set the terminal option defaults to the current value.
10040 * Used after setting the terminal name.
10041 */
10042 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010043set_term_defaults(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010044{
10045 struct vimoption *p;
10046
10047 for (p = &options[0]; p->fullname != NULL; p++)
10048 {
10049 if (istermoption(p) && p->def_val[VI_DEFAULT] != *(char_u **)(p->var))
10050 {
10051 if (p->flags & P_DEF_ALLOCED)
10052 {
10053 free_string_option(p->def_val[VI_DEFAULT]);
10054 p->flags &= ~P_DEF_ALLOCED;
10055 }
10056 p->def_val[VI_DEFAULT] = *(char_u **)(p->var);
10057 if (p->flags & P_ALLOCED)
10058 {
10059 p->flags |= P_DEF_ALLOCED;
10060 p->flags &= ~P_ALLOCED; /* don't free the value now */
10061 }
10062 }
10063 }
10064}
10065
10066/*
10067 * return TRUE if 'p' starts with 't_'
10068 */
10069 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010070istermoption(struct vimoption *p)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010071{
10072 return (p->fullname[0] == 't' && p->fullname[1] == '_');
10073}
10074
10075/*
10076 * Compute columns for ruler and shown command. 'sc_col' is also used to
10077 * decide what the maximum length of a message on the status line can be.
10078 * If there is a status line for the last window, 'sc_col' is independent
10079 * of 'ru_col'.
10080 */
10081
10082#define COL_RULER 17 /* columns needed by standard ruler */
10083
10084 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010085comp_col(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010086{
10087#if defined(FEAT_CMDL_INFO) && defined(FEAT_WINDOWS)
Bram Moolenaar459ca562016-11-10 18:16:33 +010010088 int last_has_status = (p_ls == 2 || (p_ls == 1 && !ONE_WINDOW));
Bram Moolenaar071d4272004-06-13 20:20:40 +000010089
10090 sc_col = 0;
10091 ru_col = 0;
10092 if (p_ru)
10093 {
10094#ifdef FEAT_STL_OPT
10095 ru_col = (ru_wid ? ru_wid : COL_RULER) + 1;
10096#else
10097 ru_col = COL_RULER + 1;
10098#endif
10099 /* no last status line, adjust sc_col */
10100 if (!last_has_status)
10101 sc_col = ru_col;
10102 }
10103 if (p_sc)
10104 {
10105 sc_col += SHOWCMD_COLS;
10106 if (!p_ru || last_has_status) /* no need for separating space */
10107 ++sc_col;
10108 }
10109 sc_col = Columns - sc_col;
10110 ru_col = Columns - ru_col;
10111 if (sc_col <= 0) /* screen too narrow, will become a mess */
10112 sc_col = 1;
10113 if (ru_col <= 0)
10114 ru_col = 1;
10115#else
10116 sc_col = Columns;
10117 ru_col = Columns;
10118#endif
10119}
10120
10121/*
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010122 * Unset local option value, similar to ":set opt<".
10123 */
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010124 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010125unset_global_local_option(char_u *name, void *from)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010126{
10127 struct vimoption *p;
10128 int opt_idx;
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010129 buf_T *buf = (buf_T *)from;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010130
10131 opt_idx = findoption(name);
Bram Moolenaarbd8539a2015-08-11 18:53:03 +020010132 if (opt_idx < 0)
10133 return;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010134 p = &(options[opt_idx]);
10135
10136 switch ((int)p->indir)
10137 {
10138 /* global option with local value: use local value if it's been set */
10139 case PV_EP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010140 clear_string_option(&buf->b_p_ep);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010141 break;
10142 case PV_KP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010143 clear_string_option(&buf->b_p_kp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010144 break;
10145 case PV_PATH:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010146 clear_string_option(&buf->b_p_path);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010147 break;
10148 case PV_AR:
10149 buf->b_p_ar = -1;
10150 break;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010151 case PV_BKC:
10152 clear_string_option(&buf->b_p_bkc);
10153 buf->b_bkc_flags = 0;
10154 break;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010155 case PV_TAGS:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010156 clear_string_option(&buf->b_p_tags);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010157 break;
Bram Moolenaar0f6562e2015-11-24 18:48:14 +010010158 case PV_TC:
10159 clear_string_option(&buf->b_p_tc);
10160 buf->b_tc_flags = 0;
10161 break;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010162#ifdef FEAT_FIND_ID
10163 case PV_DEF:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010164 clear_string_option(&buf->b_p_def);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010165 break;
10166 case PV_INC:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010167 clear_string_option(&buf->b_p_inc);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010168 break;
10169#endif
10170#ifdef FEAT_INS_EXPAND
10171 case PV_DICT:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010172 clear_string_option(&buf->b_p_dict);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010173 break;
10174 case PV_TSR:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010175 clear_string_option(&buf->b_p_tsr);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010176 break;
10177#endif
10178#ifdef FEAT_QUICKFIX
10179 case PV_EFM:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010180 clear_string_option(&buf->b_p_efm);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010181 break;
10182 case PV_GP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010183 clear_string_option(&buf->b_p_gp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010184 break;
10185 case PV_MP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010186 clear_string_option(&buf->b_p_mp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010187 break;
10188#endif
10189#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10190 case PV_BEXPR:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010191 clear_string_option(&buf->b_p_bexpr);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010192 break;
10193#endif
10194#if defined(FEAT_CRYPT)
10195 case PV_CM:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010196 clear_string_option(&buf->b_p_cm);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010197 break;
10198#endif
10199#ifdef FEAT_STL_OPT
10200 case PV_STL:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010201 clear_string_option(&((win_T *)from)->w_p_stl);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010202 break;
10203#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010204 case PV_UL:
10205 buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
10206 break;
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010207#ifdef FEAT_LISP
10208 case PV_LW:
10209 clear_string_option(&buf->b_p_lw);
10210 break;
10211#endif
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010212 }
10213}
10214
10215/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000010216 * Get pointer to option variable, depending on local or global scope.
10217 */
10218 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +010010219get_varp_scope(struct vimoption *p, int opt_flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010220{
10221 if ((opt_flags & OPT_GLOBAL) && p->indir != PV_NONE)
10222 {
10223 if (p->var == VAR_WIN)
10224 return (char_u *)GLOBAL_WO(get_varp(p));
10225 return p->var;
10226 }
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010227 if ((opt_flags & OPT_LOCAL) && ((int)p->indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +000010228 {
10229 switch ((int)p->indir)
10230 {
10231#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010232 case PV_EFM: return (char_u *)&(curbuf->b_p_efm);
10233 case PV_GP: return (char_u *)&(curbuf->b_p_gp);
10234 case PV_MP: return (char_u *)&(curbuf->b_p_mp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010235#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010236 case PV_EP: return (char_u *)&(curbuf->b_p_ep);
10237 case PV_KP: return (char_u *)&(curbuf->b_p_kp);
10238 case PV_PATH: return (char_u *)&(curbuf->b_p_path);
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010239 case PV_AR: return (char_u *)&(curbuf->b_p_ar);
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010240 case PV_TAGS: return (char_u *)&(curbuf->b_p_tags);
Bram Moolenaar0f6562e2015-11-24 18:48:14 +010010241 case PV_TC: return (char_u *)&(curbuf->b_p_tc);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010242#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010243 case PV_DEF: return (char_u *)&(curbuf->b_p_def);
10244 case PV_INC: return (char_u *)&(curbuf->b_p_inc);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010245#endif
10246#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010247 case PV_DICT: return (char_u *)&(curbuf->b_p_dict);
10248 case PV_TSR: return (char_u *)&(curbuf->b_p_tsr);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010249#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000010250#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10251 case PV_BEXPR: return (char_u *)&(curbuf->b_p_bexpr);
10252#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020010253#if defined(FEAT_CRYPT)
10254 case PV_CM: return (char_u *)&(curbuf->b_p_cm);
10255#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010256#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010257 case PV_STL: return (char_u *)&(curwin->w_p_stl);
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010258#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010259 case PV_UL: return (char_u *)&(curbuf->b_p_ul);
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010260#ifdef FEAT_LISP
10261 case PV_LW: return (char_u *)&(curbuf->b_p_lw);
10262#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010263 case PV_BKC: return (char_u *)&(curbuf->b_p_bkc);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010264 }
10265 return NULL; /* "cannot happen" */
10266 }
10267 return get_varp(p);
10268}
10269
10270/*
10271 * Get pointer to option variable.
10272 */
10273 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +010010274get_varp(struct vimoption *p)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010275{
10276 /* hidden option, always return NULL */
10277 if (p->var == NULL)
10278 return NULL;
10279
10280 switch ((int)p->indir)
10281 {
10282 case PV_NONE: return p->var;
10283
10284 /* global option with local value: use local value if it's been set */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010285 case PV_EP: return *curbuf->b_p_ep != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010286 ? (char_u *)&curbuf->b_p_ep : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010287 case PV_KP: return *curbuf->b_p_kp != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010288 ? (char_u *)&curbuf->b_p_kp : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010289 case PV_PATH: return *curbuf->b_p_path != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010290 ? (char_u *)&(curbuf->b_p_path) : p->var;
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010291 case PV_AR: return curbuf->b_p_ar >= 0
Bram Moolenaar071d4272004-06-13 20:20:40 +000010292 ? (char_u *)&(curbuf->b_p_ar) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010293 case PV_TAGS: return *curbuf->b_p_tags != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010294 ? (char_u *)&(curbuf->b_p_tags) : p->var;
Bram Moolenaar0f6562e2015-11-24 18:48:14 +010010295 case PV_TC: return *curbuf->b_p_tc != NUL
10296 ? (char_u *)&(curbuf->b_p_tc) : p->var;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010297 case PV_BKC: return *curbuf->b_p_bkc != NUL
10298 ? (char_u *)&(curbuf->b_p_bkc) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010299#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010300 case PV_DEF: return *curbuf->b_p_def != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010301 ? (char_u *)&(curbuf->b_p_def) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010302 case PV_INC: return *curbuf->b_p_inc != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010303 ? (char_u *)&(curbuf->b_p_inc) : p->var;
10304#endif
10305#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010306 case PV_DICT: return *curbuf->b_p_dict != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010307 ? (char_u *)&(curbuf->b_p_dict) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010308 case PV_TSR: return *curbuf->b_p_tsr != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010309 ? (char_u *)&(curbuf->b_p_tsr) : p->var;
10310#endif
10311#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010312 case PV_EFM: return *curbuf->b_p_efm != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010313 ? (char_u *)&(curbuf->b_p_efm) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010314 case PV_GP: return *curbuf->b_p_gp != NUL
10315 ? (char_u *)&(curbuf->b_p_gp) : p->var;
10316 case PV_MP: return *curbuf->b_p_mp != NUL
10317 ? (char_u *)&(curbuf->b_p_mp) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010318#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000010319#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10320 case PV_BEXPR: return *curbuf->b_p_bexpr != NUL
10321 ? (char_u *)&(curbuf->b_p_bexpr) : p->var;
10322#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020010323#if defined(FEAT_CRYPT)
10324 case PV_CM: return *curbuf->b_p_cm != NUL
10325 ? (char_u *)&(curbuf->b_p_cm) : p->var;
10326#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010327#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010328 case PV_STL: return *curwin->w_p_stl != NUL
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010329 ? (char_u *)&(curwin->w_p_stl) : p->var;
10330#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010331 case PV_UL: return curbuf->b_p_ul != NO_LOCAL_UNDOLEVEL
10332 ? (char_u *)&(curbuf->b_p_ul) : p->var;
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010333#ifdef FEAT_LISP
10334 case PV_LW: return *curbuf->b_p_lw != NUL
10335 ? (char_u *)&(curbuf->b_p_lw) : p->var;
10336#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010337
10338#ifdef FEAT_ARABIC
10339 case PV_ARAB: return (char_u *)&(curwin->w_p_arab);
10340#endif
10341 case PV_LIST: return (char_u *)&(curwin->w_p_list);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010342#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +000010343 case PV_SPELL: return (char_u *)&(curwin->w_p_spell);
10344#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010345#ifdef FEAT_SYN_HL
10346 case PV_CUC: return (char_u *)&(curwin->w_p_cuc);
10347 case PV_CUL: return (char_u *)&(curwin->w_p_cul);
Bram Moolenaar1a384422010-07-14 19:53:30 +020010348 case PV_CC: return (char_u *)&(curwin->w_p_cc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010349#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010350#ifdef FEAT_DIFF
10351 case PV_DIFF: return (char_u *)&(curwin->w_p_diff);
10352#endif
10353#ifdef FEAT_FOLDING
10354 case PV_FDC: return (char_u *)&(curwin->w_p_fdc);
10355 case PV_FEN: return (char_u *)&(curwin->w_p_fen);
10356 case PV_FDI: return (char_u *)&(curwin->w_p_fdi);
10357 case PV_FDL: return (char_u *)&(curwin->w_p_fdl);
10358 case PV_FDM: return (char_u *)&(curwin->w_p_fdm);
10359 case PV_FML: return (char_u *)&(curwin->w_p_fml);
10360 case PV_FDN: return (char_u *)&(curwin->w_p_fdn);
10361# ifdef FEAT_EVAL
10362 case PV_FDE: return (char_u *)&(curwin->w_p_fde);
10363 case PV_FDT: return (char_u *)&(curwin->w_p_fdt);
10364# endif
10365 case PV_FMR: return (char_u *)&(curwin->w_p_fmr);
10366#endif
10367 case PV_NU: return (char_u *)&(curwin->w_p_nu);
Bram Moolenaar64486672010-05-16 15:46:46 +020010368 case PV_RNU: return (char_u *)&(curwin->w_p_rnu);
Bram Moolenaar592e0a22004-07-03 16:05:59 +000010369#ifdef FEAT_LINEBREAK
10370 case PV_NUW: return (char_u *)&(curwin->w_p_nuw);
10371#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010372#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +000010373 case PV_WFH: return (char_u *)&(curwin->w_p_wfh);
Bram Moolenaar97b2ad32006-03-18 21:40:56 +000010374 case PV_WFW: return (char_u *)&(curwin->w_p_wfw);
10375#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010376#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
10377 case PV_PVW: return (char_u *)&(curwin->w_p_pvw);
10378#endif
10379#ifdef FEAT_RIGHTLEFT
10380 case PV_RL: return (char_u *)&(curwin->w_p_rl);
10381 case PV_RLC: return (char_u *)&(curwin->w_p_rlc);
10382#endif
10383 case PV_SCROLL: return (char_u *)&(curwin->w_p_scr);
10384 case PV_WRAP: return (char_u *)&(curwin->w_p_wrap);
10385#ifdef FEAT_LINEBREAK
10386 case PV_LBR: return (char_u *)&(curwin->w_p_lbr);
Bram Moolenaar597a4222014-06-25 14:39:50 +020010387 case PV_BRI: return (char_u *)&(curwin->w_p_bri);
10388 case PV_BRIOPT: return (char_u *)&(curwin->w_p_briopt);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010389#endif
10390#ifdef FEAT_SCROLLBIND
10391 case PV_SCBIND: return (char_u *)&(curwin->w_p_scb);
10392#endif
Bram Moolenaar860cae12010-06-05 23:22:07 +020010393#ifdef FEAT_CURSORBIND
10394 case PV_CRBIND: return (char_u *)&(curwin->w_p_crb);
10395#endif
10396#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010397 case PV_COCU: return (char_u *)&(curwin->w_p_cocu);
10398 case PV_COLE: return (char_u *)&(curwin->w_p_cole);
Bram Moolenaar860cae12010-06-05 23:22:07 +020010399#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010400
10401 case PV_AI: return (char_u *)&(curbuf->b_p_ai);
10402 case PV_BIN: return (char_u *)&(curbuf->b_p_bin);
10403#ifdef FEAT_MBYTE
10404 case PV_BOMB: return (char_u *)&(curbuf->b_p_bomb);
10405#endif
10406#if defined(FEAT_QUICKFIX)
10407 case PV_BH: return (char_u *)&(curbuf->b_p_bh);
10408 case PV_BT: return (char_u *)&(curbuf->b_p_bt);
10409#endif
10410 case PV_BL: return (char_u *)&(curbuf->b_p_bl);
10411 case PV_CI: return (char_u *)&(curbuf->b_p_ci);
10412#ifdef FEAT_CINDENT
10413 case PV_CIN: return (char_u *)&(curbuf->b_p_cin);
10414 case PV_CINK: return (char_u *)&(curbuf->b_p_cink);
10415 case PV_CINO: return (char_u *)&(curbuf->b_p_cino);
10416#endif
10417#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
10418 case PV_CINW: return (char_u *)&(curbuf->b_p_cinw);
10419#endif
10420#ifdef FEAT_COMMENTS
10421 case PV_COM: return (char_u *)&(curbuf->b_p_com);
10422#endif
10423#ifdef FEAT_FOLDING
10424 case PV_CMS: return (char_u *)&(curbuf->b_p_cms);
10425#endif
10426#ifdef FEAT_INS_EXPAND
10427 case PV_CPT: return (char_u *)&(curbuf->b_p_cpt);
10428#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010429#ifdef FEAT_COMPL_FUNC
10430 case PV_CFU: return (char_u *)&(curbuf->b_p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +000010431 case PV_OFU: return (char_u *)&(curbuf->b_p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010432#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010433 case PV_EOL: return (char_u *)&(curbuf->b_p_eol);
Bram Moolenaar34d72d42015-07-17 14:18:08 +020010434 case PV_FIXEOL: return (char_u *)&(curbuf->b_p_fixeol);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010435 case PV_ET: return (char_u *)&(curbuf->b_p_et);
10436#ifdef FEAT_MBYTE
10437 case PV_FENC: return (char_u *)&(curbuf->b_p_fenc);
10438#endif
10439 case PV_FF: return (char_u *)&(curbuf->b_p_ff);
10440#ifdef FEAT_AUTOCMD
10441 case PV_FT: return (char_u *)&(curbuf->b_p_ft);
10442#endif
10443 case PV_FO: return (char_u *)&(curbuf->b_p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +000010444 case PV_FLP: return (char_u *)&(curbuf->b_p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010445 case PV_IMI: return (char_u *)&(curbuf->b_p_iminsert);
10446 case PV_IMS: return (char_u *)&(curbuf->b_p_imsearch);
10447 case PV_INF: return (char_u *)&(curbuf->b_p_inf);
10448 case PV_ISK: return (char_u *)&(curbuf->b_p_isk);
10449#ifdef FEAT_FIND_ID
10450# ifdef FEAT_EVAL
10451 case PV_INEX: return (char_u *)&(curbuf->b_p_inex);
10452# endif
10453#endif
10454#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
10455 case PV_INDE: return (char_u *)&(curbuf->b_p_inde);
10456 case PV_INDK: return (char_u *)&(curbuf->b_p_indk);
10457#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010458#ifdef FEAT_EVAL
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +000010459 case PV_FEX: return (char_u *)&(curbuf->b_p_fex);
10460#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010461#ifdef FEAT_CRYPT
10462 case PV_KEY: return (char_u *)&(curbuf->b_p_key);
10463#endif
10464#ifdef FEAT_LISP
10465 case PV_LISP: return (char_u *)&(curbuf->b_p_lisp);
10466#endif
10467 case PV_ML: return (char_u *)&(curbuf->b_p_ml);
10468 case PV_MPS: return (char_u *)&(curbuf->b_p_mps);
10469 case PV_MA: return (char_u *)&(curbuf->b_p_ma);
10470 case PV_MOD: return (char_u *)&(curbuf->b_changed);
10471 case PV_NF: return (char_u *)&(curbuf->b_p_nf);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010472 case PV_PI: return (char_u *)&(curbuf->b_p_pi);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010473#ifdef FEAT_TEXTOBJ
10474 case PV_QE: return (char_u *)&(curbuf->b_p_qe);
10475#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010476 case PV_RO: return (char_u *)&(curbuf->b_p_ro);
10477#ifdef FEAT_SMARTINDENT
10478 case PV_SI: return (char_u *)&(curbuf->b_p_si);
10479#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010480 case PV_SN: return (char_u *)&(curbuf->b_p_sn);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010481 case PV_STS: return (char_u *)&(curbuf->b_p_sts);
10482#ifdef FEAT_SEARCHPATH
10483 case PV_SUA: return (char_u *)&(curbuf->b_p_sua);
10484#endif
10485 case PV_SWF: return (char_u *)&(curbuf->b_p_swf);
10486#ifdef FEAT_SYN_HL
Bram Moolenaar3b56eb32005-07-11 22:40:32 +000010487 case PV_SMC: return (char_u *)&(curbuf->b_p_smc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010488 case PV_SYN: return (char_u *)&(curbuf->b_p_syn);
10489#endif
10490#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +020010491 case PV_SPC: return (char_u *)&(curwin->w_s->b_p_spc);
10492 case PV_SPF: return (char_u *)&(curwin->w_s->b_p_spf);
10493 case PV_SPL: return (char_u *)&(curwin->w_s->b_p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010494#endif
10495 case PV_SW: return (char_u *)&(curbuf->b_p_sw);
10496 case PV_TS: return (char_u *)&(curbuf->b_p_ts);
10497 case PV_TW: return (char_u *)&(curbuf->b_p_tw);
10498 case PV_TX: return (char_u *)&(curbuf->b_p_tx);
Bram Moolenaar55debbe2010-05-23 23:34:36 +020010499#ifdef FEAT_PERSISTENT_UNDO
10500 case PV_UDF: return (char_u *)&(curbuf->b_p_udf);
10501#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010502 case PV_WM: return (char_u *)&(curbuf->b_p_wm);
10503#ifdef FEAT_KEYMAP
10504 case PV_KMAP: return (char_u *)&(curbuf->b_p_keymap);
10505#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020010506#ifdef FEAT_SIGNS
10507 case PV_SCL: return (char_u *)&(curwin->w_p_scl);
10508#endif
Bram Moolenaar95f09602016-11-10 20:01:45 +010010509 default: IEMSG(_("E356: get_varp ERROR"));
Bram Moolenaar071d4272004-06-13 20:20:40 +000010510 }
10511 /* always return a valid pointer to avoid a crash! */
10512 return (char_u *)&(curbuf->b_p_wm);
10513}
10514
10515/*
10516 * Get the value of 'equalprg', either the buffer-local one or the global one.
10517 */
10518 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +010010519get_equalprg(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010520{
10521 if (*curbuf->b_p_ep == NUL)
10522 return p_ep;
10523 return curbuf->b_p_ep;
10524}
10525
10526#if defined(FEAT_WINDOWS) || defined(PROTO)
10527/*
10528 * Copy options from one window to another.
10529 * Used when splitting a window.
10530 */
10531 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010532win_copy_options(win_T *wp_from, win_T *wp_to)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010533{
10534 copy_winopt(&wp_from->w_onebuf_opt, &wp_to->w_onebuf_opt);
10535 copy_winopt(&wp_from->w_allbuf_opt, &wp_to->w_allbuf_opt);
10536# ifdef FEAT_RIGHTLEFT
10537# ifdef FEAT_FKMAP
10538 /* Is this right? */
10539 wp_to->w_farsi = wp_from->w_farsi;
10540# endif
10541# endif
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020010542#if defined(FEAT_LINEBREAK)
10543 briopt_check(wp_to);
10544#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010545}
10546#endif
10547
10548/*
10549 * Copy the options from one winopt_T to another.
10550 * Doesn't free the old option values in "to", use clear_winopt() for that.
10551 * The 'scroll' option is not copied, because it depends on the window height.
10552 * The 'previewwindow' option is reset, there can be only one preview window.
10553 */
10554 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010555copy_winopt(winopt_T *from, winopt_T *to)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010556{
10557#ifdef FEAT_ARABIC
10558 to->wo_arab = from->wo_arab;
10559#endif
10560 to->wo_list = from->wo_list;
10561 to->wo_nu = from->wo_nu;
Bram Moolenaar64486672010-05-16 15:46:46 +020010562 to->wo_rnu = from->wo_rnu;
Bram Moolenaar592e0a22004-07-03 16:05:59 +000010563#ifdef FEAT_LINEBREAK
10564 to->wo_nuw = from->wo_nuw;
10565#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010566#ifdef FEAT_RIGHTLEFT
10567 to->wo_rl = from->wo_rl;
10568 to->wo_rlc = vim_strsave(from->wo_rlc);
10569#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010570#ifdef FEAT_STL_OPT
10571 to->wo_stl = vim_strsave(from->wo_stl);
10572#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010573 to->wo_wrap = from->wo_wrap;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010574#ifdef FEAT_DIFF
10575 to->wo_wrap_save = from->wo_wrap_save;
10576#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010577#ifdef FEAT_LINEBREAK
10578 to->wo_lbr = from->wo_lbr;
Bram Moolenaar597a4222014-06-25 14:39:50 +020010579 to->wo_bri = from->wo_bri;
10580 to->wo_briopt = vim_strsave(from->wo_briopt);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010581#endif
10582#ifdef FEAT_SCROLLBIND
10583 to->wo_scb = from->wo_scb;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010584 to->wo_scb_save = from->wo_scb_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010585#endif
Bram Moolenaar4161dcc2010-12-02 15:33:21 +010010586#ifdef FEAT_CURSORBIND
10587 to->wo_crb = from->wo_crb;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010588 to->wo_crb_save = from->wo_crb_save;
Bram Moolenaar4161dcc2010-12-02 15:33:21 +010010589#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010590#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +000010591 to->wo_spell = from->wo_spell;
10592#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010593#ifdef FEAT_SYN_HL
10594 to->wo_cuc = from->wo_cuc;
10595 to->wo_cul = from->wo_cul;
Bram Moolenaar1a384422010-07-14 19:53:30 +020010596 to->wo_cc = vim_strsave(from->wo_cc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010597#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010598#ifdef FEAT_DIFF
10599 to->wo_diff = from->wo_diff;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010600 to->wo_diff_saved = from->wo_diff_saved;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010601#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010602#ifdef FEAT_CONCEAL
10603 to->wo_cocu = vim_strsave(from->wo_cocu);
Bram Moolenaard497a302010-07-23 22:27:03 +020010604 to->wo_cole = from->wo_cole;
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010605#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010606#ifdef FEAT_FOLDING
10607 to->wo_fdc = from->wo_fdc;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010608 to->wo_fdc_save = from->wo_fdc_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010609 to->wo_fen = from->wo_fen;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010610 to->wo_fen_save = from->wo_fen_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010611 to->wo_fdi = vim_strsave(from->wo_fdi);
10612 to->wo_fml = from->wo_fml;
10613 to->wo_fdl = from->wo_fdl;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010614 to->wo_fdl_save = from->wo_fdl_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010615 to->wo_fdm = vim_strsave(from->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010616 to->wo_fdm_save = from->wo_diff_saved
10617 ? vim_strsave(from->wo_fdm_save) : empty_option;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010618 to->wo_fdn = from->wo_fdn;
10619# ifdef FEAT_EVAL
10620 to->wo_fde = vim_strsave(from->wo_fde);
10621 to->wo_fdt = vim_strsave(from->wo_fdt);
10622# endif
10623 to->wo_fmr = vim_strsave(from->wo_fmr);
10624#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020010625#ifdef FEAT_SIGNS
10626 to->wo_scl = vim_strsave(from->wo_scl);
10627#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010628 check_winopt(to); /* don't want NULL pointers */
10629}
10630
10631/*
10632 * Check string options in a window for a NULL value.
10633 */
10634 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010635check_win_options(win_T *win)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010636{
10637 check_winopt(&win->w_onebuf_opt);
10638 check_winopt(&win->w_allbuf_opt);
10639}
10640
10641/*
10642 * Check for NULL pointers in a winopt_T and replace them with empty_option.
10643 */
Bram Moolenaar8dc907d2014-06-25 14:44:10 +020010644 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010645check_winopt(winopt_T *wop UNUSED)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010646{
10647#ifdef FEAT_FOLDING
10648 check_string_option(&wop->wo_fdi);
10649 check_string_option(&wop->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010650 check_string_option(&wop->wo_fdm_save);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010651# ifdef FEAT_EVAL
10652 check_string_option(&wop->wo_fde);
10653 check_string_option(&wop->wo_fdt);
10654# endif
10655 check_string_option(&wop->wo_fmr);
10656#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020010657#ifdef FEAT_SIGNS
10658 check_string_option(&wop->wo_scl);
10659#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010660#ifdef FEAT_RIGHTLEFT
10661 check_string_option(&wop->wo_rlc);
10662#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010663#ifdef FEAT_STL_OPT
10664 check_string_option(&wop->wo_stl);
10665#endif
Bram Moolenaar1a384422010-07-14 19:53:30 +020010666#ifdef FEAT_SYN_HL
10667 check_string_option(&wop->wo_cc);
10668#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010669#ifdef FEAT_CONCEAL
10670 check_string_option(&wop->wo_cocu);
10671#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +020010672#ifdef FEAT_LINEBREAK
10673 check_string_option(&wop->wo_briopt);
10674#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010675}
10676
10677/*
10678 * Free the allocated memory inside a winopt_T.
10679 */
Bram Moolenaar071d4272004-06-13 20:20:40 +000010680 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010681clear_winopt(winopt_T *wop UNUSED)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010682{
10683#ifdef FEAT_FOLDING
10684 clear_string_option(&wop->wo_fdi);
10685 clear_string_option(&wop->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010686 clear_string_option(&wop->wo_fdm_save);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010687# ifdef FEAT_EVAL
10688 clear_string_option(&wop->wo_fde);
10689 clear_string_option(&wop->wo_fdt);
10690# endif
10691 clear_string_option(&wop->wo_fmr);
10692#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020010693#ifdef FEAT_SIGNS
10694 clear_string_option(&wop->wo_scl);
10695#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +020010696#ifdef FEAT_LINEBREAK
10697 clear_string_option(&wop->wo_briopt);
10698#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010699#ifdef FEAT_RIGHTLEFT
10700 clear_string_option(&wop->wo_rlc);
10701#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010702#ifdef FEAT_STL_OPT
10703 clear_string_option(&wop->wo_stl);
10704#endif
Bram Moolenaar1a384422010-07-14 19:53:30 +020010705#ifdef FEAT_SYN_HL
10706 clear_string_option(&wop->wo_cc);
10707#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010708#ifdef FEAT_CONCEAL
10709 clear_string_option(&wop->wo_cocu);
10710#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010711}
10712
10713/*
10714 * Copy global option values to local options for one buffer.
10715 * Used when creating a new buffer and sometimes when entering a buffer.
10716 * flags:
10717 * BCO_ENTER We will enter the buf buffer.
10718 * BCO_ALWAYS Always copy the options, but only set b_p_initialized when
10719 * appropriate.
10720 * BCO_NOHELP Don't copy the values to a help buffer.
10721 */
10722 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010723buf_copy_options(buf_T *buf, int flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010724{
10725 int should_copy = TRUE;
10726 char_u *save_p_isk = NULL; /* init for GCC */
10727 int dont_do_help;
10728 int did_isk = FALSE;
10729
10730 /*
Bram Moolenaar071d4272004-06-13 20:20:40 +000010731 * Skip this when the option defaults have not been set yet. Happens when
10732 * main() allocates the first buffer.
10733 */
10734 if (p_cpo != NULL)
10735 {
10736 /*
10737 * Always copy when entering and 'cpo' contains 'S'.
10738 * Don't copy when already initialized.
10739 * Don't copy when 'cpo' contains 's' and not entering.
10740 * 'S' BCO_ENTER initialized 's' should_copy
10741 * yes yes X X TRUE
10742 * yes no yes X FALSE
10743 * no X yes X FALSE
10744 * X no no yes FALSE
10745 * X no no no TRUE
10746 * no yes no X TRUE
10747 */
10748 if ((vim_strchr(p_cpo, CPO_BUFOPTGLOB) == NULL || !(flags & BCO_ENTER))
10749 && (buf->b_p_initialized
10750 || (!(flags & BCO_ENTER)
10751 && vim_strchr(p_cpo, CPO_BUFOPT) != NULL)))
10752 should_copy = FALSE;
10753
10754 if (should_copy || (flags & BCO_ALWAYS))
10755 {
10756 /* Don't copy the options specific to a help buffer when
10757 * BCO_NOHELP is given or the options were initialized already
10758 * (jumping back to a help file with CTRL-T or CTRL-O) */
10759 dont_do_help = ((flags & BCO_NOHELP) && buf->b_help)
10760 || buf->b_p_initialized;
10761 if (dont_do_help) /* don't free b_p_isk */
10762 {
10763 save_p_isk = buf->b_p_isk;
10764 buf->b_p_isk = NULL;
10765 }
10766 /*
10767 * Always free the allocated strings.
10768 * If not already initialized, set 'readonly' and copy 'fileformat'.
10769 */
10770 if (!buf->b_p_initialized)
10771 {
10772 free_buf_options(buf, TRUE);
10773 buf->b_p_ro = FALSE; /* don't copy readonly */
10774 buf->b_p_tx = p_tx;
10775#ifdef FEAT_MBYTE
10776 buf->b_p_fenc = vim_strsave(p_fenc);
10777#endif
Bram Moolenaare8ef3a02016-10-12 17:45:29 +020010778 switch (*p_ffs)
10779 {
10780 case 'm':
10781 buf->b_p_ff = vim_strsave((char_u *)FF_MAC); break;
10782 case 'd':
10783 buf->b_p_ff = vim_strsave((char_u *)FF_DOS); break;
10784 case 'u':
10785 buf->b_p_ff = vim_strsave((char_u *)FF_UNIX); break;
10786 default:
10787 buf->b_p_ff = vim_strsave(p_ff);
10788 }
10789 if (buf->b_p_ff != NULL)
10790 buf->b_start_ffc = *buf->b_p_ff;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010791#if defined(FEAT_QUICKFIX)
10792 buf->b_p_bh = empty_option;
10793 buf->b_p_bt = empty_option;
10794#endif
10795 }
10796 else
10797 free_buf_options(buf, FALSE);
10798
10799 buf->b_p_ai = p_ai;
10800 buf->b_p_ai_nopaste = p_ai_nopaste;
10801 buf->b_p_sw = p_sw;
10802 buf->b_p_tw = p_tw;
10803 buf->b_p_tw_nopaste = p_tw_nopaste;
10804 buf->b_p_tw_nobin = p_tw_nobin;
10805 buf->b_p_wm = p_wm;
10806 buf->b_p_wm_nopaste = p_wm_nopaste;
10807 buf->b_p_wm_nobin = p_wm_nobin;
10808 buf->b_p_bin = p_bin;
Bram Moolenaare8bb2552005-07-08 22:26:47 +000010809#ifdef FEAT_MBYTE
10810 buf->b_p_bomb = p_bomb;
10811#endif
Bram Moolenaarb388be02015-07-22 22:19:38 +020010812 buf->b_p_fixeol = p_fixeol;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010813 buf->b_p_et = p_et;
10814 buf->b_p_et_nobin = p_et_nobin;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020010815 buf->b_p_et_nopaste = p_et_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010816 buf->b_p_ml = p_ml;
10817 buf->b_p_ml_nobin = p_ml_nobin;
10818 buf->b_p_inf = p_inf;
10819 buf->b_p_swf = p_swf;
10820#ifdef FEAT_INS_EXPAND
10821 buf->b_p_cpt = vim_strsave(p_cpt);
10822#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010823#ifdef FEAT_COMPL_FUNC
10824 buf->b_p_cfu = vim_strsave(p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +000010825 buf->b_p_ofu = vim_strsave(p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010826#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010827 buf->b_p_sts = p_sts;
10828 buf->b_p_sts_nopaste = p_sts_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010829 buf->b_p_sn = p_sn;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010830#ifdef FEAT_COMMENTS
10831 buf->b_p_com = vim_strsave(p_com);
10832#endif
10833#ifdef FEAT_FOLDING
10834 buf->b_p_cms = vim_strsave(p_cms);
10835#endif
10836 buf->b_p_fo = vim_strsave(p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +000010837 buf->b_p_flp = vim_strsave(p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010838 buf->b_p_nf = vim_strsave(p_nf);
10839 buf->b_p_mps = vim_strsave(p_mps);
10840#ifdef FEAT_SMARTINDENT
10841 buf->b_p_si = p_si;
10842#endif
10843 buf->b_p_ci = p_ci;
10844#ifdef FEAT_CINDENT
10845 buf->b_p_cin = p_cin;
10846 buf->b_p_cink = vim_strsave(p_cink);
10847 buf->b_p_cino = vim_strsave(p_cino);
10848#endif
10849#ifdef FEAT_AUTOCMD
10850 /* Don't copy 'filetype', it must be detected */
10851 buf->b_p_ft = empty_option;
10852#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010853 buf->b_p_pi = p_pi;
10854#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
10855 buf->b_p_cinw = vim_strsave(p_cinw);
10856#endif
10857#ifdef FEAT_LISP
10858 buf->b_p_lisp = p_lisp;
10859#endif
10860#ifdef FEAT_SYN_HL
10861 /* Don't copy 'syntax', it must be set */
10862 buf->b_p_syn = empty_option;
Bram Moolenaar3b56eb32005-07-11 22:40:32 +000010863 buf->b_p_smc = p_smc;
Bram Moolenaarb8060fe2016-01-19 22:29:28 +010010864 buf->b_s.b_syn_isk = empty_option;
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010865#endif
10866#ifdef FEAT_SPELL
Bram Moolenaard5784f92010-10-13 14:05:35 +020010867 buf->b_s.b_p_spc = vim_strsave(p_spc);
Bram Moolenaar860cae12010-06-05 23:22:07 +020010868 (void)compile_cap_prog(&buf->b_s);
10869 buf->b_s.b_p_spf = vim_strsave(p_spf);
10870 buf->b_s.b_p_spl = vim_strsave(p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010871#endif
10872#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
10873 buf->b_p_inde = vim_strsave(p_inde);
10874 buf->b_p_indk = vim_strsave(p_indk);
10875#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +000010876#if defined(FEAT_EVAL)
10877 buf->b_p_fex = vim_strsave(p_fex);
10878#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010879#ifdef FEAT_CRYPT
10880 buf->b_p_key = vim_strsave(p_key);
10881#endif
10882#ifdef FEAT_SEARCHPATH
10883 buf->b_p_sua = vim_strsave(p_sua);
10884#endif
10885#ifdef FEAT_KEYMAP
10886 buf->b_p_keymap = vim_strsave(p_keymap);
10887 buf->b_kmap_state |= KEYMAP_INIT;
10888#endif
10889 /* This isn't really an option, but copying the langmap and IME
10890 * state from the current buffer is better than resetting it. */
10891 buf->b_p_iminsert = p_iminsert;
10892 buf->b_p_imsearch = p_imsearch;
10893
10894 /* options that are normally global but also have a local value
10895 * are not copied, start using the global value */
10896 buf->b_p_ar = -1;
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010897 buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010898 buf->b_p_bkc = empty_option;
10899 buf->b_bkc_flags = 0;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010900#ifdef FEAT_QUICKFIX
10901 buf->b_p_gp = empty_option;
10902 buf->b_p_mp = empty_option;
10903 buf->b_p_efm = empty_option;
10904#endif
10905 buf->b_p_ep = empty_option;
10906 buf->b_p_kp = empty_option;
10907 buf->b_p_path = empty_option;
10908 buf->b_p_tags = empty_option;
Bram Moolenaar0f6562e2015-11-24 18:48:14 +010010909 buf->b_p_tc = empty_option;
10910 buf->b_tc_flags = 0;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010911#ifdef FEAT_FIND_ID
10912 buf->b_p_def = empty_option;
10913 buf->b_p_inc = empty_option;
10914# ifdef FEAT_EVAL
10915 buf->b_p_inex = vim_strsave(p_inex);
10916# endif
10917#endif
10918#ifdef FEAT_INS_EXPAND
10919 buf->b_p_dict = empty_option;
10920 buf->b_p_tsr = empty_option;
10921#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010922#ifdef FEAT_TEXTOBJ
10923 buf->b_p_qe = vim_strsave(p_qe);
10924#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000010925#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10926 buf->b_p_bexpr = empty_option;
10927#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020010928#if defined(FEAT_CRYPT)
10929 buf->b_p_cm = empty_option;
10930#endif
Bram Moolenaar55debbe2010-05-23 23:34:36 +020010931#ifdef FEAT_PERSISTENT_UNDO
10932 buf->b_p_udf = p_udf;
10933#endif
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010934#ifdef FEAT_LISP
10935 buf->b_p_lw = empty_option;
10936#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010937
10938 /*
10939 * Don't copy the options set by ex_help(), use the saved values,
10940 * when going from a help buffer to a non-help buffer.
10941 * Don't touch these at all when BCO_NOHELP is used and going from
10942 * or to a help buffer.
10943 */
10944 if (dont_do_help)
10945 buf->b_p_isk = save_p_isk;
10946 else
10947 {
10948 buf->b_p_isk = vim_strsave(p_isk);
10949 did_isk = TRUE;
10950 buf->b_p_ts = p_ts;
10951 buf->b_help = FALSE;
10952#ifdef FEAT_QUICKFIX
10953 if (buf->b_p_bt[0] == 'h')
10954 clear_string_option(&buf->b_p_bt);
10955#endif
10956 buf->b_p_ma = p_ma;
10957 }
10958 }
10959
10960 /*
10961 * When the options should be copied (ignoring BCO_ALWAYS), set the
10962 * flag that indicates that the options have been initialized.
10963 */
10964 if (should_copy)
10965 buf->b_p_initialized = TRUE;
10966 }
10967
10968 check_buf_options(buf); /* make sure we don't have NULLs */
10969 if (did_isk)
10970 (void)buf_init_chartab(buf, FALSE);
10971}
10972
10973/*
10974 * Reset the 'modifiable' option and its default value.
10975 */
10976 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010977reset_modifiable(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010978{
10979 int opt_idx;
10980
10981 curbuf->b_p_ma = FALSE;
10982 p_ma = FALSE;
10983 opt_idx = findoption((char_u *)"ma");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000010984 if (opt_idx >= 0)
10985 options[opt_idx].def_val[VI_DEFAULT] = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010986}
10987
10988/*
10989 * Set the global value for 'iminsert' to the local value.
10990 */
10991 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010992set_iminsert_global(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010993{
10994 p_iminsert = curbuf->b_p_iminsert;
10995}
10996
10997/*
10998 * Set the global value for 'imsearch' to the local value.
10999 */
11000 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011001set_imsearch_global(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011002{
11003 p_imsearch = curbuf->b_p_imsearch;
11004}
11005
11006#if defined(FEAT_CMDL_COMPL) || defined(PROTO)
11007static int expand_option_idx = -1;
11008static char_u expand_option_name[5] = {'t', '_', NUL, NUL, NUL};
11009static int expand_option_flags = 0;
11010
11011 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011012set_context_in_set_cmd(
11013 expand_T *xp,
11014 char_u *arg,
11015 int opt_flags) /* OPT_GLOBAL and/or OPT_LOCAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011016{
11017 int nextchar;
11018 long_u flags = 0; /* init for GCC */
11019 int opt_idx = 0; /* init for GCC */
11020 char_u *p;
11021 char_u *s;
11022 int is_term_option = FALSE;
11023 int key;
11024
11025 expand_option_flags = opt_flags;
11026
11027 xp->xp_context = EXPAND_SETTINGS;
11028 if (*arg == NUL)
11029 {
11030 xp->xp_pattern = arg;
11031 return;
11032 }
11033 p = arg + STRLEN(arg) - 1;
11034 if (*p == ' ' && *(p - 1) != '\\')
11035 {
11036 xp->xp_pattern = p + 1;
11037 return;
11038 }
11039 while (p > arg)
11040 {
11041 s = p;
11042 /* count number of backslashes before ' ' or ',' */
11043 if (*p == ' ' || *p == ',')
11044 {
11045 while (s > arg && *(s - 1) == '\\')
11046 --s;
11047 }
11048 /* break at a space with an even number of backslashes */
11049 if (*p == ' ' && ((p - s) & 1) == 0)
11050 {
11051 ++p;
11052 break;
11053 }
11054 --p;
11055 }
Bram Moolenaar2a7b9ee2009-06-16 15:50:33 +000011056 if (STRNCMP(p, "no", 2) == 0 && STRNCMP(p, "novice", 6) != 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011057 {
11058 xp->xp_context = EXPAND_BOOL_SETTINGS;
11059 p += 2;
11060 }
11061 if (STRNCMP(p, "inv", 3) == 0)
11062 {
11063 xp->xp_context = EXPAND_BOOL_SETTINGS;
11064 p += 3;
11065 }
11066 xp->xp_pattern = arg = p;
11067 if (*arg == '<')
11068 {
11069 while (*p != '>')
11070 if (*p++ == NUL) /* expand terminal option name */
11071 return;
11072 key = get_special_key_code(arg + 1);
11073 if (key == 0) /* unknown name */
11074 {
11075 xp->xp_context = EXPAND_NOTHING;
11076 return;
11077 }
11078 nextchar = *++p;
11079 is_term_option = TRUE;
11080 expand_option_name[2] = KEY2TERMCAP0(key);
11081 expand_option_name[3] = KEY2TERMCAP1(key);
11082 }
11083 else
11084 {
11085 if (p[0] == 't' && p[1] == '_')
11086 {
11087 p += 2;
11088 if (*p != NUL)
11089 ++p;
11090 if (*p == NUL)
11091 return; /* expand option name */
11092 nextchar = *++p;
11093 is_term_option = TRUE;
11094 expand_option_name[2] = p[-2];
11095 expand_option_name[3] = p[-1];
11096 }
11097 else
11098 {
11099 /* Allow * wildcard */
11100 while (ASCII_ISALNUM(*p) || *p == '_' || *p == '*')
11101 p++;
11102 if (*p == NUL)
11103 return;
11104 nextchar = *p;
11105 *p = NUL;
11106 opt_idx = findoption(arg);
11107 *p = nextchar;
11108 if (opt_idx == -1 || options[opt_idx].var == NULL)
11109 {
11110 xp->xp_context = EXPAND_NOTHING;
11111 return;
11112 }
11113 flags = options[opt_idx].flags;
11114 if (flags & P_BOOL)
11115 {
11116 xp->xp_context = EXPAND_NOTHING;
11117 return;
11118 }
11119 }
11120 }
11121 /* handle "-=" and "+=" */
11122 if ((nextchar == '-' || nextchar == '+' || nextchar == '^') && p[1] == '=')
11123 {
11124 ++p;
11125 nextchar = '=';
11126 }
11127 if ((nextchar != '=' && nextchar != ':')
11128 || xp->xp_context == EXPAND_BOOL_SETTINGS)
11129 {
11130 xp->xp_context = EXPAND_UNSUCCESSFUL;
11131 return;
11132 }
11133 if (xp->xp_context != EXPAND_BOOL_SETTINGS && p[1] == NUL)
11134 {
11135 xp->xp_context = EXPAND_OLD_SETTING;
11136 if (is_term_option)
11137 expand_option_idx = -1;
11138 else
11139 expand_option_idx = opt_idx;
11140 xp->xp_pattern = p + 1;
11141 return;
11142 }
11143 xp->xp_context = EXPAND_NOTHING;
11144 if (is_term_option || (flags & P_NUM))
11145 return;
11146
11147 xp->xp_pattern = p + 1;
11148
11149 if (flags & P_EXPAND)
11150 {
11151 p = options[opt_idx].var;
11152 if (p == (char_u *)&p_bdir
11153 || p == (char_u *)&p_dir
11154 || p == (char_u *)&p_path
Bram Moolenaarf6fee0e2016-02-21 23:02:49 +010011155 || p == (char_u *)&p_pp
Bram Moolenaar071d4272004-06-13 20:20:40 +000011156 || p == (char_u *)&p_rtp
11157#ifdef FEAT_SEARCHPATH
11158 || p == (char_u *)&p_cdpath
11159#endif
11160#ifdef FEAT_SESSION
11161 || p == (char_u *)&p_vdir
11162#endif
11163 )
11164 {
11165 xp->xp_context = EXPAND_DIRECTORIES;
11166 if (p == (char_u *)&p_path
11167#ifdef FEAT_SEARCHPATH
11168 || p == (char_u *)&p_cdpath
11169#endif
11170 )
11171 xp->xp_backslash = XP_BS_THREE;
11172 else
11173 xp->xp_backslash = XP_BS_ONE;
11174 }
11175 else
11176 {
11177 xp->xp_context = EXPAND_FILES;
11178 /* for 'tags' need three backslashes for a space */
11179 if (p == (char_u *)&p_tags)
11180 xp->xp_backslash = XP_BS_THREE;
11181 else
11182 xp->xp_backslash = XP_BS_ONE;
11183 }
11184 }
11185
11186 /* For an option that is a list of file names, find the start of the
11187 * last file name. */
11188 for (p = arg + STRLEN(arg) - 1; p > xp->xp_pattern; --p)
11189 {
11190 /* count number of backslashes before ' ' or ',' */
11191 if (*p == ' ' || *p == ',')
11192 {
11193 s = p;
11194 while (s > xp->xp_pattern && *(s - 1) == '\\')
11195 --s;
11196 if ((*p == ' ' && (xp->xp_backslash == XP_BS_THREE && (p - s) < 3))
11197 || (*p == ',' && (flags & P_COMMA) && ((p - s) & 1) == 0))
11198 {
11199 xp->xp_pattern = p + 1;
11200 break;
11201 }
11202 }
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +000011203
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000011204#ifdef FEAT_SPELL
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +000011205 /* for 'spellsuggest' start at "file:" */
11206 if (options[opt_idx].var == (char_u *)&p_sps
11207 && STRNCMP(p, "file:", 5) == 0)
11208 {
11209 xp->xp_pattern = p + 5;
11210 break;
11211 }
11212#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011213 }
11214
11215 return;
11216}
11217
11218 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011219ExpandSettings(
11220 expand_T *xp,
11221 regmatch_T *regmatch,
11222 int *num_file,
11223 char_u ***file)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011224{
11225 int num_normal = 0; /* Nr of matching non-term-code settings */
11226 int num_term = 0; /* Nr of matching terminal code settings */
11227 int opt_idx;
11228 int match;
11229 int count = 0;
11230 char_u *str;
11231 int loop;
11232 int is_term_opt;
11233 char_u name_buf[MAX_KEY_NAME_LEN];
11234 static char *(names[]) = {"all", "termcap"};
11235 int ic = regmatch->rm_ic; /* remember the ignore-case flag */
11236
11237 /* do this loop twice:
11238 * loop == 0: count the number of matching options
11239 * loop == 1: copy the matching options into allocated memory
11240 */
11241 for (loop = 0; loop <= 1; ++loop)
11242 {
11243 regmatch->rm_ic = ic;
11244 if (xp->xp_context != EXPAND_BOOL_SETTINGS)
11245 {
Bram Moolenaar2c4278f2009-05-17 11:33:22 +000011246 for (match = 0; match < (int)(sizeof(names) / sizeof(char *));
11247 ++match)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011248 if (vim_regexec(regmatch, (char_u *)names[match], (colnr_T)0))
11249 {
11250 if (loop == 0)
11251 num_normal++;
11252 else
11253 (*file)[count++] = vim_strsave((char_u *)names[match]);
11254 }
11255 }
11256 for (opt_idx = 0; (str = (char_u *)options[opt_idx].fullname) != NULL;
11257 opt_idx++)
11258 {
11259 if (options[opt_idx].var == NULL)
11260 continue;
11261 if (xp->xp_context == EXPAND_BOOL_SETTINGS
11262 && !(options[opt_idx].flags & P_BOOL))
11263 continue;
11264 is_term_opt = istermoption(&options[opt_idx]);
11265 if (is_term_opt && num_normal > 0)
11266 continue;
11267 match = FALSE;
11268 if (vim_regexec(regmatch, str, (colnr_T)0)
11269 || (options[opt_idx].shortname != NULL
11270 && vim_regexec(regmatch,
11271 (char_u *)options[opt_idx].shortname, (colnr_T)0)))
11272 match = TRUE;
11273 else if (is_term_opt)
11274 {
11275 name_buf[0] = '<';
11276 name_buf[1] = 't';
11277 name_buf[2] = '_';
11278 name_buf[3] = str[2];
11279 name_buf[4] = str[3];
11280 name_buf[5] = '>';
11281 name_buf[6] = NUL;
11282 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11283 {
11284 match = TRUE;
11285 str = name_buf;
11286 }
11287 }
11288 if (match)
11289 {
11290 if (loop == 0)
11291 {
11292 if (is_term_opt)
11293 num_term++;
11294 else
11295 num_normal++;
11296 }
11297 else
11298 (*file)[count++] = vim_strsave(str);
11299 }
11300 }
11301 /*
11302 * Check terminal key codes, these are not in the option table
11303 */
11304 if (xp->xp_context != EXPAND_BOOL_SETTINGS && num_normal == 0)
11305 {
11306 for (opt_idx = 0; (str = get_termcode(opt_idx)) != NULL; opt_idx++)
11307 {
11308 if (!isprint(str[0]) || !isprint(str[1]))
11309 continue;
11310
11311 name_buf[0] = 't';
11312 name_buf[1] = '_';
11313 name_buf[2] = str[0];
11314 name_buf[3] = str[1];
11315 name_buf[4] = NUL;
11316
11317 match = FALSE;
11318 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11319 match = TRUE;
11320 else
11321 {
11322 name_buf[0] = '<';
11323 name_buf[1] = 't';
11324 name_buf[2] = '_';
11325 name_buf[3] = str[0];
11326 name_buf[4] = str[1];
11327 name_buf[5] = '>';
11328 name_buf[6] = NUL;
11329
11330 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11331 match = TRUE;
11332 }
11333 if (match)
11334 {
11335 if (loop == 0)
11336 num_term++;
11337 else
11338 (*file)[count++] = vim_strsave(name_buf);
11339 }
11340 }
11341
11342 /*
11343 * Check special key names.
11344 */
11345 regmatch->rm_ic = TRUE; /* ignore case here */
11346 for (opt_idx = 0; (str = get_key_name(opt_idx)) != NULL; opt_idx++)
11347 {
11348 name_buf[0] = '<';
11349 STRCPY(name_buf + 1, str);
11350 STRCAT(name_buf, ">");
11351
11352 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11353 {
11354 if (loop == 0)
11355 num_term++;
11356 else
11357 (*file)[count++] = vim_strsave(name_buf);
11358 }
11359 }
11360 }
11361 if (loop == 0)
11362 {
11363 if (num_normal > 0)
11364 *num_file = num_normal;
11365 else if (num_term > 0)
11366 *num_file = num_term;
11367 else
11368 return OK;
11369 *file = (char_u **)alloc((unsigned)(*num_file * sizeof(char_u *)));
11370 if (*file == NULL)
11371 {
11372 *file = (char_u **)"";
11373 return FAIL;
11374 }
11375 }
11376 }
11377 return OK;
11378}
11379
11380 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011381ExpandOldSetting(int *num_file, char_u ***file)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011382{
11383 char_u *var = NULL; /* init for GCC */
11384 char_u *buf;
11385
11386 *num_file = 0;
11387 *file = (char_u **)alloc((unsigned)sizeof(char_u *));
11388 if (*file == NULL)
11389 return FAIL;
11390
11391 /*
11392 * For a terminal key code expand_option_idx is < 0.
11393 */
11394 if (expand_option_idx < 0)
11395 {
11396 var = find_termcode(expand_option_name + 2);
11397 if (var == NULL)
11398 expand_option_idx = findoption(expand_option_name);
11399 }
11400
11401 if (expand_option_idx >= 0)
11402 {
11403 /* put string of option value in NameBuff */
11404 option_value2string(&options[expand_option_idx], expand_option_flags);
11405 var = NameBuff;
11406 }
11407 else if (var == NULL)
11408 var = (char_u *)"";
11409
11410 /* A backslash is required before some characters. This is the reverse of
11411 * what happens in do_set(). */
11412 buf = vim_strsave_escaped(var, escape_chars);
11413
11414 if (buf == NULL)
11415 {
11416 vim_free(*file);
11417 *file = NULL;
11418 return FAIL;
11419 }
11420
11421#ifdef BACKSLASH_IN_FILENAME
11422 /* For MS-Windows et al. we don't double backslashes at the start and
11423 * before a file name character. */
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011424 for (var = buf; *var != NUL; mb_ptr_adv(var))
Bram Moolenaar071d4272004-06-13 20:20:40 +000011425 if (var[0] == '\\' && var[1] == '\\'
11426 && expand_option_idx >= 0
11427 && (options[expand_option_idx].flags & P_EXPAND)
11428 && vim_isfilec(var[2])
11429 && (var[2] != '\\' || (var == buf && var[4] != '\\')))
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +000011430 STRMOVE(var, var + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011431#endif
11432
11433 *file[0] = buf;
11434 *num_file = 1;
11435 return OK;
11436}
11437#endif
11438
11439/*
11440 * Get the value for the numeric or string option *opp in a nice format into
11441 * NameBuff[]. Must not be called with a hidden option!
11442 */
11443 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011444option_value2string(
11445 struct vimoption *opp,
11446 int opt_flags) /* OPT_GLOBAL and/or OPT_LOCAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011447{
11448 char_u *varp;
11449
11450 varp = get_varp_scope(opp, opt_flags);
11451
11452 if (opp->flags & P_NUM)
11453 {
11454 long wc = 0;
11455
11456 if (wc_use_keyname(varp, &wc))
11457 STRCPY(NameBuff, get_special_key_name((int)wc, 0));
11458 else if (wc != 0)
11459 STRCPY(NameBuff, transchar((int)wc));
11460 else
11461 sprintf((char *)NameBuff, "%ld", *(long *)varp);
11462 }
11463 else /* P_STRING */
11464 {
11465 varp = *(char_u **)(varp);
11466 if (varp == NULL) /* just in case */
11467 NameBuff[0] = NUL;
11468#ifdef FEAT_CRYPT
11469 /* don't show the actual value of 'key', only that it's set */
Bram Moolenaareb3593b2006-04-22 22:33:57 +000011470 else if (opp->var == (char_u *)&p_key && *varp)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011471 STRCPY(NameBuff, "*****");
11472#endif
11473 else if (opp->flags & P_EXPAND)
11474 home_replace(NULL, varp, NameBuff, MAXPATHL, FALSE);
11475 /* Translate 'pastetoggle' into special key names */
11476 else if ((char_u **)opp->var == &p_pt)
11477 str2specialbuf(p_pt, NameBuff, MAXPATHL);
11478 else
Bram Moolenaarce0842a2005-07-18 21:58:11 +000011479 vim_strncpy(NameBuff, varp, MAXPATHL - 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011480 }
11481}
11482
11483/*
11484 * Return TRUE if "varp" points to 'wildchar' or 'wildcharm' and it can be
11485 * printed as a keyname.
11486 * "*wcp" is set to the value of the option if it's 'wildchar' or 'wildcharm'.
11487 */
11488 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011489wc_use_keyname(char_u *varp, long *wcp)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011490{
11491 if (((long *)varp == &p_wc) || ((long *)varp == &p_wcm))
11492 {
11493 *wcp = *(long *)varp;
11494 if (IS_SPECIAL(*wcp) || find_special_key_in_table((int)*wcp) >= 0)
11495 return TRUE;
11496 }
11497 return FALSE;
11498}
11499
Bram Moolenaar01615492015-02-03 13:00:38 +010011500#if defined(FEAT_LANGMAP) || defined(PROTO)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011501/*
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011502 * Any character has an equivalent 'langmap' character. This is used for
11503 * keyboards that have a special language mode that sends characters above
11504 * 128 (although other characters can be translated too). The "to" field is a
11505 * Vim command character. This avoids having to switch the keyboard back to
11506 * ASCII mode when leaving Insert mode.
11507 *
11508 * langmap_mapchar[] maps any of 256 chars to an ASCII char used for Vim
11509 * commands.
11510 * When FEAT_MBYTE is defined langmap_mapga.ga_data is a sorted table of
11511 * langmap_entry_T. This does the same as langmap_mapchar[] for characters >=
11512 * 256.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011513 */
Bram Moolenaar01615492015-02-03 13:00:38 +010011514# if defined(FEAT_MBYTE) || defined(PROTO)
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011515/*
11516 * With multi-byte support use growarray for 'langmap' chars >= 256
11517 */
11518typedef struct
11519{
11520 int from;
11521 int to;
11522} langmap_entry_T;
11523
11524static garray_T langmap_mapga;
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +010011525static void langmap_set_entry(int from, int to);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011526
11527/*
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011528 * Search for an entry in "langmap_mapga" for "from". If found set the "to"
11529 * field. If not found insert a new entry at the appropriate location.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011530 */
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011531 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011532langmap_set_entry(int from, int to)
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011533{
11534 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
Bram Moolenaarcc448b32010-07-14 16:52:17 +020011535 int a = 0;
11536 int b = langmap_mapga.ga_len;
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011537
11538 /* Do a binary search for an existing entry. */
11539 while (a != b)
11540 {
11541 int i = (a + b) / 2;
11542 int d = entries[i].from - from;
11543
11544 if (d == 0)
11545 {
11546 entries[i].to = to;
11547 return;
11548 }
11549 if (d < 0)
11550 a = i + 1;
11551 else
11552 b = i;
11553 }
11554
11555 if (ga_grow(&langmap_mapga, 1) != OK)
11556 return; /* out of memory */
11557
11558 /* insert new entry at position "a" */
11559 entries = (langmap_entry_T *)(langmap_mapga.ga_data) + a;
11560 mch_memmove(entries + 1, entries,
11561 (langmap_mapga.ga_len - a) * sizeof(langmap_entry_T));
11562 ++langmap_mapga.ga_len;
11563 entries[0].from = from;
11564 entries[0].to = to;
11565}
11566
11567/*
11568 * Apply 'langmap' to multi-byte character "c" and return the result.
11569 */
11570 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011571langmap_adjust_mb(int c)
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011572{
11573 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
11574 int a = 0;
11575 int b = langmap_mapga.ga_len;
11576
11577 while (a != b)
11578 {
11579 int i = (a + b) / 2;
11580 int d = entries[i].from - c;
11581
11582 if (d == 0)
11583 return entries[i].to; /* found matching entry */
11584 if (d < 0)
11585 a = i + 1;
11586 else
11587 b = i;
11588 }
11589 return c; /* no entry found, return "c" unmodified */
11590}
11591# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011592
11593 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011594langmap_init(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011595{
11596 int i;
11597
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011598 for (i = 0; i < 256; i++)
11599 langmap_mapchar[i] = i; /* we init with a one-to-one map */
11600# ifdef FEAT_MBYTE
11601 ga_init2(&langmap_mapga, sizeof(langmap_entry_T), 8);
11602# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011603}
11604
11605/*
11606 * Called when langmap option is set; the language map can be
11607 * changed at any time!
11608 */
11609 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011610langmap_set(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011611{
11612 char_u *p;
11613 char_u *p2;
11614 int from, to;
11615
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011616#ifdef FEAT_MBYTE
11617 ga_clear(&langmap_mapga); /* clear the previous map first */
11618#endif
11619 langmap_init(); /* back to one-to-one map */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011620
11621 for (p = p_langmap; p[0] != NUL; )
11622 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011623 for (p2 = p; p2[0] != NUL && p2[0] != ',' && p2[0] != ';';
11624 mb_ptr_adv(p2))
Bram Moolenaar071d4272004-06-13 20:20:40 +000011625 {
11626 if (p2[0] == '\\' && p2[1] != NUL)
11627 ++p2;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011628 }
11629 if (p2[0] == ';')
11630 ++p2; /* abcd;ABCD form, p2 points to A */
11631 else
11632 p2 = NULL; /* aAbBcCdD form, p2 is NULL */
11633 while (p[0])
11634 {
Bram Moolenaar6af05062010-05-14 17:32:58 +020011635 if (p[0] == ',')
11636 {
11637 ++p;
11638 break;
11639 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011640 if (p[0] == '\\' && p[1] != NUL)
11641 ++p;
11642#ifdef FEAT_MBYTE
11643 from = (*mb_ptr2char)(p);
11644#else
11645 from = p[0];
11646#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011647 to = NUL;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011648 if (p2 == NULL)
11649 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011650 mb_ptr_adv(p);
Bram Moolenaar6af05062010-05-14 17:32:58 +020011651 if (p[0] != ',')
11652 {
11653 if (p[0] == '\\')
11654 ++p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011655#ifdef FEAT_MBYTE
Bram Moolenaar6af05062010-05-14 17:32:58 +020011656 to = (*mb_ptr2char)(p);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011657#else
Bram Moolenaar6af05062010-05-14 17:32:58 +020011658 to = p[0];
Bram Moolenaar071d4272004-06-13 20:20:40 +000011659#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011660 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011661 }
11662 else
11663 {
Bram Moolenaar6af05062010-05-14 17:32:58 +020011664 if (p2[0] != ',')
11665 {
11666 if (p2[0] == '\\')
11667 ++p2;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011668#ifdef FEAT_MBYTE
Bram Moolenaar6af05062010-05-14 17:32:58 +020011669 to = (*mb_ptr2char)(p2);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011670#else
Bram Moolenaar6af05062010-05-14 17:32:58 +020011671 to = p2[0];
Bram Moolenaar071d4272004-06-13 20:20:40 +000011672#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011673 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011674 }
11675 if (to == NUL)
11676 {
11677 EMSG2(_("E357: 'langmap': Matching character missing for %s"),
11678 transchar(from));
11679 return;
11680 }
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011681
11682#ifdef FEAT_MBYTE
11683 if (from >= 256)
11684 langmap_set_entry(from, to);
11685 else
11686#endif
11687 langmap_mapchar[from & 255] = to;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011688
11689 /* Advance to next pair */
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011690 mb_ptr_adv(p);
Bram Moolenaar6af05062010-05-14 17:32:58 +020011691 if (p2 != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011692 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011693 mb_ptr_adv(p2);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011694 if (*p == ';')
11695 {
11696 p = p2;
11697 if (p[0] != NUL)
11698 {
11699 if (p[0] != ',')
11700 {
11701 EMSG2(_("E358: 'langmap': Extra characters after semicolon: %s"), p);
11702 return;
11703 }
11704 ++p;
11705 }
11706 break;
11707 }
11708 }
11709 }
11710 }
11711}
11712#endif
11713
11714/*
11715 * Return TRUE if format option 'x' is in effect.
11716 * Take care of no formatting when 'paste' is set.
11717 */
11718 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011719has_format_option(int x)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011720{
11721 if (p_paste)
11722 return FALSE;
11723 return (vim_strchr(curbuf->b_p_fo, x) != NULL);
11724}
11725
11726/*
11727 * Return TRUE if "x" is present in 'shortmess' option, or
11728 * 'shortmess' contains 'a' and "x" is present in SHM_A.
11729 */
11730 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011731shortmess(int x)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011732{
Bram Moolenaar7f29f7a2012-02-29 13:51:37 +010011733 return p_shm != NULL &&
11734 ( vim_strchr(p_shm, x) != NULL
Bram Moolenaar071d4272004-06-13 20:20:40 +000011735 || (vim_strchr(p_shm, 'a') != NULL
11736 && vim_strchr((char_u *)SHM_A, x) != NULL));
11737}
11738
11739/*
11740 * paste_option_changed() - Called after p_paste was set or reset.
11741 */
11742 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011743paste_option_changed(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011744{
11745 static int old_p_paste = FALSE;
11746 static int save_sm = 0;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020011747 static int save_sta = 0;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011748#ifdef FEAT_CMDL_INFO
11749 static int save_ru = 0;
11750#endif
11751#ifdef FEAT_RIGHTLEFT
11752 static int save_ri = 0;
11753 static int save_hkmap = 0;
11754#endif
11755 buf_T *buf;
11756
11757 if (p_paste)
11758 {
11759 /*
11760 * Paste switched from off to on.
11761 * Save the current values, so they can be restored later.
11762 */
11763 if (!old_p_paste)
11764 {
11765 /* save options for each buffer */
Bram Moolenaar29323592016-07-24 22:04:11 +020011766 FOR_ALL_BUFFERS(buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011767 {
11768 buf->b_p_tw_nopaste = buf->b_p_tw;
11769 buf->b_p_wm_nopaste = buf->b_p_wm;
11770 buf->b_p_sts_nopaste = buf->b_p_sts;
11771 buf->b_p_ai_nopaste = buf->b_p_ai;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020011772 buf->b_p_et_nopaste = buf->b_p_et;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011773 }
11774
11775 /* save global options */
11776 save_sm = p_sm;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020011777 save_sta = p_sta;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011778#ifdef FEAT_CMDL_INFO
11779 save_ru = p_ru;
11780#endif
11781#ifdef FEAT_RIGHTLEFT
11782 save_ri = p_ri;
11783 save_hkmap = p_hkmap;
11784#endif
11785 /* save global values for local buffer options */
Bram Moolenaar54f018c2015-09-15 17:30:40 +020011786 p_ai_nopaste = p_ai;
11787 p_et_nopaste = p_et;
11788 p_sts_nopaste = p_sts;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011789 p_tw_nopaste = p_tw;
11790 p_wm_nopaste = p_wm;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011791 }
11792
11793 /*
11794 * Always set the option values, also when 'paste' is set when it is
11795 * already on.
11796 */
11797 /* set options for each buffer */
Bram Moolenaar29323592016-07-24 22:04:11 +020011798 FOR_ALL_BUFFERS(buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011799 {
11800 buf->b_p_tw = 0; /* textwidth is 0 */
11801 buf->b_p_wm = 0; /* wrapmargin is 0 */
11802 buf->b_p_sts = 0; /* softtabstop is 0 */
11803 buf->b_p_ai = 0; /* no auto-indent */
Bram Moolenaar54f018c2015-09-15 17:30:40 +020011804 buf->b_p_et = 0; /* no expandtab */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011805 }
11806
11807 /* set global options */
11808 p_sm = 0; /* no showmatch */
Bram Moolenaar54f018c2015-09-15 17:30:40 +020011809 p_sta = 0; /* no smarttab */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011810#ifdef FEAT_CMDL_INFO
11811# ifdef FEAT_WINDOWS
11812 if (p_ru)
11813 status_redraw_all(); /* redraw to remove the ruler */
11814# endif
11815 p_ru = 0; /* no ruler */
11816#endif
11817#ifdef FEAT_RIGHTLEFT
11818 p_ri = 0; /* no reverse insert */
11819 p_hkmap = 0; /* no Hebrew keyboard */
11820#endif
11821 /* set global values for local buffer options */
11822 p_tw = 0;
11823 p_wm = 0;
11824 p_sts = 0;
11825 p_ai = 0;
11826 }
11827
11828 /*
11829 * Paste switched from on to off: Restore saved values.
11830 */
11831 else if (old_p_paste)
11832 {
11833 /* restore options for each buffer */
Bram Moolenaar29323592016-07-24 22:04:11 +020011834 FOR_ALL_BUFFERS(buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011835 {
11836 buf->b_p_tw = buf->b_p_tw_nopaste;
11837 buf->b_p_wm = buf->b_p_wm_nopaste;
11838 buf->b_p_sts = buf->b_p_sts_nopaste;
11839 buf->b_p_ai = buf->b_p_ai_nopaste;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020011840 buf->b_p_et = buf->b_p_et_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011841 }
11842
11843 /* restore global options */
11844 p_sm = save_sm;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020011845 p_sta = save_sta;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011846#ifdef FEAT_CMDL_INFO
11847# ifdef FEAT_WINDOWS
11848 if (p_ru != save_ru)
11849 status_redraw_all(); /* redraw to draw the ruler */
11850# endif
11851 p_ru = save_ru;
11852#endif
11853#ifdef FEAT_RIGHTLEFT
11854 p_ri = save_ri;
11855 p_hkmap = save_hkmap;
11856#endif
11857 /* set global values for local buffer options */
Bram Moolenaar54f018c2015-09-15 17:30:40 +020011858 p_ai = p_ai_nopaste;
11859 p_et = p_et_nopaste;
11860 p_sts = p_sts_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011861 p_tw = p_tw_nopaste;
11862 p_wm = p_wm_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011863 }
11864
11865 old_p_paste = p_paste;
11866}
11867
11868/*
11869 * vimrc_found() - Called when a ".vimrc" or "VIMINIT" has been found.
11870 *
11871 * Reset 'compatible' and set the values for options that didn't get set yet
11872 * to the Vim defaults.
11873 * Don't do this if the 'compatible' option has been set or reset before.
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011874 * When "fname" is not NULL, use it to set $"envname" when it wasn't set yet.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011875 */
11876 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011877vimrc_found(char_u *fname, char_u *envname)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011878{
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011879 int opt_idx;
Bram Moolenaar4c3f5362006-04-11 21:38:50 +000011880 int dofree = FALSE;
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011881 char_u *p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011882
11883 if (!option_was_set((char_u *)"cp"))
11884 {
11885 p_cp = FALSE;
11886 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
11887 if (!(options[opt_idx].flags & (P_WAS_SET|P_VI_DEF)))
11888 set_option_default(opt_idx, OPT_FREE, FALSE);
11889 didset_options();
Bram Moolenaare68c25c2015-08-25 15:39:55 +020011890 didset_options2();
Bram Moolenaar071d4272004-06-13 20:20:40 +000011891 }
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011892
11893 if (fname != NULL)
11894 {
11895 p = vim_getenv(envname, &dofree);
11896 if (p == NULL)
11897 {
11898 /* Set $MYVIMRC to the first vimrc file found. */
11899 p = FullName_save(fname, FALSE);
11900 if (p != NULL)
11901 {
11902 vim_setenv(envname, p);
11903 vim_free(p);
11904 }
11905 }
11906 else if (dofree)
11907 vim_free(p);
11908 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011909}
11910
11911/*
11912 * Set 'compatible' on or off. Called for "-C" and "-N" command line arg.
11913 */
11914 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011915change_compatible(int on)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011916{
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000011917 int opt_idx;
11918
Bram Moolenaar071d4272004-06-13 20:20:40 +000011919 if (p_cp != on)
11920 {
11921 p_cp = on;
11922 compatible_set();
11923 }
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000011924 opt_idx = findoption((char_u *)"cp");
11925 if (opt_idx >= 0)
11926 options[opt_idx].flags |= P_WAS_SET;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011927}
11928
11929/*
11930 * Return TRUE when option "name" has been set.
Bram Moolenaar1a4a75c2013-07-28 16:03:06 +020011931 * Only works correctly for global options.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011932 */
11933 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011934option_was_set(char_u *name)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011935{
11936 int idx;
11937
11938 idx = findoption(name);
11939 if (idx < 0) /* unknown option */
11940 return FALSE;
11941 if (options[idx].flags & P_WAS_SET)
11942 return TRUE;
11943 return FALSE;
11944}
11945
11946/*
Bram Moolenaar15d55de2012-12-05 14:43:02 +010011947 * Reset the flag indicating option "name" was set.
11948 */
11949 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011950reset_option_was_set(char_u *name)
Bram Moolenaar15d55de2012-12-05 14:43:02 +010011951{
11952 int idx = findoption(name);
11953
11954 if (idx >= 0)
11955 options[idx].flags &= ~P_WAS_SET;
11956}
11957
11958/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000011959 * compatible_set() - Called when 'compatible' has been set or unset.
11960 *
11961 * When 'compatible' set: Set all relevant options (those that have the P_VIM)
11962 * flag) to a Vi compatible value.
11963 * When 'compatible' is unset: Set all options that have a different default
11964 * for Vim (without the P_VI_DEF flag) to that default.
11965 */
11966 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011967compatible_set(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011968{
11969 int opt_idx;
11970
11971 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
11972 if ( ((options[opt_idx].flags & P_VIM) && p_cp)
11973 || (!(options[opt_idx].flags & P_VI_DEF) && !p_cp))
11974 set_option_default(opt_idx, OPT_FREE, p_cp);
11975 didset_options();
Bram Moolenaare68c25c2015-08-25 15:39:55 +020011976 didset_options2();
Bram Moolenaar071d4272004-06-13 20:20:40 +000011977}
11978
11979#ifdef FEAT_LINEBREAK
11980
11981# if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
11982 /* Borland C++ screws up loop optimisation here (negri) */
Bram Moolenaar8f999f12005-01-25 22:12:55 +000011983 #pragma option -O-l
Bram Moolenaar071d4272004-06-13 20:20:40 +000011984# endif
11985
11986/*
11987 * fill_breakat_flags() -- called when 'breakat' changes value.
11988 */
11989 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011990fill_breakat_flags(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011991{
Bram Moolenaarac6e65f2005-08-29 22:25:38 +000011992 char_u *p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011993 int i;
11994
11995 for (i = 0; i < 256; i++)
11996 breakat_flags[i] = FALSE;
11997
11998 if (p_breakat != NULL)
Bram Moolenaarac6e65f2005-08-29 22:25:38 +000011999 for (p = p_breakat; *p; p++)
12000 breakat_flags[*p] = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012001}
12002
12003# if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
Bram Moolenaar8f999f12005-01-25 22:12:55 +000012004 #pragma option -O.l
Bram Moolenaar071d4272004-06-13 20:20:40 +000012005# endif
12006
12007#endif
12008
12009/*
12010 * Check an option that can be a range of string values.
12011 *
12012 * Return OK for correct value, FAIL otherwise.
12013 * Empty is always OK.
12014 */
12015 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012016check_opt_strings(
12017 char_u *val,
12018 char **values,
12019 int list) /* when TRUE: accept a list of values */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012020{
12021 return opt_strings_flags(val, values, NULL, list);
12022}
12023
12024/*
12025 * Handle an option that can be a range of string values.
12026 * Set a flag in "*flagp" for each string present.
12027 *
12028 * Return OK for correct value, FAIL otherwise.
12029 * Empty is always OK.
12030 */
12031 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012032opt_strings_flags(
12033 char_u *val, /* new value */
12034 char **values, /* array of valid string values */
12035 unsigned *flagp,
12036 int list) /* when TRUE: accept a list of values */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012037{
12038 int i;
12039 int len;
12040 unsigned new_flags = 0;
12041
12042 while (*val)
12043 {
12044 for (i = 0; ; ++i)
12045 {
12046 if (values[i] == NULL) /* val not found in values[] */
12047 return FAIL;
12048
12049 len = (int)STRLEN(values[i]);
12050 if (STRNCMP(values[i], val, len) == 0
12051 && ((list && val[len] == ',') || val[len] == NUL))
12052 {
12053 val += len + (val[len] == ',');
12054 new_flags |= (1 << i);
12055 break; /* check next item in val list */
12056 }
12057 }
12058 }
12059 if (flagp != NULL)
12060 *flagp = new_flags;
12061
12062 return OK;
12063}
12064
12065/*
12066 * Read the 'wildmode' option, fill wim_flags[].
12067 */
12068 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012069check_opt_wim(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012070{
12071 char_u new_wim_flags[4];
12072 char_u *p;
12073 int i;
12074 int idx = 0;
12075
12076 for (i = 0; i < 4; ++i)
12077 new_wim_flags[i] = 0;
12078
12079 for (p = p_wim; *p; ++p)
12080 {
12081 for (i = 0; ASCII_ISALPHA(p[i]); ++i)
12082 ;
12083 if (p[i] != NUL && p[i] != ',' && p[i] != ':')
12084 return FAIL;
12085 if (i == 7 && STRNCMP(p, "longest", 7) == 0)
12086 new_wim_flags[idx] |= WIM_LONGEST;
12087 else if (i == 4 && STRNCMP(p, "full", 4) == 0)
12088 new_wim_flags[idx] |= WIM_FULL;
12089 else if (i == 4 && STRNCMP(p, "list", 4) == 0)
12090 new_wim_flags[idx] |= WIM_LIST;
12091 else
12092 return FAIL;
12093 p += i;
12094 if (*p == NUL)
12095 break;
12096 if (*p == ',')
12097 {
12098 if (idx == 3)
12099 return FAIL;
12100 ++idx;
12101 }
12102 }
12103
12104 /* fill remaining entries with last flag */
12105 while (idx < 3)
12106 {
12107 new_wim_flags[idx + 1] = new_wim_flags[idx];
12108 ++idx;
12109 }
12110
12111 /* only when there are no errors, wim_flags[] is changed */
12112 for (i = 0; i < 4; ++i)
12113 wim_flags[i] = new_wim_flags[i];
12114 return OK;
12115}
12116
12117/*
12118 * Check if backspacing over something is allowed.
12119 */
12120 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012121can_bs(
12122 int what) /* BS_INDENT, BS_EOL or BS_START */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012123{
12124 switch (*p_bs)
12125 {
12126 case '2': return TRUE;
12127 case '1': return (what != BS_START);
12128 case '0': return FALSE;
12129 }
12130 return vim_strchr(p_bs, what) != NULL;
12131}
12132
12133/*
12134 * Save the current values of 'fileformat' and 'fileencoding', so that we know
12135 * the file must be considered changed when the value is different.
12136 */
12137 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012138save_file_ff(buf_T *buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012139{
12140 buf->b_start_ffc = *buf->b_p_ff;
12141 buf->b_start_eol = buf->b_p_eol;
12142#ifdef FEAT_MBYTE
Bram Moolenaar83eb8852007-08-12 13:51:26 +000012143 buf->b_start_bomb = buf->b_p_bomb;
12144
Bram Moolenaar071d4272004-06-13 20:20:40 +000012145 /* Only use free/alloc when necessary, they take time. */
12146 if (buf->b_start_fenc == NULL
12147 || STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0)
12148 {
12149 vim_free(buf->b_start_fenc);
12150 buf->b_start_fenc = vim_strsave(buf->b_p_fenc);
12151 }
12152#endif
12153}
12154
12155/*
12156 * Return TRUE if 'fileformat' and/or 'fileencoding' has a different value
12157 * from when editing started (save_file_ff() called).
Bram Moolenaar83eb8852007-08-12 13:51:26 +000012158 * Also when 'endofline' was changed and 'binary' is set, or when 'bomb' was
12159 * changed and 'binary' is not set.
Bram Moolenaar34d72d42015-07-17 14:18:08 +020012160 * Also when 'endofline' was changed and 'fixeol' is not set.
Bram Moolenaar164c60f2011-01-22 00:11:50 +010012161 * When "ignore_empty" is true don't consider a new, empty buffer to be
12162 * changed.
Bram Moolenaar071d4272004-06-13 20:20:40 +000012163 */
12164 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012165file_ff_differs(buf_T *buf, int ignore_empty)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012166{
Bram Moolenaar9cffde92007-07-24 07:51:18 +000012167 /* In a buffer that was never loaded the options are not valid. */
12168 if (buf->b_flags & BF_NEVERLOADED)
12169 return FALSE;
Bram Moolenaar164c60f2011-01-22 00:11:50 +010012170 if (ignore_empty
12171 && (buf->b_flags & BF_NEW)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012172 && buf->b_ml.ml_line_count == 1
12173 && *ml_get_buf(buf, (linenr_T)1, FALSE) == NUL)
12174 return FALSE;
12175 if (buf->b_start_ffc != *buf->b_p_ff)
12176 return TRUE;
Bram Moolenaar34d72d42015-07-17 14:18:08 +020012177 if ((buf->b_p_bin || !buf->b_p_fixeol) && buf->b_start_eol != buf->b_p_eol)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012178 return TRUE;
12179#ifdef FEAT_MBYTE
Bram Moolenaar83eb8852007-08-12 13:51:26 +000012180 if (!buf->b_p_bin && buf->b_start_bomb != buf->b_p_bomb)
12181 return TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012182 if (buf->b_start_fenc == NULL)
12183 return (*buf->b_p_fenc != NUL);
12184 return (STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0);
12185#else
12186 return FALSE;
12187#endif
12188}
12189
12190/*
12191 * return OK if "p" is a valid fileformat name, FAIL otherwise.
12192 */
12193 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012194check_ff_value(char_u *p)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012195{
12196 return check_opt_strings(p, p_ff_values, FALSE);
12197}
Bram Moolenaar14f24742012-08-08 18:01:05 +020012198
12199/*
12200 * Return the effective shiftwidth value for current buffer, using the
12201 * 'tabstop' value when 'shiftwidth' is zero.
12202 */
12203 long
Bram Moolenaar9b578142016-01-30 19:39:49 +010012204get_sw_value(buf_T *buf)
Bram Moolenaar14f24742012-08-08 18:01:05 +020012205{
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +010012206 return buf->b_p_sw ? buf->b_p_sw : buf->b_p_ts;
Bram Moolenaar14f24742012-08-08 18:01:05 +020012207}
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020012208
12209/*
12210 * Return the effective softtabstop value for the current buffer, using the
12211 * 'tabstop' value when 'softtabstop' is negative.
12212 */
12213 long
Bram Moolenaar9b578142016-01-30 19:39:49 +010012214get_sts_value(void)
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020012215{
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +010012216 return curbuf->b_p_sts < 0 ? get_sw_value(curbuf) : curbuf->b_p_sts;
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020012217}
Bram Moolenaar8c7694a2013-01-17 17:02:05 +010012218
12219/*
12220 * Check matchpairs option for "*initc".
12221 * If there is a match set "*initc" to the matching character and "*findc" to
12222 * the opposite character. Set "*backwards" to the direction.
12223 * When "switchit" is TRUE swap the direction.
12224 */
12225 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012226find_mps_values(
12227 int *initc,
12228 int *findc,
12229 int *backwards,
12230 int switchit)
Bram Moolenaar8c7694a2013-01-17 17:02:05 +010012231{
12232 char_u *ptr;
12233
12234 ptr = curbuf->b_p_mps;
12235 while (*ptr != NUL)
12236 {
12237#ifdef FEAT_MBYTE
12238 if (has_mbyte)
12239 {
12240 char_u *prev;
12241
12242 if (mb_ptr2char(ptr) == *initc)
12243 {
12244 if (switchit)
12245 {
12246 *findc = *initc;
12247 *initc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1);
12248 *backwards = TRUE;
12249 }
12250 else
12251 {
12252 *findc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1);
12253 *backwards = FALSE;
12254 }
12255 return;
12256 }
12257 prev = ptr;
12258 ptr += mb_ptr2len(ptr) + 1;
12259 if (mb_ptr2char(ptr) == *initc)
12260 {
12261 if (switchit)
12262 {
12263 *findc = *initc;
12264 *initc = mb_ptr2char(prev);
12265 *backwards = FALSE;
12266 }
12267 else
12268 {
12269 *findc = mb_ptr2char(prev);
12270 *backwards = TRUE;
12271 }
12272 return;
12273 }
12274 ptr += mb_ptr2len(ptr);
12275 }
12276 else
12277#endif
12278 {
12279 if (*ptr == *initc)
12280 {
12281 if (switchit)
12282 {
12283 *backwards = TRUE;
12284 *findc = *initc;
12285 *initc = ptr[2];
12286 }
12287 else
12288 {
12289 *backwards = FALSE;
12290 *findc = ptr[2];
12291 }
12292 return;
12293 }
12294 ptr += 2;
12295 if (*ptr == *initc)
12296 {
12297 if (switchit)
12298 {
12299 *backwards = FALSE;
12300 *findc = *initc;
12301 *initc = ptr[-2];
12302 }
12303 else
12304 {
12305 *backwards = TRUE;
12306 *findc = ptr[-2];
12307 }
12308 return;
12309 }
12310 ++ptr;
12311 }
12312 if (*ptr == ',')
12313 ++ptr;
12314 }
12315}
Bram Moolenaar597a4222014-06-25 14:39:50 +020012316
12317#if defined(FEAT_LINEBREAK) || defined(PROTO)
12318/*
12319 * This is called when 'breakindentopt' is changed and when a window is
12320 * initialized.
12321 */
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012322 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012323briopt_check(win_T *wp)
Bram Moolenaar597a4222014-06-25 14:39:50 +020012324{
12325 char_u *p;
12326 int bri_shift = 0;
12327 long bri_min = 20;
12328 int bri_sbr = FALSE;
12329
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012330 p = wp->w_p_briopt;
Bram Moolenaar597a4222014-06-25 14:39:50 +020012331 while (*p != NUL)
12332 {
12333 if (STRNCMP(p, "shift:", 6) == 0
12334 && ((p[6] == '-' && VIM_ISDIGIT(p[7])) || VIM_ISDIGIT(p[6])))
12335 {
12336 p += 6;
12337 bri_shift = getdigits(&p);
12338 }
12339 else if (STRNCMP(p, "min:", 4) == 0 && VIM_ISDIGIT(p[4]))
12340 {
12341 p += 4;
12342 bri_min = getdigits(&p);
12343 }
12344 else if (STRNCMP(p, "sbr", 3) == 0)
12345 {
12346 p += 3;
12347 bri_sbr = TRUE;
12348 }
12349 if (*p != ',' && *p != NUL)
12350 return FAIL;
12351 if (*p == ',')
12352 ++p;
12353 }
12354
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012355 wp->w_p_brishift = bri_shift;
12356 wp->w_p_brimin = bri_min;
12357 wp->w_p_brisbr = bri_sbr;
Bram Moolenaar597a4222014-06-25 14:39:50 +020012358
12359 return OK;
12360}
12361#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020012362
12363/*
12364 * Get the local or global value of 'backupcopy'.
12365 */
12366 unsigned int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012367get_bkc_value(buf_T *buf)
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020012368{
12369 return buf->b_bkc_flags ? buf->b_bkc_flags : bkc_flags;
12370}
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020012371
12372#if defined(FEAT_SIGNS) || defined(PROTO)
12373/*
12374 * Return TRUE when window "wp" has a column to draw signs in.
12375 */
12376 int
12377signcolumn_on(win_T *wp)
12378{
12379 if (*wp->w_p_scl == 'n')
12380 return FALSE;
12381 if (*wp->w_p_scl == 'y')
12382 return TRUE;
12383 return (wp->w_buffer->b_signlist != NULL
12384# ifdef FEAT_NETBEANS_INTG
12385 || wp->w_buffer->b_has_sign_column
12386# endif
12387 );
12388}
12389#endif
Bram Moolenaarb5ae48e2016-08-12 22:23:25 +020012390
12391#if defined(FEAT_EVAL) || defined(PROTO)
12392/*
12393 * Get window or buffer local options.
12394 */
12395 dict_T *
12396get_winbuf_options(int bufopt)
12397{
12398 dict_T *d;
12399 int opt_idx;
12400
12401 d = dict_alloc();
12402 if (d == NULL)
12403 return NULL;
12404
12405 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
12406 {
12407 struct vimoption *opt = &options[opt_idx];
12408
12409 if ((bufopt && (opt->indir & PV_BUF))
12410 || (!bufopt && (opt->indir & PV_WIN)))
12411 {
12412 char_u *varp = get_varp(opt);
12413
12414 if (varp != NULL)
12415 {
12416 if (opt->flags & P_STRING)
12417 dict_add_nr_str(d, opt->fullname, 0L, *(char_u **)varp);
Bram Moolenaar789a5c02016-09-12 19:51:11 +020012418 else if (opt->flags & P_NUM)
12419 dict_add_nr_str(d, opt->fullname, *(long *)varp, NULL);
Bram Moolenaarb5ae48e2016-08-12 22:23:25 +020012420 else
Bram Moolenaar789a5c02016-09-12 19:51:11 +020012421 dict_add_nr_str(d, opt->fullname, *(int *)varp, NULL);
Bram Moolenaarb5ae48e2016-08-12 22:23:25 +020012422 }
12423 }
12424 }
12425
12426 return d;
12427}
12428#endif