blob: 39aef6eda6e2c6faffec33b412d0d2a9694e793a [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 Moolenaar9be7c042017-01-14 14:28:30 +0100110#define PV_FP OPT_BOTH(OPT_BUF(BV_FP))
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000111#ifdef FEAT_EVAL
112# define PV_FEX OPT_BUF(BV_FEX)
113#endif
114#define PV_FF OPT_BUF(BV_FF)
115#define PV_FLP OPT_BUF(BV_FLP)
116#define PV_FO OPT_BUF(BV_FO)
117#ifdef FEAT_AUTOCMD
118# define PV_FT OPT_BUF(BV_FT)
119#endif
120#define PV_IMI OPT_BUF(BV_IMI)
121#define PV_IMS OPT_BUF(BV_IMS)
122#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
123# define PV_INDE OPT_BUF(BV_INDE)
124# define PV_INDK OPT_BUF(BV_INDK)
125#endif
126#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
127# define PV_INEX OPT_BUF(BV_INEX)
128#endif
129#define PV_INF OPT_BUF(BV_INF)
130#define PV_ISK OPT_BUF(BV_ISK)
131#ifdef FEAT_CRYPT
132# define PV_KEY OPT_BUF(BV_KEY)
133#endif
134#ifdef FEAT_KEYMAP
135# define PV_KMAP OPT_BUF(BV_KMAP)
136#endif
137#define PV_KP OPT_BOTH(OPT_BUF(BV_KP))
138#ifdef FEAT_LISP
139# define PV_LISP OPT_BUF(BV_LISP)
Bram Moolenaaraf6c1312014-03-12 18:55:58 +0100140# define PV_LW OPT_BOTH(OPT_BUF(BV_LW))
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000141#endif
Bram Moolenaar2c7292d2017-03-05 17:43:31 +0100142#ifdef FEAT_MBYTE
143# define PV_MENC OPT_BOTH(OPT_BUF(BV_MENC))
144#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000145#define PV_MA OPT_BUF(BV_MA)
146#define PV_ML OPT_BUF(BV_ML)
147#define PV_MOD OPT_BUF(BV_MOD)
148#define PV_MPS OPT_BUF(BV_MPS)
149#define PV_NF OPT_BUF(BV_NF)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000150#ifdef FEAT_COMPL_FUNC
151# define PV_OFU OPT_BUF(BV_OFU)
152#endif
153#define PV_PATH OPT_BOTH(OPT_BUF(BV_PATH))
154#define PV_PI OPT_BUF(BV_PI)
155#ifdef FEAT_TEXTOBJ
156# define PV_QE OPT_BUF(BV_QE)
157#endif
158#define PV_RO OPT_BUF(BV_RO)
159#ifdef FEAT_SMARTINDENT
160# define PV_SI OPT_BUF(BV_SI)
161#endif
Bram Moolenaar48e330a2016-02-23 14:53:34 +0100162#define PV_SN OPT_BUF(BV_SN)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000163#ifdef FEAT_SYN_HL
164# define PV_SMC OPT_BUF(BV_SMC)
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000165# define PV_SYN OPT_BUF(BV_SYN)
166#endif
167#ifdef FEAT_SPELL
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000168# define PV_SPC OPT_BUF(BV_SPC)
169# define PV_SPF OPT_BUF(BV_SPF)
170# define PV_SPL OPT_BUF(BV_SPL)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000171#endif
172#define PV_STS OPT_BUF(BV_STS)
173#ifdef FEAT_SEARCHPATH
174# define PV_SUA OPT_BUF(BV_SUA)
175#endif
176#define PV_SW OPT_BUF(BV_SW)
177#define PV_SWF OPT_BUF(BV_SWF)
178#define PV_TAGS OPT_BOTH(OPT_BUF(BV_TAGS))
Bram Moolenaar0f6562e2015-11-24 18:48:14 +0100179#define PV_TC OPT_BOTH(OPT_BUF(BV_TC))
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000180#define PV_TS OPT_BUF(BV_TS)
181#define PV_TW OPT_BUF(BV_TW)
182#define PV_TX OPT_BUF(BV_TX)
Bram Moolenaar55debbe2010-05-23 23:34:36 +0200183#ifdef FEAT_PERSISTENT_UNDO
184# define PV_UDF OPT_BUF(BV_UDF)
185#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000186#define PV_WM OPT_BUF(BV_WM)
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000187
188/*
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000189 * Definition of the PV_ values for window-local options.
190 * The WV_ values are defined in option.h.
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000191 */
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000192#define PV_LIST OPT_WIN(WV_LIST)
193#ifdef FEAT_ARABIC
194# define PV_ARAB OPT_WIN(WV_ARAB)
195#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +0200196#ifdef FEAT_LINEBREAK
197# define PV_BRI OPT_WIN(WV_BRI)
198# define PV_BRIOPT OPT_WIN(WV_BRIOPT)
199#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000200#ifdef FEAT_DIFF
201# define PV_DIFF OPT_WIN(WV_DIFF)
202#endif
203#ifdef FEAT_FOLDING
204# define PV_FDC OPT_WIN(WV_FDC)
205# define PV_FEN OPT_WIN(WV_FEN)
206# define PV_FDI OPT_WIN(WV_FDI)
207# define PV_FDL OPT_WIN(WV_FDL)
208# define PV_FDM OPT_WIN(WV_FDM)
209# define PV_FML OPT_WIN(WV_FML)
210# define PV_FDN OPT_WIN(WV_FDN)
211# ifdef FEAT_EVAL
212# define PV_FDE OPT_WIN(WV_FDE)
213# define PV_FDT OPT_WIN(WV_FDT)
214# endif
215# define PV_FMR OPT_WIN(WV_FMR)
216#endif
217#ifdef FEAT_LINEBREAK
218# define PV_LBR OPT_WIN(WV_LBR)
219#endif
220#define PV_NU OPT_WIN(WV_NU)
Bram Moolenaar64486672010-05-16 15:46:46 +0200221#define PV_RNU OPT_WIN(WV_RNU)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000222#ifdef FEAT_LINEBREAK
223# define PV_NUW OPT_WIN(WV_NUW)
224#endif
225#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
226# define PV_PVW OPT_WIN(WV_PVW)
227#endif
228#ifdef FEAT_RIGHTLEFT
229# define PV_RL OPT_WIN(WV_RL)
230# define PV_RLC OPT_WIN(WV_RLC)
231#endif
232#ifdef FEAT_SCROLLBIND
233# define PV_SCBIND OPT_WIN(WV_SCBIND)
234#endif
235#define PV_SCROLL OPT_WIN(WV_SCROLL)
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000236#ifdef FEAT_SPELL
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000237# define PV_SPELL OPT_WIN(WV_SPELL)
238#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000239#ifdef FEAT_SYN_HL
240# define PV_CUC OPT_WIN(WV_CUC)
241# define PV_CUL OPT_WIN(WV_CUL)
Bram Moolenaar1a384422010-07-14 19:53:30 +0200242# define PV_CC OPT_WIN(WV_CC)
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000243#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000244#ifdef FEAT_STL_OPT
245# define PV_STL OPT_BOTH(OPT_WIN(WV_STL))
246#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +0100247#define PV_UL OPT_BOTH(OPT_BUF(BV_UL))
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000248#ifdef FEAT_WINDOWS
249# define PV_WFH OPT_WIN(WV_WFH)
Bram Moolenaar97b2ad32006-03-18 21:40:56 +0000250# define PV_WFW OPT_WIN(WV_WFW)
251#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000252#define PV_WRAP OPT_WIN(WV_WRAP)
Bram Moolenaar860cae12010-06-05 23:22:07 +0200253#ifdef FEAT_CURSORBIND
254# define PV_CRBIND OPT_WIN(WV_CRBIND)
255#endif
256#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +0200257# define PV_COCU OPT_WIN(WV_COCU)
258# define PV_COLE OPT_WIN(WV_COLE)
Bram Moolenaar860cae12010-06-05 23:22:07 +0200259#endif
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200260#ifdef FEAT_TERMINAL
Bram Moolenaar1b0675c2017-07-15 14:04:01 +0200261# define PV_TK OPT_WIN(WV_TK)
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200262# define PV_TMS OPT_WIN(WV_TMS)
263#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +0200264#ifdef FEAT_SIGNS
265# define PV_SCL OPT_WIN(WV_SCL)
266#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000267
268/* WV_ and BV_ values get typecasted to this for the "indir" field */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000269typedef enum
270{
Bram Moolenaar7d96acd2008-06-09 15:07:54 +0000271 PV_NONE = 0,
272 PV_MAXVAL = 0xffff /* to avoid warnings for value out of range */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000273} idopt_T;
274
275/*
276 * Options local to a window have a value local to a buffer and global to all
277 * buffers. Indicate this by setting "var" to VAR_WIN.
278 */
279#define VAR_WIN ((char_u *)-1)
280
281/*
Bram Moolenaar9b2200a2006-03-20 21:55:45 +0000282 * These are the global values for options which are also local to a buffer.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000283 * Only to be used in option.c!
284 */
285static int p_ai;
286static int p_bin;
287#ifdef FEAT_MBYTE
288static int p_bomb;
289#endif
290#if defined(FEAT_QUICKFIX)
291static char_u *p_bh;
292static char_u *p_bt;
293#endif
294static int p_bl;
295static int p_ci;
296#ifdef FEAT_CINDENT
297static int p_cin;
298static char_u *p_cink;
299static char_u *p_cino;
300#endif
301#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
302static char_u *p_cinw;
303#endif
304#ifdef FEAT_COMMENTS
305static char_u *p_com;
306#endif
307#ifdef FEAT_FOLDING
308static char_u *p_cms;
309#endif
310#ifdef FEAT_INS_EXPAND
311static char_u *p_cpt;
312#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000313#ifdef FEAT_COMPL_FUNC
314static char_u *p_cfu;
Bram Moolenaare344bea2005-09-01 20:46:49 +0000315static char_u *p_ofu;
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000316#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000317static int p_eol;
Bram Moolenaar34d72d42015-07-17 14:18:08 +0200318static int p_fixeol;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000319static int p_et;
320#ifdef FEAT_MBYTE
321static char_u *p_fenc;
322#endif
323static char_u *p_ff;
324static char_u *p_fo;
Bram Moolenaar86b68352004-12-27 21:59:20 +0000325static char_u *p_flp;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000326#ifdef FEAT_AUTOCMD
327static char_u *p_ft;
328#endif
329static long p_iminsert;
330static long p_imsearch;
331#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
332static char_u *p_inex;
333#endif
334#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
335static char_u *p_inde;
336static char_u *p_indk;
337#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +0000338#if defined(FEAT_EVAL)
339static char_u *p_fex;
340#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000341static int p_inf;
342static char_u *p_isk;
343#ifdef FEAT_CRYPT
344static char_u *p_key;
345#endif
346#ifdef FEAT_LISP
347static int p_lisp;
348#endif
349static int p_ml;
350static int p_ma;
351static int p_mod;
352static char_u *p_mps;
353static char_u *p_nf;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000354static int p_pi;
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000355#ifdef FEAT_TEXTOBJ
356static char_u *p_qe;
357#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000358static int p_ro;
359#ifdef FEAT_SMARTINDENT
360static int p_si;
361#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000362static int p_sn;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000363static long p_sts;
364#if defined(FEAT_SEARCHPATH)
365static char_u *p_sua;
366#endif
367static long p_sw;
368static int p_swf;
369#ifdef FEAT_SYN_HL
Bram Moolenaar3b56eb32005-07-11 22:40:32 +0000370static long p_smc;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000371static char_u *p_syn;
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000372#endif
373#ifdef FEAT_SPELL
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +0000374static char_u *p_spc;
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000375static char_u *p_spf;
Bram Moolenaar217ad922005-03-20 22:37:15 +0000376static char_u *p_spl;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000377#endif
378static long p_ts;
379static long p_tw;
380static int p_tx;
Bram Moolenaar55debbe2010-05-23 23:34:36 +0200381#ifdef FEAT_PERSISTENT_UNDO
382static int p_udf;
383#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000384static long p_wm;
385#ifdef FEAT_KEYMAP
386static char_u *p_keymap;
387#endif
388
389/* Saved values for when 'bin' is set. */
390static int p_et_nobin;
391static int p_ml_nobin;
392static long p_tw_nobin;
393static long p_wm_nobin;
394
395/* Saved values for when 'paste' is set */
Bram Moolenaar54f018c2015-09-15 17:30:40 +0200396static int p_ai_nopaste;
397static int p_et_nopaste;
398static long p_sts_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000399static long p_tw_nopaste;
400static long p_wm_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000401
402struct vimoption
403{
404 char *fullname; /* full option name */
405 char *shortname; /* permissible abbreviation */
406 long_u flags; /* see below */
407 char_u *var; /* global option: pointer to variable;
408 * window-local option: VAR_WIN;
409 * buffer-local option: global value */
410 idopt_T indir; /* global option: PV_NONE;
411 * local option: indirect option index */
412 char_u *def_val[2]; /* default values for variable (vi and vim) */
413#ifdef FEAT_EVAL
414 scid_T scriptID; /* script in which the option was last set */
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000415# define SCRIPTID_INIT , 0
416#else
417# define SCRIPTID_INIT
Bram Moolenaar071d4272004-06-13 20:20:40 +0000418#endif
419};
420
421#define VI_DEFAULT 0 /* def_val[VI_DEFAULT] is Vi default value */
422#define VIM_DEFAULT 1 /* def_val[VIM_DEFAULT] is Vim default value */
423
424/*
425 * Flags
426 */
427#define P_BOOL 0x01 /* the option is boolean */
428#define P_NUM 0x02 /* the option is numeric */
429#define P_STRING 0x04 /* the option is a string */
430#define P_ALLOCED 0x08 /* the string option is in allocated memory,
Bram Moolenaar363cb672009-07-22 12:28:17 +0000431 must use free_string_option() when
432 assigning new value. Not set if default is
433 the same. */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000434#define P_EXPAND 0x10 /* environment expansion. NOTE: P_EXPAND can
435 never be used for local or hidden options! */
436#define P_NODEFAULT 0x40 /* don't set to default value */
437#define P_DEF_ALLOCED 0x80 /* default value is in allocated memory, must
438 use vim_free() when assigning new value */
439#define P_WAS_SET 0x100 /* option has been set/reset */
440#define P_NO_MKRC 0x200 /* don't include in :mkvimrc output */
441#define P_VI_DEF 0x400 /* Use Vi default for Vim */
442#define P_VIM 0x800 /* Vim option, reset when 'cp' set */
443
444 /* when option changed, what to display: */
445#define P_RSTAT 0x1000 /* redraw status lines */
Bram Moolenaara2477fd2016-12-03 15:13:20 +0100446#define P_RWIN 0x2000 /* redraw current window and recompute text */
447#define P_RBUF 0x4000 /* redraw current buffer and recompute text */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000448#define P_RALL 0x6000 /* redraw all windows */
449#define P_RCLR 0x7000 /* clear and redraw all */
450
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200451#define P_COMMA 0x8000 /* comma separated list */
452#define P_ONECOMMA 0x18000L /* P_COMMA and cannot have two consecutive
453 * commas */
454#define P_NODUP 0x20000L /* don't allow duplicate strings */
455#define P_FLAGLIST 0x40000L /* list of single-char flags */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000456
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200457#define P_SECURE 0x80000L /* cannot change in modeline or secure mode */
458#define P_GETTEXT 0x100000L /* expand default value with _() */
459#define P_NOGLOB 0x200000L /* do not use local value for global vimrc */
460#define P_NFNAME 0x400000L /* only normal file name chars allowed */
461#define P_INSECURE 0x800000L /* option was set from a modeline */
462#define P_PRI_MKRC 0x1000000L /* priority for :mkvimrc (setting option has
Bram Moolenaar7554da42016-11-25 22:04:13 +0100463 side effects) */
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200464#define P_NO_ML 0x2000000L /* not allowed in modeline */
465#define P_CURSWANT 0x4000000L /* update curswant required; not needed when
Bram Moolenaar913077c2012-03-28 19:59:04 +0200466 * there is a redraw flag */
Bram Moolenaar7554da42016-11-25 22:04:13 +0100467#define P_NDNAME 0x8000000L /* only normal dir name chars allowed */
Bram Moolenaara2477fd2016-12-03 15:13:20 +0100468#define P_RWINONLY 0x10000000L /* only redraw current window */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000469
Bram Moolenaar362e1a32006-03-06 23:29:24 +0000470#define ISK_LATIN1 (char_u *)"@,48-57,_,192-255"
471
Bram Moolenaar910f66f2006-04-05 20:41:53 +0000472/* 'isprint' for latin1 is also used for MS-Windows cp1252, where 0x80 is used
473 * for the currency sign. */
Bram Moolenaar48e330a2016-02-23 14:53:34 +0100474#if defined(MSWIN)
Bram Moolenaare2f98b92006-03-29 21:18:24 +0000475# define ISP_LATIN1 (char_u *)"@,~-255"
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +0000476#else
477# define ISP_LATIN1 (char_u *)"@,161-255"
478#endif
479
Bram Moolenaar44a2f922016-03-19 22:11:51 +0100480/* Make the string as short as possible when compiling with few features. */
Bram Moolenaar3991dab2006-03-27 17:01:56 +0000481#if defined(FEAT_DIFF) || defined(FEAT_FOLDING) || defined(FEAT_SPELL) \
Bram Moolenaar44a2f922016-03-19 22:11:51 +0100482 || defined(FEAT_WINDOWS) || defined(FEAT_CLIPBOARD) \
Bram Moolenaar21020352017-06-13 17:21:04 +0200483 || defined(FEAT_INS_EXPAND) || defined(FEAT_SYN_HL) \
484 || defined(FEAT_CONCEAL) || defined(FEAT_QUICKFIX)
485# define HIGHLIGHT_INIT "8:SpecialKey,~:EndOfBuffer,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,m:MoreMsg,M:ModeMsg,n:LineNr,N:CursorLineNr,r:Question,s:StatusLine,S:StatusLineNC,c:VertSplit,t:Title,v:Visual,V:VisualNOS,w:WarningMsg,W:WildMenu,f:Folded,F:FoldColumn,A:DiffAdd,C:DiffChange,D:DiffDelete,T:DiffText,>:SignColumn,-:Conceal,B:SpellBad,P:SpellCap,R:SpellRare,L:SpellLocal,+:Pmenu,=:PmenuSel,x:PmenuSbar,X:PmenuThumb,*:TabLine,#:TabLineSel,_:TabLineFill,!:CursorColumn,.:CursorLine,o:ColorColumn,q:QuickFixLine"
Bram Moolenaar3991dab2006-03-27 17:01:56 +0000486#else
Bram Moolenaar06ca5132012-03-23 16:25:17 +0100487# 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 +0000488#endif
489
Bram Moolenaarf42dd3c2017-01-28 16:06:38 +0100490/* Default python version for pyx* commands */
491#if defined(FEAT_PYTHON) && defined(FEAT_PYTHON3)
492# define DEFAULT_PYTHON_VER 0
493#elif defined(FEAT_PYTHON3)
494# define DEFAULT_PYTHON_VER 3
495#elif defined(FEAT_PYTHON)
496# define DEFAULT_PYTHON_VER 2
497#else
498# define DEFAULT_PYTHON_VER 0
499#endif
500
Bram Moolenaar071d4272004-06-13 20:20:40 +0000501/*
502 * options[] is initialized here.
503 * The order of the options MUST be alphabetic for ":set all" and findoption().
504 * All option names MUST start with a lowercase letter (for findoption()).
505 * Exception: "t_" options are at the end.
506 * The options with a NULL variable are 'hidden': a set command for them is
507 * ignored and they are not printed.
508 */
Bram Moolenaare89ff042016-02-20 22:17:05 +0100509static struct vimoption options[] =
Bram Moolenaar071d4272004-06-13 20:20:40 +0000510{
Bram Moolenaar913077c2012-03-28 19:59:04 +0200511 {"aleph", "al", P_NUM|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000512#ifdef FEAT_RIGHTLEFT
513 (char_u *)&p_aleph, PV_NONE,
514#else
515 (char_u *)NULL, PV_NONE,
516#endif
517 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +0100518#if (defined(WIN3264)) && !defined(FEAT_GUI_W32)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000519 (char_u *)128L,
520#else
521 (char_u *)224L,
522#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000523 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000524 {"antialias", "anti", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
525#if defined(FEAT_GUI) && defined(MACOS_X)
526 (char_u *)&p_antialias, PV_NONE,
527 {(char_u *)FALSE, (char_u *)FALSE}
528#else
529 (char_u *)NULL, PV_NONE,
530 {(char_u *)FALSE, (char_u *)FALSE}
531#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000532 SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +0200533 {"arabic", "arab", P_BOOL|P_VI_DEF|P_VIM|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000534#ifdef FEAT_ARABIC
535 (char_u *)VAR_WIN, PV_ARAB,
536#else
537 (char_u *)NULL, PV_NONE,
538#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000539 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000540 {"arabicshape", "arshape", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
541#ifdef FEAT_ARABIC
542 (char_u *)&p_arshape, PV_NONE,
543#else
544 (char_u *)NULL, PV_NONE,
545#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000546 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000547 {"allowrevins", "ari", P_BOOL|P_VI_DEF|P_VIM,
548#ifdef FEAT_RIGHTLEFT
549 (char_u *)&p_ari, PV_NONE,
550#else
551 (char_u *)NULL, PV_NONE,
552#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000553 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000554 {"altkeymap", "akm", P_BOOL|P_VI_DEF,
555#ifdef FEAT_FKMAP
556 (char_u *)&p_altkeymap, PV_NONE,
557#else
558 (char_u *)NULL, PV_NONE,
559#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000560 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000561 {"ambiwidth", "ambw", P_STRING|P_VI_DEF|P_RCLR,
562#if defined(FEAT_MBYTE)
563 (char_u *)&p_ambw, PV_NONE,
564 {(char_u *)"single", (char_u *)0L}
565#else
566 (char_u *)NULL, PV_NONE,
567 {(char_u *)0L, (char_u *)0L}
568#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000569 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000570 {"autochdir", "acd", P_BOOL|P_VI_DEF,
Bram Moolenaara713ff82017-02-25 22:18:43 +0100571#ifdef FEAT_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +0000572 (char_u *)&p_acd, PV_NONE,
Bram Moolenaara713ff82017-02-25 22:18:43 +0100573 {(char_u *)FALSE, (char_u *)0L}
574#else
575 (char_u *)NULL, PV_NONE,
576 {(char_u *)0L, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000577#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +0100578 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000579 {"autoindent", "ai", P_BOOL|P_VI_DEF,
580 (char_u *)&p_ai, PV_AI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000581 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000582 {"autoprint", "ap", P_BOOL|P_VI_DEF,
583 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000584 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000585 {"autoread", "ar", P_BOOL|P_VI_DEF,
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000586 (char_u *)&p_ar, PV_AR,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000587 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000588 {"autowrite", "aw", P_BOOL|P_VI_DEF,
589 (char_u *)&p_aw, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000590 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000591 {"autowriteall","awa", P_BOOL|P_VI_DEF,
592 (char_u *)&p_awa, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000593 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000594 {"background", "bg", P_STRING|P_VI_DEF|P_RCLR,
595 (char_u *)&p_bg, PV_NONE,
596 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +0100597#if (defined(WIN3264)) && !defined(FEAT_GUI)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000598 (char_u *)"dark",
599#else
600 (char_u *)"light",
601#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000602 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200603 {"backspace", "bs", P_STRING|P_VI_DEF|P_VIM|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000604 (char_u *)&p_bs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000605 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000606 {"backup", "bk", P_BOOL|P_VI_DEF|P_VIM,
607 (char_u *)&p_bk, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000608 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200609 {"backupcopy", "bkc", P_STRING|P_VIM|P_ONECOMMA|P_NODUP,
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +0200610 (char_u *)&p_bkc, PV_BKC,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000611#ifdef UNIX
612 {(char_u *)"yes", (char_u *)"auto"}
613#else
614 {(char_u *)"auto", (char_u *)"auto"}
615#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000616 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200617 {"backupdir", "bdir", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA
618 |P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000619 (char_u *)&p_bdir, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000620 {(char_u *)DFLT_BDIR, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +0000621 {"backupext", "bex", P_STRING|P_VI_DEF|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000622 (char_u *)&p_bex, PV_NONE,
623 {
624#ifdef VMS
625 (char_u *)"_",
626#else
627 (char_u *)"~",
628#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000629 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200630 {"backupskip", "bsk", P_STRING|P_VI_DEF|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000631#ifdef FEAT_WILDIGN
632 (char_u *)&p_bsk, PV_NONE,
633 {(char_u *)"", (char_u *)0L}
634#else
635 (char_u *)NULL, PV_NONE,
636 {(char_u *)0L, (char_u *)0L}
637#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000638 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000639 {"balloondelay","bdlay",P_NUM|P_VI_DEF,
Bram Moolenaarc43a8b82017-02-25 21:12:29 +0100640#ifdef FEAT_BEVAL
Bram Moolenaar071d4272004-06-13 20:20:40 +0000641 (char_u *)&p_bdlay, PV_NONE,
Bram Moolenaarc43a8b82017-02-25 21:12:29 +0100642 {(char_u *)600L, (char_u *)0L}
643#else
644 (char_u *)NULL, PV_NONE,
645 {(char_u *)0L, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000646#endif
Bram Moolenaarc43a8b82017-02-25 21:12:29 +0100647 SCRIPTID_INIT},
648 {"ballooneval", "beval",P_BOOL|P_VI_DEF|P_NO_MKRC,
649#ifdef FEAT_BEVAL
650 (char_u *)&p_beval, PV_NONE,
651 {(char_u *)FALSE, (char_u *)0L}
652#else
653 (char_u *)NULL, PV_NONE,
654 {(char_u *)0L, (char_u *)0L}
655#endif
656 SCRIPTID_INIT},
657 {"balloonexpr", "bexpr", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
658#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
659 (char_u *)&p_bexpr, PV_BEXPR,
660 {(char_u *)"", (char_u *)0L}
661#else
662 (char_u *)NULL, PV_NONE,
663 {(char_u *)0L, (char_u *)0L}
664#endif
665 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000666 {"beautify", "bf", P_BOOL|P_VI_DEF,
667 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000668 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar165bc692015-07-21 17:53:25 +0200669 {"belloff", "bo", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
670 (char_u *)&p_bo, PV_NONE,
671 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000672 {"binary", "bin", P_BOOL|P_VI_DEF|P_RSTAT,
673 (char_u *)&p_bin, PV_BIN,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000674 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000675 {"bioskey", "biosk",P_BOOL|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000676 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000677 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000678 {"bomb", NULL, P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
679#ifdef FEAT_MBYTE
680 (char_u *)&p_bomb, PV_BOMB,
681#else
682 (char_u *)NULL, PV_NONE,
683#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000684 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000685 {"breakat", "brk", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST,
686#ifdef FEAT_LINEBREAK
687 (char_u *)&p_breakat, PV_NONE,
688 {(char_u *)" \t!@*-+;:,./?", (char_u *)0L}
689#else
690 (char_u *)NULL, PV_NONE,
691 {(char_u *)0L, (char_u *)0L}
692#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000693 SCRIPTID_INIT},
Bram Moolenaar597a4222014-06-25 14:39:50 +0200694 {"breakindent", "bri", P_BOOL|P_VI_DEF|P_VIM|P_RWIN,
695#ifdef FEAT_LINEBREAK
696 (char_u *)VAR_WIN, PV_BRI,
697 {(char_u *)FALSE, (char_u *)0L}
698#else
699 (char_u *)NULL, PV_NONE,
700 {(char_u *)0L, (char_u *)0L}
701#endif
702 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200703 {"breakindentopt", "briopt", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF
704 |P_ONECOMMA|P_NODUP,
Bram Moolenaar597a4222014-06-25 14:39:50 +0200705#ifdef FEAT_LINEBREAK
706 (char_u *)VAR_WIN, PV_BRIOPT,
707 {(char_u *)"", (char_u *)NULL}
708#else
709 (char_u *)NULL, PV_NONE,
710 {(char_u *)"", (char_u *)NULL}
711#endif
712 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000713 {"browsedir", "bsdir",P_STRING|P_VI_DEF,
714#ifdef FEAT_BROWSE
715 (char_u *)&p_bsdir, PV_NONE,
716 {(char_u *)"last", (char_u *)0L}
717#else
718 (char_u *)NULL, PV_NONE,
719 {(char_u *)0L, (char_u *)0L}
720#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000721 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000722 {"bufhidden", "bh", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB,
723#if defined(FEAT_QUICKFIX)
724 (char_u *)&p_bh, PV_BH,
725 {(char_u *)"", (char_u *)0L}
726#else
727 (char_u *)NULL, PV_NONE,
728 {(char_u *)0L, (char_u *)0L}
729#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000730 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000731 {"buflisted", "bl", P_BOOL|P_VI_DEF|P_NOGLOB,
732 (char_u *)&p_bl, PV_BL,
733 {(char_u *)1L, (char_u *)0L}
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000734 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000735 {"buftype", "bt", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB,
736#if defined(FEAT_QUICKFIX)
737 (char_u *)&p_bt, PV_BT,
738 {(char_u *)"", (char_u *)0L}
739#else
740 (char_u *)NULL, PV_NONE,
741 {(char_u *)0L, (char_u *)0L}
742#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000743 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200744 {"casemap", "cmp", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaarfa1d1402006-03-25 21:59:56 +0000745#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +0000746 (char_u *)&p_cmp, PV_NONE,
747 {(char_u *)"internal,keepascii", (char_u *)0L}
Bram Moolenaarfa1d1402006-03-25 21:59:56 +0000748#else
749 (char_u *)NULL, PV_NONE,
750 {(char_u *)0L, (char_u *)0L}
751#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000752 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000753 {"cdpath", "cd", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
754#ifdef FEAT_SEARCHPATH
755 (char_u *)&p_cdpath, PV_NONE,
756 {(char_u *)",,", (char_u *)0L}
757#else
758 (char_u *)NULL, PV_NONE,
759 {(char_u *)0L, (char_u *)0L}
760#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000761 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000762 {"cedit", NULL, P_STRING,
763#ifdef FEAT_CMDWIN
764 (char_u *)&p_cedit, PV_NONE,
765 {(char_u *)"", (char_u *)CTRL_F_STR}
766#else
767 (char_u *)NULL, PV_NONE,
768 {(char_u *)0L, (char_u *)0L}
769#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000770 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000771 {"charconvert", "ccv", P_STRING|P_VI_DEF|P_SECURE,
772#if defined(FEAT_MBYTE) && defined(FEAT_EVAL)
773 (char_u *)&p_ccv, PV_NONE,
774 {(char_u *)"", (char_u *)0L}
775#else
776 (char_u *)NULL, PV_NONE,
777 {(char_u *)0L, (char_u *)0L}
778#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000779 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000780 {"cindent", "cin", P_BOOL|P_VI_DEF|P_VIM,
781#ifdef FEAT_CINDENT
782 (char_u *)&p_cin, PV_CIN,
783#else
784 (char_u *)NULL, PV_NONE,
785#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000786 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200787 {"cinkeys", "cink", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000788#ifdef FEAT_CINDENT
789 (char_u *)&p_cink, PV_CINK,
790 {(char_u *)"0{,0},0),:,0#,!^F,o,O,e", (char_u *)0L}
791#else
792 (char_u *)NULL, PV_NONE,
793 {(char_u *)0L, (char_u *)0L}
794#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000795 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200796 {"cinoptions", "cino", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000797#ifdef FEAT_CINDENT
798 (char_u *)&p_cino, PV_CINO,
799#else
800 (char_u *)NULL, PV_NONE,
801#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000802 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200803 {"cinwords", "cinw", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000804#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
805 (char_u *)&p_cinw, PV_CINW,
806 {(char_u *)"if,else,while,do,for,switch",
807 (char_u *)0L}
808#else
809 (char_u *)NULL, PV_NONE,
810 {(char_u *)0L, (char_u *)0L}
811#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000812 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200813 {"clipboard", "cb", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000814#ifdef FEAT_CLIPBOARD
815 (char_u *)&p_cb, PV_NONE,
816# ifdef FEAT_XCLIPBOARD
817 {(char_u *)"autoselect,exclude:cons\\|linux",
818 (char_u *)0L}
819# else
820 {(char_u *)"", (char_u *)0L}
821# endif
822#else
823 (char_u *)NULL, PV_NONE,
824 {(char_u *)"", (char_u *)0L}
825#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000826 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000827 {"cmdheight", "ch", P_NUM|P_VI_DEF|P_RALL,
828 (char_u *)&p_ch, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000829 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000830 {"cmdwinheight", "cwh", P_NUM|P_VI_DEF,
831#ifdef FEAT_CMDWIN
832 (char_u *)&p_cwh, PV_NONE,
833#else
834 (char_u *)NULL, PV_NONE,
835#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000836 {(char_u *)7L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200837 {"colorcolumn", "cc", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_RWIN,
Bram Moolenaar1a384422010-07-14 19:53:30 +0200838#ifdef FEAT_SYN_HL
839 (char_u *)VAR_WIN, PV_CC,
840#else
841 (char_u *)NULL, PV_NONE,
842#endif
843 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000844 {"columns", "co", P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR,
845 (char_u *)&Columns, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000846 {(char_u *)80L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200847 {"comments", "com", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA
848 |P_NODUP|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000849#ifdef FEAT_COMMENTS
850 (char_u *)&p_com, PV_COM,
851 {(char_u *)"s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-",
852 (char_u *)0L}
853#else
854 (char_u *)NULL, PV_NONE,
855 {(char_u *)0L, (char_u *)0L}
856#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000857 SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +0200858 {"commentstring", "cms", P_STRING|P_ALLOCED|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000859#ifdef FEAT_FOLDING
860 (char_u *)&p_cms, PV_CMS,
861 {(char_u *)"/*%s*/", (char_u *)0L}
862#else
863 (char_u *)NULL, PV_NONE,
864 {(char_u *)0L, (char_u *)0L}
865#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000866 SCRIPTID_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +0000867 /* P_PRI_MKRC isn't needed here, optval_default()
868 * always returns TRUE for 'compatible' */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000869 {"compatible", "cp", P_BOOL|P_RALL,
870 (char_u *)&p_cp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000871 {(char_u *)TRUE, (char_u *)FALSE} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200872 {"complete", "cpt", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000873#ifdef FEAT_INS_EXPAND
874 (char_u *)&p_cpt, PV_CPT,
875 {(char_u *)".,w,b,u,t,i", (char_u *)0L}
876#else
877 (char_u *)NULL, PV_NONE,
878 {(char_u *)0L, (char_u *)0L}
879#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000880 SCRIPTID_INIT},
Bram Moolenaarf5963f72010-07-23 22:10:27 +0200881 {"concealcursor","cocu", P_STRING|P_ALLOCED|P_RWIN|P_VI_DEF,
Bram Moolenaar860cae12010-06-05 23:22:07 +0200882#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +0200883 (char_u *)VAR_WIN, PV_COCU,
884 {(char_u *)"", (char_u *)NULL}
885#else
886 (char_u *)NULL, PV_NONE,
887 {(char_u *)NULL, (char_u *)0L}
888#endif
889 SCRIPTID_INIT},
890 {"conceallevel","cole", P_NUM|P_RWIN|P_VI_DEF,
891#ifdef FEAT_CONCEAL
892 (char_u *)VAR_WIN, PV_COLE,
Bram Moolenaar860cae12010-06-05 23:22:07 +0200893#else
894 (char_u *)NULL, PV_NONE,
895#endif
896 {(char_u *)0L, (char_u *)0L}
897 SCRIPTID_INIT},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000898 {"completefunc", "cfu", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE,
899#ifdef FEAT_COMPL_FUNC
900 (char_u *)&p_cfu, PV_CFU,
901 {(char_u *)"", (char_u *)0L}
902#else
903 (char_u *)NULL, PV_NONE,
904 {(char_u *)0L, (char_u *)0L}
905#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000906 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200907 {"completeopt", "cot", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar1c7715d2005-10-03 22:02:18 +0000908#ifdef FEAT_INS_EXPAND
909 (char_u *)&p_cot, PV_NONE,
Bram Moolenaarc270d802006-03-11 21:29:41 +0000910 {(char_u *)"menu,preview", (char_u *)0L}
Bram Moolenaar1c7715d2005-10-03 22:02:18 +0000911#else
912 (char_u *)NULL, PV_NONE,
913 {(char_u *)0L, (char_u *)0L}
914#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000915 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000916 {"confirm", "cf", P_BOOL|P_VI_DEF,
917#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
918 (char_u *)&p_confirm, PV_NONE,
919#else
920 (char_u *)NULL, PV_NONE,
921#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000922 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000923 {"conskey", "consk",P_BOOL|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000924 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000925 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000926 {"copyindent", "ci", P_BOOL|P_VI_DEF|P_VIM,
927 (char_u *)&p_ci, PV_CI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000928 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000929 {"cpoptions", "cpo", P_STRING|P_VIM|P_RALL|P_FLAGLIST,
930 (char_u *)&p_cpo, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000931 {(char_u *)CPO_VI, (char_u *)CPO_VIM}
932 SCRIPTID_INIT},
Bram Moolenaar49771f42010-07-20 17:32:38 +0200933 {"cryptmethod", "cm", P_STRING|P_ALLOCED|P_VI_DEF,
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200934#ifdef FEAT_CRYPT
Bram Moolenaar40e6a712010-05-16 22:32:54 +0200935 (char_u *)&p_cm, PV_CM,
Bram Moolenaar49771f42010-07-20 17:32:38 +0200936 {(char_u *)"zip", (char_u *)0L}
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200937#else
938 (char_u *)NULL, PV_NONE,
Bram Moolenaar49771f42010-07-20 17:32:38 +0200939 {(char_u *)0L, (char_u *)0L}
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200940#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +0200941 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000942 {"cscopepathcomp", "cspc", P_NUM|P_VI_DEF|P_VIM,
943#ifdef FEAT_CSCOPE
944 (char_u *)&p_cspc, PV_NONE,
945#else
946 (char_u *)NULL, PV_NONE,
947#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000948 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000949 {"cscopeprg", "csprg", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
950#ifdef FEAT_CSCOPE
951 (char_u *)&p_csprg, PV_NONE,
952 {(char_u *)"cscope", (char_u *)0L}
953#else
954 (char_u *)NULL, PV_NONE,
955 {(char_u *)0L, (char_u *)0L}
956#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000957 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200958 {"cscopequickfix", "csqf", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000959#if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX)
960 (char_u *)&p_csqf, PV_NONE,
961 {(char_u *)"", (char_u *)0L}
962#else
963 (char_u *)NULL, PV_NONE,
964 {(char_u *)0L, (char_u *)0L}
965#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000966 SCRIPTID_INIT},
Bram Moolenaarf7befa92011-06-12 22:13:40 +0200967 {"cscoperelative", "csre", P_BOOL|P_VI_DEF|P_VIM,
968#ifdef FEAT_CSCOPE
969 (char_u *)&p_csre, PV_NONE,
970#else
971 (char_u *)NULL, PV_NONE,
972#endif
973 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000974 {"cscopetag", "cst", P_BOOL|P_VI_DEF|P_VIM,
975#ifdef FEAT_CSCOPE
976 (char_u *)&p_cst, PV_NONE,
977#else
978 (char_u *)NULL, PV_NONE,
979#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000980 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000981 {"cscopetagorder", "csto", P_NUM|P_VI_DEF|P_VIM,
982#ifdef FEAT_CSCOPE
983 (char_u *)&p_csto, PV_NONE,
984#else
985 (char_u *)NULL, PV_NONE,
986#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000987 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000988 {"cscopeverbose", "csverb", P_BOOL|P_VI_DEF|P_VIM,
989#ifdef FEAT_CSCOPE
990 (char_u *)&p_csverbose, PV_NONE,
991#else
992 (char_u *)NULL, PV_NONE,
993#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000994 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar860cae12010-06-05 23:22:07 +0200995 {"cursorbind", "crb", P_BOOL|P_VI_DEF,
996#ifdef FEAT_CURSORBIND
997 (char_u *)VAR_WIN, PV_CRBIND,
998#else
999 (char_u *)NULL, PV_NONE,
1000#endif
1001 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00001002 {"cursorcolumn", "cuc", P_BOOL|P_VI_DEF|P_RWIN,
1003#ifdef FEAT_SYN_HL
1004 (char_u *)VAR_WIN, PV_CUC,
1005#else
1006 (char_u *)NULL, PV_NONE,
1007#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001008 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaara2477fd2016-12-03 15:13:20 +01001009 {"cursorline", "cul", P_BOOL|P_VI_DEF|P_RWINONLY,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00001010#ifdef FEAT_SYN_HL
1011 (char_u *)VAR_WIN, PV_CUL,
1012#else
1013 (char_u *)NULL, PV_NONE,
1014#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001015 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001016 {"debug", NULL, P_STRING|P_VI_DEF,
1017 (char_u *)&p_debug, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001018 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001019 {"define", "def", P_STRING|P_ALLOCED|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001020#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001021 (char_u *)&p_def, PV_DEF,
Bram Moolenaard4755bb2004-09-02 19:12:26 +00001022 {(char_u *)"^\\s*#\\s*define", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001023#else
1024 (char_u *)NULL, PV_NONE,
1025 {(char_u *)NULL, (char_u *)0L}
1026#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001027 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001028 {"delcombine", "deco", P_BOOL|P_VI_DEF|P_VIM,
1029#ifdef FEAT_MBYTE
1030 (char_u *)&p_deco, PV_NONE,
1031#else
1032 (char_u *)NULL, PV_NONE,
1033#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001034 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar7554da42016-11-25 22:04:13 +01001035 {"dictionary", "dict", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP|P_NDNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001036#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001037 (char_u *)&p_dict, PV_DICT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001038#else
1039 (char_u *)NULL, PV_NONE,
1040#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001041 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001042 {"diff", NULL, P_BOOL|P_VI_DEF|P_RWIN|P_NOGLOB,
1043#ifdef FEAT_DIFF
1044 (char_u *)VAR_WIN, PV_DIFF,
1045#else
1046 (char_u *)NULL, PV_NONE,
1047#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001048 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001049 {"diffexpr", "dex", P_STRING|P_VI_DEF|P_SECURE|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001050#if defined(FEAT_DIFF) && defined(FEAT_EVAL)
1051 (char_u *)&p_dex, PV_NONE,
1052 {(char_u *)"", (char_u *)0L}
1053#else
1054 (char_u *)NULL, PV_NONE,
1055 {(char_u *)0L, (char_u *)0L}
1056#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001057 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001058 {"diffopt", "dip", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN|P_ONECOMMA
1059 |P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001060#ifdef FEAT_DIFF
1061 (char_u *)&p_dip, PV_NONE,
1062 {(char_u *)"filler", (char_u *)NULL}
1063#else
1064 (char_u *)NULL, PV_NONE,
1065 {(char_u *)"", (char_u *)NULL}
1066#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001067 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001068 {"digraph", "dg", P_BOOL|P_VI_DEF|P_VIM,
1069#ifdef FEAT_DIGRAPHS
1070 (char_u *)&p_dg, PV_NONE,
1071#else
1072 (char_u *)NULL, PV_NONE,
1073#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001074 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001075 {"directory", "dir", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA
1076 |P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001077 (char_u *)&p_dir, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001078 {(char_u *)DFLT_DIR, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001079 {"display", "dy", P_STRING|P_VI_DEF|P_ONECOMMA|P_RALL|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001080 (char_u *)&p_dy, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001081 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001082 {"eadirection", "ead", P_STRING|P_VI_DEF,
Bram Moolenaar44a2f922016-03-19 22:11:51 +01001083#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00001084 (char_u *)&p_ead, PV_NONE,
1085 {(char_u *)"both", (char_u *)0L}
1086#else
1087 (char_u *)NULL, PV_NONE,
1088 {(char_u *)NULL, (char_u *)0L}
1089#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001090 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001091 {"edcompatible","ed", P_BOOL|P_VI_DEF,
1092 (char_u *)&p_ed, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001093 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar3848e002016-03-19 18:42:29 +01001094 {"emoji", "emo", P_BOOL|P_VI_DEF|P_RCLR,
1095#if defined(FEAT_MBYTE)
1096 (char_u *)&p_emoji, PV_NONE,
1097 {(char_u *)TRUE, (char_u *)0L}
1098#else
1099 (char_u *)NULL, PV_NONE,
1100 {(char_u *)0L, (char_u *)0L}
1101#endif
1102 SCRIPTID_INIT},
Bram Moolenaar865242e2010-07-14 21:12:05 +02001103 {"encoding", "enc", P_STRING|P_VI_DEF|P_RCLR|P_NO_ML,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001104#ifdef FEAT_MBYTE
1105 (char_u *)&p_enc, PV_NONE,
1106 {(char_u *)ENC_DFLT, (char_u *)0L}
1107#else
1108 (char_u *)NULL, PV_NONE,
1109 {(char_u *)0L, (char_u *)0L}
1110#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001111 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001112 {"endofline", "eol", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
1113 (char_u *)&p_eol, PV_EOL,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001114 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001115 {"equalalways", "ea", P_BOOL|P_VI_DEF|P_RALL,
1116 (char_u *)&p_ea, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001117 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001118 {"equalprg", "ep", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001119 (char_u *)&p_ep, PV_EP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001120 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001121 {"errorbells", "eb", P_BOOL|P_VI_DEF,
1122 (char_u *)&p_eb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001123 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001124 {"errorfile", "ef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1125#ifdef FEAT_QUICKFIX
1126 (char_u *)&p_ef, PV_NONE,
1127 {(char_u *)DFLT_ERRORFILE, (char_u *)0L}
1128#else
1129 (char_u *)NULL, PV_NONE,
1130 {(char_u *)NULL, (char_u *)0L}
1131#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001132 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001133 {"errorformat", "efm", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001134#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001135 (char_u *)&p_efm, PV_EFM,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001136 {(char_u *)DFLT_EFM, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001137#else
1138 (char_u *)NULL, PV_NONE,
1139 {(char_u *)NULL, (char_u *)0L}
1140#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001141 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001142 {"esckeys", "ek", P_BOOL|P_VIM,
1143 (char_u *)&p_ek, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001144 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001145 {"eventignore", "ei", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001146#ifdef FEAT_AUTOCMD
1147 (char_u *)&p_ei, PV_NONE,
1148#else
1149 (char_u *)NULL, PV_NONE,
1150#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001151 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001152 {"expandtab", "et", P_BOOL|P_VI_DEF|P_VIM,
1153 (char_u *)&p_et, PV_ET,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001154 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001155 {"exrc", "ex", P_BOOL|P_VI_DEF|P_SECURE,
1156 (char_u *)&p_exrc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001157 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001158 {"fileencoding","fenc", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_RBUF
1159 |P_NO_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001160#ifdef FEAT_MBYTE
1161 (char_u *)&p_fenc, PV_FENC,
1162 {(char_u *)"", (char_u *)0L}
1163#else
1164 (char_u *)NULL, PV_NONE,
1165 {(char_u *)0L, (char_u *)0L}
1166#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001167 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001168 {"fileencodings","fencs", P_STRING|P_VI_DEF|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001169#ifdef FEAT_MBYTE
1170 (char_u *)&p_fencs, PV_NONE,
1171 {(char_u *)"ucs-bom", (char_u *)0L}
1172#else
1173 (char_u *)NULL, PV_NONE,
1174 {(char_u *)0L, (char_u *)0L}
1175#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001176 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001177 {"fileformat", "ff", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_NO_MKRC
1178 |P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001179 (char_u *)&p_ff, PV_FF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001180 {(char_u *)DFLT_FF, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001181 {"fileformats", "ffs", P_STRING|P_VIM|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001182 (char_u *)&p_ffs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001183 {(char_u *)DFLT_FFS_VI, (char_u *)DFLT_FFS_VIM}
1184 SCRIPTID_INIT},
Bram Moolenaar71afbfe2013-03-19 16:49:16 +01001185 {"fileignorecase", "fic", P_BOOL|P_VI_DEF,
1186 (char_u *)&p_fic, PV_NONE,
1187 {
1188#ifdef CASE_INSENSITIVE_FILENAME
1189 (char_u *)TRUE,
1190#else
1191 (char_u *)FALSE,
1192#endif
1193 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001194 {"filetype", "ft", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001195#ifdef FEAT_AUTOCMD
1196 (char_u *)&p_ft, PV_FT,
1197 {(char_u *)"", (char_u *)0L}
1198#else
1199 (char_u *)NULL, PV_NONE,
1200 {(char_u *)0L, (char_u *)0L}
1201#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001202 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001203 {"fillchars", "fcs", P_STRING|P_VI_DEF|P_RALL|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001204#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
1205 (char_u *)&p_fcs, PV_NONE,
1206 {(char_u *)"vert:|,fold:-", (char_u *)0L}
1207#else
1208 (char_u *)NULL, PV_NONE,
1209 {(char_u *)"", (char_u *)0L}
1210#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001211 SCRIPTID_INIT},
Bram Moolenaar34d72d42015-07-17 14:18:08 +02001212 {"fixendofline", "fixeol", P_BOOL|P_VI_DEF|P_RSTAT,
1213 (char_u *)&p_fixeol, PV_FIXEOL,
1214 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001215 {"fkmap", "fk", P_BOOL|P_VI_DEF,
1216#ifdef FEAT_FKMAP
1217 (char_u *)&p_fkmap, PV_NONE,
1218#else
1219 (char_u *)NULL, PV_NONE,
1220#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001221 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001222 {"flash", "fl", P_BOOL|P_VI_DEF,
1223 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001224 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001225 {"foldclose", "fcl", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_RWIN,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001226#ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00001227 (char_u *)&p_fcl, PV_NONE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001228 {(char_u *)"", (char_u *)0L}
1229#else
Bram Moolenaar071d4272004-06-13 20:20:40 +00001230 (char_u *)NULL, PV_NONE,
1231 {(char_u *)NULL, (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01001232#endif
1233 SCRIPTID_INIT},
1234 {"foldcolumn", "fdc", P_NUM|P_VI_DEF|P_RWIN,
1235#ifdef FEAT_FOLDING
1236 (char_u *)VAR_WIN, PV_FDC,
1237 {(char_u *)FALSE, (char_u *)0L}
1238#else
1239 (char_u *)NULL, PV_NONE,
1240 {(char_u *)NULL, (char_u *)0L}
1241#endif
1242 SCRIPTID_INIT},
1243 {"foldenable", "fen", P_BOOL|P_VI_DEF|P_RWIN,
1244#ifdef FEAT_FOLDING
1245 (char_u *)VAR_WIN, PV_FEN,
1246 {(char_u *)TRUE, (char_u *)0L}
1247#else
1248 (char_u *)NULL, PV_NONE,
1249 {(char_u *)NULL, (char_u *)0L}
1250#endif
1251 SCRIPTID_INIT},
1252 {"foldexpr", "fde", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1253#if defined(FEAT_FOLDING) && defined(FEAT_EVAL)
1254 (char_u *)VAR_WIN, PV_FDE,
1255 {(char_u *)"0", (char_u *)NULL}
1256#else
1257 (char_u *)NULL, PV_NONE,
1258 {(char_u *)NULL, (char_u *)0L}
1259#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001260 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001261 {"foldignore", "fdi", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001262#ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00001263 (char_u *)VAR_WIN, PV_FDI,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001264 {(char_u *)"#", (char_u *)NULL}
1265#else
1266 (char_u *)NULL, PV_NONE,
1267 {(char_u *)NULL, (char_u *)0L}
1268#endif
1269 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001270 {"foldlevel", "fdl", P_NUM|P_VI_DEF|P_RWIN,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001271#ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00001272 (char_u *)VAR_WIN, PV_FDL,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001273 {(char_u *)0L, (char_u *)0L}
1274#else
1275 (char_u *)NULL, PV_NONE,
1276 {(char_u *)NULL, (char_u *)0L}
1277#endif
1278 SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001279 {"foldlevelstart","fdls", P_NUM|P_VI_DEF|P_CURSWANT,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001280#ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00001281 (char_u *)&p_fdls, PV_NONE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001282 {(char_u *)-1L, (char_u *)0L}
1283#else
1284 (char_u *)NULL, PV_NONE,
1285 {(char_u *)NULL, (char_u *)0L}
1286#endif
1287 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001288 {"foldmarker", "fmr", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001289 P_RWIN|P_ONECOMMA|P_NODUP,
Bram Moolenaar37640762017-02-25 22:37:15 +01001290#ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00001291 (char_u *)VAR_WIN, PV_FMR,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001292 {(char_u *)"{{{,}}}", (char_u *)NULL}
Bram Moolenaara713ff82017-02-25 22:18:43 +01001293#else
Bram Moolenaar071d4272004-06-13 20:20:40 +00001294 (char_u *)NULL, PV_NONE,
1295 {(char_u *)NULL, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001296#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +01001297 SCRIPTID_INIT},
1298 {"foldmethod", "fdm", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1299#ifdef FEAT_FOLDING
1300 (char_u *)VAR_WIN, PV_FDM,
1301 {(char_u *)"manual", (char_u *)NULL}
1302#else
1303 (char_u *)NULL, PV_NONE,
1304 {(char_u *)NULL, (char_u *)0L}
1305#endif
1306 SCRIPTID_INIT},
1307 {"foldminlines","fml", P_NUM|P_VI_DEF|P_RWIN,
1308#ifdef FEAT_FOLDING
1309 (char_u *)VAR_WIN, PV_FML,
1310 {(char_u *)1L, (char_u *)0L}
1311#else
1312 (char_u *)NULL, PV_NONE,
1313 {(char_u *)NULL, (char_u *)0L}
1314#endif
1315 SCRIPTID_INIT},
1316 {"foldnestmax", "fdn", P_NUM|P_VI_DEF|P_RWIN,
1317#ifdef FEAT_FOLDING
1318 (char_u *)VAR_WIN, PV_FDN,
1319 {(char_u *)20L, (char_u *)0L}
1320#else
1321 (char_u *)NULL, PV_NONE,
1322 {(char_u *)NULL, (char_u *)0L}
1323#endif
1324 SCRIPTID_INIT},
1325 {"foldopen", "fdo", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_CURSWANT,
1326#ifdef FEAT_FOLDING
1327 (char_u *)&p_fdo, PV_NONE,
1328 {(char_u *)"block,hor,mark,percent,quickfix,search,tag,undo",
1329 (char_u *)0L}
1330#else
1331 (char_u *)NULL, PV_NONE,
1332 {(char_u *)NULL, (char_u *)0L}
1333#endif
1334 SCRIPTID_INIT},
1335 {"foldtext", "fdt", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1336#if defined(FEAT_FOLDING) && defined(FEAT_EVAL)
1337 (char_u *)VAR_WIN, PV_FDT,
1338 {(char_u *)"foldtext()", (char_u *)NULL}
1339#else
1340 (char_u *)NULL, PV_NONE,
1341 {(char_u *)NULL, (char_u *)0L}
1342#endif
1343 SCRIPTID_INIT},
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00001344 {"formatexpr", "fex", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001345#ifdef FEAT_EVAL
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00001346 (char_u *)&p_fex, PV_FEX,
1347 {(char_u *)"", (char_u *)0L}
1348#else
1349 (char_u *)NULL, PV_NONE,
1350 {(char_u *)0L, (char_u *)0L}
1351#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001352 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001353 {"formatoptions","fo", P_STRING|P_ALLOCED|P_VIM|P_FLAGLIST,
1354 (char_u *)&p_fo, PV_FO,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001355 {(char_u *)DFLT_FO_VI, (char_u *)DFLT_FO_VIM}
1356 SCRIPTID_INIT},
Bram Moolenaar86b68352004-12-27 21:59:20 +00001357 {"formatlistpat","flp", P_STRING|P_ALLOCED|P_VI_DEF,
1358 (char_u *)&p_flp, PV_FLP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001359 {(char_u *)"^\\s*\\d\\+[\\]:.)}\\t ]\\s*",
1360 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001361 {"formatprg", "fp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar9be7c042017-01-14 14:28:30 +01001362 (char_u *)&p_fp, PV_FP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001363 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001364 {"fsync", "fs", P_BOOL|P_SECURE|P_VI_DEF,
1365#ifdef HAVE_FSYNC
1366 (char_u *)&p_fs, PV_NONE,
1367 {(char_u *)TRUE, (char_u *)0L}
1368#else
1369 (char_u *)NULL, PV_NONE,
1370 {(char_u *)FALSE, (char_u *)0L}
1371#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001372 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001373 {"gdefault", "gd", P_BOOL|P_VI_DEF|P_VIM,
1374 (char_u *)&p_gd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001375 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001376 {"graphic", "gr", P_BOOL|P_VI_DEF,
1377 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001378 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001379 {"grepformat", "gfm", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001380#ifdef FEAT_QUICKFIX
1381 (char_u *)&p_gefm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001382 {(char_u *)DFLT_GREPFORMAT, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001383#else
1384 (char_u *)NULL, PV_NONE,
1385 {(char_u *)NULL, (char_u *)0L}
1386#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001387 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001388 {"grepprg", "gp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1389#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001390 (char_u *)&p_gp, PV_GP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001391 {
1392# ifdef WIN3264
1393 /* may be changed to "grep -n" in os_win32.c */
1394 (char_u *)"findstr /n",
1395# else
1396# ifdef UNIX
1397 /* Add an extra file name so that grep will always
1398 * insert a file name in the match line. */
1399 (char_u *)"grep -n $* /dev/null",
1400# else
1401# ifdef VMS
1402 (char_u *)"SEARCH/NUMBERS ",
1403# else
1404 (char_u *)"grep -n ",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001405# endif
1406# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00001407# endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001408 (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001409#else
1410 (char_u *)NULL, PV_NONE,
1411 {(char_u *)NULL, (char_u *)0L}
1412#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001413 SCRIPTID_INIT},
Bram Moolenaar8a633e32016-04-21 21:10:14 +02001414 {"guicursor", "gcr", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001415#ifdef CURSOR_SHAPE
1416 (char_u *)&p_guicursor, PV_NONE,
1417 {
1418# ifdef FEAT_GUI
1419 (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 +01001420# else /* Win32 console */
Bram Moolenaar071d4272004-06-13 20:20:40 +00001421 (char_u *)"n-v-c:block,o:hor50,i-ci:hor15,r-cr:hor30,sm:block",
1422# endif
1423 (char_u *)0L}
1424#else
1425 (char_u *)NULL, PV_NONE,
1426 {(char_u *)NULL, (char_u *)0L}
1427#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001428 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001429 {"guifont", "gfn", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001430#ifdef FEAT_GUI
1431 (char_u *)&p_guifont, PV_NONE,
1432 {(char_u *)"", (char_u *)0L}
1433#else
1434 (char_u *)NULL, PV_NONE,
1435 {(char_u *)NULL, (char_u *)0L}
1436#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001437 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001438 {"guifontset", "gfs", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001439#if defined(FEAT_GUI) && defined(FEAT_XFONTSET)
1440 (char_u *)&p_guifontset, PV_NONE,
1441 {(char_u *)"", (char_u *)0L}
1442#else
1443 (char_u *)NULL, PV_NONE,
1444 {(char_u *)NULL, (char_u *)0L}
1445#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001446 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001447 {"guifontwide", "gfw", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001448#if defined(FEAT_GUI) && defined(FEAT_MBYTE)
1449 (char_u *)&p_guifontwide, PV_NONE,
1450 {(char_u *)"", (char_u *)0L}
1451#else
1452 (char_u *)NULL, PV_NONE,
1453 {(char_u *)NULL, (char_u *)0L}
1454#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001455 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001456 {"guiheadroom", "ghr", P_NUM|P_VI_DEF,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001457#if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001458 (char_u *)&p_ghr, PV_NONE,
1459#else
1460 (char_u *)NULL, PV_NONE,
1461#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001462 {(char_u *)50L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001463 {"guioptions", "go", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001464#if defined(FEAT_GUI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001465 (char_u *)&p_go, PV_NONE,
1466# if defined(UNIX) && !defined(MACOS)
Bram Moolenaar32466aa2006-02-24 23:53:04 +00001467 {(char_u *)"aegimrLtT", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001468# else
Bram Moolenaar32466aa2006-02-24 23:53:04 +00001469 {(char_u *)"egmrLtT", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001470# endif
1471#else
1472 (char_u *)NULL, PV_NONE,
1473 {(char_u *)NULL, (char_u *)0L}
1474#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001475 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001476 {"guipty", NULL, P_BOOL|P_VI_DEF,
1477#if defined(FEAT_GUI)
1478 (char_u *)&p_guipty, PV_NONE,
1479#else
1480 (char_u *)NULL, PV_NONE,
1481#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001482 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar18144c82006-04-12 21:52:12 +00001483 {"guitablabel", "gtl", P_STRING|P_VI_DEF|P_RWIN,
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00001484#if defined(FEAT_GUI_TABLINE)
1485 (char_u *)&p_gtl, PV_NONE,
1486 {(char_u *)"", (char_u *)0L}
1487#else
1488 (char_u *)NULL, PV_NONE,
1489 {(char_u *)NULL, (char_u *)0L}
1490#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001491 SCRIPTID_INIT},
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001492 {"guitabtooltip", "gtt", P_STRING|P_VI_DEF|P_RWIN,
Bram Moolenaar57657d82006-04-21 22:12:41 +00001493#if defined(FEAT_GUI_TABLINE)
1494 (char_u *)&p_gtt, PV_NONE,
1495 {(char_u *)"", (char_u *)0L}
1496#else
1497 (char_u *)NULL, PV_NONE,
1498 {(char_u *)NULL, (char_u *)0L}
1499#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001500 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001501 {"hardtabs", "ht", P_NUM|P_VI_DEF,
1502 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001503 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001504 {"helpfile", "hf", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1505 (char_u *)&p_hf, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001506 {(char_u *)DFLT_HELPFILE, (char_u *)0L}
1507 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001508 {"helpheight", "hh", P_NUM|P_VI_DEF,
1509#ifdef FEAT_WINDOWS
1510 (char_u *)&p_hh, PV_NONE,
1511#else
1512 (char_u *)NULL, PV_NONE,
1513#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001514 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001515 {"helplang", "hlg", P_STRING|P_VI_DEF|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001516#ifdef FEAT_MULTI_LANG
1517 (char_u *)&p_hlg, PV_NONE,
1518 {(char_u *)"", (char_u *)0L}
1519#else
1520 (char_u *)NULL, PV_NONE,
1521 {(char_u *)0L, (char_u *)0L}
1522#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001523 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001524 {"hidden", "hid", P_BOOL|P_VI_DEF,
1525 (char_u *)&p_hid, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001526 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001527 {"highlight", "hl", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001528 (char_u *)&p_hl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001529 {(char_u *)HIGHLIGHT_INIT, (char_u *)0L}
1530 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001531 {"history", "hi", P_NUM|P_VIM,
1532 (char_u *)&p_hi, PV_NONE,
Bram Moolenaar78159bb2014-06-25 11:48:54 +02001533 {(char_u *)0L, (char_u *)50L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001534 {"hkmap", "hk", P_BOOL|P_VI_DEF|P_VIM,
1535#ifdef FEAT_RIGHTLEFT
1536 (char_u *)&p_hkmap, PV_NONE,
1537#else
1538 (char_u *)NULL, PV_NONE,
1539#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001540 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001541 {"hkmapp", "hkp", P_BOOL|P_VI_DEF|P_VIM,
1542#ifdef FEAT_RIGHTLEFT
1543 (char_u *)&p_hkmapp, PV_NONE,
1544#else
1545 (char_u *)NULL, PV_NONE,
1546#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001547 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001548 {"hlsearch", "hls", P_BOOL|P_VI_DEF|P_VIM|P_RALL,
1549 (char_u *)&p_hls, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001550 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001551 {"icon", NULL, P_BOOL|P_VI_DEF,
1552#ifdef FEAT_TITLE
1553 (char_u *)&p_icon, PV_NONE,
1554#else
1555 (char_u *)NULL, PV_NONE,
1556#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001557 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001558 {"iconstring", NULL, P_STRING|P_VI_DEF,
1559#ifdef FEAT_TITLE
1560 (char_u *)&p_iconstring, PV_NONE,
1561#else
1562 (char_u *)NULL, PV_NONE,
1563#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001564 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001565 {"ignorecase", "ic", P_BOOL|P_VI_DEF,
1566 (char_u *)&p_ic, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001567 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarabab85a2013-06-26 19:18:05 +02001568 {"imactivatefunc","imaf",P_STRING|P_VI_DEF|P_SECURE,
1569# if defined(FEAT_EVAL) && defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
1570 (char_u *)&p_imaf, PV_NONE,
1571 {(char_u *)"", (char_u *)NULL}
1572# else
1573 (char_u *)NULL, PV_NONE,
1574 {(char_u *)NULL, (char_u *)0L}
1575# endif
1576 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001577 {"imactivatekey","imak",P_STRING|P_VI_DEF,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001578#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001579 (char_u *)&p_imak, PV_NONE,
1580#else
1581 (char_u *)NULL, PV_NONE,
1582#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001583 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001584 {"imcmdline", "imc", P_BOOL|P_VI_DEF,
1585#ifdef USE_IM_CONTROL
1586 (char_u *)&p_imcmdline, PV_NONE,
1587#else
1588 (char_u *)NULL, PV_NONE,
1589#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001590 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001591 {"imdisable", "imd", P_BOOL|P_VI_DEF,
1592#ifdef USE_IM_CONTROL
1593 (char_u *)&p_imdisable, PV_NONE,
1594#else
1595 (char_u *)NULL, PV_NONE,
1596#endif
1597#ifdef __sgi
1598 {(char_u *)TRUE, (char_u *)0L}
1599#else
1600 {(char_u *)FALSE, (char_u *)0L}
1601#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001602 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001603 {"iminsert", "imi", P_NUM|P_VI_DEF,
1604 (char_u *)&p_iminsert, PV_IMI,
1605#ifdef B_IMODE_IM
1606 {(char_u *)B_IMODE_IM, (char_u *)0L}
1607#else
1608 {(char_u *)B_IMODE_NONE, (char_u *)0L}
1609#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001610 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001611 {"imsearch", "ims", P_NUM|P_VI_DEF,
1612 (char_u *)&p_imsearch, PV_IMS,
1613#ifdef B_IMODE_IM
1614 {(char_u *)B_IMODE_IM, (char_u *)0L}
1615#else
1616 {(char_u *)B_IMODE_NONE, (char_u *)0L}
1617#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001618 SCRIPTID_INIT},
Bram Moolenaar4a460702013-06-29 14:42:26 +02001619 {"imstatusfunc","imsf",P_STRING|P_VI_DEF|P_SECURE,
Bram Moolenaarabab85a2013-06-26 19:18:05 +02001620# if defined(FEAT_EVAL) && defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
1621 (char_u *)&p_imsf, PV_NONE,
1622 {(char_u *)"", (char_u *)NULL}
1623# else
1624 (char_u *)NULL, PV_NONE,
1625 {(char_u *)NULL, (char_u *)0L}
1626# endif
1627 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001628 {"include", "inc", P_STRING|P_ALLOCED|P_VI_DEF,
1629#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001630 (char_u *)&p_inc, PV_INC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001631 {(char_u *)"^\\s*#\\s*include", (char_u *)0L}
1632#else
1633 (char_u *)NULL, PV_NONE,
1634 {(char_u *)0L, (char_u *)0L}
1635#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001636 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001637 {"includeexpr", "inex", P_STRING|P_ALLOCED|P_VI_DEF,
1638#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
1639 (char_u *)&p_inex, PV_INEX,
1640 {(char_u *)"", (char_u *)0L}
1641#else
1642 (char_u *)NULL, PV_NONE,
1643 {(char_u *)0L, (char_u *)0L}
1644#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001645 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001646 {"incsearch", "is", P_BOOL|P_VI_DEF|P_VIM,
1647 (char_u *)&p_is, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001648 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001649 {"indentexpr", "inde", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
1650#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
1651 (char_u *)&p_inde, PV_INDE,
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 Moolenaar0e7c4b92015-06-20 15:30:03 +02001658 {"indentkeys", "indk", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001659#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
1660 (char_u *)&p_indk, PV_INDK,
1661 {(char_u *)"0{,0},:,0#,!^F,o,O,e", (char_u *)0L}
1662#else
1663 (char_u *)NULL, PV_NONE,
1664 {(char_u *)0L, (char_u *)0L}
1665#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001666 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001667 {"infercase", "inf", P_BOOL|P_VI_DEF,
1668 (char_u *)&p_inf, PV_INF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001669 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001670 {"insertmode", "im", P_BOOL|P_VI_DEF|P_VIM,
1671 (char_u *)&p_im, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001672 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001673 {"isfname", "isf", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1674 (char_u *)&p_isf, PV_NONE,
1675 {
1676#ifdef BACKSLASH_IN_FILENAME
1677 /* Excluded are: & and ^ are special in cmd.exe
1678 * ( and ) are used in text separating fnames */
1679 (char_u *)"@,48-57,/,\\,.,-,_,+,,,#,$,%,{,},[,],:,@-@,!,~,=",
1680#else
1681# ifdef AMIGA
1682 (char_u *)"@,48-57,/,.,-,_,+,,,$,:",
1683# else
1684# ifdef VMS
1685 (char_u *)"@,48-57,/,.,-,_,+,,,#,$,%,<,>,[,],:,;,~",
1686# else /* UNIX et al. */
1687# ifdef EBCDIC
1688 (char_u *)"@,240-249,/,.,-,_,+,,,#,$,%,~,=",
1689# else
1690 (char_u *)"@,48-57,/,.,-,_,+,,,#,$,%,~,=",
1691# endif
1692# endif
1693# endif
1694#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001695 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001696 {"isident", "isi", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1697 (char_u *)&p_isi, PV_NONE,
1698 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001699#if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001700 (char_u *)"@,48-57,_,128-167,224-235",
1701#else
1702# ifdef EBCDIC
1703 /* TODO: EBCDIC Check this! @ == isalpha()*/
1704 (char_u *)"@,240-249,_,66-73,81-89,98-105,"
1705 "112-120,128,140-142,156,158,172,"
1706 "174,186,191,203-207,219-225,235-239,"
1707 "251-254",
1708# else
1709 (char_u *)"@,48-57,_,192-255",
1710# endif
1711#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001712 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001713 {"iskeyword", "isk", P_STRING|P_ALLOCED|P_VIM|P_COMMA|P_NODUP,
1714 (char_u *)&p_isk, PV_ISK,
1715 {
1716#ifdef EBCDIC
1717 (char_u *)"@,240-249,_",
1718 /* TODO: EBCDIC Check this! @ == isalpha()*/
1719 (char_u *)"@,240-249,_,66-73,81-89,98-105,"
1720 "112-120,128,140-142,156,158,172,"
1721 "174,186,191,203-207,219-225,235-239,"
1722 "251-254",
1723#else
1724 (char_u *)"@,48-57,_",
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001725# if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001726 (char_u *)"@,48-57,_,128-167,224-235"
1727# else
Bram Moolenaar362e1a32006-03-06 23:29:24 +00001728 ISK_LATIN1
Bram Moolenaar071d4272004-06-13 20:20:40 +00001729# endif
1730#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001731 } SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001732 {"isprint", "isp", P_STRING|P_VI_DEF|P_RALL|P_COMMA|P_NODUP,
1733 (char_u *)&p_isp, PV_NONE,
1734 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001735#if defined(MSWIN) || (defined(MACOS) && !defined(MACOS_X)) \
Bram Moolenaar071d4272004-06-13 20:20:40 +00001736 || defined(VMS)
1737 (char_u *)"@,~-255",
1738#else
1739# ifdef EBCDIC
1740 /* all chars above 63 are printable */
1741 (char_u *)"63-255",
1742# else
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +00001743 ISP_LATIN1,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001744# endif
1745#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001746 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001747 {"joinspaces", "js", P_BOOL|P_VI_DEF|P_VIM,
1748 (char_u *)&p_js, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001749 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001750 {"key", NULL, P_STRING|P_ALLOCED|P_VI_DEF|P_NO_MKRC,
1751#ifdef FEAT_CRYPT
1752 (char_u *)&p_key, PV_KEY,
1753 {(char_u *)"", (char_u *)0L}
1754#else
1755 (char_u *)NULL, PV_NONE,
1756 {(char_u *)0L, (char_u *)0L}
1757#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001758 SCRIPTID_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +00001759 {"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 +00001760#ifdef FEAT_KEYMAP
1761 (char_u *)&p_keymap, PV_KMAP,
1762 {(char_u *)"", (char_u *)0L}
1763#else
1764 (char_u *)NULL, PV_NONE,
1765 {(char_u *)"", (char_u *)0L}
1766#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001767 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001768 {"keymodel", "km", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001769 (char_u *)&p_km, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001770 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001771 {"keywordprg", "kp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001772 (char_u *)&p_kp, PV_KP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001773 {
Bram Moolenaarfd89d7e2016-06-04 20:25:05 +02001774#ifdef MSWIN
Bram Moolenaar071d4272004-06-13 20:20:40 +00001775 (char_u *)":help",
1776#else
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001777# ifdef VMS
Bram Moolenaar071d4272004-06-13 20:20:40 +00001778 (char_u *)"help",
Bram Moolenaare7fedb62015-12-31 19:07:19 +01001779# else
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001780# ifdef USEMAN_S
1781 (char_u *)"man -s",
1782# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00001783 (char_u *)"man",
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001784# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00001785# endif
1786#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001787 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001788 {"langmap", "lmap", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001789#ifdef FEAT_LANGMAP
1790 (char_u *)&p_langmap, PV_NONE,
1791 {(char_u *)"", /* unmatched } */
1792#else
1793 (char_u *)NULL, PV_NONE,
1794 {(char_u *)NULL,
1795#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001796 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001797 {"langmenu", "lm", P_STRING|P_VI_DEF|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001798#if defined(FEAT_MENU) && defined(FEAT_MULTI_LANG)
1799 (char_u *)&p_lm, PV_NONE,
1800#else
1801 (char_u *)NULL, PV_NONE,
1802#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001803 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar4391cf92014-11-05 17:44:52 +01001804 {"langnoremap", "lnr", P_BOOL|P_VI_DEF,
1805#ifdef FEAT_LANGMAP
1806 (char_u *)&p_lnr, PV_NONE,
1807#else
1808 (char_u *)NULL, PV_NONE,
1809#endif
1810 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar920694c2016-08-21 17:45:02 +02001811 {"langremap", "lrm", P_BOOL|P_VI_DEF,
1812#ifdef FEAT_LANGMAP
1813 (char_u *)&p_lrm, PV_NONE,
1814#else
1815 (char_u *)NULL, PV_NONE,
1816#endif
Bram Moolenaarda9ce2c2016-09-02 19:34:10 +02001817 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001818 {"laststatus", "ls", P_NUM|P_VI_DEF|P_RALL,
1819#ifdef FEAT_WINDOWS
1820 (char_u *)&p_ls, PV_NONE,
1821#else
1822 (char_u *)NULL, PV_NONE,
1823#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001824 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001825 {"lazyredraw", "lz", P_BOOL|P_VI_DEF,
1826 (char_u *)&p_lz, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001827 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001828 {"linebreak", "lbr", P_BOOL|P_VI_DEF|P_RWIN,
1829#ifdef FEAT_LINEBREAK
1830 (char_u *)VAR_WIN, PV_LBR,
1831#else
1832 (char_u *)NULL, PV_NONE,
1833#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001834 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001835 {"lines", NULL, P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR,
1836 (char_u *)&Rows, PV_NONE,
1837 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001838#if defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001839 (char_u *)25L,
1840#else
1841 (char_u *)24L,
1842#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001843 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001844 {"linespace", "lsp", P_NUM|P_VI_DEF|P_RCLR,
1845#ifdef FEAT_GUI
1846 (char_u *)&p_linespace, PV_NONE,
1847#else
1848 (char_u *)NULL, PV_NONE,
1849#endif
1850#ifdef FEAT_GUI_W32
1851 {(char_u *)1L, (char_u *)0L}
1852#else
1853 {(char_u *)0L, (char_u *)0L}
1854#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001855 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001856 {"lisp", NULL, P_BOOL|P_VI_DEF,
1857#ifdef FEAT_LISP
1858 (char_u *)&p_lisp, PV_LISP,
1859#else
1860 (char_u *)NULL, PV_NONE,
1861#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001862 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001863 {"lispwords", "lw", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001864#ifdef FEAT_LISP
Bram Moolenaaraf6c1312014-03-12 18:55:58 +01001865 (char_u *)&p_lispwords, PV_LW,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001866 {(char_u *)LISPWORD_VALUE, (char_u *)0L}
1867#else
1868 (char_u *)NULL, PV_NONE,
1869 {(char_u *)"", (char_u *)0L}
1870#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001871 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001872 {"list", NULL, P_BOOL|P_VI_DEF|P_RWIN,
1873 (char_u *)VAR_WIN, PV_LIST,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001874 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001875 {"listchars", "lcs", P_STRING|P_VI_DEF|P_RALL|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001876 (char_u *)&p_lcs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001877 {(char_u *)"eol:$", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001878 {"loadplugins", "lpl", P_BOOL|P_VI_DEF,
1879 (char_u *)&p_lpl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001880 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaara6e42502016-04-20 16:19:52 +02001881 {"luadll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001882#if defined(DYNAMIC_LUA)
Bram Moolenaard94464e2015-11-02 15:28:18 +01001883 (char_u *)&p_luadll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01001884 {(char_u *)DYNAMIC_LUA_DLL, (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01001885#else
1886 (char_u *)NULL, PV_NONE,
1887 {(char_u *)"", (char_u *)0L}
1888#endif
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01001889 SCRIPTID_INIT},
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001890 {"macatsui", NULL, P_BOOL|P_VI_DEF|P_RCLR,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001891#ifdef FEAT_GUI_MAC
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001892 (char_u *)&p_macatsui, PV_NONE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001893 {(char_u *)TRUE, (char_u *)0L}
1894#else
1895 (char_u *)NULL, PV_NONE,
1896 {(char_u *)"", (char_u *)0L}
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001897#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +01001898 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001899 {"magic", NULL, P_BOOL|P_VI_DEF,
1900 (char_u *)&p_magic, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001901 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00001902 {"makeef", "mef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001903#ifdef FEAT_QUICKFIX
1904 (char_u *)&p_mef, PV_NONE,
1905 {(char_u *)"", (char_u *)0L}
1906#else
1907 (char_u *)NULL, PV_NONE,
1908 {(char_u *)NULL, (char_u *)0L}
1909#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001910 SCRIPTID_INIT},
Bram Moolenaar2c7292d2017-03-05 17:43:31 +01001911 {"makeencoding","menc", P_STRING|P_VI_DEF,
1912#ifdef FEAT_MBYTE
1913 (char_u *)&p_menc, PV_MENC,
1914 {(char_u *)"", (char_u *)0L}
1915#else
1916 (char_u *)NULL, PV_NONE,
1917 {(char_u *)0L, (char_u *)0L}
1918#endif
1919 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001920 {"makeprg", "mp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1921#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001922 (char_u *)&p_mp, PV_MP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001923# ifdef VMS
1924 {(char_u *)"MMS", (char_u *)0L}
1925# else
1926 {(char_u *)"make", (char_u *)0L}
1927# endif
1928#else
1929 (char_u *)NULL, PV_NONE,
1930 {(char_u *)NULL, (char_u *)0L}
1931#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001932 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001933 {"matchpairs", "mps", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001934 (char_u *)&p_mps, PV_MPS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001935 {(char_u *)"(:),{:},[:]", (char_u *)0L}
1936 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001937 {"matchtime", "mat", P_NUM|P_VI_DEF,
1938 (char_u *)&p_mat, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001939 {(char_u *)5L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001940 {"maxcombine", "mco", P_NUM|P_VI_DEF|P_CURSWANT,
Bram Moolenaar362e1a32006-03-06 23:29:24 +00001941#ifdef FEAT_MBYTE
1942 (char_u *)&p_mco, PV_NONE,
1943#else
1944 (char_u *)NULL, PV_NONE,
1945#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001946 {(char_u *)2, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001947 {"maxfuncdepth", "mfd", P_NUM|P_VI_DEF,
1948#ifdef FEAT_EVAL
1949 (char_u *)&p_mfd, PV_NONE,
1950#else
1951 (char_u *)NULL, PV_NONE,
1952#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001953 {(char_u *)100L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001954 {"maxmapdepth", "mmd", P_NUM|P_VI_DEF,
1955 (char_u *)&p_mmd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001956 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001957 {"maxmem", "mm", P_NUM|P_VI_DEF,
1958 (char_u *)&p_mm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001959 {(char_u *)DFLT_MAXMEM, (char_u *)0L}
1960 SCRIPTID_INIT},
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00001961 {"maxmempattern","mmp", P_NUM|P_VI_DEF,
1962 (char_u *)&p_mmp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001963 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001964 {"maxmemtot", "mmt", P_NUM|P_VI_DEF,
1965 (char_u *)&p_mmt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001966 {(char_u *)DFLT_MAXMEMTOT, (char_u *)0L}
1967 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001968 {"menuitems", "mis", P_NUM|P_VI_DEF,
1969#ifdef FEAT_MENU
1970 (char_u *)&p_mis, PV_NONE,
1971#else
1972 (char_u *)NULL, PV_NONE,
1973#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001974 {(char_u *)25L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001975 {"mesg", NULL, P_BOOL|P_VI_DEF,
1976 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001977 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001978 {"mkspellmem", "msm", P_STRING|P_VI_DEF|P_EXPAND|P_SECURE,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00001979#ifdef FEAT_SPELL
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001980 (char_u *)&p_msm, PV_NONE,
1981 {(char_u *)"460000,2000,500", (char_u *)0L}
1982#else
1983 (char_u *)NULL, PV_NONE,
1984 {(char_u *)0L, (char_u *)0L}
1985#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001986 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001987 {"modeline", "ml", P_BOOL|P_VIM,
1988 (char_u *)&p_ml, PV_ML,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001989 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001990 {"modelines", "mls", P_NUM|P_VI_DEF,
1991 (char_u *)&p_mls, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001992 {(char_u *)5L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001993 {"modifiable", "ma", P_BOOL|P_VI_DEF|P_NOGLOB,
1994 (char_u *)&p_ma, PV_MA,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001995 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001996 {"modified", "mod", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
1997 (char_u *)&p_mod, PV_MOD,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001998 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001999 {"more", NULL, P_BOOL|P_VIM,
2000 (char_u *)&p_more, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002001 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002002 {"mouse", NULL, P_STRING|P_VI_DEF|P_FLAGLIST,
2003 (char_u *)&p_mouse, PV_NONE,
2004 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002005#if defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002006 (char_u *)"a",
2007#else
2008 (char_u *)"",
2009#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002010 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002011 {"mousefocus", "mousef", P_BOOL|P_VI_DEF,
2012#ifdef FEAT_GUI
2013 (char_u *)&p_mousef, PV_NONE,
2014#else
2015 (char_u *)NULL, PV_NONE,
2016#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002017 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002018 {"mousehide", "mh", P_BOOL|P_VI_DEF,
2019#ifdef FEAT_GUI
2020 (char_u *)&p_mh, PV_NONE,
2021#else
2022 (char_u *)NULL, PV_NONE,
2023#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002024 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002025 {"mousemodel", "mousem", P_STRING|P_VI_DEF,
2026 (char_u *)&p_mousem, PV_NONE,
2027 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002028#if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002029 (char_u *)"popup",
2030#else
2031# if defined(MACOS)
2032 (char_u *)"popup_setpos",
2033# else
2034 (char_u *)"extend",
2035# endif
2036#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002037 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002038 {"mouseshape", "mouses", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002039#ifdef FEAT_MOUSESHAPE
2040 (char_u *)&p_mouseshape, PV_NONE,
2041 {(char_u *)"i-r:beam,s:updown,sd:udsizing,vs:leftright,vd:lrsizing,m:no,ml:up-arrow,v:rightup-arrow", (char_u *)0L}
2042#else
2043 (char_u *)NULL, PV_NONE,
2044 {(char_u *)NULL, (char_u *)0L}
2045#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002046 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002047 {"mousetime", "mouset", P_NUM|P_VI_DEF,
2048 (char_u *)&p_mouset, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002049 {(char_u *)500L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar325b7a22004-07-05 15:58:32 +00002050 {"mzquantum", "mzq", P_NUM,
2051#ifdef FEAT_MZSCHEME
2052 (char_u *)&p_mzq, PV_NONE,
2053#else
2054 (char_u *)NULL, PV_NONE,
2055#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002056 {(char_u *)100L, (char_u *)100L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002057 {"novice", NULL, P_BOOL|P_VI_DEF,
2058 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002059 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002060 {"nrformats", "nf", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002061 (char_u *)&p_nf, PV_NF,
Bram Moolenaar887c1fe2016-01-02 17:56:35 +01002062 {(char_u *)"bin,octal,hex", (char_u *)0L}
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002063 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002064 {"number", "nu", P_BOOL|P_VI_DEF|P_RWIN,
2065 (char_u *)VAR_WIN, PV_NU,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002066 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar592e0a22004-07-03 16:05:59 +00002067 {"numberwidth", "nuw", P_NUM|P_RWIN|P_VIM,
2068#ifdef FEAT_LINEBREAK
2069 (char_u *)VAR_WIN, PV_NUW,
2070#else
2071 (char_u *)NULL, PV_NONE,
2072#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002073 {(char_u *)8L, (char_u *)4L} SCRIPTID_INIT},
Bram Moolenaarf75a9632005-09-13 21:20:47 +00002074 {"omnifunc", "ofu", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE,
Bram Moolenaare344bea2005-09-01 20:46:49 +00002075#ifdef FEAT_COMPL_FUNC
2076 (char_u *)&p_ofu, PV_OFU,
2077 {(char_u *)"", (char_u *)0L}
2078#else
2079 (char_u *)NULL, PV_NONE,
2080 {(char_u *)0L, (char_u *)0L}
2081#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002082 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002083 {"open", NULL, P_BOOL|P_VI_DEF,
2084 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002085 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar043545e2006-10-10 16:44:07 +00002086 {"opendevice", "odev", P_BOOL|P_VI_DEF,
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002087#if defined(MSWIN)
Bram Moolenaar043545e2006-10-10 16:44:07 +00002088 (char_u *)&p_odev, PV_NONE,
2089#else
2090 (char_u *)NULL, PV_NONE,
2091#endif
2092 {(char_u *)FALSE, (char_u *)FALSE}
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002093 SCRIPTID_INIT},
Bram Moolenaar2c7a29c2005-12-12 22:02:31 +00002094 {"operatorfunc", "opfunc", P_STRING|P_VI_DEF|P_SECURE,
2095 (char_u *)&p_opfunc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002096 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002097 {"optimize", "opt", P_BOOL|P_VI_DEF,
2098 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002099 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002100 {"osfiletype", "oft", P_STRING|P_ALLOCED|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002101 (char_u *)NULL, PV_NONE,
Bram Moolenaarb07269a2011-05-19 13:41:14 +02002102 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf6fee0e2016-02-21 23:02:49 +01002103 {"packpath", "pp", P_STRING|P_VI_DEF|P_EXPAND|P_ONECOMMA|P_NODUP
2104 |P_SECURE,
2105 (char_u *)&p_pp, PV_NONE,
2106 {(char_u *)DFLT_RUNTIMEPATH, (char_u *)0L}
2107 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002108 {"paragraphs", "para", P_STRING|P_VI_DEF,
2109 (char_u *)&p_para, PV_NONE,
Bram Moolenaar57e48462008-03-12 16:38:55 +00002110 {(char_u *)"IPLPPPQPP TPHPLIPpLpItpplpipbp",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002111 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +00002112 {"paste", NULL, P_BOOL|P_VI_DEF|P_PRI_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002113 (char_u *)&p_paste, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002114 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002115 {"pastetoggle", "pt", P_STRING|P_VI_DEF,
2116 (char_u *)&p_pt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002117 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002118 {"patchexpr", "pex", P_STRING|P_VI_DEF|P_SECURE,
2119#if defined(FEAT_DIFF) && defined(FEAT_EVAL)
2120 (char_u *)&p_pex, PV_NONE,
2121 {(char_u *)"", (char_u *)0L}
2122#else
2123 (char_u *)NULL, PV_NONE,
2124 {(char_u *)0L, (char_u *)0L}
2125#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002126 SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002127 {"patchmode", "pm", P_STRING|P_VI_DEF|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002128 (char_u *)&p_pm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002129 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002130 {"path", "pa", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002131 (char_u *)&p_path, PV_PATH,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002132 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002133#if defined(AMIGA) || defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002134 (char_u *)".,,",
2135#else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002136 (char_u *)".,/usr/include,,",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002137#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002138 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaara6e42502016-04-20 16:19:52 +02002139 {"perldll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002140#if defined(DYNAMIC_PERL)
Bram Moolenaard94464e2015-11-02 15:28:18 +01002141 (char_u *)&p_perldll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002142 {(char_u *)DYNAMIC_PERL_DLL, (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01002143#else
2144 (char_u *)NULL, PV_NONE,
2145 {(char_u *)0L, (char_u *)0L}
Bram Moolenaard94464e2015-11-02 15:28:18 +01002146#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +01002147 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002148 {"preserveindent", "pi", P_BOOL|P_VI_DEF|P_VIM,
2149 (char_u *)&p_pi, PV_PI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002150 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar592e0a22004-07-03 16:05:59 +00002151 {"previewheight", "pvh", P_NUM|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002152#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
2153 (char_u *)&p_pvh, PV_NONE,
2154#else
2155 (char_u *)NULL, PV_NONE,
2156#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002157 {(char_u *)12L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002158 {"previewwindow", "pvw", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB,
2159#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
2160 (char_u *)VAR_WIN, PV_PVW,
2161#else
2162 (char_u *)NULL, PV_NONE,
2163#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002164 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002165 {"printdevice", "pdev", P_STRING|P_VI_DEF|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002166#ifdef FEAT_PRINTER
2167 (char_u *)&p_pdev, PV_NONE,
2168 {(char_u *)"", (char_u *)0L}
2169#else
2170 (char_u *)NULL, PV_NONE,
2171 {(char_u *)NULL, (char_u *)0L}
2172#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002173 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002174 {"printencoding", "penc", P_STRING|P_VI_DEF,
2175#ifdef FEAT_POSTSCRIPT
2176 (char_u *)&p_penc, PV_NONE,
2177 {(char_u *)"", (char_u *)0L}
2178#else
2179 (char_u *)NULL, PV_NONE,
2180 {(char_u *)NULL, (char_u *)0L}
2181#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002182 SCRIPTID_INIT},
Bram Moolenaar031cb742016-11-24 21:46:19 +01002183 {"printexpr", "pexpr", P_STRING|P_VI_DEF|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002184#ifdef FEAT_POSTSCRIPT
2185 (char_u *)&p_pexpr, PV_NONE,
2186 {(char_u *)"", (char_u *)0L}
2187#else
2188 (char_u *)NULL, PV_NONE,
2189 {(char_u *)NULL, (char_u *)0L}
2190#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002191 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002192 {"printfont", "pfn", P_STRING|P_VI_DEF,
2193#ifdef FEAT_PRINTER
2194 (char_u *)&p_pfn, PV_NONE,
2195 {
2196# ifdef MSWIN
2197 (char_u *)"Courier_New:h10",
2198# else
2199 (char_u *)"courier",
2200# endif
2201 (char_u *)0L}
2202#else
2203 (char_u *)NULL, PV_NONE,
2204 {(char_u *)NULL, (char_u *)0L}
2205#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002206 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002207 {"printheader", "pheader", P_STRING|P_VI_DEF|P_GETTEXT,
2208#ifdef FEAT_PRINTER
2209 (char_u *)&p_header, PV_NONE,
2210 {(char_u *)N_("%<%f%h%m%=Page %N"), (char_u *)0L}
2211#else
2212 (char_u *)NULL, PV_NONE,
2213 {(char_u *)NULL, (char_u *)0L}
2214#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002215 SCRIPTID_INIT},
Bram Moolenaar8299df92004-07-10 09:47:34 +00002216 {"printmbcharset", "pmbcs", P_STRING|P_VI_DEF,
2217#if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE)
2218 (char_u *)&p_pmcs, PV_NONE,
2219 {(char_u *)"", (char_u *)0L}
2220#else
2221 (char_u *)NULL, PV_NONE,
2222 {(char_u *)NULL, (char_u *)0L}
2223#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002224 SCRIPTID_INIT},
Bram Moolenaar8299df92004-07-10 09:47:34 +00002225 {"printmbfont", "pmbfn", P_STRING|P_VI_DEF,
2226#if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE)
2227 (char_u *)&p_pmfn, PV_NONE,
2228 {(char_u *)"", (char_u *)0L}
2229#else
2230 (char_u *)NULL, PV_NONE,
2231 {(char_u *)NULL, (char_u *)0L}
2232#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002233 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002234 {"printoptions", "popt", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002235#ifdef FEAT_PRINTER
2236 (char_u *)&p_popt, PV_NONE,
2237 {(char_u *)"", (char_u *)0L}
2238#else
2239 (char_u *)NULL, PV_NONE,
2240 {(char_u *)NULL, (char_u *)0L}
2241#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002242 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002243 {"prompt", NULL, P_BOOL|P_VI_DEF,
Bram Moolenaar26a60b42005-02-22 08:49:11 +00002244 (char_u *)&p_prompt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002245 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar9d47f172006-03-15 23:03:01 +00002246 {"pumheight", "ph", P_NUM|P_VI_DEF,
2247#ifdef FEAT_INS_EXPAND
2248 (char_u *)&p_ph, PV_NONE,
2249#else
2250 (char_u *)NULL, PV_NONE,
2251#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002252 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaara6e42502016-04-20 16:19:52 +02002253 {"pythonthreedll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002254#if defined(DYNAMIC_PYTHON3)
Bram Moolenaard94464e2015-11-02 15:28:18 +01002255 (char_u *)&p_py3dll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002256 {(char_u *)DYNAMIC_PYTHON3_DLL, (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01002257#else
2258 (char_u *)NULL, PV_NONE,
2259 {(char_u *)NULL, (char_u *)0L}
Bram Moolenaard94464e2015-11-02 15:28:18 +01002260#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +01002261 SCRIPTID_INIT},
Bram Moolenaara6e42502016-04-20 16:19:52 +02002262 {"pythondll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002263#if defined(DYNAMIC_PYTHON)
Bram Moolenaard94464e2015-11-02 15:28:18 +01002264 (char_u *)&p_pydll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002265 {(char_u *)DYNAMIC_PYTHON_DLL, (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01002266#else
2267 (char_u *)NULL, PV_NONE,
2268 {(char_u *)NULL, (char_u *)0L}
Bram Moolenaard94464e2015-11-02 15:28:18 +01002269#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +01002270 SCRIPTID_INIT},
Bram Moolenaarf42dd3c2017-01-28 16:06:38 +01002271 {"pyxversion", "pyx", P_NUM|P_VI_DEF|P_SECURE,
2272#if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3)
2273 (char_u *)&p_pyx, PV_NONE,
2274#else
2275 (char_u *)NULL, PV_NONE,
2276#endif
2277 {(char_u *)DEFAULT_PYTHON_VER, (char_u *)0L}
2278 SCRIPTID_INIT},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00002279 {"quoteescape", "qe", P_STRING|P_ALLOCED|P_VI_DEF,
2280#ifdef FEAT_TEXTOBJ
2281 (char_u *)&p_qe, PV_QE,
2282 {(char_u *)"\\", (char_u *)0L}
2283#else
2284 (char_u *)NULL, PV_NONE,
2285 {(char_u *)NULL, (char_u *)0L}
2286#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002287 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002288 {"readonly", "ro", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB,
2289 (char_u *)&p_ro, PV_RO,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002290 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002291 {"redraw", NULL, P_BOOL|P_VI_DEF,
2292 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002293 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar91a4e822008-01-19 14:59:58 +00002294 {"redrawtime", "rdt", P_NUM|P_VI_DEF,
2295#ifdef FEAT_RELTIME
2296 (char_u *)&p_rdt, PV_NONE,
2297#else
2298 (char_u *)NULL, PV_NONE,
2299#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002300 {(char_u *)2000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarfbc0d2e2013-05-19 19:40:29 +02002301 {"regexpengine", "re", P_NUM|P_VI_DEF,
2302 (char_u *)&p_re, PV_NONE,
2303 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar64486672010-05-16 15:46:46 +02002304 {"relativenumber", "rnu", P_BOOL|P_VI_DEF|P_RWIN,
2305 (char_u *)VAR_WIN, PV_RNU,
2306 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002307 {"remap", NULL, P_BOOL|P_VI_DEF,
2308 (char_u *)&p_remap, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002309 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002310 {"renderoptions", "rop", P_STRING|P_ONECOMMA|P_RCLR|P_VI_DEF,
Bram Moolenaarb5a7a8b2014-08-06 14:52:30 +02002311#ifdef FEAT_RENDER_OPTIONS
2312 (char_u *)&p_rop, PV_NONE,
2313 {(char_u *)"", (char_u *)0L}
2314#else
2315 (char_u *)NULL, PV_NONE,
2316 {(char_u *)NULL, (char_u *)0L}
2317#endif
2318 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002319 {"report", NULL, P_NUM|P_VI_DEF,
2320 (char_u *)&p_report, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002321 {(char_u *)2L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002322 {"restorescreen", "rs", P_BOOL|P_VI_DEF,
2323#ifdef WIN3264
2324 (char_u *)&p_rs, PV_NONE,
2325#else
2326 (char_u *)NULL, PV_NONE,
2327#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002328 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002329 {"revins", "ri", P_BOOL|P_VI_DEF|P_VIM,
2330#ifdef FEAT_RIGHTLEFT
2331 (char_u *)&p_ri, PV_NONE,
2332#else
2333 (char_u *)NULL, PV_NONE,
2334#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002335 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002336 {"rightleft", "rl", P_BOOL|P_VI_DEF|P_RWIN,
2337#ifdef FEAT_RIGHTLEFT
2338 (char_u *)VAR_WIN, PV_RL,
2339#else
2340 (char_u *)NULL, PV_NONE,
2341#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002342 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002343 {"rightleftcmd", "rlc", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN,
2344#ifdef FEAT_RIGHTLEFT
2345 (char_u *)VAR_WIN, PV_RLC,
2346 {(char_u *)"search", (char_u *)NULL}
2347#else
2348 (char_u *)NULL, PV_NONE,
2349 {(char_u *)NULL, (char_u *)0L}
2350#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002351 SCRIPTID_INIT},
Bram Moolenaara6e42502016-04-20 16:19:52 +02002352 {"rubydll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002353#if defined(DYNAMIC_RUBY)
Bram Moolenaard94464e2015-11-02 15:28:18 +01002354 (char_u *)&p_rubydll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002355 {(char_u *)DYNAMIC_RUBY_DLL, (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01002356#else
2357 (char_u *)NULL, PV_NONE,
2358 {(char_u *)NULL, (char_u *)0L}
Bram Moolenaard94464e2015-11-02 15:28:18 +01002359#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +01002360 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002361 {"ruler", "ru", P_BOOL|P_VI_DEF|P_VIM|P_RSTAT,
2362#ifdef FEAT_CMDL_INFO
2363 (char_u *)&p_ru, PV_NONE,
2364#else
2365 (char_u *)NULL, PV_NONE,
2366#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002367 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002368 {"rulerformat", "ruf", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT,
2369#ifdef FEAT_STL_OPT
2370 (char_u *)&p_ruf, PV_NONE,
2371#else
2372 (char_u *)NULL, PV_NONE,
2373#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002374 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002375 {"runtimepath", "rtp", P_STRING|P_VI_DEF|P_EXPAND|P_ONECOMMA|P_NODUP
2376 |P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002377 (char_u *)&p_rtp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002378 {(char_u *)DFLT_RUNTIMEPATH, (char_u *)0L}
2379 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002380 {"scroll", "scr", P_NUM|P_NO_MKRC|P_VI_DEF,
2381 (char_u *)VAR_WIN, PV_SCROLL,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002382 {(char_u *)12L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002383 {"scrollbind", "scb", P_BOOL|P_VI_DEF,
2384#ifdef FEAT_SCROLLBIND
2385 (char_u *)VAR_WIN, PV_SCBIND,
2386#else
2387 (char_u *)NULL, PV_NONE,
2388#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002389 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002390 {"scrolljump", "sj", P_NUM|P_VI_DEF|P_VIM,
2391 (char_u *)&p_sj, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002392 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002393 {"scrolloff", "so", P_NUM|P_VI_DEF|P_VIM|P_RALL,
2394 (char_u *)&p_so, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002395 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002396 {"scrollopt", "sbo", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002397#ifdef FEAT_SCROLLBIND
2398 (char_u *)&p_sbo, PV_NONE,
2399 {(char_u *)"ver,jump", (char_u *)0L}
2400#else
2401 (char_u *)NULL, PV_NONE,
2402 {(char_u *)0L, (char_u *)0L}
2403#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002404 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002405 {"sections", "sect", P_STRING|P_VI_DEF,
2406 (char_u *)&p_sections, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002407 {(char_u *)"SHNHH HUnhsh", (char_u *)0L}
2408 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002409 {"secure", NULL, P_BOOL|P_VI_DEF|P_SECURE,
2410 (char_u *)&p_secure, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002411 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002412 {"selection", "sel", P_STRING|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002413 (char_u *)&p_sel, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002414 {(char_u *)"inclusive", (char_u *)0L}
2415 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002416 {"selectmode", "slm", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002417 (char_u *)&p_slm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002418 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002419 {"sessionoptions", "ssop", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002420#ifdef FEAT_SESSION
2421 (char_u *)&p_ssop, PV_NONE,
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00002422 {(char_u *)"blank,buffers,curdir,folds,help,options,tabpages,winsize",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002423 (char_u *)0L}
2424#else
2425 (char_u *)NULL, PV_NONE,
2426 {(char_u *)0L, (char_u *)0L}
2427#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002428 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002429 {"shell", "sh", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2430 (char_u *)&p_sh, PV_NONE,
2431 {
2432#ifdef VMS
2433 (char_u *)"-",
2434#else
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002435# if defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002436 (char_u *)"", /* set in set_init_1() */
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002437# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002438 (char_u *)"sh",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002439# endif
2440#endif /* VMS */
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002441 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002442 {"shellcmdflag","shcf", P_STRING|P_VI_DEF|P_SECURE,
2443 (char_u *)&p_shcf, PV_NONE,
2444 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002445#if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002446 (char_u *)"/c",
2447#else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002448 (char_u *)"-c",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002449#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002450 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002451 {"shellpipe", "sp", P_STRING|P_VI_DEF|P_SECURE,
2452#ifdef FEAT_QUICKFIX
2453 (char_u *)&p_sp, PV_NONE,
2454 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01002455#if defined(UNIX)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002456 (char_u *)"| tee",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002457#else
2458 (char_u *)">",
2459#endif
2460 (char_u *)0L}
2461#else
2462 (char_u *)NULL, PV_NONE,
2463 {(char_u *)0L, (char_u *)0L}
2464#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002465 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002466 {"shellquote", "shq", P_STRING|P_VI_DEF|P_SECURE,
2467 (char_u *)&p_shq, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002468 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002469 {"shellredir", "srr", P_STRING|P_VI_DEF|P_SECURE,
2470 (char_u *)&p_srr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002471 {(char_u *)">", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002472 {"shellslash", "ssl", P_BOOL|P_VI_DEF,
2473#ifdef BACKSLASH_IN_FILENAME
2474 (char_u *)&p_ssl, PV_NONE,
2475#else
2476 (char_u *)NULL, PV_NONE,
2477#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002478 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar26a60b42005-02-22 08:49:11 +00002479 {"shelltemp", "stmp", P_BOOL,
2480 (char_u *)&p_stmp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002481 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002482 {"shelltype", "st", P_NUM|P_VI_DEF,
2483#ifdef AMIGA
2484 (char_u *)&p_st, PV_NONE,
2485#else
2486 (char_u *)NULL, PV_NONE,
2487#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002488 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002489 {"shellxquote", "sxq", P_STRING|P_VI_DEF|P_SECURE,
2490 (char_u *)&p_sxq, PV_NONE,
2491 {
Bram Moolenaara06ecab2016-07-16 14:47:36 +02002492#if defined(UNIX) && defined(USE_SYSTEM)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002493 (char_u *)"\"",
2494#else
2495 (char_u *)"",
2496#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002497 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf66b3fc2012-02-20 22:18:30 +01002498 {"shellxescape", "sxe", P_STRING|P_VI_DEF|P_SECURE,
2499 (char_u *)&p_sxe, PV_NONE,
2500 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002501#if defined(WIN3264)
Bram Moolenaarf66b3fc2012-02-20 22:18:30 +01002502 (char_u *)"\"&|<>()@^",
2503#else
2504 (char_u *)"",
2505#endif
2506 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002507 {"shiftround", "sr", P_BOOL|P_VI_DEF|P_VIM,
2508 (char_u *)&p_sr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002509 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002510 {"shiftwidth", "sw", P_NUM|P_VI_DEF,
2511 (char_u *)&p_sw, PV_SW,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002512 {(char_u *)8L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002513 {"shortmess", "shm", P_STRING|P_VIM|P_FLAGLIST,
2514 (char_u *)&p_shm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002515 {(char_u *)"", (char_u *)"filnxtToO"}
2516 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002517 {"shortname", "sn", P_BOOL|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002518 (char_u *)&p_sn, PV_SN,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002519 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002520 {"showbreak", "sbr", P_STRING|P_VI_DEF|P_RALL,
2521#ifdef FEAT_LINEBREAK
2522 (char_u *)&p_sbr, PV_NONE,
2523#else
2524 (char_u *)NULL, PV_NONE,
2525#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002526 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002527 {"showcmd", "sc", P_BOOL|P_VIM,
2528#ifdef FEAT_CMDL_INFO
2529 (char_u *)&p_sc, PV_NONE,
2530#else
2531 (char_u *)NULL, PV_NONE,
2532#endif
2533 {(char_u *)FALSE,
2534#ifdef UNIX
2535 (char_u *)FALSE
2536#else
2537 (char_u *)TRUE
2538#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002539 } SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002540 {"showfulltag", "sft", P_BOOL|P_VI_DEF,
2541 (char_u *)&p_sft, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002542 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002543 {"showmatch", "sm", P_BOOL|P_VI_DEF,
2544 (char_u *)&p_sm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002545 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002546 {"showmode", "smd", P_BOOL|P_VIM,
2547 (char_u *)&p_smd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002548 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00002549 {"showtabline", "stal", P_NUM|P_VI_DEF|P_RALL,
2550#ifdef FEAT_WINDOWS
2551 (char_u *)&p_stal, PV_NONE,
2552#else
2553 (char_u *)NULL, PV_NONE,
2554#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002555 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002556 {"sidescroll", "ss", P_NUM|P_VI_DEF,
2557 (char_u *)&p_ss, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002558 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002559 {"sidescrolloff", "siso", P_NUM|P_VI_DEF|P_VIM|P_RBUF,
2560 (char_u *)&p_siso, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002561 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar95ec9d62016-08-12 18:29:59 +02002562 {"signcolumn", "scl", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN,
2563#ifdef FEAT_SIGNS
2564 (char_u *)VAR_WIN, PV_SCL,
Bram Moolenaarb3384832016-08-12 18:51:58 +02002565 {(char_u *)"auto", (char_u *)0L}
Bram Moolenaar95ec9d62016-08-12 18:29:59 +02002566#else
2567 (char_u *)NULL, PV_NONE,
2568 {(char_u *)NULL, (char_u *)0L}
2569#endif
Bram Moolenaarb3384832016-08-12 18:51:58 +02002570 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002571 {"slowopen", "slow", P_BOOL|P_VI_DEF,
2572 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002573 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002574 {"smartcase", "scs", P_BOOL|P_VI_DEF|P_VIM,
2575 (char_u *)&p_scs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002576 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002577 {"smartindent", "si", P_BOOL|P_VI_DEF|P_VIM,
2578#ifdef FEAT_SMARTINDENT
2579 (char_u *)&p_si, PV_SI,
2580#else
2581 (char_u *)NULL, PV_NONE,
2582#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002583 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002584 {"smarttab", "sta", P_BOOL|P_VI_DEF|P_VIM,
2585 (char_u *)&p_sta, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002586 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002587 {"softtabstop", "sts", P_NUM|P_VI_DEF|P_VIM,
2588 (char_u *)&p_sts, PV_STS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002589 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002590 {"sourceany", NULL, P_BOOL|P_VI_DEF,
2591 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002592 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar217ad922005-03-20 22:37:15 +00002593 {"spell", NULL, P_BOOL|P_VI_DEF|P_RWIN,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002594#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +00002595 (char_u *)VAR_WIN, PV_SPELL,
2596#else
2597 (char_u *)NULL, PV_NONE,
2598#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002599 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar488c6512005-08-11 20:09:58 +00002600 {"spellcapcheck", "spc", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002601#ifdef FEAT_SPELL
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00002602 (char_u *)&p_spc, PV_SPC,
Bram Moolenaar0dc065e2005-07-04 22:49:24 +00002603 {(char_u *)"[.?!]\\_[\\])'\" ]\\+", (char_u *)0L}
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00002604#else
2605 (char_u *)NULL, PV_NONE,
2606 {(char_u *)0L, (char_u *)0L}
2607#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002608 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002609 {"spellfile", "spf", P_STRING|P_EXPAND|P_ALLOCED|P_VI_DEF|P_SECURE
2610 |P_ONECOMMA,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002611#ifdef FEAT_SPELL
Bram Moolenaar82cf9b62005-06-07 21:09:25 +00002612 (char_u *)&p_spf, PV_SPF,
2613 {(char_u *)"", (char_u *)0L}
2614#else
2615 (char_u *)NULL, PV_NONE,
2616 {(char_u *)0L, (char_u *)0L}
2617#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002618 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002619 {"spelllang", "spl", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA
2620 |P_RBUF|P_EXPAND,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002621#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +00002622 (char_u *)&p_spl, PV_SPL,
Bram Moolenaar82cf9b62005-06-07 21:09:25 +00002623 {(char_u *)"en", (char_u *)0L}
Bram Moolenaar217ad922005-03-20 22:37:15 +00002624#else
2625 (char_u *)NULL, PV_NONE,
2626 {(char_u *)0L, (char_u *)0L}
2627#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002628 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002629 {"spellsuggest", "sps", P_STRING|P_VI_DEF|P_EXPAND|P_SECURE|P_ONECOMMA,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002630#ifdef FEAT_SPELL
Bram Moolenaard857f0e2005-06-21 22:37:39 +00002631 (char_u *)&p_sps, PV_NONE,
2632 {(char_u *)"best", (char_u *)0L}
2633#else
2634 (char_u *)NULL, PV_NONE,
2635 {(char_u *)0L, (char_u *)0L}
2636#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002637 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002638 {"splitbelow", "sb", P_BOOL|P_VI_DEF,
2639#ifdef FEAT_WINDOWS
2640 (char_u *)&p_sb, PV_NONE,
2641#else
2642 (char_u *)NULL, PV_NONE,
2643#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002644 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002645 {"splitright", "spr", P_BOOL|P_VI_DEF,
Bram Moolenaar44a2f922016-03-19 22:11:51 +01002646#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002647 (char_u *)&p_spr, PV_NONE,
2648#else
2649 (char_u *)NULL, PV_NONE,
2650#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002651 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002652 {"startofline", "sol", P_BOOL|P_VI_DEF|P_VIM,
2653 (char_u *)&p_sol, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002654 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002655 {"statusline" ,"stl", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT,
2656#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002657 (char_u *)&p_stl, PV_STL,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002658#else
2659 (char_u *)NULL, PV_NONE,
2660#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002661 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002662 {"suffixes", "su", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002663 (char_u *)&p_su, PV_NONE,
2664 {(char_u *)".bak,~,.o,.h,.info,.swp,.obj",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002665 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002666 {"suffixesadd", "sua", P_STRING|P_VI_DEF|P_ALLOCED|P_ONECOMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002667#ifdef FEAT_SEARCHPATH
Bram Moolenaar071d4272004-06-13 20:20:40 +00002668 (char_u *)&p_sua, PV_SUA,
2669 {(char_u *)"", (char_u *)0L}
2670#else
2671 (char_u *)NULL, PV_NONE,
2672 {(char_u *)0L, (char_u *)0L}
2673#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002674 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002675 {"swapfile", "swf", P_BOOL|P_VI_DEF|P_RSTAT,
2676 (char_u *)&p_swf, PV_SWF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002677 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002678 {"swapsync", "sws", P_STRING|P_VI_DEF,
2679 (char_u *)&p_sws, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002680 {(char_u *)"fsync", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002681 {"switchbuf", "swb", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002682 (char_u *)&p_swb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002683 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar3b56eb32005-07-11 22:40:32 +00002684 {"synmaxcol", "smc", P_NUM|P_VI_DEF|P_RBUF,
2685#ifdef FEAT_SYN_HL
2686 (char_u *)&p_smc, PV_SMC,
2687 {(char_u *)3000L, (char_u *)0L}
2688#else
2689 (char_u *)NULL, PV_NONE,
2690 {(char_u *)0L, (char_u *)0L}
2691#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002692 SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002693 {"syntax", "syn", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002694#ifdef FEAT_SYN_HL
2695 (char_u *)&p_syn, PV_SYN,
2696 {(char_u *)"", (char_u *)0L}
2697#else
2698 (char_u *)NULL, PV_NONE,
2699 {(char_u *)0L, (char_u *)0L}
2700#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002701 SCRIPTID_INIT},
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00002702 {"tabline", "tal", P_STRING|P_VI_DEF|P_RALL,
2703#ifdef FEAT_STL_OPT
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00002704 (char_u *)&p_tal, PV_NONE,
2705#else
2706 (char_u *)NULL, PV_NONE,
2707#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002708 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarfd2ac762006-03-01 22:09:21 +00002709 {"tabpagemax", "tpm", P_NUM|P_VI_DEF,
2710#ifdef FEAT_WINDOWS
2711 (char_u *)&p_tpm, PV_NONE,
2712#else
2713 (char_u *)NULL, PV_NONE,
2714#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002715 {(char_u *)10L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002716 {"tabstop", "ts", P_NUM|P_VI_DEF|P_RBUF,
2717 (char_u *)&p_ts, PV_TS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002718 {(char_u *)8L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002719 {"tagbsearch", "tbs", P_BOOL|P_VI_DEF,
2720 (char_u *)&p_tbs, PV_NONE,
2721#ifdef VMS /* binary searching doesn't appear to work on VMS */
2722 {(char_u *)0L, (char_u *)0L}
2723#else
2724 {(char_u *)TRUE, (char_u *)0L}
2725#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002726 SCRIPTID_INIT},
Bram Moolenaar0f6562e2015-11-24 18:48:14 +01002727 {"tagcase", "tc", P_STRING|P_VIM,
2728 (char_u *)&p_tc, PV_TC,
2729 {(char_u *)"followic", (char_u *)"followic"} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002730 {"taglength", "tl", P_NUM|P_VI_DEF,
2731 (char_u *)&p_tl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002732 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002733 {"tagrelative", "tr", P_BOOL|P_VIM,
2734 (char_u *)&p_tr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002735 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002736 {"tags", "tag", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002737 (char_u *)&p_tags, PV_TAGS,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002738 {
2739#if defined(FEAT_EMACS_TAGS) && !defined(CASE_INSENSITIVE_FILENAME)
2740 (char_u *)"./tags,./TAGS,tags,TAGS",
2741#else
2742 (char_u *)"./tags,tags",
2743#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002744 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002745 {"tagstack", "tgst", P_BOOL|P_VI_DEF,
2746 (char_u *)&p_tgst, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002747 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaara6e42502016-04-20 16:19:52 +02002748 {"tcldll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002749#if defined(DYNAMIC_TCL)
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01002750 (char_u *)&p_tcldll, PV_NONE,
2751 {(char_u *)DYNAMIC_TCL_DLL, (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01002752#else
2753 (char_u *)NULL, PV_NONE,
2754 {(char_u *)0L, (char_u *)0L}
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01002755#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +01002756 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002757 {"term", NULL, P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL,
2758 (char_u *)&T_NAME, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002759 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002760 {"termbidi", "tbidi", P_BOOL|P_VI_DEF,
2761#ifdef FEAT_ARABIC
2762 (char_u *)&p_tbidi, PV_NONE,
2763#else
2764 (char_u *)NULL, PV_NONE,
2765#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002766 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002767 {"termencoding", "tenc", P_STRING|P_VI_DEF|P_RCLR,
2768#ifdef FEAT_MBYTE
2769 (char_u *)&p_tenc, PV_NONE,
2770 {(char_u *)"", (char_u *)0L}
2771#else
2772 (char_u *)NULL, PV_NONE,
2773 {(char_u *)0L, (char_u *)0L}
2774#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002775 SCRIPTID_INIT},
Bram Moolenaar61be73b2016-04-29 22:59:22 +02002776 {"termguicolors", "tgc", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
2777#ifdef FEAT_TERMGUICOLORS
2778 (char_u *)&p_tgc, PV_NONE,
2779 {(char_u *)FALSE, (char_u *)FALSE}
2780#else
2781 (char_u*)NULL, PV_NONE,
2782 {(char_u *)FALSE, (char_u *)FALSE}
2783#endif
2784 SCRIPTID_INIT},
Bram Moolenaar1b0675c2017-07-15 14:04:01 +02002785 {"termkey", "tk", P_STRING|P_ALLOCED|P_RWIN|P_VI_DEF,
2786#ifdef FEAT_TERMINAL
2787 (char_u *)VAR_WIN, PV_TK,
2788 {(char_u *)"\x17", (char_u *)NULL}
2789#else
2790 (char_u *)NULL, PV_NONE,
2791 {(char_u *)NULL, (char_u *)0L}
2792#endif
2793 SCRIPTID_INIT},
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002794 {"termsize", "tms", P_STRING|P_ALLOCED|P_RWIN|P_VI_DEF,
2795#ifdef FEAT_TERMINAL
2796 (char_u *)VAR_WIN, PV_TMS,
2797 {(char_u *)"", (char_u *)NULL}
2798#else
2799 (char_u *)NULL, PV_NONE,
2800 {(char_u *)NULL, (char_u *)0L}
2801#endif
2802 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002803 {"terse", NULL, P_BOOL|P_VI_DEF,
2804 (char_u *)&p_terse, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002805 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002806 {"textauto", "ta", P_BOOL|P_VIM,
2807 (char_u *)&p_ta, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002808 {(char_u *)DFLT_TEXTAUTO, (char_u *)TRUE}
2809 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002810 {"textmode", "tx", P_BOOL|P_VI_DEF|P_NO_MKRC,
2811 (char_u *)&p_tx, PV_TX,
2812 {
2813#ifdef USE_CRNL
2814 (char_u *)TRUE,
2815#else
2816 (char_u *)FALSE,
2817#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002818 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar1a384422010-07-14 19:53:30 +02002819 {"textwidth", "tw", P_NUM|P_VI_DEF|P_VIM|P_RBUF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002820 (char_u *)&p_tw, PV_TW,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002821 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf422bcc2016-11-26 17:45:53 +01002822 {"thesaurus", "tsr", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP|P_NDNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002823#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002824 (char_u *)&p_tsr, PV_TSR,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002825#else
2826 (char_u *)NULL, PV_NONE,
2827#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002828 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002829 {"tildeop", "top", P_BOOL|P_VI_DEF|P_VIM,
2830 (char_u *)&p_to, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002831 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002832 {"timeout", "to", P_BOOL|P_VI_DEF,
2833 (char_u *)&p_timeout, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002834 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002835 {"timeoutlen", "tm", P_NUM|P_VI_DEF,
2836 (char_u *)&p_tm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002837 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002838 {"title", NULL, P_BOOL|P_VI_DEF,
2839#ifdef FEAT_TITLE
2840 (char_u *)&p_title, PV_NONE,
2841#else
2842 (char_u *)NULL, PV_NONE,
2843#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002844 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002845 {"titlelen", NULL, P_NUM|P_VI_DEF,
2846#ifdef FEAT_TITLE
2847 (char_u *)&p_titlelen, PV_NONE,
2848#else
2849 (char_u *)NULL, PV_NONE,
2850#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002851 {(char_u *)85L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00002852 {"titleold", NULL, P_STRING|P_VI_DEF|P_GETTEXT|P_SECURE|P_NO_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002853#ifdef FEAT_TITLE
2854 (char_u *)&p_titleold, PV_NONE,
2855 {(char_u *)N_("Thanks for flying Vim"),
2856 (char_u *)0L}
2857#else
2858 (char_u *)NULL, PV_NONE,
2859 {(char_u *)0L, (char_u *)0L}
2860#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002861 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002862 {"titlestring", NULL, P_STRING|P_VI_DEF,
2863#ifdef FEAT_TITLE
2864 (char_u *)&p_titlestring, 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 Moolenaar0e7c4b92015-06-20 15:30:03 +02002869 {"toolbar", "tb", P_STRING|P_ONECOMMA|P_VI_DEF|P_NODUP,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002870#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002871 (char_u *)&p_toolbar, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002872 {(char_u *)"icons,tooltips", (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01002873#else
2874 (char_u *)NULL, PV_NONE,
2875 {(char_u *)0L, (char_u *)0L}
2876#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002877 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002878 {"toolbariconsize", "tbis", P_STRING|P_VI_DEF,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002879#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002880 (char_u *)&p_tbis, PV_NONE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002881 {(char_u *)"small", (char_u *)0L}
2882#else
2883 (char_u *)NULL, PV_NONE,
2884 {(char_u *)0L, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002885#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +01002886 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002887 {"ttimeout", NULL, P_BOOL|P_VI_DEF|P_VIM,
2888 (char_u *)&p_ttimeout, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002889 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002890 {"ttimeoutlen", "ttm", P_NUM|P_VI_DEF,
2891 (char_u *)&p_ttm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002892 {(char_u *)-1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002893 {"ttybuiltin", "tbi", P_BOOL|P_VI_DEF,
2894 (char_u *)&p_tbi, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002895 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002896 {"ttyfast", "tf", P_BOOL|P_NO_MKRC|P_VI_DEF,
2897 (char_u *)&p_tf, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002898 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002899 {"ttymouse", "ttym", P_STRING|P_NODEFAULT|P_NO_MKRC|P_VI_DEF,
2900#if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
2901 (char_u *)&p_ttym, PV_NONE,
2902#else
2903 (char_u *)NULL, PV_NONE,
2904#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002905 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002906 {"ttyscroll", "tsl", P_NUM|P_VI_DEF,
2907 (char_u *)&p_ttyscroll, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002908 {(char_u *)999L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002909 {"ttytype", "tty", P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL,
2910 (char_u *)&T_NAME, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002911 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002912 {"undodir", "udir", P_STRING|P_EXPAND|P_ONECOMMA|P_NODUP|P_SECURE
2913 |P_VI_DEF,
Bram Moolenaar55debbe2010-05-23 23:34:36 +02002914#ifdef FEAT_PERSISTENT_UNDO
2915 (char_u *)&p_udir, PV_NONE,
2916 {(char_u *)".", (char_u *)0L}
2917#else
2918 (char_u *)NULL, PV_NONE,
2919 {(char_u *)0L, (char_u *)0L}
2920#endif
2921 SCRIPTID_INIT},
2922 {"undofile", "udf", P_BOOL|P_VI_DEF|P_VIM,
2923#ifdef FEAT_PERSISTENT_UNDO
2924 (char_u *)&p_udf, PV_UDF,
2925#else
2926 (char_u *)NULL, PV_NONE,
2927#endif
2928 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002929 {"undolevels", "ul", P_NUM|P_VI_DEF,
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01002930 (char_u *)&p_ul, PV_UL,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002931 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01002932#if defined(UNIX) || defined(WIN3264) || defined(VMS)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002933 (char_u *)1000L,
2934#else
2935 (char_u *)100L,
2936#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002937 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar59f931e2010-07-24 20:27:03 +02002938 {"undoreload", "ur", P_NUM|P_VI_DEF,
2939 (char_u *)&p_ur, PV_NONE,
2940 { (char_u *)10000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002941 {"updatecount", "uc", P_NUM|P_VI_DEF,
2942 (char_u *)&p_uc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002943 {(char_u *)200L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002944 {"updatetime", "ut", P_NUM|P_VI_DEF,
2945 (char_u *)&p_ut, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002946 {(char_u *)4000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002947 {"verbose", "vbs", P_NUM|P_VI_DEF,
2948 (char_u *)&p_verbose, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002949 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar54ee7752005-05-31 22:22:17 +00002950 {"verbosefile", "vfile", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2951 (char_u *)&p_vfile, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002952 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002953 {"viewdir", "vdir", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2954#ifdef FEAT_SESSION
2955 (char_u *)&p_vdir, PV_NONE,
2956 {(char_u *)DFLT_VDIR, (char_u *)0L}
2957#else
2958 (char_u *)NULL, PV_NONE,
2959 {(char_u *)0L, (char_u *)0L}
2960#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002961 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002962 {"viewoptions", "vop", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002963#ifdef FEAT_SESSION
2964 (char_u *)&p_vop, PV_NONE,
2965 {(char_u *)"folds,options,cursor", (char_u *)0L}
2966#else
2967 (char_u *)NULL, PV_NONE,
2968 {(char_u *)0L, (char_u *)0L}
2969#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002970 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002971 {"viminfo", "vi", P_STRING|P_ONECOMMA|P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002972#ifdef FEAT_VIMINFO
2973 (char_u *)&p_viminfo, PV_NONE,
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002974#if defined(MSWIN)
Bram Moolenaard812df62008-11-09 12:46:09 +00002975 {(char_u *)"", (char_u *)"'100,<50,s10,h,rA:,rB:"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002976#else
2977# ifdef AMIGA
2978 {(char_u *)"",
Bram Moolenaard812df62008-11-09 12:46:09 +00002979 (char_u *)"'100,<50,s10,h,rdf0:,rdf1:,rdf2:"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002980# else
Bram Moolenaard812df62008-11-09 12:46:09 +00002981 {(char_u *)"", (char_u *)"'100,<50,s10,h"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002982# endif
2983#endif
2984#else
2985 (char_u *)NULL, PV_NONE,
2986 {(char_u *)0L, (char_u *)0L}
2987#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002988 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002989 {"virtualedit", "ve", P_STRING|P_ONECOMMA|P_NODUP|P_VI_DEF
2990 |P_VIM|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002991#ifdef FEAT_VIRTUALEDIT
2992 (char_u *)&p_ve, PV_NONE,
2993 {(char_u *)"", (char_u *)""}
2994#else
2995 (char_u *)NULL, PV_NONE,
2996 {(char_u *)0L, (char_u *)0L}
2997#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002998 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002999 {"visualbell", "vb", P_BOOL|P_VI_DEF,
3000 (char_u *)&p_vb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003001 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003002 {"w300", NULL, P_NUM|P_VI_DEF,
3003 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003004 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003005 {"w1200", NULL, P_NUM|P_VI_DEF,
3006 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003007 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003008 {"w9600", NULL, P_NUM|P_VI_DEF,
3009 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003010 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003011 {"warn", NULL, P_BOOL|P_VI_DEF,
3012 (char_u *)&p_warn, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003013 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003014 {"weirdinvert", "wiv", P_BOOL|P_VI_DEF|P_RCLR,
3015 (char_u *)&p_wiv, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003016 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02003017 {"whichwrap", "ww", P_STRING|P_VIM|P_ONECOMMA|P_FLAGLIST,
Bram Moolenaar071d4272004-06-13 20:20:40 +00003018 (char_u *)&p_ww, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003019 {(char_u *)"", (char_u *)"b,s"} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003020 {"wildchar", "wc", P_NUM|P_VIM,
3021 (char_u *)&p_wc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003022 {(char_u *)(long)Ctrl_E, (char_u *)(long)TAB}
3023 SCRIPTID_INIT},
Bram Moolenaar94950a92010-12-02 16:01:29 +01003024 {"wildcharm", "wcm", P_NUM|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00003025 (char_u *)&p_wcm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003026 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02003027 {"wildignore", "wig", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00003028#ifdef FEAT_WILDIGN
3029 (char_u *)&p_wig, PV_NONE,
3030#else
3031 (char_u *)NULL, PV_NONE,
3032#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003033 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar94950a92010-12-02 16:01:29 +01003034 {"wildignorecase", "wic", P_BOOL|P_VI_DEF,
3035 (char_u *)&p_wic, PV_NONE,
3036 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003037 {"wildmenu", "wmnu", P_BOOL|P_VI_DEF,
3038#ifdef FEAT_WILDMENU
3039 (char_u *)&p_wmnu, PV_NONE,
3040#else
3041 (char_u *)NULL, PV_NONE,
3042#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003043 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02003044 {"wildmode", "wim", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00003045 (char_u *)&p_wim, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003046 {(char_u *)"full", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00003047 {"wildoptions", "wop", P_STRING|P_VI_DEF,
3048#ifdef FEAT_CMDL_COMPL
3049 (char_u *)&p_wop, PV_NONE,
3050 {(char_u *)"", (char_u *)0L}
3051#else
3052 (char_u *)NULL, PV_NONE,
3053 {(char_u *)NULL, (char_u *)0L}
3054#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003055 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003056 {"winaltkeys", "wak", P_STRING|P_VI_DEF,
3057#ifdef FEAT_WAK
3058 (char_u *)&p_wak, PV_NONE,
3059 {(char_u *)"menu", (char_u *)0L}
3060#else
3061 (char_u *)NULL, PV_NONE,
3062 {(char_u *)NULL, (char_u *)0L}
3063#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003064 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003065 {"window", "wi", P_NUM|P_VI_DEF,
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003066 (char_u *)&p_window, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003067 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003068 {"winheight", "wh", P_NUM|P_VI_DEF,
3069#ifdef FEAT_WINDOWS
3070 (char_u *)&p_wh, PV_NONE,
3071#else
3072 (char_u *)NULL, PV_NONE,
3073#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003074 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003075 {"winfixheight", "wfh", P_BOOL|P_VI_DEF|P_RSTAT,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003076#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00003077 (char_u *)VAR_WIN, PV_WFH,
3078#else
3079 (char_u *)NULL, PV_NONE,
3080#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003081 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00003082 {"winfixwidth", "wfw", P_BOOL|P_VI_DEF|P_RSTAT,
Bram Moolenaar44a2f922016-03-19 22:11:51 +01003083#ifdef FEAT_WINDOWS
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00003084 (char_u *)VAR_WIN, PV_WFW,
3085#else
3086 (char_u *)NULL, PV_NONE,
3087#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003088 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003089 {"winminheight", "wmh", P_NUM|P_VI_DEF,
3090#ifdef FEAT_WINDOWS
3091 (char_u *)&p_wmh, PV_NONE,
3092#else
3093 (char_u *)NULL, PV_NONE,
3094#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003095 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003096 {"winminwidth", "wmw", P_NUM|P_VI_DEF,
Bram Moolenaar44a2f922016-03-19 22:11:51 +01003097#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00003098 (char_u *)&p_wmw, PV_NONE,
3099#else
3100 (char_u *)NULL, PV_NONE,
3101#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003102 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003103 {"winwidth", "wiw", P_NUM|P_VI_DEF,
Bram Moolenaar44a2f922016-03-19 22:11:51 +01003104#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00003105 (char_u *)&p_wiw, PV_NONE,
3106#else
3107 (char_u *)NULL, PV_NONE,
3108#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003109 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003110 {"wrap", NULL, P_BOOL|P_VI_DEF|P_RWIN,
3111 (char_u *)VAR_WIN, PV_WRAP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003112 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003113 {"wrapmargin", "wm", P_NUM|P_VI_DEF,
3114 (char_u *)&p_wm, PV_WM,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003115 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003116 {"wrapscan", "ws", P_BOOL|P_VI_DEF,
3117 (char_u *)&p_ws, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003118 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003119 {"write", NULL, P_BOOL|P_VI_DEF,
3120 (char_u *)&p_write, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003121 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003122 {"writeany", "wa", P_BOOL|P_VI_DEF,
3123 (char_u *)&p_wa, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003124 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003125 {"writebackup", "wb", P_BOOL|P_VI_DEF|P_VIM,
3126 (char_u *)&p_wb, PV_NONE,
3127 {
3128#ifdef FEAT_WRITEBACKUP
3129 (char_u *)TRUE,
3130#else
3131 (char_u *)FALSE,
3132#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003133 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003134 {"writedelay", "wd", P_NUM|P_VI_DEF,
3135 (char_u *)&p_wd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003136 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003137
3138/* terminal output codes */
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00003139#define p_term(sss, vvv) {sss, NULL, P_STRING|P_VI_DEF|P_RALL|P_SECURE, \
Bram Moolenaar071d4272004-06-13 20:20:40 +00003140 (char_u *)&vvv, PV_NONE, \
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003141 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003142
3143 p_term("t_AB", T_CAB)
3144 p_term("t_AF", T_CAF)
3145 p_term("t_AL", T_CAL)
3146 p_term("t_al", T_AL)
3147 p_term("t_bc", T_BC)
3148 p_term("t_cd", T_CD)
3149 p_term("t_ce", T_CE)
3150 p_term("t_cl", T_CL)
3151 p_term("t_cm", T_CM)
Bram Moolenaar450ca432015-11-10 13:30:39 +01003152 p_term("t_Ce", T_UCE)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003153 p_term("t_Co", T_CCO)
3154 p_term("t_CS", T_CCS)
Bram Moolenaar450ca432015-11-10 13:30:39 +01003155 p_term("t_Cs", T_UCS)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003156 p_term("t_cs", T_CS)
Bram Moolenaar44a2f922016-03-19 22:11:51 +01003157#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00003158 p_term("t_CV", T_CSV)
3159#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003160 p_term("t_da", T_DA)
3161 p_term("t_db", T_DB)
3162 p_term("t_DL", T_CDL)
3163 p_term("t_dl", T_DL)
Bram Moolenaare5401222015-06-25 19:16:56 +02003164 p_term("t_EI", T_CEI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003165 p_term("t_fs", T_FS)
3166 p_term("t_IE", T_CIE)
3167 p_term("t_IS", T_CIS)
3168 p_term("t_ke", T_KE)
3169 p_term("t_ks", T_KS)
3170 p_term("t_le", T_LE)
3171 p_term("t_mb", T_MB)
3172 p_term("t_md", T_MD)
3173 p_term("t_me", T_ME)
3174 p_term("t_mr", T_MR)
3175 p_term("t_ms", T_MS)
3176 p_term("t_nd", T_ND)
3177 p_term("t_op", T_OP)
Bram Moolenaare5401222015-06-25 19:16:56 +02003178 p_term("t_RB", T_RBG)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003179 p_term("t_RI", T_CRI)
3180 p_term("t_RV", T_CRV)
3181 p_term("t_Sb", T_CSB)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003182 p_term("t_se", T_SE)
Bram Moolenaare5401222015-06-25 19:16:56 +02003183 p_term("t_Sf", T_CSF)
3184 p_term("t_SI", T_CSI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003185 p_term("t_so", T_SO)
Bram Moolenaare5401222015-06-25 19:16:56 +02003186 p_term("t_SR", T_CSR)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003187 p_term("t_sr", T_SR)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003188 p_term("t_te", T_TE)
3189 p_term("t_ti", T_TI)
Bram Moolenaare5401222015-06-25 19:16:56 +02003190 p_term("t_ts", T_TS)
3191 p_term("t_u7", T_U7)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003192 p_term("t_ue", T_UE)
3193 p_term("t_us", T_US)
Bram Moolenaare5401222015-06-25 19:16:56 +02003194 p_term("t_ut", T_UT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003195 p_term("t_vb", T_VB)
3196 p_term("t_ve", T_VE)
3197 p_term("t_vi", T_VI)
3198 p_term("t_vs", T_VS)
3199 p_term("t_WP", T_CWP)
Bram Moolenaar9f928862017-04-11 22:44:05 +02003200 p_term("t_GP", T_CGP)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003201 p_term("t_WS", T_CWS)
Bram Moolenaar494838a2015-02-10 19:20:37 +01003202 p_term("t_xn", T_XN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003203 p_term("t_xs", T_XS)
3204 p_term("t_ZH", T_CZH)
3205 p_term("t_ZR", T_CZR)
Bram Moolenaar8a633e32016-04-21 21:10:14 +02003206 p_term("t_8f", T_8F)
3207 p_term("t_8b", T_8B)
Bram Moolenaarec2da362017-01-21 20:04:22 +01003208 p_term("t_BE", T_BE)
3209 p_term("t_BD", T_BD)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003210
3211/* terminal key codes are not in here */
3212
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003213 /* end marker */
3214 {NULL, NULL, 0, NULL, PV_NONE, {NULL, NULL} SCRIPTID_INIT}
Bram Moolenaar071d4272004-06-13 20:20:40 +00003215};
3216
3217#define PARAM_COUNT (sizeof(options) / sizeof(struct vimoption))
3218
3219#ifdef FEAT_MBYTE
3220static char *(p_ambw_values[]) = {"single", "double", NULL};
3221#endif
3222static char *(p_bg_values[]) = {"light", "dark", NULL};
Bram Moolenaar887c1fe2016-01-02 17:56:35 +01003223static char *(p_nf_values[]) = {"bin", "octal", "hex", "alpha", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003224static char *(p_ff_values[]) = {FF_UNIX, FF_DOS, FF_MAC, NULL};
Bram Moolenaar49771f42010-07-20 17:32:38 +02003225#ifdef FEAT_CRYPT
Bram Moolenaar8f4ac012014-08-10 13:38:34 +02003226static char *(p_cm_values[]) = {"zip", "blowfish", "blowfish2", NULL};
Bram Moolenaar49771f42010-07-20 17:32:38 +02003227#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00003228#ifdef FEAT_CMDL_COMPL
3229static char *(p_wop_values[]) = {"tagfile", NULL};
3230#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003231#ifdef FEAT_WAK
3232static char *(p_wak_values[]) = {"yes", "menu", "no", NULL};
3233#endif
3234static char *(p_mousem_values[]) = {"extend", "popup", "popup_setpos", "mac", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003235static char *(p_sel_values[]) = {"inclusive", "exclusive", "old", NULL};
3236static char *(p_slm_values[]) = {"mouse", "key", "cmd", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003237static char *(p_km_values[]) = {"startsel", "stopsel", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003238#ifdef FEAT_BROWSE
3239static char *(p_bsdir_values[]) = {"current", "last", "buffer", NULL};
3240#endif
3241#ifdef FEAT_SCROLLBIND
3242static char *(p_scbopt_values[]) = {"ver", "hor", "jump", NULL};
3243#endif
Bram Moolenaar57657d82006-04-21 22:12:41 +00003244static char *(p_debug_values[]) = {"msg", "throw", "beep", NULL};
Bram Moolenaar44a2f922016-03-19 22:11:51 +01003245#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00003246static char *(p_ead_values[]) = {"both", "ver", "hor", NULL};
3247#endif
3248#if defined(FEAT_QUICKFIX)
Bram Moolenaar21cf8232004-07-16 20:18:37 +00003249# ifdef FEAT_AUTOCMD
3250static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", "acwrite", NULL};
3251# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00003252static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", NULL};
Bram Moolenaar21cf8232004-07-16 20:18:37 +00003253# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003254static char *(p_bufhidden_values[]) = {"hide", "unload", "delete", "wipe", NULL};
3255#endif
3256static char *(p_bs_values[]) = {"indent", "eol", "start", NULL};
3257#ifdef FEAT_FOLDING
3258static char *(p_fdm_values[]) = {"manual", "expr", "marker", "indent", "syntax",
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003259# ifdef FEAT_DIFF
Bram Moolenaar071d4272004-06-13 20:20:40 +00003260 "diff",
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003261# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003262 NULL};
3263static char *(p_fcl_values[]) = {"all", NULL};
3264#endif
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003265#ifdef FEAT_INS_EXPAND
Bram Moolenaarb6be1e22015-07-10 18:18:40 +02003266static char *(p_cot_values[]) = {"menu", "menuone", "longest", "preview", "noinsert", "noselect", NULL};
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003267#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +02003268#ifdef FEAT_SIGNS
3269static char *(p_scl_values[]) = {"yes", "no", "auto", NULL};
3270#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003271
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003272static void set_option_default(int, int opt_flags, int compatible);
3273static void set_options_default(int opt_flags);
3274static char_u *term_bg_default(void);
3275static void did_set_option(int opt_idx, int opt_flags, int new_value);
3276static char_u *illegal_char(char_u *, int);
3277static int string_to_key(char_u *arg);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003278#ifdef FEAT_CMDWIN
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003279static char_u *check_cedit(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003280#endif
3281#ifdef FEAT_TITLE
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003282static void did_set_title(int icon);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003283#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003284static char_u *option_expand(int opt_idx, char_u *val);
3285static void didset_options(void);
3286static void didset_options2(void);
3287static void check_string_option(char_u **pp);
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003288#if defined(FEAT_EVAL) || defined(PROTO)
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003289static long_u *insecure_flag(int opt_idx, int opt_flags);
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003290#else
3291# define insecure_flag(opt_idx, opt_flags) (&options[opt_idx].flags)
3292#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003293static void set_string_option_global(int opt_idx, char_u **varp);
3294static char_u *set_string_option(int opt_idx, char_u *value, int opt_flags);
3295static 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);
3296static char_u *set_chars_option(char_u **varp);
Bram Moolenaar1a384422010-07-14 19:53:30 +02003297#ifdef FEAT_SYN_HL
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003298static int int_cmp(const void *a, const void *b);
Bram Moolenaar1a384422010-07-14 19:53:30 +02003299#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003300#ifdef FEAT_CLIPBOARD
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003301static char_u *check_clipboard_option(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003302#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00003303#ifdef FEAT_SPELL
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003304static char_u *did_set_spell_option(int is_spellfile);
3305static char_u *compile_cap_prog(synblock_T *synblock);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00003306#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003307#ifdef FEAT_EVAL
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003308static void set_option_scriptID_idx(int opt_idx, int opt_flags, int id);
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003309#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003310static char_u *set_bool_option(int opt_idx, char_u *varp, int value, int opt_flags);
3311static char_u *set_num_option(int opt_idx, char_u *varp, long value, char_u *errbuf, size_t errbuflen, int opt_flags);
3312static void check_redraw(long_u flags);
3313static int findoption(char_u *);
3314static int find_key_option(char_u *);
3315static void showoptions(int all, int opt_flags);
3316static int optval_default(struct vimoption *, char_u *varp);
3317static void showoneopt(struct vimoption *, int opt_flags);
3318static int put_setstring(FILE *fd, char *cmd, char *name, char_u **valuep, int expand);
3319static int put_setnum(FILE *fd, char *cmd, char *name, long *valuep);
3320static int put_setbool(FILE *fd, char *cmd, char *name, int value);
3321static int istermoption(struct vimoption *);
3322static char_u *get_varp_scope(struct vimoption *p, int opt_flags);
3323static char_u *get_varp(struct vimoption *);
3324static void option_value2string(struct vimoption *, int opt_flags);
3325static void check_winopt(winopt_T *wop);
3326static int wc_use_keyname(char_u *varp, long *wcp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003327#ifdef FEAT_LANGMAP
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003328static void langmap_init(void);
3329static void langmap_set(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003330#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003331static void paste_option_changed(void);
3332static void compatible_set(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003333#ifdef FEAT_LINEBREAK
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003334static void fill_breakat_flags(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003335#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003336static int opt_strings_flags(char_u *val, char **values, unsigned *flagp, int list);
3337static int check_opt_strings(char_u *val, char **values, int);
3338static int check_opt_wim(void);
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02003339#ifdef FEAT_LINEBREAK
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003340static int briopt_check(win_T *wp);
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02003341#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003342
3343/*
3344 * Initialize the options, first part.
3345 *
3346 * Called only once from main(), just after creating the first buffer.
3347 */
3348 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003349set_init_1(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003350{
3351 char_u *p;
3352 int opt_idx;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00003353 long_u n;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003354
3355#ifdef FEAT_LANGMAP
3356 langmap_init();
3357#endif
3358
3359 /* Be Vi compatible by default */
3360 p_cp = TRUE;
3361
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003362 /* Use POSIX compatibility when $VIM_POSIX is set. */
3363 if (mch_getenv((char_u *)"VIM_POSIX") != NULL)
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003364 {
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003365 set_string_default("cpo", (char_u *)CPO_ALL);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003366 set_string_default("shm", (char_u *)"A");
3367 }
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003368
Bram Moolenaar071d4272004-06-13 20:20:40 +00003369 /*
3370 * Find default value for 'shell' option.
Bram Moolenaar7c626922005-02-07 22:01:03 +00003371 * Don't use it if it is empty.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003372 */
Bram Moolenaar7c626922005-02-07 22:01:03 +00003373 if (((p = mch_getenv((char_u *)"SHELL")) != NULL && *p != NUL)
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003374#if defined(MSWIN)
Bram Moolenaar7c626922005-02-07 22:01:03 +00003375 || ((p = mch_getenv((char_u *)"COMSPEC")) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003376# ifdef WIN3264
Bram Moolenaar6aa2cd42016-02-16 15:06:59 +01003377 || ((p = (char_u *)default_shell()) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003378# endif
3379#endif
Bram Moolenaar7c626922005-02-07 22:01:03 +00003380 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00003381 set_string_default("sh", p);
3382
3383#ifdef FEAT_WILDIGN
3384 /*
3385 * Set the default for 'backupskip' to include environment variables for
3386 * temp files.
3387 */
3388 {
3389# ifdef UNIX
3390 static char *(names[4]) = {"", "TMPDIR", "TEMP", "TMP"};
3391# else
3392 static char *(names[3]) = {"TMPDIR", "TEMP", "TMP"};
3393# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003394 int len;
3395 garray_T ga;
3396 int mustfree;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003397
3398 ga_init2(&ga, 1, 100);
3399 for (n = 0; n < (long)(sizeof(names) / sizeof(char *)); ++n)
3400 {
Bram Moolenaar05159a02005-02-26 23:04:13 +00003401 mustfree = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003402# ifdef UNIX
3403 if (*names[n] == NUL)
3404 p = (char_u *)"/tmp";
3405 else
3406# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003407 p = vim_getenv((char_u *)names[n], &mustfree);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003408 if (p != NULL && *p != NUL)
3409 {
3410 /* First time count the NUL, otherwise count the ','. */
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00003411 len = (int)STRLEN(p) + 3;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003412 if (ga_grow(&ga, len) == OK)
3413 {
3414 if (ga.ga_len > 0)
3415 STRCAT(ga.ga_data, ",");
3416 STRCAT(ga.ga_data, p);
3417 add_pathsep(ga.ga_data);
3418 STRCAT(ga.ga_data, "*");
Bram Moolenaar071d4272004-06-13 20:20:40 +00003419 ga.ga_len += len;
3420 }
3421 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00003422 if (mustfree)
3423 vim_free(p);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003424 }
3425 if (ga.ga_data != NULL)
3426 {
3427 set_string_default("bsk", ga.ga_data);
3428 vim_free(ga.ga_data);
3429 }
3430 }
3431#endif
3432
3433 /*
3434 * 'maxmemtot' and 'maxmem' may have to be adjusted for available memory
3435 */
3436 opt_idx = findoption((char_u *)"maxmemtot");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003437 if (opt_idx >= 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003438 {
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003439#if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM)
3440 if (options[opt_idx].def_val[VI_DEFAULT] == (char_u *)0L)
3441#endif
3442 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00003443#ifdef HAVE_AVAIL_MEM
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003444 /* Use amount of memory available at this moment. */
Bram Moolenaar11b73d62012-06-29 15:51:30 +02003445 n = (mch_avail_mem(FALSE) >> 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003446#else
3447# ifdef HAVE_TOTAL_MEM
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003448 /* Use amount of memory available to Vim. */
Bram Moolenaar914572a2007-05-01 11:37:47 +00003449 n = (mch_total_mem(FALSE) >> 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003450# else
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003451 n = (0x7fffffff >> 11);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003452# endif
3453#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003454 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n;
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003455 opt_idx = findoption((char_u *)"maxmem");
3456 if (opt_idx >= 0)
3457 {
3458#if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM)
Bram Moolenaar35be4532015-12-11 22:38:36 +01003459 if ((long)(long_i)options[opt_idx].def_val[VI_DEFAULT] > (long)n
3460 || (long)(long_i)options[opt_idx].def_val[VI_DEFAULT] == 0L)
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003461#endif
3462 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n;
3463 }
3464 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003465 }
3466
Bram Moolenaar071d4272004-06-13 20:20:40 +00003467#ifdef FEAT_SEARCHPATH
3468 {
3469 char_u *cdpath;
3470 char_u *buf;
3471 int i;
3472 int j;
Bram Moolenaar05159a02005-02-26 23:04:13 +00003473 int mustfree = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003474
3475 /* Initialize the 'cdpath' option's default value. */
Bram Moolenaar05159a02005-02-26 23:04:13 +00003476 cdpath = vim_getenv((char_u *)"CDPATH", &mustfree);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003477 if (cdpath != NULL)
3478 {
3479 buf = alloc((unsigned)((STRLEN(cdpath) << 1) + 2));
3480 if (buf != NULL)
3481 {
3482 buf[0] = ','; /* start with ",", current dir first */
3483 j = 1;
3484 for (i = 0; cdpath[i] != NUL; ++i)
3485 {
3486 if (vim_ispathlistsep(cdpath[i]))
3487 buf[j++] = ',';
3488 else
3489 {
3490 if (cdpath[i] == ' ' || cdpath[i] == ',')
3491 buf[j++] = '\\';
3492 buf[j++] = cdpath[i];
3493 }
3494 }
3495 buf[j] = NUL;
3496 opt_idx = findoption((char_u *)"cdpath");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003497 if (opt_idx >= 0)
3498 {
3499 options[opt_idx].def_val[VI_DEFAULT] = buf;
3500 options[opt_idx].flags |= P_DEF_ALLOCED;
3501 }
Bram Moolenaara9d52e32010-07-31 16:44:19 +02003502 else
3503 vim_free(buf); /* cannot happen */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003504 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00003505 if (mustfree)
3506 vim_free(cdpath);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003507 }
3508 }
3509#endif
3510
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003511#if defined(FEAT_POSTSCRIPT) && (defined(MSWIN) || defined(VMS) || defined(EBCDIC) || defined(MAC) || defined(hpux))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003512 /* Set print encoding on platforms that don't default to latin1 */
3513 set_string_default("penc",
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003514# if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003515 (char_u *)"cp1252"
3516# else
3517# ifdef VMS
3518 (char_u *)"dec-mcs"
3519# else
3520# ifdef EBCDIC
3521 (char_u *)"ebcdic-uk"
3522# else
3523# ifdef MAC
3524 (char_u *)"mac-roman"
3525# else /* HPUX */
3526 (char_u *)"hp-roman8"
3527# endif
3528# endif
3529# endif
3530# endif
3531 );
3532#endif
3533
3534#ifdef FEAT_POSTSCRIPT
3535 /* 'printexpr' must be allocated to be able to evaluate it. */
3536 set_string_default("pexpr",
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003537# if defined(MSWIN)
Bram Moolenaared203462004-06-16 11:19:22 +00003538 (char_u *)"system('copy' . ' ' . v:fname_in . (&printdevice == '' ? ' LPT1:' : (' \"' . &printdevice . '\"'))) . delete(v:fname_in)"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003539# else
3540# ifdef VMS
3541 (char_u *)"system('print/delete' . (&printdevice == '' ? '' : ' /queue=' . &printdevice) . ' ' . v:fname_in)"
3542
3543# else
3544 (char_u *)"system('lpr' . (&printdevice == '' ? '' : ' -P' . &printdevice) . ' ' . v:fname_in) . delete(v:fname_in) + v:shell_error"
3545# endif
3546# endif
3547 );
3548#endif
3549
3550 /*
3551 * Set all the options (except the terminal options) to their default
3552 * value. Also set the global value for local options.
3553 */
3554 set_options_default(0);
3555
3556#ifdef FEAT_GUI
3557 if (found_reverse_arg)
3558 set_option_value((char_u *)"bg", 0L, (char_u *)"dark", 0);
3559#endif
3560
3561 curbuf->b_p_initialized = TRUE;
3562 curbuf->b_p_ar = -1; /* no local 'autoread' value */
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01003563 curbuf->b_p_ul = NO_LOCAL_UNDOLEVEL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003564 check_buf_options(curbuf);
3565 check_win_options(curwin);
3566 check_options();
3567
3568 /* Must be before option_expand(), because that one needs vim_isIDc() */
3569 didset_options();
3570
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00003571#ifdef FEAT_SPELL
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003572 /* Use the current chartab for the generic chartab. This is not in
3573 * didset_options() because it only depends on 'encoding'. */
Bram Moolenaar6bb68362005-03-22 23:03:44 +00003574 init_spell_chartab();
3575#endif
3576
Bram Moolenaar071d4272004-06-13 20:20:40 +00003577 /*
3578 * Expand environment variables and things like "~" for the defaults.
3579 * If option_expand() returns non-NULL the variable is expanded. This can
3580 * only happen for non-indirect options.
3581 * Also set the default to the expanded value, so ":set" does not list
3582 * them.
3583 * Don't set the P_ALLOCED flag, because we don't want to free the
3584 * default.
3585 */
3586 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
3587 {
3588 if ((options[opt_idx].flags & P_GETTEXT)
3589 && options[opt_idx].var != NULL)
3590 p = (char_u *)_(*(char **)options[opt_idx].var);
3591 else
3592 p = option_expand(opt_idx, NULL);
3593 if (p != NULL && (p = vim_strsave(p)) != NULL)
3594 {
3595 *(char_u **)options[opt_idx].var = p;
3596 /* VIMEXP
3597 * Defaults for all expanded options are currently the same for Vi
3598 * and Vim. When this changes, add some code here! Also need to
3599 * split P_DEF_ALLOCED in two.
3600 */
3601 if (options[opt_idx].flags & P_DEF_ALLOCED)
3602 vim_free(options[opt_idx].def_val[VI_DEFAULT]);
3603 options[opt_idx].def_val[VI_DEFAULT] = p;
3604 options[opt_idx].flags |= P_DEF_ALLOCED;
3605 }
3606 }
3607
Bram Moolenaar071d4272004-06-13 20:20:40 +00003608 save_file_ff(curbuf); /* Buffer is unchanged */
3609
Bram Moolenaar071d4272004-06-13 20:20:40 +00003610#if defined(FEAT_ARABIC)
3611 /* Detect use of mlterm.
3612 * Mlterm is a terminal emulator akin to xterm that has some special
3613 * abilities (bidi namely).
3614 * NOTE: mlterm's author is being asked to 'set' a variable
3615 * instead of an environment variable due to inheritance.
3616 */
3617 if (mch_getenv((char_u *)"MLTERM") != NULL)
3618 set_option_value((char_u *)"tbidi", 1L, NULL, 0);
3619#endif
3620
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003621 didset_options2();
Bram Moolenaar071d4272004-06-13 20:20:40 +00003622
3623#ifdef FEAT_MBYTE
3624# if defined(WIN3264) && defined(FEAT_GETTEXT)
3625 /*
3626 * If $LANG isn't set, try to get a good value for it. This makes the
3627 * right language be used automatically. Don't do this for English.
3628 */
3629 if (mch_getenv((char_u *)"LANG") == NULL)
3630 {
3631 char buf[20];
3632
3633 /* Could use LOCALE_SISO639LANGNAME, but it's not in Win95.
3634 * LOCALE_SABBREVLANGNAME gives us three letters, like "enu", we use
3635 * only the first two. */
3636 n = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME,
3637 (LPTSTR)buf, 20);
3638 if (n >= 2 && STRNICMP(buf, "en", 2) != 0)
3639 {
3640 /* There are a few exceptions (probably more) */
3641 if (STRNICMP(buf, "cht", 3) == 0 || STRNICMP(buf, "zht", 3) == 0)
3642 STRCPY(buf, "zh_TW");
3643 else if (STRNICMP(buf, "chs", 3) == 0
3644 || STRNICMP(buf, "zhc", 3) == 0)
3645 STRCPY(buf, "zh_CN");
3646 else if (STRNICMP(buf, "jp", 2) == 0)
3647 STRCPY(buf, "ja");
3648 else
3649 buf[2] = NUL; /* truncate to two-letter code */
Bram Moolenaar6aa2cd42016-02-16 15:06:59 +01003650 vim_setenv((char_u *)"LANG", (char_u *)buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003651 }
3652 }
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003653# else
Bram Moolenaar9d47f172006-03-15 23:03:01 +00003654# ifdef MACOS_CONVERT
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00003655 /* Moved to os_mac_conv.c to avoid dependency problems. */
3656 mac_lang_init();
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003657# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003658# endif
3659
3660 /* enc_locale() will try to find the encoding of the current locale. */
3661 p = enc_locale();
3662 if (p != NULL)
3663 {
3664 char_u *save_enc;
3665
3666 /* Try setting 'encoding' and check if the value is valid.
3667 * If not, go back to the default "latin1". */
3668 save_enc = p_enc;
3669 p_enc = p;
Bram Moolenaar733f0a22007-03-02 18:56:27 +00003670 if (STRCMP(p_enc, "gb18030") == 0)
3671 {
3672 /* We don't support "gb18030", but "cp936" is a good substitute
3673 * for practical purposes, thus use that. It's not an alias to
3674 * still support conversion between gb18030 and utf-8. */
3675 p_enc = vim_strsave((char_u *)"cp936");
3676 vim_free(p);
3677 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003678 if (mb_init() == NULL)
3679 {
3680 opt_idx = findoption((char_u *)"encoding");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003681 if (opt_idx >= 0)
3682 {
3683 options[opt_idx].def_val[VI_DEFAULT] = p_enc;
3684 options[opt_idx].flags |= P_DEF_ALLOCED;
3685 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003686
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003687#if defined(MSWIN) || defined(MACOS) || defined(VMS)
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003688 if (STRCMP(p_enc, "latin1") == 0
3689# ifdef FEAT_MBYTE
3690 || enc_utf8
3691# endif
3692 )
3693 {
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003694 /* Adjust the default for 'isprint' and 'iskeyword' to match
3695 * latin1. Also set the defaults for when 'nocompatible' is
3696 * set. */
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003697 set_string_option_direct((char_u *)"isp", -1,
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +00003698 ISP_LATIN1, OPT_FREE, SID_NONE);
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003699 set_string_option_direct((char_u *)"isk", -1,
3700 ISK_LATIN1, OPT_FREE, SID_NONE);
3701 opt_idx = findoption((char_u *)"isp");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003702 if (opt_idx >= 0)
3703 options[opt_idx].def_val[VIM_DEFAULT] = ISP_LATIN1;
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003704 opt_idx = findoption((char_u *)"isk");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003705 if (opt_idx >= 0)
3706 options[opt_idx].def_val[VIM_DEFAULT] = ISK_LATIN1;
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003707 (void)init_chartab();
3708 }
3709#endif
3710
Bram Moolenaar071d4272004-06-13 20:20:40 +00003711# if defined(WIN3264) && !defined(FEAT_GUI)
3712 /* Win32 console: When GetACP() returns a different value from
3713 * GetConsoleCP() set 'termencoding'. */
3714 if (GetACP() != GetConsoleCP())
3715 {
3716 char buf[50];
3717
3718 sprintf(buf, "cp%ld", (long)GetConsoleCP());
3719 p_tenc = vim_strsave((char_u *)buf);
3720 if (p_tenc != NULL)
3721 {
3722 opt_idx = findoption((char_u *)"termencoding");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003723 if (opt_idx >= 0)
3724 {
3725 options[opt_idx].def_val[VI_DEFAULT] = p_tenc;
3726 options[opt_idx].flags |= P_DEF_ALLOCED;
3727 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003728 convert_setup(&input_conv, p_tenc, p_enc);
3729 convert_setup(&output_conv, p_enc, p_tenc);
3730 }
3731 else
3732 p_tenc = empty_option;
3733 }
3734# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003735# if defined(WIN3264) && defined(FEAT_MBYTE)
3736 /* $HOME may have characters in active code page. */
3737 init_homedir();
3738# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003739 }
3740 else
3741 {
3742 vim_free(p_enc);
3743 p_enc = save_enc;
3744 }
3745 }
3746#endif
3747
3748#ifdef FEAT_MULTI_LANG
3749 /* Set the default for 'helplang'. */
3750 set_helplang_default(get_mess_lang());
3751#endif
3752}
3753
3754/*
3755 * Set an option to its default value.
3756 * This does not take care of side effects!
3757 */
3758 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003759set_option_default(
3760 int opt_idx,
3761 int opt_flags, /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
3762 int compatible) /* use Vi default value */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003763{
3764 char_u *varp; /* pointer to variable for current option */
3765 int dvi; /* index in def_val[] */
3766 long_u flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003767 long_u *flagsp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003768 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
3769
3770 varp = get_varp_scope(&(options[opt_idx]), both ? OPT_LOCAL : opt_flags);
3771 flags = options[opt_idx].flags;
Bram Moolenaar3638c682005-06-08 22:05:14 +00003772 if (varp != NULL) /* skip hidden option, nothing to do for it */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003773 {
3774 dvi = ((flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT;
3775 if (flags & P_STRING)
3776 {
3777 /* Use set_string_option_direct() for local options to handle
3778 * freeing and allocating the value. */
3779 if (options[opt_idx].indir != PV_NONE)
3780 set_string_option_direct(NULL, opt_idx,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003781 options[opt_idx].def_val[dvi], opt_flags, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003782 else
3783 {
3784 if ((opt_flags & OPT_FREE) && (flags & P_ALLOCED))
3785 free_string_option(*(char_u **)(varp));
3786 *(char_u **)varp = options[opt_idx].def_val[dvi];
3787 options[opt_idx].flags &= ~P_ALLOCED;
3788 }
3789 }
3790 else if (flags & P_NUM)
3791 {
Bram Moolenaar5fc1a8b2006-10-17 16:34:24 +00003792 if (options[opt_idx].indir == PV_SCROLL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003793 win_comp_scroll(curwin);
3794 else
3795 {
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003796 *(long *)varp = (long)(long_i)options[opt_idx].def_val[dvi];
Bram Moolenaar071d4272004-06-13 20:20:40 +00003797 /* May also set global value for local option. */
3798 if (both)
3799 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) =
3800 *(long *)varp;
3801 }
3802 }
3803 else /* P_BOOL */
3804 {
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003805 /* the cast to long is required for Manx C, long_i is needed for
3806 * MSVC */
3807 *(int *)varp = (int)(long)(long_i)options[opt_idx].def_val[dvi];
Bram Moolenaar8243a792007-05-01 17:05:03 +00003808#ifdef UNIX
3809 /* 'modeline' defaults to off for root */
3810 if (options[opt_idx].indir == PV_ML && getuid() == ROOT_UID)
3811 *(int *)varp = FALSE;
3812#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003813 /* May also set global value for local option. */
3814 if (both)
3815 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) =
3816 *(int *)varp;
3817 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00003818
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003819 /* The default value is not insecure. */
3820 flagsp = insecure_flag(opt_idx, opt_flags);
3821 *flagsp = *flagsp & ~P_INSECURE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003822 }
3823
3824#ifdef FEAT_EVAL
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003825 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003826#endif
3827}
3828
3829/*
3830 * Set all options (except terminal options) to their default value.
Bram Moolenaarb341dda2015-08-25 12:56:31 +02003831 * When "opt_flags" is non-zero skip 'encoding'.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003832 */
3833 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003834set_options_default(
3835 int opt_flags) /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003836{
3837 int i;
3838#ifdef FEAT_WINDOWS
3839 win_T *wp;
Bram Moolenaarf740b292006-02-16 22:11:02 +00003840 tabpage_T *tp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003841#endif
3842
3843 for (i = 0; !istermoption(&options[i]); i++)
Bram Moolenaarb341dda2015-08-25 12:56:31 +02003844 if (!(options[i].flags & P_NODEFAULT)
Bram Moolenaar5ea87a02015-08-26 23:24:09 +02003845#if defined(FEAT_MBYTE) || defined(FEAT_CRYPT)
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003846 && (opt_flags == 0
Bram Moolenaar5ea87a02015-08-26 23:24:09 +02003847 || (TRUE
3848# if defined(FEAT_MBYTE)
3849 && options[i].var != (char_u *)&p_enc
3850# endif
3851# if defined(FEAT_CRYPT)
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003852 && options[i].var != (char_u *)&p_cm
Bram Moolenaar80606872015-08-25 21:27:35 +02003853 && options[i].var != (char_u *)&p_key
Bram Moolenaar5ea87a02015-08-26 23:24:09 +02003854# endif
3855 ))
Bram Moolenaar80606872015-08-25 21:27:35 +02003856#endif
Bram Moolenaar5ea87a02015-08-26 23:24:09 +02003857 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00003858 set_option_default(i, opt_flags, p_cp);
3859
3860#ifdef FEAT_WINDOWS
3861 /* The 'scroll' option must be computed for all windows. */
Bram Moolenaarf740b292006-02-16 22:11:02 +00003862 FOR_ALL_TAB_WINDOWS(tp, wp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003863 win_comp_scroll(wp);
3864#else
3865 win_comp_scroll(curwin);
3866#endif
Bram Moolenaar5a4eceb2014-09-09 17:33:07 +02003867#ifdef FEAT_CINDENT
3868 parse_cino(curbuf);
3869#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003870}
3871
3872/*
3873 * Set the Vi-default value of a string option.
3874 * Used for 'sh', 'backupskip' and 'term'.
3875 */
3876 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003877set_string_default(char *name, char_u *val)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003878{
3879 char_u *p;
3880 int opt_idx;
3881
3882 p = vim_strsave(val);
3883 if (p != NULL) /* we don't want a NULL */
3884 {
3885 opt_idx = findoption((char_u *)name);
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003886 if (opt_idx >= 0)
3887 {
3888 if (options[opt_idx].flags & P_DEF_ALLOCED)
3889 vim_free(options[opt_idx].def_val[VI_DEFAULT]);
3890 options[opt_idx].def_val[VI_DEFAULT] = p;
3891 options[opt_idx].flags |= P_DEF_ALLOCED;
3892 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003893 }
3894}
3895
3896/*
3897 * Set the Vi-default value of a number option.
3898 * Used for 'lines' and 'columns'.
3899 */
3900 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003901set_number_default(char *name, long val)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003902{
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003903 int opt_idx;
3904
3905 opt_idx = findoption((char_u *)name);
3906 if (opt_idx >= 0)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003907 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003908}
3909
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00003910#if defined(EXITFREE) || defined(PROTO)
3911/*
3912 * Free all options.
3913 */
3914 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003915free_all_options(void)
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00003916{
3917 int i;
3918
3919 for (i = 0; !istermoption(&options[i]); i++)
3920 {
3921 if (options[i].indir == PV_NONE)
3922 {
3923 /* global option: free value and default value. */
Bram Moolenaar67391142017-02-19 21:07:04 +01003924 if ((options[i].flags & P_ALLOCED) && options[i].var != NULL)
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00003925 free_string_option(*(char_u **)options[i].var);
3926 if (options[i].flags & P_DEF_ALLOCED)
3927 free_string_option(options[i].def_val[VI_DEFAULT]);
3928 }
3929 else if (options[i].var != VAR_WIN
3930 && (options[i].flags & P_STRING))
3931 /* buffer-local option: free global value */
3932 free_string_option(*(char_u **)options[i].var);
3933 }
3934}
3935#endif
3936
3937
Bram Moolenaar071d4272004-06-13 20:20:40 +00003938/*
3939 * Initialize the options, part two: After getting Rows and Columns and
3940 * setting 'term'.
3941 */
3942 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003943set_init_2(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003944{
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003945 int idx;
3946
Bram Moolenaar071d4272004-06-13 20:20:40 +00003947 /*
3948 * 'scroll' defaults to half the window height. Note that this default is
3949 * wrong when the window height changes.
3950 */
Bram Moolenaarc1e37902006-04-18 21:55:01 +00003951 set_number_default("scroll", (long)((long_u)Rows >> 1));
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003952 idx = findoption((char_u *)"scroll");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003953 if (idx >= 0 && !(options[idx].flags & P_WAS_SET))
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003954 set_option_default(idx, OPT_LOCAL, p_cp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003955 comp_col();
3956
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003957 /*
3958 * 'window' is only for backwards compatibility with Vi.
3959 * Default is Rows - 1.
3960 */
Bram Moolenaard68071d2006-05-02 22:08:30 +00003961 if (!option_was_set((char_u *)"window"))
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003962 p_window = Rows - 1;
3963 set_number_default("window", Rows - 1);
3964
Bram Moolenaarf740b292006-02-16 22:11:02 +00003965 /* For DOS console the default is always black. */
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003966#if !((defined(WIN3264)) && !defined(FEAT_GUI))
Bram Moolenaarf740b292006-02-16 22:11:02 +00003967 /*
3968 * If 'background' wasn't set by the user, try guessing the value,
3969 * depending on the terminal name. Only need to check for terminals
3970 * with a dark background, that can handle color.
3971 */
3972 idx = findoption((char_u *)"bg");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003973 if (idx >= 0 && !(options[idx].flags & P_WAS_SET)
3974 && *term_bg_default() == 'd')
Bram Moolenaar071d4272004-06-13 20:20:40 +00003975 {
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003976 set_string_option_direct(NULL, idx, (char_u *)"dark", OPT_FREE, 0);
Bram Moolenaarf740b292006-02-16 22:11:02 +00003977 /* don't mark it as set, when starting the GUI it may be
3978 * changed again */
3979 options[idx].flags &= ~P_WAS_SET;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003980 }
3981#endif
Bram Moolenaar58d98232005-07-23 22:25:46 +00003982
3983#ifdef CURSOR_SHAPE
3984 parse_shape_opt(SHAPE_CURSOR); /* set cursor shapes from 'guicursor' */
3985#endif
3986#ifdef FEAT_MOUSESHAPE
3987 parse_shape_opt(SHAPE_MOUSE); /* set mouse shapes from 'mouseshape' */
3988#endif
3989#ifdef FEAT_PRINTER
3990 (void)parse_printoptions(); /* parse 'printoptions' default value */
3991#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003992}
3993
3994/*
Bram Moolenaarf740b292006-02-16 22:11:02 +00003995 * Return "dark" or "light" depending on the kind of terminal.
3996 * This is just guessing! Recognized are:
3997 * "linux" Linux console
3998 * "screen.linux" Linux console with screen
3999 * "cygwin" Cygwin shell
4000 * "putty" Putty program
4001 * We also check the COLORFGBG environment variable, which is set by
4002 * rxvt and derivatives. This variable contains either two or three
4003 * values separated by semicolons; we want the last value in either
4004 * case. If this value is 0-6 or 8, our background is dark.
4005 */
4006 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01004007term_bg_default(void)
Bram Moolenaarf740b292006-02-16 22:11:02 +00004008{
Bram Moolenaar48e330a2016-02-23 14:53:34 +01004009#if defined(WIN3264)
Bram Moolenaarf740b292006-02-16 22:11:02 +00004010 /* DOS console nearly always black */
4011 return (char_u *)"dark";
4012#else
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00004013 char_u *p;
4014
Bram Moolenaarf740b292006-02-16 22:11:02 +00004015 if (STRCMP(T_NAME, "linux") == 0
4016 || STRCMP(T_NAME, "screen.linux") == 0
4017 || STRCMP(T_NAME, "cygwin") == 0
4018 || STRCMP(T_NAME, "putty") == 0
4019 || ((p = mch_getenv((char_u *)"COLORFGBG")) != NULL
4020 && (p = vim_strrchr(p, ';')) != NULL
4021 && ((p[1] >= '0' && p[1] <= '6') || p[1] == '8')
4022 && p[2] == NUL))
4023 return (char_u *)"dark";
4024 return (char_u *)"light";
4025#endif
4026}
4027
4028/*
Bram Moolenaar071d4272004-06-13 20:20:40 +00004029 * Initialize the options, part three: After reading the .vimrc
4030 */
4031 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01004032set_init_3(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004033{
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004034#if defined(UNIX) || defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004035/*
4036 * Set 'shellpipe' and 'shellredir', depending on the 'shell' option.
4037 * This is done after other initializations, where 'shell' might have been
4038 * set, but only if they have not been set before.
4039 */
4040 char_u *p;
4041 int idx_srr;
4042 int do_srr;
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004043# ifdef FEAT_QUICKFIX
Bram Moolenaar071d4272004-06-13 20:20:40 +00004044 int idx_sp;
4045 int do_sp;
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004046# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004047
4048 idx_srr = findoption((char_u *)"srr");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004049 if (idx_srr < 0)
4050 do_srr = FALSE;
4051 else
4052 do_srr = !(options[idx_srr].flags & P_WAS_SET);
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004053# ifdef FEAT_QUICKFIX
Bram Moolenaar071d4272004-06-13 20:20:40 +00004054 idx_sp = findoption((char_u *)"sp");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004055 if (idx_sp < 0)
4056 do_sp = FALSE;
4057 else
4058 do_sp = !(options[idx_sp].flags & P_WAS_SET);
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004059# endif
Bram Moolenaar75a8d742014-05-07 15:10:21 +02004060 p = get_isolated_shell_name();
Bram Moolenaar071d4272004-06-13 20:20:40 +00004061 if (p != NULL)
4062 {
4063 /*
4064 * Default for p_sp is "| tee", for p_srr is ">".
4065 * For known shells it is changed here to include stderr.
4066 */
4067 if ( fnamecmp(p, "csh") == 0
4068 || fnamecmp(p, "tcsh") == 0
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004069# if defined(WIN3264) /* also check with .exe extension */
Bram Moolenaar071d4272004-06-13 20:20:40 +00004070 || fnamecmp(p, "csh.exe") == 0
4071 || fnamecmp(p, "tcsh.exe") == 0
4072# endif
4073 )
4074 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004075# if defined(FEAT_QUICKFIX)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004076 if (do_sp)
4077 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004078# ifdef WIN3264
Bram Moolenaar071d4272004-06-13 20:20:40 +00004079 p_sp = (char_u *)">&";
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004080# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00004081 p_sp = (char_u *)"|& tee";
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004082# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004083 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
4084 }
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004085# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004086 if (do_srr)
4087 {
4088 p_srr = (char_u *)">&";
4089 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
4090 }
4091 }
4092 else
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004093 /* Always use bourne shell style redirection if we reach this */
Bram Moolenaar071d4272004-06-13 20:20:40 +00004094 if ( fnamecmp(p, "sh") == 0
4095 || fnamecmp(p, "ksh") == 0
Bram Moolenaarf1fda2d2011-04-28 12:57:36 +02004096 || fnamecmp(p, "mksh") == 0
4097 || fnamecmp(p, "pdksh") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00004098 || fnamecmp(p, "zsh") == 0
Bram Moolenaarc1e37902006-04-18 21:55:01 +00004099 || fnamecmp(p, "zsh-beta") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00004100 || fnamecmp(p, "bash") == 0
Bram Moolenaar75a8d742014-05-07 15:10:21 +02004101 || fnamecmp(p, "fish") == 0
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004102# ifdef WIN3264
Bram Moolenaar071d4272004-06-13 20:20:40 +00004103 || fnamecmp(p, "cmd") == 0
4104 || fnamecmp(p, "sh.exe") == 0
4105 || fnamecmp(p, "ksh.exe") == 0
Bram Moolenaarf1fda2d2011-04-28 12:57:36 +02004106 || fnamecmp(p, "mksh.exe") == 0
4107 || fnamecmp(p, "pdksh.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00004108 || fnamecmp(p, "zsh.exe") == 0
Bram Moolenaarc1e37902006-04-18 21:55:01 +00004109 || fnamecmp(p, "zsh-beta.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00004110 || fnamecmp(p, "bash.exe") == 0
4111 || fnamecmp(p, "cmd.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00004112# endif
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004113 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00004114 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004115# if defined(FEAT_QUICKFIX)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004116 if (do_sp)
4117 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004118# ifdef WIN3264
Bram Moolenaar071d4272004-06-13 20:20:40 +00004119 p_sp = (char_u *)">%s 2>&1";
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004120# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00004121 p_sp = (char_u *)"2>&1| tee";
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004122# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004123 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
4124 }
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004125# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004126 if (do_srr)
4127 {
4128 p_srr = (char_u *)">%s 2>&1";
4129 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
4130 }
4131 }
4132 vim_free(p);
4133 }
4134#endif
4135
Bram Moolenaar48e330a2016-02-23 14:53:34 +01004136#if defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004137 /*
Bram Moolenaara64ba222012-02-12 23:23:31 +01004138 * Set 'shellcmdflag', 'shellxquote', and 'shellquote' depending on the
4139 * 'shell' option.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004140 * This is done after other initializations, where 'shell' might have been
4141 * set, but only if they have not been set before. Default for p_shcf is
4142 * "/c", for p_shq is "". For "sh" like shells it is changed here to
Bram Moolenaar48e330a2016-02-23 14:53:34 +01004143 * "-c" and "\"". And for Win32 we need to set p_sxq instead.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004144 */
Bram Moolenaarf4b8e572004-06-24 15:53:16 +00004145 if (strstr((char *)gettail(p_sh), "sh") != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004146 {
4147 int idx3;
4148
4149 idx3 = findoption((char_u *)"shcf");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004150 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004151 {
4152 p_shcf = (char_u *)"-c";
4153 options[idx3].def_val[VI_DEFAULT] = p_shcf;
4154 }
4155
Bram Moolenaar071d4272004-06-13 20:20:40 +00004156 /* Somehow Win32 requires the quotes around the redirection too */
4157 idx3 = findoption((char_u *)"sxq");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004158 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004159 {
4160 p_sxq = (char_u *)"\"";
4161 options[idx3].def_val[VI_DEFAULT] = p_sxq;
4162 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004163 }
Bram Moolenaara64ba222012-02-12 23:23:31 +01004164 else if (strstr((char *)gettail(p_sh), "cmd.exe") != NULL)
4165 {
4166 int idx3;
4167
4168 /*
4169 * cmd.exe on Windows will strip the first and last double quote given
4170 * on the command line, e.g. most of the time things like:
4171 * cmd /c "my path/to/echo" "my args to echo"
4172 * become:
4173 * my path/to/echo" "my args to echo
4174 * when executed.
4175 *
Bram Moolenaar034b1152012-02-19 18:19:30 +01004176 * To avoid this, set shellxquote to surround the command in
4177 * parenthesis. This appears to make most commands work, without
4178 * breaking commands that worked previously, such as
4179 * '"path with spaces/cmd" "a&b"'.
Bram Moolenaara64ba222012-02-12 23:23:31 +01004180 */
Bram Moolenaara64ba222012-02-12 23:23:31 +01004181 idx3 = findoption((char_u *)"sxq");
4182 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
4183 {
Bram Moolenaar034b1152012-02-19 18:19:30 +01004184 p_sxq = (char_u *)"(";
Bram Moolenaara64ba222012-02-12 23:23:31 +01004185 options[idx3].def_val[VI_DEFAULT] = p_sxq;
4186 }
4187
Bram Moolenaara64ba222012-02-12 23:23:31 +01004188 idx3 = findoption((char_u *)"shcf");
4189 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
4190 {
Bram Moolenaar034b1152012-02-19 18:19:30 +01004191 p_shcf = (char_u *)"/c";
Bram Moolenaara64ba222012-02-12 23:23:31 +01004192 options[idx3].def_val[VI_DEFAULT] = p_shcf;
4193 }
4194 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004195#endif
4196
Bram Moolenaarb5aedf32017-03-12 18:23:53 +01004197 if (BUFEMPTY())
Bram Moolenaar364fa5c2016-03-20 17:53:25 +01004198 {
4199 int idx_ffs = findoption((char_u *)"ffs");
4200
4201 /* Apply the first entry of 'fileformats' to the initial buffer. */
4202 if (idx_ffs >= 0 && (options[idx_ffs].flags & P_WAS_SET))
4203 set_fileformat(default_fileformat(), OPT_LOCAL);
4204 }
4205
Bram Moolenaar071d4272004-06-13 20:20:40 +00004206#ifdef FEAT_TITLE
4207 set_title_defaults();
4208#endif
4209}
4210
4211#if defined(FEAT_MULTI_LANG) || defined(PROTO)
4212/*
4213 * When 'helplang' is still at its default value, set it to "lang".
4214 * Only the first two characters of "lang" are used.
4215 */
4216 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01004217set_helplang_default(char_u *lang)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004218{
4219 int idx;
4220
4221 if (lang == NULL || STRLEN(lang) < 2) /* safety check */
4222 return;
4223 idx = findoption((char_u *)"hlg");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004224 if (idx >= 0 && !(options[idx].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004225 {
4226 if (options[idx].flags & P_ALLOCED)
4227 free_string_option(p_hlg);
4228 p_hlg = vim_strsave(lang);
4229 if (p_hlg == NULL)
4230 p_hlg = empty_option;
4231 else
Bram Moolenaarab79bcb2004-07-18 21:34:53 +00004232 {
4233 /* zh_CN becomes "cn", zh_TW becomes "tw". */
4234 if (STRNICMP(p_hlg, "zh_", 3) == 0 && STRLEN(p_hlg) >= 5)
4235 {
4236 p_hlg[0] = TOLOWER_ASC(p_hlg[3]);
4237 p_hlg[1] = TOLOWER_ASC(p_hlg[4]);
4238 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004239 p_hlg[2] = NUL;
Bram Moolenaarab79bcb2004-07-18 21:34:53 +00004240 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004241 options[idx].flags |= P_ALLOCED;
4242 }
4243}
4244#endif
4245
4246#ifdef FEAT_GUI
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01004247static char_u *gui_bg_default(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004248
4249 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01004250gui_bg_default(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004251{
4252 if (gui_get_lightness(gui.back_pixel) < 127)
4253 return (char_u *)"dark";
4254 return (char_u *)"light";
4255}
4256
4257/*
4258 * Option initializations that can only be done after opening the GUI window.
4259 */
4260 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01004261init_gui_options(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004262{
4263 /* Set the 'background' option according to the lightness of the
4264 * background color, unless the user has set it already. */
4265 if (!option_was_set((char_u *)"bg") && STRCMP(p_bg, gui_bg_default()) != 0)
4266 {
4267 set_option_value((char_u *)"bg", 0L, gui_bg_default(), 0);
4268 highlight_changed();
4269 }
4270}
4271#endif
4272
4273#ifdef FEAT_TITLE
4274/*
4275 * 'title' and 'icon' only default to true if they have not been set or reset
4276 * in .vimrc and we can read the old value.
4277 * When 'title' and 'icon' have been reset in .vimrc, we won't even check if
4278 * they can be reset. This reduces startup time when using X on a remote
4279 * machine.
4280 */
4281 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01004282set_title_defaults(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004283{
4284 int idx1;
4285 long val;
4286
4287 /*
4288 * If GUI is (going to be) used, we can always set the window title and
4289 * icon name. Saves a bit of time, because the X11 display server does
4290 * not need to be contacted.
4291 */
4292 idx1 = findoption((char_u *)"title");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004293 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004294 {
4295#ifdef FEAT_GUI
4296 if (gui.starting || gui.in_use)
4297 val = TRUE;
4298 else
4299#endif
4300 val = mch_can_restore_title();
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004301 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004302 p_title = val;
4303 }
4304 idx1 = findoption((char_u *)"icon");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004305 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004306 {
4307#ifdef FEAT_GUI
4308 if (gui.starting || gui.in_use)
4309 val = TRUE;
4310 else
4311#endif
4312 val = mch_can_restore_icon();
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004313 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004314 p_icon = val;
4315 }
4316}
4317#endif
4318
Bram Moolenaar182a17b2017-06-25 20:57:18 +02004319#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
4320 static void
4321trigger_optionsset_string(
4322 int opt_idx,
4323 int opt_flags,
4324 char_u *oldval,
4325 char_u *newval)
4326{
4327 if (oldval != NULL && newval != NULL)
4328 {
4329 char_u buf_type[7];
4330
4331 sprintf((char *)buf_type, "%s",
4332 (opt_flags & OPT_LOCAL) ? "local" : "global");
4333 set_vim_var_string(VV_OPTION_OLD, oldval, -1);
4334 set_vim_var_string(VV_OPTION_NEW, newval, -1);
4335 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
4336 apply_autocmds(EVENT_OPTIONSET,
4337 (char_u *)options[opt_idx].fullname, NULL, FALSE, NULL);
4338 reset_v_option_vars();
4339 }
4340 vim_free(oldval);
4341 vim_free(newval);
4342}
4343#endif
4344
Bram Moolenaar071d4272004-06-13 20:20:40 +00004345/*
4346 * Parse 'arg' for option settings.
4347 *
4348 * 'arg' may be IObuff, but only when no errors can be present and option
4349 * does not need to be expanded with option_expand().
4350 * "opt_flags":
4351 * 0 for ":set"
Bram Moolenaara3227e22006-03-08 21:32:40 +00004352 * OPT_GLOBAL for ":setglobal"
4353 * OPT_LOCAL for ":setlocal" and a modeline
Bram Moolenaar071d4272004-06-13 20:20:40 +00004354 * OPT_MODELINE for a modeline
Bram Moolenaara3227e22006-03-08 21:32:40 +00004355 * OPT_WINONLY to only set window-local options
4356 * OPT_NOWIN to skip setting window-local options
Bram Moolenaar071d4272004-06-13 20:20:40 +00004357 *
4358 * returns FAIL if an error is detected, OK otherwise
4359 */
4360 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01004361do_set(
4362 char_u *arg, /* option string (may be written to!) */
4363 int opt_flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004364{
4365 int opt_idx;
4366 char_u *errmsg;
4367 char_u errbuf[80];
4368 char_u *startarg;
4369 int prefix; /* 1: nothing, 0: "no", 2: "inv" in front of name */
4370 int nextchar; /* next non-white char after option name */
4371 int afterchar; /* character just after option name */
4372 int len;
4373 int i;
Bram Moolenaar22fcfad2016-07-01 18:17:26 +02004374 varnumber_T value;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004375 int key;
4376 long_u flags; /* flags for current option */
4377 char_u *varp = NULL; /* pointer to variable for current option */
4378 int did_show = FALSE; /* already showed one value */
4379 int adding; /* "opt+=arg" */
4380 int prepending; /* "opt^=arg" */
4381 int removing; /* "opt-=arg" */
4382 int cp_val = 0;
4383 char_u key_name[2];
4384
4385 if (*arg == NUL)
4386 {
4387 showoptions(0, opt_flags);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004388 did_show = TRUE;
4389 goto theend;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004390 }
4391
4392 while (*arg != NUL) /* loop to process all options */
4393 {
4394 errmsg = NULL;
4395 startarg = arg; /* remember for error message */
4396
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00004397 if (STRNCMP(arg, "all", 3) == 0 && !isalpha(arg[3])
4398 && !(opt_flags & OPT_MODELINE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004399 {
4400 /*
4401 * ":set all" show all options.
4402 * ":set all&" set all options to their default value.
4403 */
4404 arg += 3;
4405 if (*arg == '&')
4406 {
4407 ++arg;
4408 /* Only for :set command set global value of local options. */
4409 set_options_default(OPT_FREE | opt_flags);
Bram Moolenaare68c25c2015-08-25 15:39:55 +02004410 didset_options();
4411 didset_options2();
Bram Moolenaarb341dda2015-08-25 12:56:31 +02004412 redraw_all_later(CLEAR);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004413 }
4414 else
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004415 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00004416 showoptions(1, opt_flags);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004417 did_show = TRUE;
4418 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004419 }
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00004420 else if (STRNCMP(arg, "termcap", 7) == 0 && !(opt_flags & OPT_MODELINE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004421 {
4422 showoptions(2, opt_flags);
4423 show_termcodes();
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004424 did_show = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004425 arg += 7;
4426 }
4427 else
4428 {
4429 prefix = 1;
Bram Moolenaar2a7b9ee2009-06-16 15:50:33 +00004430 if (STRNCMP(arg, "no", 2) == 0 && STRNCMP(arg, "novice", 6) != 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004431 {
4432 prefix = 0;
4433 arg += 2;
4434 }
4435 else if (STRNCMP(arg, "inv", 3) == 0)
4436 {
4437 prefix = 2;
4438 arg += 3;
4439 }
4440
4441 /* find end of name */
4442 key = 0;
4443 if (*arg == '<')
4444 {
4445 nextchar = 0;
4446 opt_idx = -1;
4447 /* look out for <t_>;> */
4448 if (arg[1] == 't' && arg[2] == '_' && arg[3] && arg[4])
4449 len = 5;
4450 else
4451 {
4452 len = 1;
4453 while (arg[len] != NUL && arg[len] != '>')
4454 ++len;
4455 }
4456 if (arg[len] != '>')
4457 {
4458 errmsg = e_invarg;
4459 goto skip;
4460 }
4461 arg[len] = NUL; /* put NUL after name */
4462 if (arg[1] == 't' && arg[2] == '_') /* could be term code */
4463 opt_idx = findoption(arg + 1);
4464 arg[len++] = '>'; /* restore '>' */
4465 if (opt_idx == -1)
4466 key = find_key_option(arg + 1);
4467 }
4468 else
4469 {
4470 len = 0;
4471 /*
4472 * The two characters after "t_" may not be alphanumeric.
4473 */
4474 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
4475 len = 4;
4476 else
4477 while (ASCII_ISALNUM(arg[len]) || arg[len] == '_')
4478 ++len;
4479 nextchar = arg[len];
4480 arg[len] = NUL; /* put NUL after name */
4481 opt_idx = findoption(arg);
4482 arg[len] = nextchar; /* restore nextchar */
4483 if (opt_idx == -1)
4484 key = find_key_option(arg);
4485 }
4486
4487 /* remember character after option name */
4488 afterchar = arg[len];
4489
4490 /* skip white space, allow ":set ai ?" */
Bram Moolenaar1c465442017-03-12 20:10:05 +01004491 while (VIM_ISWHITE(arg[len]))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004492 ++len;
4493
4494 adding = FALSE;
4495 prepending = FALSE;
4496 removing = FALSE;
4497 if (arg[len] != NUL && arg[len + 1] == '=')
4498 {
4499 if (arg[len] == '+')
4500 {
4501 adding = TRUE; /* "+=" */
4502 ++len;
4503 }
4504 else if (arg[len] == '^')
4505 {
4506 prepending = TRUE; /* "^=" */
4507 ++len;
4508 }
4509 else if (arg[len] == '-')
4510 {
4511 removing = TRUE; /* "-=" */
4512 ++len;
4513 }
4514 }
4515 nextchar = arg[len];
4516
4517 if (opt_idx == -1 && key == 0) /* found a mismatch: skip */
4518 {
4519 errmsg = (char_u *)N_("E518: Unknown option");
4520 goto skip;
4521 }
4522
4523 if (opt_idx >= 0)
4524 {
4525 if (options[opt_idx].var == NULL) /* hidden option: skip */
4526 {
4527 /* Only give an error message when requesting the value of
4528 * a hidden option, ignore setting it. */
4529 if (vim_strchr((char_u *)"=:!&<", nextchar) == NULL
4530 && (!(options[opt_idx].flags & P_BOOL)
4531 || nextchar == '?'))
4532 errmsg = (char_u *)N_("E519: Option not supported");
4533 goto skip;
4534 }
4535
4536 flags = options[opt_idx].flags;
4537 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
4538 }
4539 else
4540 {
4541 flags = P_STRING;
4542 if (key < 0)
4543 {
4544 key_name[0] = KEY2TERMCAP0(key);
4545 key_name[1] = KEY2TERMCAP1(key);
4546 }
4547 else
4548 {
4549 key_name[0] = KS_KEY;
4550 key_name[1] = (key & 0xff);
4551 }
4552 }
4553
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004554 /* Skip all options that are not window-local (used when showing
4555 * an already loaded buffer in a window). */
4556 if ((opt_flags & OPT_WINONLY)
4557 && (opt_idx < 0 || options[opt_idx].var != VAR_WIN))
4558 goto skip;
4559
Bram Moolenaara3227e22006-03-08 21:32:40 +00004560 /* Skip all options that are window-local (used for :vimgrep). */
4561 if ((opt_flags & OPT_NOWIN) && opt_idx >= 0
4562 && options[opt_idx].var == VAR_WIN)
4563 goto skip;
4564
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004565 /* Disallow changing some options from modelines. */
4566 if (opt_flags & OPT_MODELINE)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004567 {
Bram Moolenaar865242e2010-07-14 21:12:05 +02004568 if (flags & (P_SECURE | P_NO_ML))
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004569 {
4570 errmsg = (char_u *)_("E520: Not allowed in a modeline");
4571 goto skip;
4572 }
Bram Moolenaarf69d9a32009-02-11 21:48:40 +00004573#ifdef FEAT_DIFF
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004574 /* In diff mode some options are overruled. This avoids that
4575 * 'foldmethod' becomes "marker" instead of "diff" and that
4576 * "wrap" gets set. */
4577 if (curwin->w_p_diff
Bram Moolenaara9d52e32010-07-31 16:44:19 +02004578 && opt_idx >= 0 /* shut up coverity warning */
Bram Moolenaara6c07602017-03-05 21:18:27 +01004579 && (
4580#ifdef FEAT_FOLDING
4581 options[opt_idx].indir == PV_FDM ||
4582#endif
4583 options[opt_idx].indir == PV_WRAP))
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004584 goto skip;
Bram Moolenaarf69d9a32009-02-11 21:48:40 +00004585#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004586 }
4587
4588#ifdef HAVE_SANDBOX
4589 /* Disallow changing some options in the sandbox */
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004590 if (sandbox != 0 && (flags & P_SECURE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004591 {
4592 errmsg = (char_u *)_(e_sandbox);
4593 goto skip;
4594 }
4595#endif
4596
4597 if (vim_strchr((char_u *)"?=:!&<", nextchar) != NULL)
4598 {
4599 arg += len;
4600 cp_val = p_cp;
4601 if (nextchar == '&' && arg[1] == 'v' && arg[2] == 'i')
4602 {
4603 if (arg[3] == 'm') /* "opt&vim": set to Vim default */
4604 {
4605 cp_val = FALSE;
4606 arg += 3;
4607 }
4608 else /* "opt&vi": set to Vi default */
4609 {
4610 cp_val = TRUE;
4611 arg += 2;
4612 }
4613 }
4614 if (vim_strchr((char_u *)"?!&<", nextchar) != NULL
Bram Moolenaar1c465442017-03-12 20:10:05 +01004615 && arg[1] != NUL && !VIM_ISWHITE(arg[1]))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004616 {
4617 errmsg = e_trailing;
4618 goto skip;
4619 }
4620 }
4621
4622 /*
Bram Moolenaar48e330a2016-02-23 14:53:34 +01004623 * allow '=' and ':' for hystorical reasons (MSDOS command.com
4624 * allows only one '=' character per "set" command line. grrr. (jw)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004625 */
4626 if (nextchar == '?'
4627 || (prefix == 1
4628 && vim_strchr((char_u *)"=:&<", nextchar) == NULL
4629 && !(flags & P_BOOL)))
4630 {
4631 /*
4632 * print value
4633 */
4634 if (did_show)
4635 msg_putchar('\n'); /* cursor below last one */
4636 else
4637 {
4638 gotocmdline(TRUE); /* cursor at status line */
4639 did_show = TRUE; /* remember that we did a line */
4640 }
4641 if (opt_idx >= 0)
4642 {
4643 showoneopt(&options[opt_idx], opt_flags);
4644#ifdef FEAT_EVAL
4645 if (p_verbose > 0)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00004646 {
4647 /* Mention where the option was last set. */
4648 if (varp == options[opt_idx].var)
4649 last_set_msg(options[opt_idx].scriptID);
4650 else if ((int)options[opt_idx].indir & PV_WIN)
4651 last_set_msg(curwin->w_p_scriptID[
4652 (int)options[opt_idx].indir & PV_MASK]);
4653 else if ((int)options[opt_idx].indir & PV_BUF)
4654 last_set_msg(curbuf->b_p_scriptID[
4655 (int)options[opt_idx].indir & PV_MASK]);
4656 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004657#endif
4658 }
4659 else
4660 {
4661 char_u *p;
4662
4663 p = find_termcode(key_name);
4664 if (p == NULL)
4665 {
Bram Moolenaar0b2f94d2011-03-22 14:35:05 +01004666 errmsg = (char_u *)N_("E846: Key code not set");
Bram Moolenaar071d4272004-06-13 20:20:40 +00004667 goto skip;
4668 }
4669 else
4670 (void)show_one_termcode(key_name, p, TRUE);
4671 }
4672 if (nextchar != '?'
Bram Moolenaar1c465442017-03-12 20:10:05 +01004673 && nextchar != NUL && !VIM_ISWHITE(afterchar))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004674 errmsg = e_trailing;
4675 }
4676 else
4677 {
4678 if (flags & P_BOOL) /* boolean */
4679 {
4680 if (nextchar == '=' || nextchar == ':')
4681 {
4682 errmsg = e_invarg;
4683 goto skip;
4684 }
4685
4686 /*
4687 * ":set opt!": invert
4688 * ":set opt&": reset to default value
4689 * ":set opt<": reset to global value
4690 */
4691 if (nextchar == '!')
4692 value = *(int *)(varp) ^ 1;
4693 else if (nextchar == '&')
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004694 value = (int)(long)(long_i)options[opt_idx].def_val[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004695 ((flags & P_VI_DEF) || cp_val)
4696 ? VI_DEFAULT : VIM_DEFAULT];
4697 else if (nextchar == '<')
4698 {
4699 /* For 'autoread' -1 means to use global value. */
4700 if ((int *)varp == &curbuf->b_p_ar
4701 && opt_flags == OPT_LOCAL)
4702 value = -1;
4703 else
4704 value = *(int *)get_varp_scope(&(options[opt_idx]),
4705 OPT_GLOBAL);
4706 }
4707 else
4708 {
4709 /*
4710 * ":set invopt": invert
4711 * ":set opt" or ":set noopt": set or reset
4712 */
Bram Moolenaar1c465442017-03-12 20:10:05 +01004713 if (nextchar != NUL && !VIM_ISWHITE(afterchar))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004714 {
4715 errmsg = e_trailing;
4716 goto skip;
4717 }
4718 if (prefix == 2) /* inv */
4719 value = *(int *)(varp) ^ 1;
4720 else
4721 value = prefix;
4722 }
4723
4724 errmsg = set_bool_option(opt_idx, varp, (int)value,
4725 opt_flags);
4726 }
4727 else /* numeric or string */
4728 {
4729 if (vim_strchr((char_u *)"=:&<", nextchar) == NULL
4730 || prefix != 1)
4731 {
4732 errmsg = e_invarg;
4733 goto skip;
4734 }
4735
4736 if (flags & P_NUM) /* numeric */
4737 {
4738 /*
4739 * Different ways to set a number option:
4740 * & set to default value
4741 * < set to global value
4742 * <xx> accept special key codes for 'wildchar'
4743 * c accept any non-digit for 'wildchar'
4744 * [-]0-9 set number
4745 * other error
4746 */
4747 ++arg;
4748 if (nextchar == '&')
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004749 value = (long)(long_i)options[opt_idx].def_val[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004750 ((flags & P_VI_DEF) || cp_val)
4751 ? VI_DEFAULT : VIM_DEFAULT];
4752 else if (nextchar == '<')
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01004753 {
4754 /* For 'undolevels' NO_LOCAL_UNDOLEVEL means to
4755 * use the global value. */
4756 if ((long *)varp == &curbuf->b_p_ul
4757 && opt_flags == OPT_LOCAL)
4758 value = NO_LOCAL_UNDOLEVEL;
4759 else
4760 value = *(long *)get_varp_scope(
4761 &(options[opt_idx]), OPT_GLOBAL);
4762 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004763 else if (((long *)varp == &p_wc
4764 || (long *)varp == &p_wcm)
4765 && (*arg == '<'
4766 || *arg == '^'
Bram Moolenaar1c465442017-03-12 20:10:05 +01004767 || (*arg != NUL
4768 && (!arg[1] || VIM_ISWHITE(arg[1]))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004769 && !VIM_ISDIGIT(*arg))))
4770 {
4771 value = string_to_key(arg);
4772 if (value == 0 && (long *)varp != &p_wcm)
4773 {
4774 errmsg = e_invarg;
4775 goto skip;
4776 }
4777 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004778 else if (*arg == '-' || VIM_ISDIGIT(*arg))
4779 {
Bram Moolenaar18400e62015-01-27 15:58:40 +01004780 /* Allow negative (for 'undolevels'), octal and
4781 * hex numbers. */
Bram Moolenaar887c1fe2016-01-02 17:56:35 +01004782 vim_str2nr(arg, NULL, &i, STR2NR_ALL,
4783 &value, NULL, 0);
Bram Moolenaar1c465442017-03-12 20:10:05 +01004784 if (arg[i] != NUL && !VIM_ISWHITE(arg[i]))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004785 {
4786 errmsg = e_invarg;
4787 goto skip;
4788 }
4789 }
4790 else
4791 {
4792 errmsg = (char_u *)N_("E521: Number required after =");
4793 goto skip;
4794 }
4795
4796 if (adding)
4797 value = *(long *)varp + value;
4798 if (prepending)
4799 value = *(long *)varp * value;
4800 if (removing)
4801 value = *(long *)varp - value;
4802 errmsg = set_num_option(opt_idx, varp, value,
Bram Moolenaar555b2802005-05-19 21:08:39 +00004803 errbuf, sizeof(errbuf), opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004804 }
4805 else if (opt_idx >= 0) /* string */
4806 {
4807 char_u *save_arg = NULL;
4808 char_u *s = NULL;
Bram Moolenaar53744302015-07-17 17:38:22 +02004809 char_u *oldval = NULL; /* previous value if *varp */
Bram Moolenaar071d4272004-06-13 20:20:40 +00004810 char_u *newval;
Bram Moolenaar53744302015-07-17 17:38:22 +02004811 char_u *origval = NULL;
4812#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
4813 char_u *saved_origval = NULL;
Bram Moolenaar182a17b2017-06-25 20:57:18 +02004814 char_u *saved_newval = NULL;
Bram Moolenaar53744302015-07-17 17:38:22 +02004815#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004816 unsigned newlen;
4817 int comma;
4818 int bs;
4819 int new_value_alloced; /* new string option
4820 was allocated */
4821
4822 /* When using ":set opt=val" for a global option
4823 * with a local value the local value will be
4824 * reset, use the global value here. */
4825 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00004826 && ((int)options[opt_idx].indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004827 varp = options[opt_idx].var;
4828
4829 /* The old value is kept until we are sure that the
4830 * new value is valid. */
4831 oldval = *(char_u **)varp;
4832 if (nextchar == '&') /* set to default val */
4833 {
4834 newval = options[opt_idx].def_val[
4835 ((flags & P_VI_DEF) || cp_val)
4836 ? VI_DEFAULT : VIM_DEFAULT];
4837 if ((char_u **)varp == &p_bg)
4838 {
4839 /* guess the value of 'background' */
4840#ifdef FEAT_GUI
4841 if (gui.in_use)
4842 newval = gui_bg_default();
4843 else
4844#endif
Bram Moolenaarf740b292006-02-16 22:11:02 +00004845 newval = term_bg_default();
Bram Moolenaar071d4272004-06-13 20:20:40 +00004846 }
4847
4848 /* expand environment variables and ~ (since the
4849 * default value was already expanded, only
4850 * required when an environment variable was set
4851 * later */
4852 if (newval == NULL)
4853 newval = empty_option;
4854 else
4855 {
4856 s = option_expand(opt_idx, newval);
4857 if (s == NULL)
4858 s = newval;
4859 newval = vim_strsave(s);
4860 }
4861 new_value_alloced = TRUE;
4862 }
4863 else if (nextchar == '<') /* set to global val */
4864 {
4865 newval = vim_strsave(*(char_u **)get_varp_scope(
4866 &(options[opt_idx]), OPT_GLOBAL));
4867 new_value_alloced = TRUE;
4868 }
4869 else
4870 {
4871 ++arg; /* jump to after the '=' or ':' */
4872
4873 /*
4874 * Set 'keywordprg' to ":help" if an empty
4875 * value was passed to :set by the user.
4876 * Misuse errbuf[] for the resulting string.
4877 */
4878 if (varp == (char_u *)&p_kp
4879 && (*arg == NUL || *arg == ' '))
4880 {
4881 STRCPY(errbuf, ":help");
4882 save_arg = arg;
4883 arg = errbuf;
4884 }
4885 /*
Bram Moolenaar4e5ccfa2011-11-30 11:15:47 +01004886 * Convert 'backspace' number to string, for
4887 * adding, prepending and removing string.
4888 */
4889 else if (varp == (char_u *)&p_bs
4890 && VIM_ISDIGIT(**(char_u **)varp))
4891 {
4892 i = getdigits((char_u **)varp);
4893 switch (i)
4894 {
4895 case 0:
4896 *(char_u **)varp = empty_option;
4897 break;
4898 case 1:
4899 *(char_u **)varp = vim_strsave(
4900 (char_u *)"indent,eol");
4901 break;
4902 case 2:
4903 *(char_u **)varp = vim_strsave(
4904 (char_u *)"indent,eol,start");
4905 break;
4906 }
4907 vim_free(oldval);
4908 oldval = *(char_u **)varp;
4909 }
4910 /*
Bram Moolenaar071d4272004-06-13 20:20:40 +00004911 * Convert 'whichwrap' number to string, for
4912 * backwards compatibility with Vim 3.0.
4913 * Misuse errbuf[] for the resulting string.
4914 */
4915 else if (varp == (char_u *)&p_ww
4916 && VIM_ISDIGIT(*arg))
4917 {
4918 *errbuf = NUL;
4919 i = getdigits(&arg);
4920 if (i & 1)
4921 STRCAT(errbuf, "b,");
4922 if (i & 2)
4923 STRCAT(errbuf, "s,");
4924 if (i & 4)
4925 STRCAT(errbuf, "h,l,");
4926 if (i & 8)
4927 STRCAT(errbuf, "<,>,");
4928 if (i & 16)
4929 STRCAT(errbuf, "[,],");
4930 if (*errbuf != NUL) /* remove trailing , */
4931 errbuf[STRLEN(errbuf) - 1] = NUL;
4932 save_arg = arg;
4933 arg = errbuf;
4934 }
4935 /*
4936 * Remove '>' before 'dir' and 'bdir', for
4937 * backwards compatibility with version 3.0
4938 */
4939 else if ( *arg == '>'
4940 && (varp == (char_u *)&p_dir
4941 || varp == (char_u *)&p_bdir))
4942 {
4943 ++arg;
4944 }
4945
4946 /* When setting the local value of a global
4947 * option, the old value may be the global value. */
Bram Moolenaara23ccb82006-02-27 00:08:02 +00004948 if (((int)options[opt_idx].indir & PV_BOTH)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004949 && (opt_flags & OPT_LOCAL))
4950 origval = *(char_u **)get_varp(
4951 &options[opt_idx]);
4952 else
4953 origval = oldval;
4954
4955 /*
4956 * Copy the new string into allocated memory.
4957 * Can't use set_string_option_direct(), because
4958 * we need to remove the backslashes.
4959 */
4960 /* get a bit too much */
4961 newlen = (unsigned)STRLEN(arg) + 1;
4962 if (adding || prepending || removing)
4963 newlen += (unsigned)STRLEN(origval) + 1;
4964 newval = alloc(newlen);
4965 if (newval == NULL) /* out of mem, don't change */
4966 break;
4967 s = newval;
4968
4969 /*
4970 * Copy the string, skip over escaped chars.
4971 * For MS-DOS and WIN32 backslashes before normal
4972 * file name characters are not removed, and keep
4973 * backslash at start, for "\\machine\path", but
4974 * do remove it for "\\\\machine\\path".
4975 * The reverse is found in ExpandOldSetting().
4976 */
Bram Moolenaar1c465442017-03-12 20:10:05 +01004977 while (*arg && !VIM_ISWHITE(*arg))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004978 {
4979 if (*arg == '\\' && arg[1] != NUL
4980#ifdef BACKSLASH_IN_FILENAME
4981 && !((flags & P_EXPAND)
4982 && vim_isfilec(arg[1])
4983 && (arg[1] != '\\'
4984 || (s == newval
4985 && arg[2] != '\\')))
4986#endif
4987 )
4988 ++arg; /* remove backslash */
4989#ifdef FEAT_MBYTE
4990 if (has_mbyte
Bram Moolenaar0fa313a2005-08-10 21:07:57 +00004991 && (i = (*mb_ptr2len)(arg)) > 1)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004992 {
4993 /* copy multibyte char */
4994 mch_memmove(s, arg, (size_t)i);
4995 arg += i;
4996 s += i;
4997 }
4998 else
4999#endif
5000 *s++ = *arg++;
5001 }
5002 *s = NUL;
5003
5004 /*
5005 * Expand environment variables and ~.
5006 * Don't do it when adding without inserting a
5007 * comma.
5008 */
5009 if (!(adding || prepending || removing)
5010 || (flags & P_COMMA))
5011 {
5012 s = option_expand(opt_idx, newval);
5013 if (s != NULL)
5014 {
5015 vim_free(newval);
5016 newlen = (unsigned)STRLEN(s) + 1;
5017 if (adding || prepending || removing)
5018 newlen += (unsigned)STRLEN(origval) + 1;
5019 newval = alloc(newlen);
5020 if (newval == NULL)
5021 break;
5022 STRCPY(newval, s);
5023 }
5024 }
5025
5026 /* locate newval[] in origval[] when removing it
5027 * and when adding to avoid duplicates */
5028 i = 0; /* init for GCC */
5029 if (removing || (flags & P_NODUP))
5030 {
5031 i = (int)STRLEN(newval);
5032 bs = 0;
5033 for (s = origval; *s; ++s)
5034 {
5035 if ((!(flags & P_COMMA)
5036 || s == origval
5037 || (s[-1] == ',' && !(bs & 1)))
5038 && STRNCMP(s, newval, i) == 0
5039 && (!(flags & P_COMMA)
5040 || s[i] == ','
5041 || s[i] == NUL))
5042 break;
Bram Moolenaar0b2f94d2011-03-22 14:35:05 +01005043 /* Count backslashes. Only a comma with an
Bram Moolenaar8f79acd2016-01-01 14:48:20 +01005044 * even number of backslashes or a single
5045 * backslash preceded by a comma before it
5046 * is recognized as a separator */
5047 if ((s > origval + 1
5048 && s[-1] == '\\'
5049 && s[-2] != ',')
5050 || (s == origval + 1
5051 && s[-1] == '\\'))
5052
Bram Moolenaar071d4272004-06-13 20:20:40 +00005053 ++bs;
5054 else
5055 bs = 0;
5056 }
5057
5058 /* do not add if already there */
5059 if ((adding || prepending) && *s)
5060 {
5061 prepending = FALSE;
5062 adding = FALSE;
5063 STRCPY(newval, origval);
5064 }
5065 }
5066
5067 /* concatenate the two strings; add a ',' if
5068 * needed */
5069 if (adding || prepending)
5070 {
5071 comma = ((flags & P_COMMA) && *origval != NUL
5072 && *newval != NUL);
5073 if (adding)
5074 {
5075 i = (int)STRLEN(origval);
Bram Moolenaara7b7b1c2015-06-19 14:06:43 +02005076 /* strip a trailing comma, would get 2 */
Bram Moolenaar17467472015-11-10 17:50:24 +01005077 if (comma && i > 1
5078 && (flags & P_ONECOMMA) == P_ONECOMMA
5079 && origval[i - 1] == ','
5080 && origval[i - 2] != '\\')
Bram Moolenaara7b7b1c2015-06-19 14:06:43 +02005081 i--;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005082 mch_memmove(newval + i + comma, newval,
5083 STRLEN(newval) + 1);
5084 mch_memmove(newval, origval, (size_t)i);
5085 }
5086 else
5087 {
5088 i = (int)STRLEN(newval);
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00005089 STRMOVE(newval + i + comma, origval);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005090 }
5091 if (comma)
5092 newval[i] = ',';
5093 }
5094
5095 /* Remove newval[] from origval[]. (Note: "i" has
5096 * been set above and is used here). */
5097 if (removing)
5098 {
5099 STRCPY(newval, origval);
5100 if (*s)
5101 {
5102 /* may need to remove a comma */
5103 if (flags & P_COMMA)
5104 {
5105 if (s == origval)
5106 {
5107 /* include comma after string */
5108 if (s[i] == ',')
5109 ++i;
5110 }
5111 else
5112 {
5113 /* include comma before string */
5114 --s;
5115 ++i;
5116 }
5117 }
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00005118 STRMOVE(newval + (s - origval), s + i);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005119 }
5120 }
5121
5122 if (flags & P_FLAGLIST)
5123 {
5124 /* Remove flags that appear twice. */
Bram Moolenaaraaaf57d2017-02-05 14:13:20 +01005125 for (s = newval; *s;)
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02005126 {
5127 /* if options have P_FLAGLIST and
5128 * P_ONECOMMA such as 'whichwrap' */
5129 if (flags & P_ONECOMMA)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005130 {
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02005131 if (*s != ',' && *(s + 1) == ','
5132 && vim_strchr(s + 2, *s) != NULL)
5133 {
5134 /* Remove the duplicated value and
5135 * the next comma. */
5136 STRMOVE(s, s + 2);
Bram Moolenaaraaaf57d2017-02-05 14:13:20 +01005137 continue;
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02005138 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005139 }
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02005140 else
5141 {
5142 if ((!(flags & P_COMMA) || *s != ',')
5143 && vim_strchr(s + 1, *s) != NULL)
5144 {
5145 STRMOVE(s, s + 1);
Bram Moolenaaraaaf57d2017-02-05 14:13:20 +01005146 continue;
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02005147 }
5148 }
Bram Moolenaaraaaf57d2017-02-05 14:13:20 +01005149 ++s;
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02005150 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005151 }
5152
5153 if (save_arg != NULL) /* number for 'whichwrap' */
5154 arg = save_arg;
5155 new_value_alloced = TRUE;
5156 }
5157
5158 /* Set the new value. */
5159 *(char_u **)(varp) = newval;
5160
Bram Moolenaar53744302015-07-17 17:38:22 +02005161#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
Bram Moolenaar5cbb8db2015-07-17 23:08:29 +02005162 if (!starting
5163# ifdef FEAT_CRYPT
5164 && options[opt_idx].indir != PV_KEY
5165# endif
Bram Moolenaar182a17b2017-06-25 20:57:18 +02005166 && origval != NULL && newval != NULL)
5167 {
Bram Moolenaar53744302015-07-17 17:38:22 +02005168 /* origval may be freed by
5169 * did_set_string_option(), make a copy. */
5170 saved_origval = vim_strsave(origval);
Bram Moolenaar182a17b2017-06-25 20:57:18 +02005171 /* newval (and varp) may become invalid if the
5172 * buffer is closed by autocommands. */
5173 saved_newval = vim_strsave(newval);
5174 }
Bram Moolenaar53744302015-07-17 17:38:22 +02005175#endif
5176
Bram Moolenaar071d4272004-06-13 20:20:40 +00005177 /* Handle side effects, and set the global value for
Bram Moolenaar182a17b2017-06-25 20:57:18 +02005178 * ":set" on local options. Note: when setting 'syntax'
5179 * or 'filetype' autocommands may be triggered that can
5180 * cause havoc. */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005181 errmsg = did_set_string_option(opt_idx, (char_u **)varp,
5182 new_value_alloced, oldval, errbuf, opt_flags);
5183
5184 /* If error detected, print the error message. */
5185 if (errmsg != NULL)
Bram Moolenaara9884962015-12-13 15:08:56 +01005186 {
5187#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
5188 vim_free(saved_origval);
Bram Moolenaar182a17b2017-06-25 20:57:18 +02005189 vim_free(saved_newval);
Bram Moolenaara9884962015-12-13 15:08:56 +01005190#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005191 goto skip;
Bram Moolenaara9884962015-12-13 15:08:56 +01005192 }
Bram Moolenaar53744302015-07-17 17:38:22 +02005193#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
Bram Moolenaar182a17b2017-06-25 20:57:18 +02005194 trigger_optionsset_string(opt_idx, opt_flags,
5195 saved_origval, saved_newval);
Bram Moolenaar53744302015-07-17 17:38:22 +02005196#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005197 }
5198 else /* key code option */
5199 {
5200 char_u *p;
5201
5202 if (nextchar == '&')
5203 {
5204 if (add_termcap_entry(key_name, TRUE) == FAIL)
5205 errmsg = (char_u *)N_("E522: Not found in termcap");
5206 }
5207 else
5208 {
5209 ++arg; /* jump to after the '=' or ':' */
Bram Moolenaar1c465442017-03-12 20:10:05 +01005210 for (p = arg; *p && !VIM_ISWHITE(*p); ++p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005211 if (*p == '\\' && p[1] != NUL)
5212 ++p;
5213 nextchar = *p;
5214 *p = NUL;
5215 add_termcode(key_name, arg, FALSE);
5216 *p = nextchar;
5217 }
5218 if (full_screen)
5219 ttest(FALSE);
5220 redraw_all_later(CLEAR);
5221 }
5222 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005223
Bram Moolenaar071d4272004-06-13 20:20:40 +00005224 if (opt_idx >= 0)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005225 did_set_option(opt_idx, opt_flags,
5226 !prepending && !adding && !removing);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005227 }
5228
5229skip:
5230 /*
5231 * Advance to next argument.
5232 * - skip until a blank found, taking care of backslashes
5233 * - skip blanks
5234 * - skip one "=val" argument (for hidden options ":set gfn =xx")
5235 */
5236 for (i = 0; i < 2 ; ++i)
5237 {
Bram Moolenaar1c465442017-03-12 20:10:05 +01005238 while (*arg != NUL && !VIM_ISWHITE(*arg))
Bram Moolenaar071d4272004-06-13 20:20:40 +00005239 if (*arg++ == '\\' && *arg != NUL)
5240 ++arg;
5241 arg = skipwhite(arg);
5242 if (*arg != '=')
5243 break;
5244 }
5245 }
5246
5247 if (errmsg != NULL)
5248 {
Bram Moolenaarce0842a2005-07-18 21:58:11 +00005249 vim_strncpy(IObuff, (char_u *)_(errmsg), IOSIZE - 1);
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00005250 i = (int)STRLEN(IObuff) + 2;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005251 if (i + (arg - startarg) < IOSIZE)
5252 {
5253 /* append the argument with the error */
5254 STRCAT(IObuff, ": ");
5255 mch_memmove(IObuff + i, startarg, (arg - startarg));
5256 IObuff[i + (arg - startarg)] = NUL;
5257 }
5258 /* make sure all characters are printable */
5259 trans_characters(IObuff, IOSIZE);
5260
5261 ++no_wait_return; /* wait_return done later */
5262 emsg(IObuff); /* show error highlighted */
5263 --no_wait_return;
5264
5265 return FAIL;
5266 }
5267
5268 arg = skipwhite(arg);
5269 }
5270
Bram Moolenaar26a60b42005-02-22 08:49:11 +00005271theend:
5272 if (silent_mode && did_show)
5273 {
5274 /* After displaying option values in silent mode. */
5275 silent_mode = FALSE;
5276 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
5277 msg_putchar('\n');
5278 cursor_on(); /* msg_start() switches it off */
5279 out_flush();
5280 silent_mode = TRUE;
5281 info_message = FALSE; /* use mch_msg(), not mch_errmsg() */
5282 }
5283
Bram Moolenaar071d4272004-06-13 20:20:40 +00005284 return OK;
5285}
5286
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005287/*
5288 * Call this when an option has been given a new value through a user command.
5289 * Sets the P_WAS_SET flag and takes care of the P_INSECURE flag.
5290 */
5291 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005292did_set_option(
5293 int opt_idx,
5294 int opt_flags, /* possibly with OPT_MODELINE */
5295 int new_value) /* value was replaced completely */
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005296{
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005297 long_u *p;
5298
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005299 options[opt_idx].flags |= P_WAS_SET;
5300
5301 /* When an option is set in the sandbox, from a modeline or in secure mode
5302 * set the P_INSECURE flag. Otherwise, if a new value is stored reset the
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005303 * flag. */
5304 p = insecure_flag(opt_idx, opt_flags);
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005305 if (secure
5306#ifdef HAVE_SANDBOX
5307 || sandbox != 0
5308#endif
5309 || (opt_flags & OPT_MODELINE))
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005310 *p = *p | P_INSECURE;
5311 else if (new_value)
5312 *p = *p & ~P_INSECURE;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005313}
5314
Bram Moolenaar071d4272004-06-13 20:20:40 +00005315 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005316illegal_char(char_u *errbuf, int c)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005317{
5318 if (errbuf == NULL)
5319 return (char_u *)"";
5320 sprintf((char *)errbuf, _("E539: Illegal character <%s>"),
Bram Moolenaar555b2802005-05-19 21:08:39 +00005321 (char *)transchar(c));
Bram Moolenaar071d4272004-06-13 20:20:40 +00005322 return errbuf;
5323}
5324
5325/*
5326 * Convert a key name or string into a key value.
5327 * Used for 'wildchar' and 'cedit' options.
5328 */
5329 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01005330string_to_key(char_u *arg)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005331{
5332 if (*arg == '<')
5333 return find_key_option(arg + 1);
5334 if (*arg == '^')
5335 return Ctrl_chr(arg[1]);
5336 return *arg;
5337}
5338
5339#ifdef FEAT_CMDWIN
5340/*
5341 * Check value of 'cedit' and set cedit_key.
5342 * Returns NULL if value is OK, error message otherwise.
5343 */
5344 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005345check_cedit(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005346{
5347 int n;
5348
5349 if (*p_cedit == NUL)
5350 cedit_key = -1;
5351 else
5352 {
5353 n = string_to_key(p_cedit);
5354 if (vim_isprintc(n))
5355 return e_invarg;
5356 cedit_key = n;
5357 }
5358 return NULL;
5359}
5360#endif
5361
5362#ifdef FEAT_TITLE
5363/*
5364 * When changing 'title', 'titlestring', 'icon' or 'iconstring', call
5365 * maketitle() to create and display it.
5366 * When switching the title or icon off, call mch_restore_title() to get
5367 * the old value back.
5368 */
5369 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005370did_set_title(
5371 int icon) /* Did set icon instead of title */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005372{
5373 if (starting != NO_SCREEN
5374#ifdef FEAT_GUI
5375 && !gui.starting
5376#endif
5377 )
5378 {
5379 maketitle();
5380 if (icon)
5381 {
5382 if (!p_icon)
5383 mch_restore_title(2);
5384 }
5385 else
5386 {
5387 if (!p_title)
5388 mch_restore_title(1);
5389 }
5390 }
5391}
5392#endif
5393
5394/*
5395 * set_options_bin - called when 'bin' changes value.
5396 */
5397 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005398set_options_bin(
5399 int oldval,
5400 int newval,
5401 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005402{
5403 /*
5404 * The option values that are changed when 'bin' changes are
5405 * copied when 'bin is set and restored when 'bin' is reset.
5406 */
5407 if (newval)
5408 {
5409 if (!oldval) /* switched on */
5410 {
5411 if (!(opt_flags & OPT_GLOBAL))
5412 {
5413 curbuf->b_p_tw_nobin = curbuf->b_p_tw;
5414 curbuf->b_p_wm_nobin = curbuf->b_p_wm;
5415 curbuf->b_p_ml_nobin = curbuf->b_p_ml;
5416 curbuf->b_p_et_nobin = curbuf->b_p_et;
5417 }
5418 if (!(opt_flags & OPT_LOCAL))
5419 {
5420 p_tw_nobin = p_tw;
5421 p_wm_nobin = p_wm;
5422 p_ml_nobin = p_ml;
5423 p_et_nobin = p_et;
5424 }
5425 }
5426
5427 if (!(opt_flags & OPT_GLOBAL))
5428 {
5429 curbuf->b_p_tw = 0; /* no automatic line wrap */
5430 curbuf->b_p_wm = 0; /* no automatic line wrap */
5431 curbuf->b_p_ml = 0; /* no modelines */
5432 curbuf->b_p_et = 0; /* no expandtab */
5433 }
5434 if (!(opt_flags & OPT_LOCAL))
5435 {
5436 p_tw = 0;
5437 p_wm = 0;
5438 p_ml = FALSE;
5439 p_et = FALSE;
5440 p_bin = TRUE; /* needed when called for the "-b" argument */
5441 }
5442 }
5443 else if (oldval) /* switched off */
5444 {
5445 if (!(opt_flags & OPT_GLOBAL))
5446 {
5447 curbuf->b_p_tw = curbuf->b_p_tw_nobin;
5448 curbuf->b_p_wm = curbuf->b_p_wm_nobin;
5449 curbuf->b_p_ml = curbuf->b_p_ml_nobin;
5450 curbuf->b_p_et = curbuf->b_p_et_nobin;
5451 }
5452 if (!(opt_flags & OPT_LOCAL))
5453 {
5454 p_tw = p_tw_nobin;
5455 p_wm = p_wm_nobin;
5456 p_ml = p_ml_nobin;
5457 p_et = p_et_nobin;
5458 }
5459 }
5460}
5461
5462#ifdef FEAT_VIMINFO
5463/*
5464 * Find the parameter represented by the given character (eg ', :, ", or /),
5465 * and return its associated value in the 'viminfo' string.
5466 * Only works for number parameters, not for 'r' or 'n'.
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +00005467 * If the parameter is not specified in the string or there is no following
5468 * number, return -1.
Bram Moolenaar071d4272004-06-13 20:20:40 +00005469 */
5470 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01005471get_viminfo_parameter(int type)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005472{
5473 char_u *p;
5474
5475 p = find_viminfo_parameter(type);
5476 if (p != NULL && VIM_ISDIGIT(*p))
5477 return atoi((char *)p);
5478 return -1;
5479}
5480
5481/*
5482 * Find the parameter represented by the given character (eg ''', ':', '"', or
5483 * '/') in the 'viminfo' option and return a pointer to the string after it.
5484 * Return NULL if the parameter is not specified in the string.
5485 */
5486 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005487find_viminfo_parameter(int type)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005488{
5489 char_u *p;
5490
5491 for (p = p_viminfo; *p; ++p)
5492 {
5493 if (*p == type)
5494 return p + 1;
5495 if (*p == 'n') /* 'n' is always the last one */
5496 break;
5497 p = vim_strchr(p, ','); /* skip until next ',' */
5498 if (p == NULL) /* hit the end without finding parameter */
5499 break;
5500 }
5501 return NULL;
5502}
5503#endif
5504
5505/*
5506 * Expand environment variables for some string options.
5507 * These string options cannot be indirect!
5508 * If "val" is NULL expand the current value of the option.
5509 * Return pointer to NameBuff, or NULL when not expanded.
5510 */
5511 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005512option_expand(int opt_idx, char_u *val)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005513{
5514 /* if option doesn't need expansion nothing to do */
5515 if (!(options[opt_idx].flags & P_EXPAND) || options[opt_idx].var == NULL)
5516 return NULL;
5517
5518 /* If val is longer than MAXPATHL no meaningful expansion can be done,
5519 * expand_env() would truncate the string. */
5520 if (val != NULL && STRLEN(val) > MAXPATHL)
5521 return NULL;
5522
5523 if (val == NULL)
5524 val = *(char_u **)options[opt_idx].var;
5525
5526 /*
5527 * Expanding this with NameBuff, expand_env() must not be passed IObuff.
5528 * Escape spaces when expanding 'tags', they are used to separate file
5529 * names.
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005530 * For 'spellsuggest' expand after "file:".
Bram Moolenaar071d4272004-06-13 20:20:40 +00005531 */
5532 expand_env_esc(val, NameBuff, MAXPATHL,
Bram Moolenaar9f0545d2007-09-26 20:36:32 +00005533 (char_u **)options[opt_idx].var == &p_tags, FALSE,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005534#ifdef FEAT_SPELL
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005535 (char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" :
5536#endif
5537 NULL);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005538 if (STRCMP(NameBuff, val) == 0) /* they are the same */
5539 return NULL;
5540
5541 return NameBuff;
5542}
5543
5544/*
5545 * After setting various option values: recompute variables that depend on
5546 * option values.
5547 */
5548 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005549didset_options(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005550{
5551 /* initialize the table for 'iskeyword' et.al. */
5552 (void)init_chartab();
5553
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00005554#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +00005555 (void)opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE);
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00005556#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005557 (void)opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, TRUE);
Bram Moolenaar165bc692015-07-21 17:53:25 +02005558 (void)opt_strings_flags(p_bo, p_bo_values, &bo_flags, TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005559#ifdef FEAT_SESSION
5560 (void)opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE);
5561 (void)opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE);
5562#endif
5563#ifdef FEAT_FOLDING
5564 (void)opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE);
5565#endif
5566 (void)opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE);
Bram Moolenaar0f6562e2015-11-24 18:48:14 +01005567 (void)opt_strings_flags(p_tc, p_tc_values, &tc_flags, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005568#ifdef FEAT_VIRTUALEDIT
5569 (void)opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE);
5570#endif
5571#if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
5572 (void)opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE);
5573#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005574#ifdef FEAT_SPELL
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00005575 (void)spell_check_msm();
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005576 (void)spell_check_sps();
Bram Moolenaar860cae12010-06-05 23:22:07 +02005577 (void)compile_cap_prog(curwin->w_s);
Bram Moolenaare68c25c2015-08-25 15:39:55 +02005578 (void)did_set_spell_option(TRUE);
Bram Moolenaard857f0e2005-06-21 22:37:39 +00005579#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005580#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
5581 (void)opt_strings_flags(p_toolbar, p_toolbar_values, &toolbar_flags, TRUE);
5582#endif
Bram Moolenaar182c5be2010-06-25 05:37:59 +02005583#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005584 (void)opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE);
5585#endif
5586#ifdef FEAT_CMDWIN
5587 /* set cedit_key */
5588 (void)check_cedit();
5589#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +02005590#ifdef FEAT_LINEBREAK
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02005591 briopt_check(curwin);
Bram Moolenaar597a4222014-06-25 14:39:50 +02005592#endif
Bram Moolenaare68c25c2015-08-25 15:39:55 +02005593#ifdef FEAT_LINEBREAK
5594 /* initialize the table for 'breakat'. */
5595 fill_breakat_flags();
5596#endif
5597
5598}
5599
5600/*
5601 * More side effects of setting options.
5602 */
5603 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005604didset_options2(void)
Bram Moolenaare68c25c2015-08-25 15:39:55 +02005605{
5606 /* Initialize the highlight_attr[] table. */
5607 (void)highlight_changed();
5608
5609 /* Parse default for 'wildmode' */
5610 check_opt_wim();
5611
5612 (void)set_chars_option(&p_lcs);
5613#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
5614 /* Parse default for 'fillchars'. */
5615 (void)set_chars_option(&p_fcs);
5616#endif
5617
5618#ifdef FEAT_CLIPBOARD
5619 /* Parse default for 'clipboard' */
5620 (void)check_clipboard_option();
5621#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005622}
5623
5624/*
5625 * Check for string options that are NULL (normally only termcap options).
5626 */
5627 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005628check_options(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005629{
5630 int opt_idx;
5631
5632 for (opt_idx = 0; options[opt_idx].fullname != NULL; opt_idx++)
5633 if ((options[opt_idx].flags & P_STRING) && options[opt_idx].var != NULL)
5634 check_string_option((char_u **)get_varp(&(options[opt_idx])));
5635}
5636
5637/*
5638 * Check string options in a buffer for NULL value.
5639 */
5640 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005641check_buf_options(buf_T *buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005642{
5643#if defined(FEAT_QUICKFIX)
5644 check_string_option(&buf->b_p_bh);
5645 check_string_option(&buf->b_p_bt);
5646#endif
5647#ifdef FEAT_MBYTE
5648 check_string_option(&buf->b_p_fenc);
5649#endif
5650 check_string_option(&buf->b_p_ff);
5651#ifdef FEAT_FIND_ID
5652 check_string_option(&buf->b_p_def);
5653 check_string_option(&buf->b_p_inc);
5654# ifdef FEAT_EVAL
5655 check_string_option(&buf->b_p_inex);
5656# endif
5657#endif
5658#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
5659 check_string_option(&buf->b_p_inde);
5660 check_string_option(&buf->b_p_indk);
5661#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00005662#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
5663 check_string_option(&buf->b_p_bexpr);
5664#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +02005665#if defined(FEAT_CRYPT)
5666 check_string_option(&buf->b_p_cm);
5667#endif
Bram Moolenaar9be7c042017-01-14 14:28:30 +01005668 check_string_option(&buf->b_p_fp);
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00005669#if defined(FEAT_EVAL)
5670 check_string_option(&buf->b_p_fex);
5671#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005672#ifdef FEAT_CRYPT
5673 check_string_option(&buf->b_p_key);
5674#endif
5675 check_string_option(&buf->b_p_kp);
5676 check_string_option(&buf->b_p_mps);
5677 check_string_option(&buf->b_p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +00005678 check_string_option(&buf->b_p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005679 check_string_option(&buf->b_p_isk);
5680#ifdef FEAT_COMMENTS
5681 check_string_option(&buf->b_p_com);
5682#endif
5683#ifdef FEAT_FOLDING
5684 check_string_option(&buf->b_p_cms);
5685#endif
5686 check_string_option(&buf->b_p_nf);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005687#ifdef FEAT_TEXTOBJ
5688 check_string_option(&buf->b_p_qe);
5689#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005690#ifdef FEAT_SYN_HL
5691 check_string_option(&buf->b_p_syn);
Bram Moolenaarb8060fe2016-01-19 22:29:28 +01005692 check_string_option(&buf->b_s.b_syn_isk);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005693#endif
5694#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02005695 check_string_option(&buf->b_s.b_p_spc);
5696 check_string_option(&buf->b_s.b_p_spf);
5697 check_string_option(&buf->b_s.b_p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005698#endif
5699#ifdef FEAT_SEARCHPATH
5700 check_string_option(&buf->b_p_sua);
5701#endif
5702#ifdef FEAT_CINDENT
5703 check_string_option(&buf->b_p_cink);
5704 check_string_option(&buf->b_p_cino);
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01005705 parse_cino(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005706#endif
5707#ifdef FEAT_AUTOCMD
5708 check_string_option(&buf->b_p_ft);
5709#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005710#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
5711 check_string_option(&buf->b_p_cinw);
5712#endif
5713#ifdef FEAT_INS_EXPAND
5714 check_string_option(&buf->b_p_cpt);
5715#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005716#ifdef FEAT_COMPL_FUNC
5717 check_string_option(&buf->b_p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +00005718 check_string_option(&buf->b_p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005719#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005720#ifdef FEAT_KEYMAP
5721 check_string_option(&buf->b_p_keymap);
5722#endif
5723#ifdef FEAT_QUICKFIX
5724 check_string_option(&buf->b_p_gp);
5725 check_string_option(&buf->b_p_mp);
5726 check_string_option(&buf->b_p_efm);
5727#endif
5728 check_string_option(&buf->b_p_ep);
5729 check_string_option(&buf->b_p_path);
5730 check_string_option(&buf->b_p_tags);
Bram Moolenaar0f6562e2015-11-24 18:48:14 +01005731 check_string_option(&buf->b_p_tc);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005732#ifdef FEAT_INS_EXPAND
5733 check_string_option(&buf->b_p_dict);
5734 check_string_option(&buf->b_p_tsr);
5735#endif
Bram Moolenaaraf6c1312014-03-12 18:55:58 +01005736#ifdef FEAT_LISP
5737 check_string_option(&buf->b_p_lw);
5738#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02005739 check_string_option(&buf->b_p_bkc);
Bram Moolenaar2c7292d2017-03-05 17:43:31 +01005740#ifdef FEAT_MBYTE
5741 check_string_option(&buf->b_p_menc);
5742#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005743}
5744
5745/*
5746 * Free the string allocated for an option.
5747 * Checks for the string being empty_option. This may happen if we're out of
5748 * memory, vim_strsave() returned NULL, which was replaced by empty_option by
5749 * check_options().
5750 * Does NOT check for P_ALLOCED flag!
5751 */
5752 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005753free_string_option(char_u *p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005754{
5755 if (p != empty_option)
5756 vim_free(p);
5757}
5758
5759 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005760clear_string_option(char_u **pp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005761{
5762 if (*pp != empty_option)
5763 vim_free(*pp);
5764 *pp = empty_option;
5765}
5766
5767 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005768check_string_option(char_u **pp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005769{
5770 if (*pp == NULL)
5771 *pp = empty_option;
5772}
5773
5774/*
5775 * Mark a terminal option as allocated, found by a pointer into term_strings[].
5776 */
5777 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005778set_term_option_alloced(char_u **p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005779{
5780 int opt_idx;
5781
5782 for (opt_idx = 1; options[opt_idx].fullname != NULL; opt_idx++)
5783 if (options[opt_idx].var == (char_u *)p)
5784 {
5785 options[opt_idx].flags |= P_ALLOCED;
5786 return;
5787 }
5788 return; /* cannot happen: didn't find it! */
5789}
5790
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005791#if defined(FEAT_EVAL) || defined(PROTO)
5792/*
5793 * Return TRUE when option "opt" was set from a modeline or in secure mode.
5794 * Return FALSE when it wasn't.
5795 * Return -1 for an unknown option.
5796 */
5797 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01005798was_set_insecurely(char_u *opt, int opt_flags)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005799{
5800 int idx = findoption(opt);
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005801 long_u *flagp;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005802
5803 if (idx >= 0)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005804 {
5805 flagp = insecure_flag(idx, opt_flags);
5806 return (*flagp & P_INSECURE) != 0;
5807 }
Bram Moolenaar95f09602016-11-10 20:01:45 +01005808 internal_error("was_set_insecurely()");
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005809 return -1;
5810}
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005811
5812/*
5813 * Get a pointer to the flags used for the P_INSECURE flag of option
5814 * "opt_idx". For some local options a local flags field is used.
5815 */
5816 static long_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005817insecure_flag(int opt_idx, int opt_flags)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005818{
5819 if (opt_flags & OPT_LOCAL)
5820 switch ((int)options[opt_idx].indir)
5821 {
5822#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005823 case PV_STL: return &curwin->w_p_stl_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005824#endif
5825#ifdef FEAT_EVAL
Bram Moolenaar2e978902006-05-13 12:37:50 +00005826# ifdef FEAT_FOLDING
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005827 case PV_FDE: return &curwin->w_p_fde_flags;
5828 case PV_FDT: return &curwin->w_p_fdt_flags;
Bram Moolenaar2e978902006-05-13 12:37:50 +00005829# endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00005830# ifdef FEAT_BEVAL
5831 case PV_BEXPR: return &curbuf->b_p_bexpr_flags;
5832# endif
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005833# if defined(FEAT_CINDENT)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005834 case PV_INDE: return &curbuf->b_p_inde_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005835# endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005836 case PV_FEX: return &curbuf->b_p_fex_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005837# ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005838 case PV_INEX: return &curbuf->b_p_inex_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005839# endif
5840#endif
5841 }
5842
5843 /* Nothing special, return global flags field. */
5844 return &options[opt_idx].flags;
5845}
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005846#endif
5847
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005848#ifdef FEAT_TITLE
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01005849static void redraw_titles(void);
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005850
5851/*
5852 * Redraw the window title and/or tab page text later.
5853 */
Bram Moolenaar9b578142016-01-30 19:39:49 +01005854static void redraw_titles(void)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005855{
5856 need_maketitle = TRUE;
5857# ifdef FEAT_WINDOWS
5858 redraw_tabline = TRUE;
5859# endif
5860}
5861#endif
5862
Bram Moolenaar071d4272004-06-13 20:20:40 +00005863/*
5864 * Set a string option to a new value (without checking the effect).
5865 * The string is copied into allocated memory.
5866 * if ("opt_idx" == -1) "name" is used, otherwise "opt_idx" is used.
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005867 * When "set_sid" is zero set the scriptID to current_SID. When "set_sid" is
Bram Moolenaard55de222007-05-06 13:38:48 +00005868 * SID_NONE don't set the scriptID. Otherwise set the scriptID to "set_sid".
Bram Moolenaar071d4272004-06-13 20:20:40 +00005869 */
5870 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005871set_string_option_direct(
5872 char_u *name,
5873 int opt_idx,
5874 char_u *val,
5875 int opt_flags, /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
5876 int set_sid UNUSED)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005877{
5878 char_u *s;
5879 char_u **varp;
5880 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
Bram Moolenaar89d40322006-08-29 15:30:07 +00005881 int idx = opt_idx;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005882
Bram Moolenaar89d40322006-08-29 15:30:07 +00005883 if (idx == -1) /* use name */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005884 {
Bram Moolenaar89d40322006-08-29 15:30:07 +00005885 idx = findoption(name);
5886 if (idx < 0) /* not found (should not happen) */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005887 {
5888 EMSG2(_(e_intern2), "set_string_option_direct()");
Bram Moolenaar95f09602016-11-10 20:01:45 +01005889 IEMSG2(_("For option %s"), name);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005890 return;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005891 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005892 }
5893
Bram Moolenaar89d40322006-08-29 15:30:07 +00005894 if (options[idx].var == NULL) /* can't set hidden option */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005895 return;
5896
5897 s = vim_strsave(val);
5898 if (s != NULL)
5899 {
Bram Moolenaar89d40322006-08-29 15:30:07 +00005900 varp = (char_u **)get_varp_scope(&(options[idx]),
Bram Moolenaar071d4272004-06-13 20:20:40 +00005901 both ? OPT_LOCAL : opt_flags);
Bram Moolenaar89d40322006-08-29 15:30:07 +00005902 if ((opt_flags & OPT_FREE) && (options[idx].flags & P_ALLOCED))
Bram Moolenaar071d4272004-06-13 20:20:40 +00005903 free_string_option(*varp);
5904 *varp = s;
5905
5906 /* For buffer/window local option may also set the global value. */
5907 if (both)
Bram Moolenaar89d40322006-08-29 15:30:07 +00005908 set_string_option_global(idx, varp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005909
Bram Moolenaar89d40322006-08-29 15:30:07 +00005910 options[idx].flags |= P_ALLOCED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005911
5912 /* When setting both values of a global option with a local value,
5913 * make the local value empty, so that the global value is used. */
Bram Moolenaar89d40322006-08-29 15:30:07 +00005914 if (((int)options[idx].indir & PV_BOTH) && both)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005915 {
5916 free_string_option(*varp);
5917 *varp = empty_option;
5918 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005919# ifdef FEAT_EVAL
5920 if (set_sid != SID_NONE)
Bram Moolenaar89d40322006-08-29 15:30:07 +00005921 set_option_scriptID_idx(idx, opt_flags,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005922 set_sid == 0 ? current_SID : set_sid);
5923# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005924 }
5925}
5926
5927/*
5928 * Set global value for string option when it's a local option.
5929 */
5930 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005931set_string_option_global(
5932 int opt_idx, /* option index */
5933 char_u **varp) /* pointer to option variable */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005934{
5935 char_u **p, *s;
5936
5937 /* the global value is always allocated */
5938 if (options[opt_idx].var == VAR_WIN)
5939 p = (char_u **)GLOBAL_WO(varp);
5940 else
5941 p = (char_u **)options[opt_idx].var;
5942 if (options[opt_idx].indir != PV_NONE
5943 && p != varp
5944 && (s = vim_strsave(*varp)) != NULL)
5945 {
5946 free_string_option(*p);
5947 *p = s;
5948 }
5949}
5950
5951/*
5952 * Set a string option to a new value, and handle the effects.
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005953 *
5954 * Returns NULL on success or error message on error.
Bram Moolenaar071d4272004-06-13 20:20:40 +00005955 */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005956 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005957set_string_option(
5958 int opt_idx,
5959 char_u *value,
5960 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005961{
5962 char_u *s;
5963 char_u **varp;
5964 char_u *oldval;
Bram Moolenaar53744302015-07-17 17:38:22 +02005965#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
5966 char_u *saved_oldval = NULL;
Bram Moolenaar182a17b2017-06-25 20:57:18 +02005967 char_u *saved_newval = NULL;
Bram Moolenaar53744302015-07-17 17:38:22 +02005968#endif
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005969 char_u *r = NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005970
5971 if (options[opt_idx].var == NULL) /* don't set hidden option */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005972 return NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005973
5974 s = vim_strsave(value);
5975 if (s != NULL)
5976 {
5977 varp = (char_u **)get_varp_scope(&(options[opt_idx]),
5978 (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00005979 ? (((int)options[opt_idx].indir & PV_BOTH)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005980 ? OPT_GLOBAL : OPT_LOCAL)
5981 : opt_flags);
5982 oldval = *varp;
5983 *varp = s;
Bram Moolenaar53744302015-07-17 17:38:22 +02005984
5985#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
Bram Moolenaar5cbb8db2015-07-17 23:08:29 +02005986 if (!starting
5987# ifdef FEAT_CRYPT
5988 && options[opt_idx].indir != PV_KEY
5989# endif
5990 )
Bram Moolenaar182a17b2017-06-25 20:57:18 +02005991 {
Bram Moolenaar53744302015-07-17 17:38:22 +02005992 saved_oldval = vim_strsave(oldval);
Bram Moolenaar182a17b2017-06-25 20:57:18 +02005993 saved_newval = vim_strsave(s);
5994 }
Bram Moolenaar53744302015-07-17 17:38:22 +02005995#endif
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005996 if ((r = did_set_string_option(opt_idx, varp, TRUE, oldval, NULL,
5997 opt_flags)) == NULL)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005998 did_set_option(opt_idx, opt_flags, TRUE);
Bram Moolenaar53744302015-07-17 17:38:22 +02005999
Bram Moolenaar53744302015-07-17 17:38:22 +02006000#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
Bram Moolenaar182a17b2017-06-25 20:57:18 +02006001 /* call autocommand after handling side effects */
6002 trigger_optionsset_string(opt_idx, opt_flags,
6003 saved_oldval, saved_newval);
Bram Moolenaar53744302015-07-17 17:38:22 +02006004#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006005 }
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02006006 return r;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006007}
6008
Bram Moolenaar40d3f132016-11-05 20:13:35 +01006009#if defined(FEAT_KEYMAP) || defined(FEAT_AUTOCMD) || defined(FEAT_SYN_HL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006010/*
Bram Moolenaard0b51382016-11-04 15:23:45 +01006011 * Return TRUE if "val" is a valid 'filetype' name.
6012 * Also used for 'syntax' and 'keymap'.
6013 */
6014 static int
6015valid_filetype(char_u *val)
6016{
6017 char_u *s;
6018
6019 for (s = val; *s != NUL; ++s)
6020 if (!ASCII_ISALNUM(*s) && vim_strchr((char_u *)".-_", *s) == NULL)
6021 return FALSE;
6022 return TRUE;
6023}
Bram Moolenaar40d3f132016-11-05 20:13:35 +01006024#endif
Bram Moolenaard0b51382016-11-04 15:23:45 +01006025
6026/*
Bram Moolenaar071d4272004-06-13 20:20:40 +00006027 * Handle string options that need some action to perform when changed.
6028 * Returns NULL for success, or an error message for an error.
6029 */
6030 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01006031did_set_string_option(
6032 int opt_idx, /* index in options[] table */
6033 char_u **varp, /* pointer to the option variable */
6034 int new_value_alloced, /* new value was allocated */
6035 char_u *oldval, /* previous value of the option */
6036 char_u *errbuf, /* buffer for errors, or NULL */
6037 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00006038{
6039 char_u *errmsg = NULL;
6040 char_u *s, *p;
6041 int did_chartab = FALSE;
6042 char_u **gvarp;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00006043 long_u free_oldval = (options[opt_idx].flags & P_ALLOCED);
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006044#ifdef FEAT_GUI
6045 /* set when changing an option that only requires a redraw in the GUI */
6046 int redraw_gui_only = FALSE;
6047#endif
Bram Moolenaar90492982017-06-22 14:16:31 +02006048#ifdef FEAT_AUTOCMD
6049 int ft_changed = FALSE;
6050#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006051
6052 /* Get the global option to compare with, otherwise we would have to check
6053 * two values for all local options. */
6054 gvarp = (char_u **)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL);
6055
6056 /* Disallow changing some options from secure mode */
6057 if ((secure
6058#ifdef HAVE_SANDBOX
6059 || sandbox != 0
6060#endif
6061 ) && (options[opt_idx].flags & P_SECURE))
6062 {
6063 errmsg = e_secure;
6064 }
6065
Bram Moolenaar7554da42016-11-25 22:04:13 +01006066 /* Check for a "normal" directory or file name in some options. Disallow a
6067 * path separator (slash and/or backslash), wildcards and characters that
Bram Moolenaar0945eaf2016-11-29 22:10:48 +01006068 * are often illegal in a file name. Be more permissive if "secure" is off.
6069 */
Bram Moolenaar7554da42016-11-25 22:04:13 +01006070 else if (((options[opt_idx].flags & P_NFNAME)
Bram Moolenaar0945eaf2016-11-29 22:10:48 +01006071 && vim_strpbrk(*varp, (char_u *)(secure
6072 ? "/\\*?[|;&<>\r\n" : "/\\*?[<>\r\n")) != NULL)
Bram Moolenaar7554da42016-11-25 22:04:13 +01006073 || ((options[opt_idx].flags & P_NDNAME)
6074 && vim_strpbrk(*varp, (char_u *)"*?[|;&<>\r\n") != NULL))
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00006075 {
6076 errmsg = e_invarg;
6077 }
6078
Bram Moolenaar071d4272004-06-13 20:20:40 +00006079 /* 'term' */
6080 else if (varp == &T_NAME)
6081 {
6082 if (T_NAME[0] == NUL)
6083 errmsg = (char_u *)N_("E529: Cannot set 'term' to empty string");
6084#ifdef FEAT_GUI
6085 if (gui.in_use)
6086 errmsg = (char_u *)N_("E530: Cannot change term in GUI");
6087 else if (term_is_gui(T_NAME))
6088 errmsg = (char_u *)N_("E531: Use \":gui\" to start the GUI");
6089#endif
6090 else if (set_termname(T_NAME) == FAIL)
6091 errmsg = (char_u *)N_("E522: Not found in termcap");
6092 else
Bram Moolenaar67391142017-02-19 21:07:04 +01006093 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00006094 /* Screen colors may have changed. */
6095 redraw_later_clear();
Bram Moolenaar67391142017-02-19 21:07:04 +01006096
6097 /* Both 'term' and 'ttytype' point to T_NAME, only set the
6098 * P_ALLOCED flag on 'term'. */
6099 opt_idx = findoption((char_u *)"term");
Bram Moolenaar354796c2017-02-23 17:18:37 +01006100 free_oldval = (options[opt_idx].flags & P_ALLOCED);
Bram Moolenaar67391142017-02-19 21:07:04 +01006101 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006102 }
6103
6104 /* 'backupcopy' */
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02006105 else if (gvarp == &p_bkc)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006106 {
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02006107 char_u *bkc = p_bkc;
6108 unsigned int *flags = &bkc_flags;
6109
6110 if (opt_flags & OPT_LOCAL)
6111 {
6112 bkc = curbuf->b_p_bkc;
6113 flags = &curbuf->b_bkc_flags;
6114 }
6115
Bram Moolenaar84d17a62014-09-29 17:15:18 +02006116 if ((opt_flags & OPT_LOCAL) && *bkc == NUL)
6117 /* make the local value empty: use the global value */
6118 *flags = 0;
6119 else
Bram Moolenaar071d4272004-06-13 20:20:40 +00006120 {
Bram Moolenaar84d17a62014-09-29 17:15:18 +02006121 if (opt_strings_flags(bkc, p_bkc_values, flags, TRUE) != OK)
6122 errmsg = e_invarg;
6123 if ((((int)*flags & BKC_AUTO) != 0)
6124 + (((int)*flags & BKC_YES) != 0)
6125 + (((int)*flags & BKC_NO) != 0) != 1)
6126 {
6127 /* Must have exactly one of "auto", "yes" and "no". */
6128 (void)opt_strings_flags(oldval, p_bkc_values, flags, TRUE);
6129 errmsg = e_invarg;
6130 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006131 }
6132 }
6133
6134 /* 'backupext' and 'patchmode' */
6135 else if (varp == &p_bex || varp == &p_pm)
6136 {
6137 if (STRCMP(*p_bex == '.' ? p_bex + 1 : p_bex,
6138 *p_pm == '.' ? p_pm + 1 : p_pm) == 0)
6139 errmsg = (char_u *)N_("E589: 'backupext' and 'patchmode' are equal");
6140 }
Bram Moolenaar597a4222014-06-25 14:39:50 +02006141#ifdef FEAT_LINEBREAK
6142 /* 'breakindentopt' */
6143 else if (varp == &curwin->w_p_briopt)
6144 {
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02006145 if (briopt_check(curwin) == FAIL)
Bram Moolenaar597a4222014-06-25 14:39:50 +02006146 errmsg = e_invarg;
6147 }
6148#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006149
6150 /*
Bram Moolenaar88e8f9f2016-01-20 22:48:02 +01006151 * 'isident', 'iskeyword', 'isprint or 'isfname' option: refill g_chartab[]
Bram Moolenaar071d4272004-06-13 20:20:40 +00006152 * If the new option is invalid, use old value. 'lisp' option: refill
Bram Moolenaar88e8f9f2016-01-20 22:48:02 +01006153 * g_chartab[] for '-' char
Bram Moolenaar071d4272004-06-13 20:20:40 +00006154 */
6155 else if ( varp == &p_isi
6156 || varp == &(curbuf->b_p_isk)
6157 || varp == &p_isp
6158 || varp == &p_isf)
6159 {
6160 if (init_chartab() == FAIL)
6161 {
6162 did_chartab = TRUE; /* need to restore it below */
6163 errmsg = e_invarg; /* error in value */
6164 }
6165 }
6166
6167 /* 'helpfile' */
6168 else if (varp == &p_hf)
6169 {
6170 /* May compute new values for $VIM and $VIMRUNTIME */
6171 if (didset_vim)
6172 {
6173 vim_setenv((char_u *)"VIM", (char_u *)"");
6174 didset_vim = FALSE;
6175 }
6176 if (didset_vimruntime)
6177 {
6178 vim_setenv((char_u *)"VIMRUNTIME", (char_u *)"");
6179 didset_vimruntime = FALSE;
6180 }
6181 }
6182
Bram Moolenaar1a384422010-07-14 19:53:30 +02006183#ifdef FEAT_SYN_HL
6184 /* 'colorcolumn' */
6185 else if (varp == &curwin->w_p_cc)
6186 errmsg = check_colorcolumn(curwin);
6187#endif
6188
Bram Moolenaar071d4272004-06-13 20:20:40 +00006189#ifdef FEAT_MULTI_LANG
6190 /* 'helplang' */
6191 else if (varp == &p_hlg)
6192 {
6193 /* Check for "", "ab", "ab,cd", etc. */
6194 for (s = p_hlg; *s != NUL; s += 3)
6195 {
6196 if (s[1] == NUL || ((s[2] != ',' || s[3] == NUL) && s[2] != NUL))
6197 {
6198 errmsg = e_invarg;
6199 break;
6200 }
6201 if (s[2] == NUL)
6202 break;
6203 }
6204 }
6205#endif
6206
6207 /* 'highlight' */
6208 else if (varp == &p_hl)
6209 {
6210 if (highlight_changed() == FAIL)
6211 errmsg = e_invarg; /* invalid flags */
6212 }
6213
6214 /* 'nrformats' */
6215 else if (gvarp == &p_nf)
6216 {
6217 if (check_opt_strings(*varp, p_nf_values, TRUE) != OK)
6218 errmsg = e_invarg;
6219 }
6220
6221#ifdef FEAT_SESSION
6222 /* 'sessionoptions' */
6223 else if (varp == &p_ssop)
6224 {
6225 if (opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE) != OK)
6226 errmsg = e_invarg;
6227 if ((ssop_flags & SSOP_CURDIR) && (ssop_flags & SSOP_SESDIR))
6228 {
6229 /* Don't allow both "sesdir" and "curdir". */
6230 (void)opt_strings_flags(oldval, p_ssop_values, &ssop_flags, TRUE);
6231 errmsg = e_invarg;
6232 }
6233 }
6234 /* 'viewoptions' */
6235 else if (varp == &p_vop)
6236 {
6237 if (opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE) != OK)
6238 errmsg = e_invarg;
6239 }
6240#endif
6241
6242 /* 'scrollopt' */
6243#ifdef FEAT_SCROLLBIND
6244 else if (varp == &p_sbo)
6245 {
6246 if (check_opt_strings(p_sbo, p_scbopt_values, TRUE) != OK)
6247 errmsg = e_invarg;
6248 }
6249#endif
6250
6251 /* 'ambiwidth' */
6252#ifdef FEAT_MBYTE
Bram Moolenaar3848e002016-03-19 18:42:29 +01006253 else if (varp == &p_ambw || varp == &p_emoji)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006254 {
6255 if (check_opt_strings(p_ambw, p_ambw_values, FALSE) != OK)
6256 errmsg = e_invarg;
Bram Moolenaar5c3bd0a2010-08-04 20:55:44 +02006257 else if (set_chars_option(&p_lcs) != NULL)
6258 errmsg = (char_u *)_("E834: Conflicts with value of 'listchars'");
6259# if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
6260 else if (set_chars_option(&p_fcs) != NULL)
6261 errmsg = (char_u *)_("E835: Conflicts with value of 'fillchars'");
6262# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006263 }
6264#endif
6265
6266 /* 'background' */
6267 else if (varp == &p_bg)
6268 {
6269 if (check_opt_strings(p_bg, p_bg_values, FALSE) == OK)
6270 {
6271#ifdef FEAT_EVAL
6272 int dark = (*p_bg == 'd');
6273#endif
6274
6275 init_highlight(FALSE, FALSE);
6276
6277#ifdef FEAT_EVAL
6278 if (dark != (*p_bg == 'd')
6279 && get_var_value((char_u *)"g:colors_name") != NULL)
6280 {
6281 /* The color scheme must have set 'background' back to another
6282 * value, that's not what we want here. Disable the color
6283 * scheme and set the colors again. */
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00006284 do_unlet((char_u *)"g:colors_name", TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006285 free_string_option(p_bg);
6286 p_bg = vim_strsave((char_u *)(dark ? "dark" : "light"));
6287 check_string_option(&p_bg);
6288 init_highlight(FALSE, FALSE);
6289 }
6290#endif
6291 }
6292 else
6293 errmsg = e_invarg;
6294 }
6295
6296 /* 'wildmode' */
6297 else if (varp == &p_wim)
6298 {
6299 if (check_opt_wim() == FAIL)
6300 errmsg = e_invarg;
6301 }
6302
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00006303#ifdef FEAT_CMDL_COMPL
6304 /* 'wildoptions' */
6305 else if (varp == &p_wop)
6306 {
6307 if (check_opt_strings(p_wop, p_wop_values, TRUE) != OK)
6308 errmsg = e_invarg;
6309 }
6310#endif
6311
Bram Moolenaar071d4272004-06-13 20:20:40 +00006312#ifdef FEAT_WAK
6313 /* 'winaltkeys' */
6314 else if (varp == &p_wak)
6315 {
6316 if (*p_wak == NUL
6317 || check_opt_strings(p_wak, p_wak_values, FALSE) != OK)
6318 errmsg = e_invarg;
6319# ifdef FEAT_MENU
6320# ifdef FEAT_GUI_MOTIF
6321 else if (gui.in_use)
6322 gui_motif_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
6323# else
6324# ifdef FEAT_GUI_GTK
6325 else if (gui.in_use)
6326 gui_gtk_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
6327# endif
6328# endif
6329# endif
6330 }
6331#endif
6332
6333#ifdef FEAT_AUTOCMD
6334 /* 'eventignore' */
6335 else if (varp == &p_ei)
6336 {
6337 if (check_ei() == FAIL)
6338 errmsg = e_invarg;
6339 }
6340#endif
6341
6342#ifdef FEAT_MBYTE
Bram Moolenaar2c7292d2017-03-05 17:43:31 +01006343 /* 'encoding', 'fileencoding', 'termencoding' and 'makeencoding' */
6344 else if (varp == &p_enc || gvarp == &p_fenc || varp == &p_tenc
6345 || gvarp == &p_menc)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006346 {
6347 if (gvarp == &p_fenc)
6348 {
Bram Moolenaarf2f70252008-02-13 17:36:06 +00006349 if (!curbuf->b_p_ma && opt_flags != OPT_GLOBAL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006350 errmsg = e_modifiable;
6351 else if (vim_strchr(*varp, ',') != NULL)
6352 /* No comma allowed in 'fileencoding'; catches confusing it
6353 * with 'fileencodings'. */
6354 errmsg = e_invarg;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006355 else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006356 {
6357# ifdef FEAT_TITLE
Bram Moolenaar071d4272004-06-13 20:20:40 +00006358 /* May show a "+" in the title now. */
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006359 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006360# endif
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006361 /* Add 'fileencoding' to the swap file. */
6362 ml_setflags(curbuf);
6363 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006364 }
6365 if (errmsg == NULL)
6366 {
6367 /* canonize the value, so that STRCMP() can be used on it */
6368 p = enc_canonize(*varp);
6369 if (p != NULL)
6370 {
6371 vim_free(*varp);
6372 *varp = p;
6373 }
6374 if (varp == &p_enc)
6375 {
6376 errmsg = mb_init();
6377# ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006378 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006379# endif
6380 }
6381 }
6382
Bram Moolenaar182c5be2010-06-25 05:37:59 +02006383# if defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006384 if (errmsg == NULL && varp == &p_tenc && gui.in_use)
6385 {
6386 /* GTK+ 2 uses only a single encoding, and that is UTF-8. */
6387 if (STRCMP(p_tenc, "utf-8") != 0)
6388 errmsg = (char_u *)N_("E617: Cannot be changed in the GTK+ 2 GUI");
6389 }
6390# endif
6391
6392 if (errmsg == NULL)
6393 {
6394# ifdef FEAT_KEYMAP
6395 /* When 'keymap' is used and 'encoding' changes, reload the keymap
6396 * (with another encoding). */
6397 if (varp == &p_enc && *curbuf->b_p_keymap != NUL)
6398 (void)keymap_init();
6399# endif
6400
6401 /* When 'termencoding' is not empty and 'encoding' changes or when
6402 * 'termencoding' changes, need to setup for keyboard input and
6403 * display output conversion. */
6404 if (((varp == &p_enc && *p_tenc != NUL) || varp == &p_tenc))
6405 {
6406 convert_setup(&input_conv, p_tenc, p_enc);
6407 convert_setup(&output_conv, p_enc, p_tenc);
6408 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00006409
6410# if defined(WIN3264) && defined(FEAT_MBYTE)
6411 /* $HOME may have characters in active code page. */
6412 if (varp == &p_enc)
6413 init_homedir();
6414# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006415 }
6416 }
6417#endif
6418
6419#if defined(FEAT_POSTSCRIPT)
6420 else if (varp == &p_penc)
6421 {
6422 /* Canonize printencoding if VIM standard one */
6423 p = enc_canonize(p_penc);
6424 if (p != NULL)
6425 {
6426 vim_free(p_penc);
6427 p_penc = p;
6428 }
6429 else
6430 {
6431 /* Ensure lower case and '-' for '_' */
6432 for (s = p_penc; *s != NUL; s++)
6433 {
6434 if (*s == '_')
6435 *s = '-';
6436 else
6437 *s = TOLOWER_ASC(*s);
6438 }
6439 }
6440 }
6441#endif
6442
Bram Moolenaar9372a112005-12-06 19:59:18 +00006443#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006444 else if (varp == &p_imak)
6445 {
Bram Moolenaar86e57922017-04-23 18:44:26 +02006446 if (!im_xim_isvalid_imactivate())
Bram Moolenaar071d4272004-06-13 20:20:40 +00006447 errmsg = e_invarg;
6448 }
6449#endif
6450
6451#ifdef FEAT_KEYMAP
6452 else if (varp == &curbuf->b_p_keymap)
6453 {
Bram Moolenaard0b51382016-11-04 15:23:45 +01006454 if (!valid_filetype(*varp))
6455 errmsg = e_invarg;
6456 else
6457 /* load or unload key mapping tables */
6458 errmsg = keymap_init();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006459
Bram Moolenaarfab06232009-03-04 03:13:35 +00006460 if (errmsg == NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006461 {
Bram Moolenaarfab06232009-03-04 03:13:35 +00006462 if (*curbuf->b_p_keymap != NUL)
6463 {
6464 /* Installed a new keymap, switch on using it. */
6465 curbuf->b_p_iminsert = B_IMODE_LMAP;
6466 if (curbuf->b_p_imsearch != B_IMODE_USE_INSERT)
6467 curbuf->b_p_imsearch = B_IMODE_LMAP;
6468 }
6469 else
6470 {
6471 /* Cleared the keymap, may reset 'iminsert' and 'imsearch'. */
6472 if (curbuf->b_p_iminsert == B_IMODE_LMAP)
6473 curbuf->b_p_iminsert = B_IMODE_NONE;
6474 if (curbuf->b_p_imsearch == B_IMODE_LMAP)
6475 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
6476 }
6477 if ((opt_flags & OPT_LOCAL) == 0)
6478 {
6479 set_iminsert_global();
6480 set_imsearch_global();
6481 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006482# ifdef FEAT_WINDOWS
6483 status_redraw_curbuf();
6484# endif
6485 }
6486 }
6487#endif
6488
6489 /* 'fileformat' */
6490 else if (gvarp == &p_ff)
6491 {
6492 if (!curbuf->b_p_ma && !(opt_flags & OPT_GLOBAL))
6493 errmsg = e_modifiable;
6494 else if (check_opt_strings(*varp, p_ff_values, FALSE) != OK)
6495 errmsg = e_invarg;
6496 else
6497 {
6498 /* may also change 'textmode' */
6499 if (get_fileformat(curbuf) == EOL_DOS)
6500 curbuf->b_p_tx = TRUE;
6501 else
6502 curbuf->b_p_tx = FALSE;
6503#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006504 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006505#endif
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006506 /* update flag in swap file */
6507 ml_setflags(curbuf);
Bram Moolenaar0413d482010-02-11 17:02:11 +01006508 /* Redraw needed when switching to/from "mac": a CR in the text
6509 * will be displayed differently. */
6510 if (get_fileformat(curbuf) == EOL_MAC || *oldval == 'm')
6511 redraw_curbuf_later(NOT_VALID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006512 }
6513 }
6514
6515 /* 'fileformats' */
6516 else if (varp == &p_ffs)
6517 {
6518 if (check_opt_strings(p_ffs, p_ff_values, TRUE) != OK)
6519 errmsg = e_invarg;
6520 else
6521 {
6522 /* also change 'textauto' */
6523 if (*p_ffs == NUL)
6524 p_ta = FALSE;
6525 else
6526 p_ta = TRUE;
6527 }
6528 }
6529
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006530#if defined(FEAT_CRYPT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006531 /* 'cryptkey' */
6532 else if (gvarp == &p_key)
6533 {
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006534# if defined(FEAT_CMDHIST)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006535 /* Make sure the ":set" command doesn't show the new value in the
6536 * history. */
6537 remove_key_from_history();
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006538# endif
6539 if (STRCMP(curbuf->b_p_key, oldval) != 0)
6540 /* Need to update the swapfile. */
Bram Moolenaarbc563362015-06-09 18:35:25 +02006541 ml_set_crypt_key(curbuf, oldval,
6542 *curbuf->b_p_cm == NUL ? p_cm : curbuf->b_p_cm);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006543 }
6544
6545 else if (gvarp == &p_cm)
6546 {
6547 if (opt_flags & OPT_LOCAL)
6548 p = curbuf->b_p_cm;
6549 else
6550 p = p_cm;
6551 if (check_opt_strings(p, p_cm_values, TRUE) != OK)
6552 errmsg = e_invarg;
Bram Moolenaar8f4ac012014-08-10 13:38:34 +02006553 else if (crypt_self_test() == FAIL)
Bram Moolenaar49771f42010-07-20 17:32:38 +02006554 errmsg = e_invarg;
6555 else
6556 {
6557 /* When setting the global value to empty, make it "zip". */
6558 if (*p_cm == NUL)
6559 {
6560 if (new_value_alloced)
6561 free_string_option(p_cm);
6562 p_cm = vim_strsave((char_u *)"zip");
6563 new_value_alloced = TRUE;
6564 }
Bram Moolenaar2be79502014-08-13 21:58:28 +02006565 /* When using ":set cm=name" the local value is going to be empty.
6566 * Do that here, otherwise the crypt functions will still use the
6567 * local value. */
6568 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
6569 {
6570 free_string_option(curbuf->b_p_cm);
6571 curbuf->b_p_cm = empty_option;
6572 }
Bram Moolenaar49771f42010-07-20 17:32:38 +02006573
6574 /* Need to update the swapfile when the effective method changed.
6575 * Set "s" to the effective old value, "p" to the effective new
6576 * method and compare. */
6577 if ((opt_flags & OPT_LOCAL) && *oldval == NUL)
6578 s = p_cm; /* was previously using the global value */
6579 else
6580 s = oldval;
6581 if (*curbuf->b_p_cm == NUL)
6582 p = p_cm; /* is now using the global value */
6583 else
6584 p = curbuf->b_p_cm;
6585 if (STRCMP(s, p) != 0)
Bram Moolenaarbc563362015-06-09 18:35:25 +02006586 ml_set_crypt_key(curbuf, curbuf->b_p_key, s);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006587
6588 /* If the global value changes need to update the swapfile for all
6589 * buffers using that value. */
6590 if ((opt_flags & OPT_GLOBAL) && STRCMP(p_cm, oldval) != 0)
6591 {
6592 buf_T *buf;
6593
Bram Moolenaar29323592016-07-24 22:04:11 +02006594 FOR_ALL_BUFFERS(buf)
Bram Moolenaar49771f42010-07-20 17:32:38 +02006595 if (buf != curbuf && *buf->b_p_cm == NUL)
Bram Moolenaarbc563362015-06-09 18:35:25 +02006596 ml_set_crypt_key(buf, buf->b_p_key, oldval);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006597 }
6598 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006599 }
6600#endif
6601
6602 /* 'matchpairs' */
6603 else if (gvarp == &p_mps)
6604 {
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006605#ifdef FEAT_MBYTE
6606 if (has_mbyte)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006607 {
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006608 for (p = *varp; *p != NUL; ++p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006609 {
Bram Moolenaar09365022013-01-17 17:37:35 +01006610 int x2 = -1;
6611 int x3 = -1;
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006612
6613 if (*p != NUL)
6614 p += mb_ptr2len(p);
6615 if (*p != NUL)
6616 x2 = *p++;
6617 if (*p != NUL)
6618 {
6619 x3 = mb_ptr2char(p);
6620 p += mb_ptr2len(p);
6621 }
Bram Moolenaar09365022013-01-17 17:37:35 +01006622 if (x2 != ':' || x3 == -1 || (*p != NUL && *p != ','))
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006623 {
6624 errmsg = e_invarg;
6625 break;
6626 }
6627 if (*p == NUL)
6628 break;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006629 }
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006630 }
6631 else
6632#endif
6633 {
6634 /* Check for "x:y,x:y" */
6635 for (p = *varp; *p != NUL; p += 4)
6636 {
6637 if (p[1] != ':' || p[2] == NUL || (p[3] != NUL && p[3] != ','))
6638 {
6639 errmsg = e_invarg;
6640 break;
6641 }
6642 if (p[3] == NUL)
6643 break;
6644 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006645 }
6646 }
6647
6648#ifdef FEAT_COMMENTS
6649 /* 'comments' */
6650 else if (gvarp == &p_com)
6651 {
6652 for (s = *varp; *s; )
6653 {
6654 while (*s && *s != ':')
6655 {
6656 if (vim_strchr((char_u *)COM_ALL, *s) == NULL
6657 && !VIM_ISDIGIT(*s) && *s != '-')
6658 {
6659 errmsg = illegal_char(errbuf, *s);
6660 break;
6661 }
6662 ++s;
6663 }
6664 if (*s++ == NUL)
6665 errmsg = (char_u *)N_("E524: Missing colon");
6666 else if (*s == ',' || *s == NUL)
6667 errmsg = (char_u *)N_("E525: Zero length string");
6668 if (errmsg != NULL)
6669 break;
6670 while (*s && *s != ',')
6671 {
6672 if (*s == '\\' && s[1] != NUL)
6673 ++s;
6674 ++s;
6675 }
6676 s = skip_to_option_part(s);
6677 }
6678 }
6679#endif
6680
6681 /* 'listchars' */
6682 else if (varp == &p_lcs)
6683 {
6684 errmsg = set_chars_option(varp);
6685 }
6686
6687#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
6688 /* 'fillchars' */
6689 else if (varp == &p_fcs)
6690 {
6691 errmsg = set_chars_option(varp);
6692 }
6693#endif
6694
6695#ifdef FEAT_CMDWIN
6696 /* 'cedit' */
6697 else if (varp == &p_cedit)
6698 {
6699 errmsg = check_cedit();
6700 }
6701#endif
6702
Bram Moolenaar54ee7752005-05-31 22:22:17 +00006703 /* 'verbosefile' */
6704 else if (varp == &p_vfile)
6705 {
6706 verbose_stop();
6707 if (*p_vfile != NUL && verbose_open() == FAIL)
6708 errmsg = e_invarg;
6709 }
6710
Bram Moolenaar071d4272004-06-13 20:20:40 +00006711#ifdef FEAT_VIMINFO
6712 /* 'viminfo' */
6713 else if (varp == &p_viminfo)
6714 {
6715 for (s = p_viminfo; *s;)
6716 {
6717 /* Check it's a valid character */
6718 if (vim_strchr((char_u *)"!\"%'/:<@cfhnrs", *s) == NULL)
6719 {
6720 errmsg = illegal_char(errbuf, *s);
6721 break;
6722 }
6723 if (*s == 'n') /* name is always last one */
6724 {
6725 break;
6726 }
6727 else if (*s == 'r') /* skip until next ',' */
6728 {
6729 while (*++s && *s != ',')
6730 ;
6731 }
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +00006732 else if (*s == '%')
6733 {
6734 /* optional number */
6735 while (vim_isdigit(*++s))
6736 ;
6737 }
6738 else if (*s == '!' || *s == 'h' || *s == 'c')
Bram Moolenaar071d4272004-06-13 20:20:40 +00006739 ++s; /* no extra chars */
6740 else /* must have a number */
6741 {
6742 while (vim_isdigit(*++s))
6743 ;
6744
6745 if (!VIM_ISDIGIT(*(s - 1)))
6746 {
6747 if (errbuf != NULL)
6748 {
Bram Moolenaar8f999f12005-01-25 22:12:55 +00006749 sprintf((char *)errbuf,
6750 _("E526: Missing number after <%s>"),
Bram Moolenaar071d4272004-06-13 20:20:40 +00006751 transchar_byte(*(s - 1)));
6752 errmsg = errbuf;
6753 }
6754 else
6755 errmsg = (char_u *)"";
6756 break;
6757 }
6758 }
6759 if (*s == ',')
6760 ++s;
6761 else if (*s)
6762 {
6763 if (errbuf != NULL)
6764 errmsg = (char_u *)N_("E527: Missing comma");
6765 else
6766 errmsg = (char_u *)"";
6767 break;
6768 }
6769 }
6770 if (*p_viminfo && errmsg == NULL && get_viminfo_parameter('\'') < 0)
6771 errmsg = (char_u *)N_("E528: Must specify a ' value");
6772 }
6773#endif /* FEAT_VIMINFO */
6774
6775 /* terminal options */
6776 else if (istermoption(&options[opt_idx]) && full_screen)
6777 {
6778 /* ":set t_Co=0" and ":set t_Co=1" do ":set t_Co=" */
6779 if (varp == &T_CCO)
6780 {
Bram Moolenaarc84e8952009-03-18 13:21:18 +00006781 int colors = atoi((char *)T_CCO);
6782
6783 /* Only reinitialize colors if t_Co value has really changed to
6784 * avoid expensive reload of colorscheme if t_Co is set to the
6785 * same value multiple times. */
6786 if (colors != t_colors)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006787 {
Bram Moolenaarc84e8952009-03-18 13:21:18 +00006788 t_colors = colors;
6789 if (t_colors <= 1)
6790 {
6791 if (new_value_alloced)
6792 vim_free(T_CCO);
6793 T_CCO = empty_option;
6794 }
6795 /* We now have a different color setup, initialize it again. */
6796 init_highlight(TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006797 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006798 }
6799 ttest(FALSE);
6800 if (varp == &T_ME)
6801 {
6802 out_str(T_ME);
6803 redraw_later(CLEAR);
Bram Moolenaar48e330a2016-02-23 14:53:34 +01006804#if defined(WIN3264) && !defined(FEAT_GUI_W32)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006805 /* Since t_me has been set, this probably means that the user
6806 * wants to use this as default colors. Need to reset default
6807 * background/foreground colors. */
6808 mch_set_normal_colors();
6809#endif
6810 }
Bram Moolenaard9c60642017-01-27 20:03:18 +01006811 if (varp == &T_BE && termcap_active)
6812 {
6813 if (*T_BE == NUL)
6814 /* When clearing t_BE we assume the user no longer wants
6815 * bracketed paste, thus disable it by writing t_BD. */
6816 out_str(T_BD);
6817 else
6818 out_str(T_BE);
6819 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006820 }
6821
6822#ifdef FEAT_LINEBREAK
6823 /* 'showbreak' */
6824 else if (varp == &p_sbr)
6825 {
6826 for (s = p_sbr; *s; )
6827 {
6828 if (ptr2cells(s) != 1)
6829 errmsg = (char_u *)N_("E595: contains unprintable or wide character");
Bram Moolenaar91acfff2017-03-12 19:22:36 +01006830 MB_PTR_ADV(s);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006831 }
6832 }
6833#endif
6834
6835#ifdef FEAT_GUI
6836 /* 'guifont' */
6837 else if (varp == &p_guifont)
6838 {
6839 if (gui.in_use)
6840 {
6841 p = p_guifont;
Bram Moolenaar9372a112005-12-06 19:59:18 +00006842# if defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006843 /*
6844 * Put up a font dialog and let the user select a new value.
6845 * If this is cancelled go back to the old value but don't
6846 * give an error message.
6847 */
6848 if (STRCMP(p, "*") == 0)
6849 {
6850 p = gui_mch_font_dialog(oldval);
6851
6852 if (new_value_alloced)
6853 free_string_option(p_guifont);
6854
6855 p_guifont = (p != NULL) ? p : vim_strsave(oldval);
6856 new_value_alloced = TRUE;
6857 }
6858# endif
6859 if (p != NULL && gui_init_font(p_guifont, FALSE) != OK)
6860 {
6861# if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_PHOTON)
6862 if (STRCMP(p_guifont, "*") == 0)
6863 {
6864 /* Dialog was cancelled: Keep the old value without giving
6865 * an error message. */
6866 if (new_value_alloced)
6867 free_string_option(p_guifont);
6868 p_guifont = vim_strsave(oldval);
6869 new_value_alloced = TRUE;
6870 }
6871 else
6872# endif
6873 errmsg = (char_u *)N_("E596: Invalid font(s)");
6874 }
6875 }
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006876 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006877 }
6878# ifdef FEAT_XFONTSET
6879 else if (varp == &p_guifontset)
6880 {
6881 if (STRCMP(p_guifontset, "*") == 0)
6882 errmsg = (char_u *)N_("E597: can't select fontset");
6883 else if (gui.in_use && gui_init_font(p_guifontset, TRUE) != OK)
6884 errmsg = (char_u *)N_("E598: Invalid fontset");
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006885 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006886 }
6887# endif
6888# ifdef FEAT_MBYTE
6889 else if (varp == &p_guifontwide)
6890 {
6891 if (STRCMP(p_guifontwide, "*") == 0)
6892 errmsg = (char_u *)N_("E533: can't select wide font");
6893 else if (gui_get_wide_font() == FAIL)
6894 errmsg = (char_u *)N_("E534: Invalid wide font");
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006895 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006896 }
6897# endif
6898#endif
6899
6900#ifdef CURSOR_SHAPE
6901 /* 'guicursor' */
6902 else if (varp == &p_guicursor)
6903 errmsg = parse_shape_opt(SHAPE_CURSOR);
6904#endif
6905
6906#ifdef FEAT_MOUSESHAPE
6907 /* 'mouseshape' */
6908 else if (varp == &p_mouseshape)
6909 {
6910 errmsg = parse_shape_opt(SHAPE_MOUSE);
6911 update_mouseshape(-1);
6912 }
6913#endif
6914
6915#ifdef FEAT_PRINTER
6916 else if (varp == &p_popt)
Bram Moolenaar58d98232005-07-23 22:25:46 +00006917 errmsg = parse_printoptions();
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00006918# if defined(FEAT_MBYTE) && defined(FEAT_POSTSCRIPT)
Bram Moolenaar8299df92004-07-10 09:47:34 +00006919 else if (varp == &p_pmfn)
Bram Moolenaar58d98232005-07-23 22:25:46 +00006920 errmsg = parse_printmbfont();
Bram Moolenaar8299df92004-07-10 09:47:34 +00006921# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006922#endif
6923
6924#ifdef FEAT_LANGMAP
6925 /* 'langmap' */
6926 else if (varp == &p_langmap)
6927 langmap_set();
6928#endif
6929
6930#ifdef FEAT_LINEBREAK
6931 /* 'breakat' */
6932 else if (varp == &p_breakat)
6933 fill_breakat_flags();
6934#endif
6935
6936#ifdef FEAT_TITLE
6937 /* 'titlestring' and 'iconstring' */
6938 else if (varp == &p_titlestring || varp == &p_iconstring)
6939 {
6940# ifdef FEAT_STL_OPT
6941 int flagval = (varp == &p_titlestring) ? STL_IN_TITLE : STL_IN_ICON;
6942
6943 /* NULL => statusline syntax */
6944 if (vim_strchr(*varp, '%') && check_stl_option(*varp) == NULL)
6945 stl_syntax |= flagval;
6946 else
6947 stl_syntax &= ~flagval;
6948# endif
6949 did_set_title(varp == &p_iconstring);
6950
6951 }
6952#endif
6953
6954#ifdef FEAT_GUI
6955 /* 'guioptions' */
6956 else if (varp == &p_go)
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006957 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00006958 gui_init_which_components(oldval);
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006959 redraw_gui_only = TRUE;
6960 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006961#endif
6962
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00006963#if defined(FEAT_GUI_TABLINE)
6964 /* 'guitablabel' */
6965 else if (varp == &p_gtl)
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006966 {
Bram Moolenaar18144c82006-04-12 21:52:12 +00006967 redraw_tabline = TRUE;
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006968 redraw_gui_only = TRUE;
6969 }
6970 /* 'guitabtooltip' */
6971 else if (varp == &p_gtt)
6972 {
6973 redraw_gui_only = TRUE;
6974 }
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00006975#endif
6976
Bram Moolenaar071d4272004-06-13 20:20:40 +00006977#if defined(FEAT_MOUSE_TTY) && (defined(UNIX) || defined(VMS))
6978 /* 'ttymouse' */
6979 else if (varp == &p_ttym)
6980 {
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00006981 /* Switch the mouse off before changing the escape sequences used for
6982 * that. */
6983 mch_setmouse(FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006984 if (opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE) != OK)
6985 errmsg = e_invarg;
6986 else
6987 check_mouse_termcode();
Bram Moolenaar6bb68362005-03-22 23:03:44 +00006988 if (termcap_active)
6989 setmouse(); /* may switch it on again */
Bram Moolenaar071d4272004-06-13 20:20:40 +00006990 }
6991#endif
6992
Bram Moolenaar071d4272004-06-13 20:20:40 +00006993 /* 'selection' */
6994 else if (varp == &p_sel)
6995 {
6996 if (*p_sel == NUL
6997 || check_opt_strings(p_sel, p_sel_values, FALSE) != OK)
6998 errmsg = e_invarg;
6999 }
7000
7001 /* 'selectmode' */
7002 else if (varp == &p_slm)
7003 {
7004 if (check_opt_strings(p_slm, p_slm_values, TRUE) != OK)
7005 errmsg = e_invarg;
7006 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007007
7008#ifdef FEAT_BROWSE
7009 /* 'browsedir' */
7010 else if (varp == &p_bsdir)
7011 {
7012 if (check_opt_strings(p_bsdir, p_bsdir_values, FALSE) != OK
7013 && !mch_isdir(p_bsdir))
7014 errmsg = e_invarg;
7015 }
7016#endif
7017
Bram Moolenaar071d4272004-06-13 20:20:40 +00007018 /* 'keymodel' */
7019 else if (varp == &p_km)
7020 {
7021 if (check_opt_strings(p_km, p_km_values, TRUE) != OK)
7022 errmsg = e_invarg;
7023 else
7024 {
7025 km_stopsel = (vim_strchr(p_km, 'o') != NULL);
7026 km_startsel = (vim_strchr(p_km, 'a') != NULL);
7027 }
7028 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007029
7030 /* 'mousemodel' */
7031 else if (varp == &p_mousem)
7032 {
7033 if (check_opt_strings(p_mousem, p_mousem_values, FALSE) != OK)
7034 errmsg = e_invarg;
7035#if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU) && (XmVersion <= 1002)
7036 else if (*p_mousem != *oldval)
7037 /* Changed from "extend" to "popup" or "popup_setpos" or vv: need
7038 * to create or delete the popup menus. */
7039 gui_motif_update_mousemodel(root_menu);
7040#endif
7041 }
7042
7043 /* 'switchbuf' */
7044 else if (varp == &p_swb)
7045 {
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00007046 if (opt_strings_flags(p_swb, p_swb_values, &swb_flags, TRUE) != OK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007047 errmsg = e_invarg;
7048 }
7049
7050 /* 'debug' */
7051 else if (varp == &p_debug)
7052 {
Bram Moolenaar57657d82006-04-21 22:12:41 +00007053 if (check_opt_strings(p_debug, p_debug_values, TRUE) != OK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007054 errmsg = e_invarg;
7055 }
7056
7057 /* 'display' */
7058 else if (varp == &p_dy)
7059 {
7060 if (opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE) != OK)
7061 errmsg = e_invarg;
7062 else
7063 (void)init_chartab();
7064
7065 }
7066
Bram Moolenaar44a2f922016-03-19 22:11:51 +01007067#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00007068 /* 'eadirection' */
7069 else if (varp == &p_ead)
7070 {
7071 if (check_opt_strings(p_ead, p_ead_values, FALSE) != OK)
7072 errmsg = e_invarg;
7073 }
7074#endif
7075
7076#ifdef FEAT_CLIPBOARD
7077 /* 'clipboard' */
7078 else if (varp == &p_cb)
7079 errmsg = check_clipboard_option();
7080#endif
7081
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007082#ifdef FEAT_SPELL
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00007083 /* When 'spelllang' or 'spellfile' is set and there is a window for this
7084 * buffer in which 'spell' is set load the wordlists. */
Bram Moolenaar2683c8e2014-11-19 19:33:16 +01007085 else if (varp == &(curwin->w_s->b_p_spl)
7086 || varp == &(curwin->w_s->b_p_spf))
Bram Moolenaar217ad922005-03-20 22:37:15 +00007087 {
Bram Moolenaare68c25c2015-08-25 15:39:55 +02007088 errmsg = did_set_spell_option(varp == &(curwin->w_s->b_p_spf));
Bram Moolenaar217ad922005-03-20 22:37:15 +00007089 }
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007090 /* When 'spellcapcheck' is set compile the regexp program. */
Bram Moolenaar860cae12010-06-05 23:22:07 +02007091 else if (varp == &(curwin->w_s->b_p_spc))
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007092 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007093 errmsg = compile_cap_prog(curwin->w_s);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007094 }
Bram Moolenaard857f0e2005-06-21 22:37:39 +00007095 /* 'spellsuggest' */
7096 else if (varp == &p_sps)
7097 {
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00007098 if (spell_check_sps() != OK)
Bram Moolenaard857f0e2005-06-21 22:37:39 +00007099 errmsg = e_invarg;
7100 }
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00007101 /* 'mkspellmem' */
7102 else if (varp == &p_msm)
7103 {
7104 if (spell_check_msm() != OK)
7105 errmsg = e_invarg;
7106 }
Bram Moolenaar217ad922005-03-20 22:37:15 +00007107#endif
7108
Bram Moolenaar071d4272004-06-13 20:20:40 +00007109#ifdef FEAT_QUICKFIX
7110 /* When 'bufhidden' is set, check for valid value. */
7111 else if (gvarp == &p_bh)
7112 {
7113 if (check_opt_strings(curbuf->b_p_bh, p_bufhidden_values, FALSE) != OK)
7114 errmsg = e_invarg;
7115 }
7116
7117 /* When 'buftype' is set, check for valid value. */
7118 else if (gvarp == &p_bt)
7119 {
7120 if (check_opt_strings(curbuf->b_p_bt, p_buftype_values, FALSE) != OK)
7121 errmsg = e_invarg;
7122 else
7123 {
7124# ifdef FEAT_WINDOWS
7125 if (curwin->w_status_height)
7126 {
7127 curwin->w_redr_status = TRUE;
7128 redraw_later(VALID);
7129 }
7130# endif
7131 curbuf->b_help = (curbuf->b_p_bt[0] == 'h');
Bram Moolenaar5075aad2010-01-27 15:58:13 +01007132# ifdef FEAT_TITLE
7133 redraw_titles();
7134# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007135 }
7136 }
7137#endif
7138
7139#ifdef FEAT_STL_OPT
7140 /* 'statusline' or 'rulerformat' */
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00007141 else if (gvarp == &p_stl || varp == &p_ruf)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007142 {
7143 int wid;
7144
7145 if (varp == &p_ruf) /* reset ru_wid first */
7146 ru_wid = 0;
7147 s = *varp;
7148 if (varp == &p_ruf && *s == '%')
7149 {
7150 /* set ru_wid if 'ruf' starts with "%99(" */
7151 if (*++s == '-') /* ignore a '-' */
7152 s++;
7153 wid = getdigits(&s);
7154 if (wid && *s == '(' && (errmsg = check_stl_option(p_ruf)) == NULL)
7155 ru_wid = wid;
7156 else
7157 errmsg = check_stl_option(p_ruf);
7158 }
Bram Moolenaar3709e7c2006-08-08 14:29:16 +00007159 /* check 'statusline' only if it doesn't start with "%!" */
Bram Moolenaar177d8c62007-09-06 11:33:37 +00007160 else if (varp == &p_ruf || s[0] != '%' || s[1] != '!')
Bram Moolenaar071d4272004-06-13 20:20:40 +00007161 errmsg = check_stl_option(s);
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00007162 if (varp == &p_ruf && errmsg == NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007163 comp_col();
7164 }
7165#endif
7166
7167#ifdef FEAT_INS_EXPAND
7168 /* check if it is a valid value for 'complete' -- Acevedo */
7169 else if (gvarp == &p_cpt)
7170 {
7171 for (s = *varp; *s;)
7172 {
Bram Moolenaar11b73d62012-06-29 15:51:30 +02007173 while (*s == ',' || *s == ' ')
Bram Moolenaar071d4272004-06-13 20:20:40 +00007174 s++;
7175 if (!*s)
7176 break;
7177 if (vim_strchr((char_u *)".wbuksid]tU", *s) == NULL)
7178 {
7179 errmsg = illegal_char(errbuf, *s);
7180 break;
7181 }
7182 if (*++s != NUL && *s != ',' && *s != ' ')
7183 {
7184 if (s[-1] == 'k' || s[-1] == 's')
7185 {
7186 /* skip optional filename after 'k' and 's' */
7187 while (*s && *s != ',' && *s != ' ')
7188 {
Bram Moolenaar226c5342017-02-17 14:53:15 +01007189 if (*s == '\\' && s[1] != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007190 ++s;
7191 ++s;
7192 }
7193 }
7194 else
7195 {
7196 if (errbuf != NULL)
7197 {
7198 sprintf((char *)errbuf,
7199 _("E535: Illegal character after <%c>"),
7200 *--s);
7201 errmsg = errbuf;
7202 }
7203 else
7204 errmsg = (char_u *)"";
7205 break;
7206 }
7207 }
7208 }
7209 }
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00007210
7211 /* 'completeopt' */
7212 else if (varp == &p_cot)
7213 {
7214 if (check_opt_strings(p_cot, p_cot_values, TRUE) != OK)
7215 errmsg = e_invarg;
Bram Moolenaarc0200422016-04-20 12:02:02 +02007216 else
7217 completeopt_was_set();
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00007218 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007219#endif /* FEAT_INS_EXPAND */
7220
Bram Moolenaar95ec9d62016-08-12 18:29:59 +02007221#ifdef FEAT_SIGNS
7222 /* 'signcolumn' */
7223 else if (varp == &curwin->w_p_scl)
7224 {
7225 if (check_opt_strings(*varp, p_scl_values, FALSE) != OK)
7226 errmsg = e_invarg;
7227 }
7228#endif
7229
Bram Moolenaar071d4272004-06-13 20:20:40 +00007230
7231#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
Bram Moolenaar031cb742016-11-24 21:46:19 +01007232 /* 'toolbar' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007233 else if (varp == &p_toolbar)
7234 {
7235 if (opt_strings_flags(p_toolbar, p_toolbar_values,
7236 &toolbar_flags, TRUE) != OK)
7237 errmsg = e_invarg;
7238 else
7239 {
7240 out_flush();
7241 gui_mch_show_toolbar((toolbar_flags &
7242 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
7243 }
7244 }
7245#endif
7246
Bram Moolenaar182c5be2010-06-25 05:37:59 +02007247#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007248 /* 'toolbariconsize': GTK+ 2 only */
7249 else if (varp == &p_tbis)
7250 {
7251 if (opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE) != OK)
7252 errmsg = e_invarg;
7253 else
7254 {
7255 out_flush();
7256 gui_mch_show_toolbar((toolbar_flags &
7257 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
7258 }
7259 }
7260#endif
7261
7262 /* 'pastetoggle': translate key codes like in a mapping */
7263 else if (varp == &p_pt)
7264 {
7265 if (*p_pt)
7266 {
Bram Moolenaar9c102382006-05-03 21:26:49 +00007267 (void)replace_termcodes(p_pt, &p, TRUE, TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007268 if (p != NULL)
7269 {
7270 if (new_value_alloced)
7271 free_string_option(p_pt);
7272 p_pt = p;
7273 new_value_alloced = TRUE;
7274 }
7275 }
7276 }
7277
7278 /* 'backspace' */
7279 else if (varp == &p_bs)
7280 {
7281 if (VIM_ISDIGIT(*p_bs))
7282 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01007283 if (*p_bs > '2' || p_bs[1] != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007284 errmsg = e_invarg;
7285 }
7286 else if (check_opt_strings(p_bs, p_bs_values, TRUE) != OK)
7287 errmsg = e_invarg;
7288 }
Bram Moolenaar165bc692015-07-21 17:53:25 +02007289 else if (varp == &p_bo)
7290 {
7291 if (opt_strings_flags(p_bo, p_bo_values, &bo_flags, TRUE) != OK)
7292 errmsg = e_invarg;
7293 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007294
Bram Moolenaar0f6562e2015-11-24 18:48:14 +01007295 /* 'tagcase' */
7296 else if (gvarp == &p_tc)
7297 {
7298 unsigned int *flags;
7299
7300 if (opt_flags & OPT_LOCAL)
7301 {
7302 p = curbuf->b_p_tc;
7303 flags = &curbuf->b_tc_flags;
7304 }
7305 else
7306 {
7307 p = p_tc;
7308 flags = &tc_flags;
7309 }
7310
7311 if ((opt_flags & OPT_LOCAL) && *p == NUL)
7312 /* make the local value empty: use the global value */
7313 *flags = 0;
7314 else if (*p == NUL
7315 || opt_strings_flags(p, p_tc_values, flags, FALSE) != OK)
7316 errmsg = e_invarg;
7317 }
7318
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00007319#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +00007320 /* 'casemap' */
7321 else if (varp == &p_cmp)
7322 {
7323 if (opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE) != OK)
7324 errmsg = e_invarg;
7325 }
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00007326#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007327
7328#ifdef FEAT_DIFF
7329 /* 'diffopt' */
7330 else if (varp == &p_dip)
7331 {
7332 if (diffopt_changed() == FAIL)
7333 errmsg = e_invarg;
7334 }
7335#endif
7336
7337#ifdef FEAT_FOLDING
7338 /* 'foldmethod' */
7339 else if (gvarp == &curwin->w_allbuf_opt.wo_fdm)
7340 {
7341 if (check_opt_strings(*varp, p_fdm_values, FALSE) != OK
7342 || *curwin->w_p_fdm == NUL)
7343 errmsg = e_invarg;
7344 else
Bram Moolenaarf4d7f942010-02-24 14:34:19 +01007345 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00007346 foldUpdateAll(curwin);
Bram Moolenaarf4d7f942010-02-24 14:34:19 +01007347 if (foldmethodIsDiff(curwin))
7348 newFoldLevel();
7349 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007350 }
7351# ifdef FEAT_EVAL
7352 /* 'foldexpr' */
7353 else if (varp == &curwin->w_p_fde)
7354 {
7355 if (foldmethodIsExpr(curwin))
7356 foldUpdateAll(curwin);
7357 }
7358# endif
7359 /* 'foldmarker' */
7360 else if (gvarp == &curwin->w_allbuf_opt.wo_fmr)
7361 {
7362 p = vim_strchr(*varp, ',');
7363 if (p == NULL)
7364 errmsg = (char_u *)N_("E536: comma required");
7365 else if (p == *varp || p[1] == NUL)
7366 errmsg = e_invarg;
7367 else if (foldmethodIsMarker(curwin))
7368 foldUpdateAll(curwin);
7369 }
7370 /* 'commentstring' */
7371 else if (gvarp == &p_cms)
7372 {
7373 if (**varp != NUL && strstr((char *)*varp, "%s") == NULL)
7374 errmsg = (char_u *)N_("E537: 'commentstring' must be empty or contain %s");
7375 }
7376 /* 'foldopen' */
7377 else if (varp == &p_fdo)
7378 {
7379 if (opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE) != OK)
7380 errmsg = e_invarg;
7381 }
7382 /* 'foldclose' */
7383 else if (varp == &p_fcl)
7384 {
7385 if (check_opt_strings(p_fcl, p_fcl_values, TRUE) != OK)
7386 errmsg = e_invarg;
7387 }
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00007388 /* 'foldignore' */
7389 else if (gvarp == &curwin->w_allbuf_opt.wo_fdi)
7390 {
7391 if (foldmethodIsIndent(curwin))
7392 foldUpdateAll(curwin);
7393 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007394#endif
7395
7396#ifdef FEAT_VIRTUALEDIT
7397 /* 'virtualedit' */
7398 else if (varp == &p_ve)
7399 {
7400 if (opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE) != OK)
7401 errmsg = e_invarg;
7402 else if (STRCMP(p_ve, oldval) != 0)
7403 {
7404 /* Recompute cursor position in case the new 've' setting
7405 * changes something. */
7406 validate_virtcol();
7407 coladvance(curwin->w_virtcol);
7408 }
7409 }
7410#endif
7411
7412#if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX)
7413 else if (varp == &p_csqf)
7414 {
7415 if (p_csqf != NULL)
7416 {
7417 p = p_csqf;
7418 while (*p != NUL)
7419 {
7420 if (vim_strchr((char_u *)CSQF_CMDS, *p) == NULL
7421 || p[1] == NUL
7422 || vim_strchr((char_u *)CSQF_FLAGS, p[1]) == NULL
7423 || (p[2] != NUL && p[2] != ','))
7424 {
7425 errmsg = e_invarg;
7426 break;
7427 }
7428 else if (p[2] == NUL)
7429 break;
7430 else
7431 p += 3;
7432 }
7433 }
7434 }
7435#endif
7436
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01007437#ifdef FEAT_CINDENT
7438 /* 'cinoptions' */
7439 else if (gvarp == &p_cino)
7440 {
7441 /* TODO: recognize errors */
7442 parse_cino(curbuf);
7443 }
7444#endif
7445
Bram Moolenaarb5a7a8b2014-08-06 14:52:30 +02007446#if defined(FEAT_RENDER_OPTIONS)
Bram Moolenaar031cb742016-11-24 21:46:19 +01007447 /* 'renderoptions' */
Bram Moolenaarb5a7a8b2014-08-06 14:52:30 +02007448 else if (varp == &p_rop && gui.in_use)
7449 {
7450 if (!gui_mch_set_rendering_options(p_rop))
7451 errmsg = e_invarg;
7452 }
7453#endif
7454
Bram Moolenaard0b51382016-11-04 15:23:45 +01007455#ifdef FEAT_AUTOCMD
7456 else if (gvarp == &p_ft)
7457 {
7458 if (!valid_filetype(*varp))
7459 errmsg = e_invarg;
Bram Moolenaar90492982017-06-22 14:16:31 +02007460 else
7461 ft_changed = STRCMP(oldval, *varp) != 0;
Bram Moolenaard0b51382016-11-04 15:23:45 +01007462 }
7463#endif
7464
7465#ifdef FEAT_SYN_HL
7466 else if (gvarp == &p_syn)
7467 {
7468 if (!valid_filetype(*varp))
7469 errmsg = e_invarg;
7470 }
7471#endif
7472
Bram Moolenaar071d4272004-06-13 20:20:40 +00007473 /* Options that are a list of flags. */
7474 else
7475 {
7476 p = NULL;
Bram Moolenaar031cb742016-11-24 21:46:19 +01007477 if (varp == &p_ww) /* 'whichwrap' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007478 p = (char_u *)WW_ALL;
Bram Moolenaar031cb742016-11-24 21:46:19 +01007479 if (varp == &p_shm) /* 'shortmess' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007480 p = (char_u *)SHM_ALL;
Bram Moolenaar031cb742016-11-24 21:46:19 +01007481 else if (varp == &(p_cpo)) /* 'cpoptions' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007482 p = (char_u *)CPO_ALL;
Bram Moolenaar031cb742016-11-24 21:46:19 +01007483 else if (varp == &(curbuf->b_p_fo)) /* 'formatoptions' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007484 p = (char_u *)FO_ALL;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02007485#ifdef FEAT_CONCEAL
Bram Moolenaar031cb742016-11-24 21:46:19 +01007486 else if (varp == &curwin->w_p_cocu) /* 'concealcursor' */
Bram Moolenaarf5963f72010-07-23 22:10:27 +02007487 p = (char_u *)COCU_ALL;
7488#endif
Bram Moolenaar031cb742016-11-24 21:46:19 +01007489 else if (varp == &p_mouse) /* 'mouse' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007490 {
7491#ifdef FEAT_MOUSE
7492 p = (char_u *)MOUSE_ALL;
7493#else
7494 if (*p_mouse != NUL)
7495 errmsg = (char_u *)N_("E538: No mouse support");
7496#endif
7497 }
7498#if defined(FEAT_GUI)
Bram Moolenaar031cb742016-11-24 21:46:19 +01007499 else if (varp == &p_go) /* 'guioptions' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007500 p = (char_u *)GO_ALL;
7501#endif
7502 if (p != NULL)
7503 {
7504 for (s = *varp; *s; ++s)
7505 if (vim_strchr(p, *s) == NULL)
7506 {
7507 errmsg = illegal_char(errbuf, *s);
7508 break;
7509 }
7510 }
7511 }
7512
7513 /*
7514 * If error detected, restore the previous value.
7515 */
7516 if (errmsg != NULL)
7517 {
7518 if (new_value_alloced)
7519 free_string_option(*varp);
7520 *varp = oldval;
7521 /*
7522 * When resetting some values, need to act on it.
7523 */
7524 if (did_chartab)
7525 (void)init_chartab();
7526 if (varp == &p_hl)
7527 (void)highlight_changed();
7528 }
7529 else
7530 {
7531#ifdef FEAT_EVAL
7532 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007533 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007534#endif
7535 /*
7536 * Free string options that are in allocated memory.
Bram Moolenaarc0197e22004-09-13 20:26:32 +00007537 * Use "free_oldval", because recursiveness may change the flags under
7538 * our fingers (esp. init_highlight()).
Bram Moolenaar071d4272004-06-13 20:20:40 +00007539 */
Bram Moolenaarc0197e22004-09-13 20:26:32 +00007540 if (free_oldval)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007541 free_string_option(oldval);
7542 if (new_value_alloced)
7543 options[opt_idx].flags |= P_ALLOCED;
7544 else
7545 options[opt_idx].flags &= ~P_ALLOCED;
7546
7547 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00007548 && ((int)options[opt_idx].indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007549 {
7550 /* global option with local value set to use global value; free
7551 * the local value and make it empty */
7552 p = get_varp_scope(&(options[opt_idx]), OPT_LOCAL);
7553 free_string_option(*(char_u **)p);
7554 *(char_u **)p = empty_option;
7555 }
7556
7557 /* May set global value for local option. */
7558 else if (!(opt_flags & OPT_LOCAL) && opt_flags != OPT_GLOBAL)
7559 set_string_option_global(opt_idx, varp);
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007560
7561#ifdef FEAT_AUTOCMD
7562 /*
7563 * Trigger the autocommand only after setting the flags.
7564 */
7565# ifdef FEAT_SYN_HL
7566 /* When 'syntax' is set, load the syntax of that name */
7567 if (varp == &(curbuf->b_p_syn))
7568 {
7569 apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn,
7570 curbuf->b_fname, TRUE, curbuf);
7571 }
7572# endif
7573 else if (varp == &(curbuf->b_p_ft))
7574 {
Bram Moolenaar90492982017-06-22 14:16:31 +02007575 /* 'filetype' is set, trigger the FileType autocommand.
7576 * Skip this when called from a modeline and the filetype was
7577 * already set to this value. */
7578 if (!(opt_flags & OPT_MODELINE) || ft_changed)
7579 {
7580 did_filetype = TRUE;
7581 apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft,
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007582 curbuf->b_fname, TRUE, curbuf);
Bram Moolenaar163095f2017-07-09 15:41:53 +02007583 /* Just in case the old "curbuf" is now invalid. */
7584 if (varp != &(curbuf->b_p_ft))
7585 varp = NULL;
Bram Moolenaar90492982017-06-22 14:16:31 +02007586 }
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007587 }
7588#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007589#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02007590 if (varp == &(curwin->w_s->b_p_spl))
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007591 {
7592 char_u fname[200];
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007593 char_u *q = curwin->w_s->b_p_spl;
7594
7595 /* Skip the first name if it is "cjk". */
7596 if (STRNCMP(q, "cjk,", 4) == 0)
7597 q += 4;
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007598
7599 /*
7600 * Source the spell/LANG.vim in 'runtimepath'.
7601 * They could set 'spellcapcheck' depending on the language.
7602 * Use the first name in 'spelllang' up to '_region' or
7603 * '.encoding'.
7604 */
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007605 for (p = q; *p != NUL; ++p)
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007606 if (vim_strchr((char_u *)"_.,", *p) != NULL)
7607 break;
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007608 vim_snprintf((char *)fname, 200, "spell/%.*s.vim", (int)(p - q), q);
Bram Moolenaar7f8989d2016-03-12 22:11:39 +01007609 source_runtime(fname, DIP_ALL);
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007610 }
7611#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007612 }
7613
7614#ifdef FEAT_MOUSE
7615 if (varp == &p_mouse)
7616 {
7617# ifdef FEAT_MOUSE_TTY
7618 if (*p_mouse == NUL)
7619 mch_setmouse(FALSE); /* switch mouse off */
7620 else
7621# endif
7622 setmouse(); /* in case 'mouse' changed */
7623 }
7624#endif
7625
Bram Moolenaar913077c2012-03-28 19:59:04 +02007626 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01007627 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02007628 curwin->w_set_curswant = TRUE;
7629
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00007630#ifdef FEAT_GUI
7631 /* check redraw when it's not a GUI option or the GUI is active. */
7632 if (!redraw_gui_only || gui.in_use)
7633#endif
7634 check_redraw(options[opt_idx].flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007635
7636 return errmsg;
7637}
7638
Bram Moolenaarf4e5e862013-02-13 15:44:26 +01007639#if defined(FEAT_SYN_HL) || defined(PROTO)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007640/*
7641 * Simple int comparison function for use with qsort()
7642 */
7643 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01007644int_cmp(const void *a, const void *b)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007645{
7646 return *(const int *)a - *(const int *)b;
7647}
7648
7649/*
7650 * Handle setting 'colorcolumn' or 'textwidth' in window "wp".
7651 * Returns error message, NULL if it's OK.
7652 */
7653 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007654check_colorcolumn(win_T *wp)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007655{
7656 char_u *s;
7657 int col;
7658 int count = 0;
7659 int color_cols[256];
7660 int i;
7661 int j = 0;
7662
Bram Moolenaar50f834d2011-09-21 13:40:17 +02007663 if (wp->w_buffer == NULL)
7664 return NULL; /* buffer was closed */
7665
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007666 for (s = wp->w_p_cc; *s != NUL && count < 255;)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007667 {
7668 if (*s == '-' || *s == '+')
7669 {
7670 /* -N and +N: add to 'textwidth' */
7671 col = (*s == '-') ? -1 : 1;
7672 ++s;
7673 if (!VIM_ISDIGIT(*s))
7674 return e_invarg;
7675 col = col * getdigits(&s);
7676 if (wp->w_buffer->b_p_tw == 0)
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007677 goto skip; /* 'textwidth' not set, skip this item */
Bram Moolenaar1a384422010-07-14 19:53:30 +02007678 col += wp->w_buffer->b_p_tw;
7679 if (col < 0)
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007680 goto skip;
Bram Moolenaar1a384422010-07-14 19:53:30 +02007681 }
7682 else if (VIM_ISDIGIT(*s))
7683 col = getdigits(&s);
7684 else
7685 return e_invarg;
7686 color_cols[count++] = col - 1; /* 1-based to 0-based */
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007687skip:
Bram Moolenaar1a384422010-07-14 19:53:30 +02007688 if (*s == NUL)
7689 break;
7690 if (*s != ',')
7691 return e_invarg;
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007692 if (*++s == NUL)
7693 return e_invarg; /* illegal trailing comma as in "set cc=80," */
Bram Moolenaar1a384422010-07-14 19:53:30 +02007694 }
7695
7696 vim_free(wp->w_p_cc_cols);
7697 if (count == 0)
7698 wp->w_p_cc_cols = NULL;
7699 else
7700 {
7701 wp->w_p_cc_cols = (int *)alloc((unsigned)sizeof(int) * (count + 1));
7702 if (wp->w_p_cc_cols != NULL)
7703 {
7704 /* sort the columns for faster usage on screen redraw inside
7705 * win_line() */
7706 qsort(color_cols, count, sizeof(int), int_cmp);
7707
7708 for (i = 0; i < count; ++i)
7709 /* skip duplicates */
7710 if (j == 0 || wp->w_p_cc_cols[j - 1] != color_cols[i])
7711 wp->w_p_cc_cols[j++] = color_cols[i];
7712 wp->w_p_cc_cols[j] = -1; /* end marker */
7713 }
7714 }
7715
7716 return NULL; /* no error */
7717}
7718#endif
7719
Bram Moolenaar071d4272004-06-13 20:20:40 +00007720/*
7721 * Handle setting 'listchars' or 'fillchars'.
7722 * Returns error message, NULL if it's OK.
7723 */
7724 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007725set_chars_option(char_u **varp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007726{
7727 int round, i, len, entries;
7728 char_u *p, *s;
7729 int c1, c2 = 0;
7730 struct charstab
7731 {
7732 int *cp;
7733 char *name;
7734 };
7735#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7736 static struct charstab filltab[] =
7737 {
7738 {&fill_stl, "stl"},
7739 {&fill_stlnc, "stlnc"},
7740 {&fill_vert, "vert"},
7741 {&fill_fold, "fold"},
7742 {&fill_diff, "diff"},
7743 };
7744#endif
7745 static struct charstab lcstab[] =
7746 {
7747 {&lcs_eol, "eol"},
7748 {&lcs_ext, "extends"},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00007749 {&lcs_nbsp, "nbsp"},
Bram Moolenaar071d4272004-06-13 20:20:40 +00007750 {&lcs_prec, "precedes"},
Bram Moolenaar4c6b3b22015-04-21 19:10:48 +02007751 {&lcs_space, "space"},
Bram Moolenaar071d4272004-06-13 20:20:40 +00007752 {&lcs_tab2, "tab"},
7753 {&lcs_trail, "trail"},
Bram Moolenaar860cae12010-06-05 23:22:07 +02007754#ifdef FEAT_CONCEAL
7755 {&lcs_conceal, "conceal"},
7756#else
7757 {NULL, "conceal"},
7758#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007759 };
7760 struct charstab *tab;
7761
7762#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7763 if (varp == &p_lcs)
7764#endif
7765 {
7766 tab = lcstab;
7767 entries = sizeof(lcstab) / sizeof(struct charstab);
7768 }
7769#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7770 else
7771 {
7772 tab = filltab;
7773 entries = sizeof(filltab) / sizeof(struct charstab);
7774 }
7775#endif
7776
7777 /* first round: check for valid value, second round: assign values */
7778 for (round = 0; round <= 1; ++round)
7779 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007780 if (round > 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007781 {
7782 /* After checking that the value is valid: set defaults: space for
7783 * 'fillchars', NUL for 'listchars' */
7784 for (i = 0; i < entries; ++i)
Bram Moolenaar860cae12010-06-05 23:22:07 +02007785 if (tab[i].cp != NULL)
7786 *(tab[i].cp) = (varp == &p_lcs ? NUL : ' ');
Bram Moolenaar071d4272004-06-13 20:20:40 +00007787 if (varp == &p_lcs)
7788 lcs_tab1 = NUL;
7789#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7790 else
7791 fill_diff = '-';
7792#endif
7793 }
7794 p = *varp;
7795 while (*p)
7796 {
7797 for (i = 0; i < entries; ++i)
7798 {
7799 len = (int)STRLEN(tab[i].name);
7800 if (STRNCMP(p, tab[i].name, len) == 0
7801 && p[len] == ':'
7802 && p[len + 1] != NUL)
7803 {
7804 s = p + len + 1;
7805#ifdef FEAT_MBYTE
7806 c1 = mb_ptr2char_adv(&s);
Bram Moolenaar910f66f2006-04-05 20:41:53 +00007807 if (mb_char2cells(c1) > 1)
7808 continue;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007809#else
7810 c1 = *s++;
7811#endif
7812 if (tab[i].cp == &lcs_tab2)
7813 {
7814 if (*s == NUL)
7815 continue;
7816#ifdef FEAT_MBYTE
7817 c2 = mb_ptr2char_adv(&s);
Bram Moolenaar910f66f2006-04-05 20:41:53 +00007818 if (mb_char2cells(c2) > 1)
7819 continue;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007820#else
7821 c2 = *s++;
7822#endif
7823 }
7824 if (*s == ',' || *s == NUL)
7825 {
7826 if (round)
7827 {
7828 if (tab[i].cp == &lcs_tab2)
7829 {
7830 lcs_tab1 = c1;
7831 lcs_tab2 = c2;
7832 }
Bram Moolenaar860cae12010-06-05 23:22:07 +02007833 else if (tab[i].cp != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007834 *(tab[i].cp) = c1;
7835
7836 }
7837 p = s;
7838 break;
7839 }
7840 }
7841 }
7842
7843 if (i == entries)
7844 return e_invarg;
7845 if (*p == ',')
7846 ++p;
7847 }
7848 }
7849
7850 return NULL; /* no error */
7851}
7852
7853#ifdef FEAT_STL_OPT
7854/*
7855 * Check validity of options with the 'statusline' format.
7856 * Return error message or NULL.
7857 */
7858 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007859check_stl_option(char_u *s)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007860{
7861 int itemcnt = 0;
7862 int groupdepth = 0;
7863 static char_u errbuf[80];
7864
7865 while (*s && itemcnt < STL_MAX_ITEM)
7866 {
7867 /* Check for valid keys after % sequences */
7868 while (*s && *s != '%')
7869 s++;
7870 if (!*s)
7871 break;
7872 s++;
7873 if (*s != '%' && *s != ')')
7874 ++itemcnt;
7875 if (*s == '%' || *s == STL_TRUNCMARK || *s == STL_MIDDLEMARK)
7876 {
7877 s++;
7878 continue;
7879 }
7880 if (*s == ')')
7881 {
7882 s++;
7883 if (--groupdepth < 0)
7884 break;
7885 continue;
7886 }
7887 if (*s == '-')
7888 s++;
7889 while (VIM_ISDIGIT(*s))
7890 s++;
Bram Moolenaar238a5642006-02-21 22:12:05 +00007891 if (*s == STL_USER_HL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007892 continue;
7893 if (*s == '.')
7894 {
7895 s++;
7896 while (*s && VIM_ISDIGIT(*s))
7897 s++;
7898 }
7899 if (*s == '(')
7900 {
7901 groupdepth++;
7902 continue;
7903 }
7904 if (vim_strchr(STL_ALL, *s) == NULL)
7905 {
7906 return illegal_char(errbuf, *s);
7907 }
7908 if (*s == '{')
7909 {
7910 s++;
7911 while (*s != '}' && *s)
7912 s++;
7913 if (*s != '}')
7914 return (char_u *)N_("E540: Unclosed expression sequence");
7915 }
7916 }
7917 if (itemcnt >= STL_MAX_ITEM)
7918 return (char_u *)N_("E541: too many items");
7919 if (groupdepth != 0)
7920 return (char_u *)N_("E542: unbalanced groups");
7921 return NULL;
7922}
7923#endif
7924
7925#ifdef FEAT_CLIPBOARD
7926/*
7927 * Extract the items in the 'clipboard' option and set global values.
7928 */
7929 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007930check_clipboard_option(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007931{
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007932 int new_unnamed = 0;
Bram Moolenaar89af4392012-07-10 18:31:54 +02007933 int new_autoselect_star = FALSE;
7934 int new_autoselect_plus = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007935 int new_autoselectml = FALSE;
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007936 int new_html = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007937 regprog_T *new_exclude_prog = NULL;
7938 char_u *errmsg = NULL;
7939 char_u *p;
7940
7941 for (p = p_cb; *p != NUL; )
7942 {
7943 if (STRNCMP(p, "unnamed", 7) == 0 && (p[7] == ',' || p[7] == NUL))
7944 {
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007945 new_unnamed |= CLIP_UNNAMED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007946 p += 7;
7947 }
Bram Moolenaar11b73d62012-06-29 15:51:30 +02007948 else if (STRNCMP(p, "unnamedplus", 11) == 0
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007949 && (p[11] == ',' || p[11] == NUL))
7950 {
7951 new_unnamed |= CLIP_UNNAMED_PLUS;
7952 p += 11;
7953 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007954 else if (STRNCMP(p, "autoselect", 10) == 0
Bram Moolenaar89af4392012-07-10 18:31:54 +02007955 && (p[10] == ',' || p[10] == NUL))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007956 {
Bram Moolenaar89af4392012-07-10 18:31:54 +02007957 new_autoselect_star = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007958 p += 10;
7959 }
Bram Moolenaar89af4392012-07-10 18:31:54 +02007960 else if (STRNCMP(p, "autoselectplus", 14) == 0
7961 && (p[14] == ',' || p[14] == NUL))
7962 {
7963 new_autoselect_plus = TRUE;
7964 p += 14;
7965 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007966 else if (STRNCMP(p, "autoselectml", 12) == 0
Bram Moolenaar89af4392012-07-10 18:31:54 +02007967 && (p[12] == ',' || p[12] == NUL))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007968 {
7969 new_autoselectml = TRUE;
7970 p += 12;
7971 }
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007972 else if (STRNCMP(p, "html", 4) == 0 && (p[4] == ',' || p[4] == NUL))
7973 {
7974 new_html = TRUE;
7975 p += 4;
7976 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007977 else if (STRNCMP(p, "exclude:", 8) == 0 && new_exclude_prog == NULL)
7978 {
7979 p += 8;
7980 new_exclude_prog = vim_regcomp(p, RE_MAGIC);
7981 if (new_exclude_prog == NULL)
7982 errmsg = e_invarg;
7983 break;
7984 }
7985 else
7986 {
7987 errmsg = e_invarg;
7988 break;
7989 }
7990 if (*p == ',')
7991 ++p;
7992 }
7993 if (errmsg == NULL)
7994 {
7995 clip_unnamed = new_unnamed;
Bram Moolenaar89af4392012-07-10 18:31:54 +02007996 clip_autoselect_star = new_autoselect_star;
7997 clip_autoselect_plus = new_autoselect_plus;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007998 clip_autoselectml = new_autoselectml;
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007999 clip_html = new_html;
Bram Moolenaar473de612013-06-08 18:19:48 +02008000 vim_regfree(clip_exclude_prog);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008001 clip_exclude_prog = new_exclude_prog;
Bram Moolenaara76638f2010-06-05 12:49:46 +02008002#ifdef FEAT_GUI_GTK
8003 if (gui.in_use)
8004 {
8005 gui_gtk_set_selection_targets();
8006 gui_gtk_set_dnd_targets();
8007 }
8008#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008009 }
8010 else
Bram Moolenaar473de612013-06-08 18:19:48 +02008011 vim_regfree(new_exclude_prog);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008012
8013 return errmsg;
8014}
8015#endif
8016
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00008017#ifdef FEAT_SPELL
Bram Moolenaare68c25c2015-08-25 15:39:55 +02008018 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01008019did_set_spell_option(int is_spellfile)
Bram Moolenaare68c25c2015-08-25 15:39:55 +02008020{
8021 char_u *errmsg = NULL;
8022 win_T *wp;
8023 int l;
8024
8025 if (is_spellfile)
8026 {
8027 l = (int)STRLEN(curwin->w_s->b_p_spf);
8028 if (l > 0 && (l < 4
8029 || STRCMP(curwin->w_s->b_p_spf + l - 4, ".add") != 0))
8030 errmsg = e_invarg;
8031 }
8032
8033 if (errmsg == NULL)
8034 {
8035 FOR_ALL_WINDOWS(wp)
8036 if (wp->w_buffer == curbuf && wp->w_p_spell)
8037 {
8038 errmsg = did_set_spelllang(wp);
8039# ifdef FEAT_WINDOWS
8040 break;
8041# endif
8042 }
8043 }
8044 return errmsg;
8045}
8046
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00008047/*
8048 * Set curbuf->b_cap_prog to the regexp program for 'spellcapcheck'.
8049 * Return error message when failed, NULL when OK.
8050 */
8051 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01008052compile_cap_prog(synblock_T *synblock)
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00008053{
Bram Moolenaar860cae12010-06-05 23:22:07 +02008054 regprog_T *rp = synblock->b_cap_prog;
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008055 char_u *re;
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00008056
Bram Moolenaar860cae12010-06-05 23:22:07 +02008057 if (*synblock->b_p_spc == NUL)
8058 synblock->b_cap_prog = NULL;
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008059 else
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00008060 {
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008061 /* Prepend a ^ so that we only match at one column */
Bram Moolenaar860cae12010-06-05 23:22:07 +02008062 re = concat_str((char_u *)"^", synblock->b_p_spc);
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008063 if (re != NULL)
8064 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02008065 synblock->b_cap_prog = vim_regcomp(re, RE_MAGIC);
Bram Moolenaar473de612013-06-08 18:19:48 +02008066 vim_free(re);
Bram Moolenaar860cae12010-06-05 23:22:07 +02008067 if (synblock->b_cap_prog == NULL)
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008068 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02008069 synblock->b_cap_prog = rp; /* restore the previous program */
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008070 return e_invarg;
8071 }
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008072 }
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00008073 }
8074
Bram Moolenaar473de612013-06-08 18:19:48 +02008075 vim_regfree(rp);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00008076 return NULL;
8077}
8078#endif
8079
Bram Moolenaard1f56e62006-02-22 21:25:37 +00008080#if defined(FEAT_EVAL) || defined(PROTO)
8081/*
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008082 * Set the scriptID for an option, taking care of setting the buffer- or
8083 * window-local value.
Bram Moolenaard1f56e62006-02-22 21:25:37 +00008084 */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008085 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01008086set_option_scriptID_idx(int opt_idx, int opt_flags, int id)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00008087{
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008088 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
8089 int indir = (int)options[opt_idx].indir;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00008090
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008091 /* Remember where the option was set. For local options need to do that
8092 * in the buffer or window structure. */
8093 if (both || (opt_flags & OPT_GLOBAL) || (indir & (PV_BUF|PV_WIN)) == 0)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00008094 options[opt_idx].scriptID = id;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008095 if (both || (opt_flags & OPT_LOCAL))
8096 {
8097 if (indir & PV_BUF)
8098 curbuf->b_p_scriptID[indir & PV_MASK] = id;
8099 else if (indir & PV_WIN)
8100 curwin->w_p_scriptID[indir & PV_MASK] = id;
8101 }
Bram Moolenaard1f56e62006-02-22 21:25:37 +00008102}
8103#endif
8104
Bram Moolenaar071d4272004-06-13 20:20:40 +00008105/*
8106 * Set the value of a boolean option, and take care of side effects.
8107 * Returns NULL for success, or an error message for an error.
8108 */
8109 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01008110set_bool_option(
8111 int opt_idx, /* index in options[] table */
8112 char_u *varp, /* pointer to the option variable */
8113 int value, /* new value */
8114 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008115{
8116 int old_value = *(int *)varp;
8117
Bram Moolenaar071d4272004-06-13 20:20:40 +00008118 /* Disallow changing some options from secure mode */
8119 if ((secure
8120#ifdef HAVE_SANDBOX
8121 || sandbox != 0
8122#endif
8123 ) && (options[opt_idx].flags & P_SECURE))
8124 return e_secure;
8125
8126 *(int *)varp = value; /* set the new value */
8127#ifdef FEAT_EVAL
8128 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008129 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008130#endif
8131
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008132#ifdef FEAT_GUI
8133 need_mouse_correct = TRUE;
8134#endif
8135
Bram Moolenaar071d4272004-06-13 20:20:40 +00008136 /* May set global value for local option. */
8137 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
8138 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = value;
8139
8140 /*
8141 * Handle side effects of changing a bool option.
8142 */
8143
8144 /* 'compatible' */
8145 if ((int *)varp == &p_cp)
8146 {
8147 compatible_set();
8148 }
8149
Bram Moolenaar920694c2016-08-21 17:45:02 +02008150#ifdef FEAT_LANGMAP
8151 if ((int *)varp == &p_lrm)
8152 /* 'langremap' -> !'langnoremap' */
8153 p_lnr = !p_lrm;
8154 else if ((int *)varp == &p_lnr)
8155 /* 'langnoremap' -> !'langremap' */
8156 p_lrm = !p_lnr;
8157#endif
8158
Bram Moolenaar374d32d2012-01-04 19:34:37 +01008159#ifdef FEAT_PERSISTENT_UNDO
8160 /* 'undofile' */
8161 else if ((int *)varp == &curbuf->b_p_udf || (int *)varp == &p_udf)
8162 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02008163 /* Only take action when the option was set. When reset we do not
8164 * delete the undo file, the option may be set again without making
8165 * any changes in between. */
8166 if (curbuf->b_p_udf || p_udf)
Bram Moolenaar374d32d2012-01-04 19:34:37 +01008167 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02008168 char_u hash[UNDO_HASH_SIZE];
8169 buf_T *save_curbuf = curbuf;
8170
Bram Moolenaar29323592016-07-24 22:04:11 +02008171 FOR_ALL_BUFFERS(curbuf)
Bram Moolenaar374d32d2012-01-04 19:34:37 +01008172 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02008173 /* When 'undofile' is set globally: for every buffer, otherwise
8174 * only for the current buffer: Try to read in the undofile,
8175 * if one exists, the buffer wasn't changed and the buffer was
8176 * loaded */
8177 if ((curbuf == save_curbuf
8178 || (opt_flags & OPT_GLOBAL) || opt_flags == 0)
8179 && !curbufIsChanged() && curbuf->b_ml.ml_mfp != NULL)
8180 {
8181 u_compute_hash(hash);
8182 u_read_undo(NULL, hash, curbuf->b_fname);
8183 }
Bram Moolenaar374d32d2012-01-04 19:34:37 +01008184 }
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02008185 curbuf = save_curbuf;
Bram Moolenaar374d32d2012-01-04 19:34:37 +01008186 }
Bram Moolenaar374d32d2012-01-04 19:34:37 +01008187 }
8188#endif
8189
Bram Moolenaar071d4272004-06-13 20:20:40 +00008190 else if ((int *)varp == &curbuf->b_p_ro)
8191 {
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00008192 /* when 'readonly' is reset globally, also reset readonlymode */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008193 if (!curbuf->b_p_ro && (opt_flags & OPT_LOCAL) == 0)
8194 readonlymode = FALSE;
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00008195
8196 /* when 'readonly' is set may give W10 again */
8197 if (curbuf->b_p_ro)
8198 curbuf->b_did_warn = FALSE;
8199
Bram Moolenaar071d4272004-06-13 20:20:40 +00008200#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008201 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008202#endif
8203 }
8204
Bram Moolenaar9c449722010-07-20 18:44:27 +02008205#ifdef FEAT_GUI
8206 else if ((int *)varp == &p_mh)
8207 {
8208 if (!p_mh)
8209 gui_mch_mousehide(FALSE);
8210 }
8211#endif
8212
Bram Moolenaara539df02010-08-01 14:35:05 +02008213#ifdef FEAT_TITLE
8214 /* when 'modifiable' is changed, redraw the window title */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008215 else if ((int *)varp == &curbuf->b_p_ma)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008216 {
8217 redraw_titles();
8218 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008219 /* when 'endofline' is changed, redraw the window title */
8220 else if ((int *)varp == &curbuf->b_p_eol)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008221 {
8222 redraw_titles();
8223 }
Bram Moolenaar34d72d42015-07-17 14:18:08 +02008224 /* when 'fixeol' is changed, redraw the window title */
8225 else if ((int *)varp == &curbuf->b_p_fixeol)
8226 {
8227 redraw_titles();
8228 }
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008229# ifdef FEAT_MBYTE
8230 /* when 'bomb' is changed, redraw the window title and tab page text */
Bram Moolenaar83eb8852007-08-12 13:51:26 +00008231 else if ((int *)varp == &curbuf->b_p_bomb)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008232 {
8233 redraw_titles();
8234 }
8235# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008236#endif
8237
8238 /* when 'bin' is set also set some other options */
8239 else if ((int *)varp == &curbuf->b_p_bin)
8240 {
8241 set_options_bin(old_value, curbuf->b_p_bin, opt_flags);
8242#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008243 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008244#endif
8245 }
8246
8247#ifdef FEAT_AUTOCMD
8248 /* when 'buflisted' changes, trigger autocommands */
8249 else if ((int *)varp == &curbuf->b_p_bl && old_value != curbuf->b_p_bl)
8250 {
8251 apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE,
8252 NULL, NULL, TRUE, curbuf);
8253 }
8254#endif
8255
8256 /* when 'swf' is set, create swapfile, when reset remove swapfile */
8257 else if ((int *)varp == &curbuf->b_p_swf)
8258 {
8259 if (curbuf->b_p_swf && p_uc)
8260 ml_open_file(curbuf); /* create the swap file */
8261 else
Bram Moolenaard55de222007-05-06 13:38:48 +00008262 /* no need to reset curbuf->b_may_swap, ml_open_file() will check
8263 * buf->b_p_swf */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008264 mf_close_file(curbuf, TRUE); /* remove the swap file */
8265 }
8266
8267 /* when 'terse' is set change 'shortmess' */
8268 else if ((int *)varp == &p_terse)
8269 {
8270 char_u *p;
8271
8272 p = vim_strchr(p_shm, SHM_SEARCH);
8273
8274 /* insert 's' in p_shm */
8275 if (p_terse && p == NULL)
8276 {
8277 STRCPY(IObuff, p_shm);
8278 STRCAT(IObuff, "s");
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008279 set_string_option_direct((char_u *)"shm", -1, IObuff, OPT_FREE, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008280 }
8281 /* remove 's' from p_shm */
8282 else if (!p_terse && p != NULL)
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00008283 STRMOVE(p, p + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008284 }
8285
8286 /* when 'paste' is set or reset also change other options */
8287 else if ((int *)varp == &p_paste)
8288 {
8289 paste_option_changed();
8290 }
8291
8292 /* when 'insertmode' is set from an autocommand need to do work here */
8293 else if ((int *)varp == &p_im)
8294 {
8295 if (p_im)
8296 {
8297 if ((State & INSERT) == 0)
8298 need_start_insertmode = TRUE;
8299 stop_insert_mode = FALSE;
8300 }
Bram Moolenaar00672e12016-06-26 18:38:13 +02008301 /* only reset if it was set previously */
8302 else if (old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008303 {
8304 need_start_insertmode = FALSE;
8305 stop_insert_mode = TRUE;
Bram Moolenaard12f5c12006-01-25 22:10:52 +00008306 if (restart_edit != 0 && mode_displayed)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008307 clear_cmdline = TRUE; /* remove "(insert)" */
8308 restart_edit = 0;
8309 }
8310 }
8311
8312 /* when 'ignorecase' is set or reset and 'hlsearch' is set, redraw */
8313 else if ((int *)varp == &p_ic && p_hls)
8314 {
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00008315 redraw_all_later(SOME_VALID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008316 }
8317
8318#ifdef FEAT_SEARCH_EXTRA
8319 /* when 'hlsearch' is set or reset: reset no_hlsearch */
8320 else if ((int *)varp == &p_hls)
8321 {
Bram Moolenaar8050efa2013-11-08 04:30:20 +01008322 SET_NO_HLSEARCH(FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008323 }
8324#endif
8325
8326#ifdef FEAT_SCROLLBIND
8327 /* when 'scrollbind' is set: snapshot the current position to avoid a jump
8328 * at the end of normal_cmd() */
8329 else if ((int *)varp == &curwin->w_p_scb)
8330 {
8331 if (curwin->w_p_scb)
Bram Moolenaar04c5c9e2013-07-09 13:44:59 +02008332 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00008333 do_check_scrollbind(FALSE);
Bram Moolenaar04c5c9e2013-07-09 13:44:59 +02008334 curwin->w_scbind_pos = curwin->w_topline;
8335 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008336 }
8337#endif
8338
8339#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
8340 /* There can be only one window with 'previewwindow' set. */
8341 else if ((int *)varp == &curwin->w_p_pvw)
8342 {
8343 if (curwin->w_p_pvw)
8344 {
8345 win_T *win;
8346
Bram Moolenaar29323592016-07-24 22:04:11 +02008347 FOR_ALL_WINDOWS(win)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008348 if (win->w_p_pvw && win != curwin)
8349 {
8350 curwin->w_p_pvw = FALSE;
8351 return (char_u *)N_("E590: A preview window already exists");
8352 }
8353 }
8354 }
8355#endif
8356
8357 /* when 'textmode' is set or reset also change 'fileformat' */
8358 else if ((int *)varp == &curbuf->b_p_tx)
8359 {
8360 set_fileformat(curbuf->b_p_tx ? EOL_DOS : EOL_UNIX, opt_flags);
8361 }
8362
8363 /* when 'textauto' is set or reset also change 'fileformats' */
8364 else if ((int *)varp == &p_ta)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008365 set_string_option_direct((char_u *)"ffs", -1,
8366 p_ta ? (char_u *)DFLT_FFS_VIM : (char_u *)"",
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008367 OPT_FREE | opt_flags, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008368
8369 /*
8370 * When 'lisp' option changes include/exclude '-' in
8371 * keyword characters.
8372 */
8373#ifdef FEAT_LISP
8374 else if (varp == (char_u *)&(curbuf->b_p_lisp))
8375 {
8376 (void)buf_init_chartab(curbuf, FALSE); /* ignore errors */
8377 }
8378#endif
8379
8380#ifdef FEAT_TITLE
8381 /* when 'title' changed, may need to change the title; same for 'icon' */
8382 else if ((int *)varp == &p_title)
8383 {
8384 did_set_title(FALSE);
8385 }
8386
8387 else if ((int *)varp == &p_icon)
8388 {
8389 did_set_title(TRUE);
8390 }
8391#endif
8392
8393 else if ((int *)varp == &curbuf->b_changed)
8394 {
8395 if (!value)
8396 save_file_ff(curbuf); /* Buffer is unchanged */
8397#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008398 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008399#endif
8400#ifdef FEAT_AUTOCMD
8401 modified_was_set = value;
8402#endif
8403 }
8404
8405#ifdef BACKSLASH_IN_FILENAME
8406 else if ((int *)varp == &p_ssl)
8407 {
8408 if (p_ssl)
8409 {
8410 psepc = '/';
8411 psepcN = '\\';
8412 pseps[0] = '/';
Bram Moolenaar071d4272004-06-13 20:20:40 +00008413 }
8414 else
8415 {
8416 psepc = '\\';
8417 psepcN = '/';
8418 pseps[0] = '\\';
Bram Moolenaar071d4272004-06-13 20:20:40 +00008419 }
8420
8421 /* need to adjust the file name arguments and buffer names. */
8422 buflist_slash_adjust();
8423 alist_slash_adjust();
8424# ifdef FEAT_EVAL
8425 scriptnames_slash_adjust();
8426# endif
8427 }
8428#endif
8429
8430 /* If 'wrap' is set, set w_leftcol to zero. */
8431 else if ((int *)varp == &curwin->w_p_wrap)
8432 {
8433 if (curwin->w_p_wrap)
8434 curwin->w_leftcol = 0;
8435 }
8436
8437#ifdef FEAT_WINDOWS
8438 else if ((int *)varp == &p_ea)
8439 {
8440 if (p_ea && !old_value)
8441 win_equal(curwin, FALSE, 0);
8442 }
8443#endif
8444
8445 else if ((int *)varp == &p_wiv)
8446 {
8447 /*
8448 * When 'weirdinvert' changed, set/reset 't_xs'.
8449 * Then set 'weirdinvert' according to value of 't_xs'.
8450 */
8451 if (p_wiv && !old_value)
8452 T_XS = (char_u *)"y";
8453 else if (!p_wiv && old_value)
8454 T_XS = empty_option;
8455 p_wiv = (*T_XS != NUL);
8456 }
8457
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00008458#ifdef FEAT_BEVAL
Bram Moolenaar071d4272004-06-13 20:20:40 +00008459 else if ((int *)varp == &p_beval)
8460 {
Bram Moolenaar49e4ec62011-11-30 11:31:30 +01008461 if (p_beval && !old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008462 gui_mch_enable_beval_area(balloonEval);
Bram Moolenaar49e4ec62011-11-30 11:31:30 +01008463 else if (!p_beval && old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008464 gui_mch_disable_beval_area(balloonEval);
8465 }
Bram Moolenaar8dff8182006-04-06 20:18:50 +00008466#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008467
Bram Moolenaar8dff8182006-04-06 20:18:50 +00008468#ifdef FEAT_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +00008469 else if ((int *)varp == &p_acd)
8470 {
Bram Moolenaar498efdb2006-09-05 14:31:54 +00008471 /* Change directories when the 'acd' option is set now. */
8472 DO_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +00008473 }
8474#endif
8475
8476#ifdef FEAT_DIFF
8477 /* 'diff' */
8478 else if ((int *)varp == &curwin->w_p_diff)
8479 {
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008480 /* May add or remove the buffer from the list of diff buffers. */
8481 diff_buf_adjust(curwin);
8482# ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00008483 if (foldmethodIsDiff(curwin))
8484 foldUpdateAll(curwin);
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008485# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008486 }
8487#endif
8488
8489#ifdef USE_IM_CONTROL
8490 /* 'imdisable' */
8491 else if ((int *)varp == &p_imdisable)
8492 {
8493 /* Only de-activate it here, it will be enabled when changing mode. */
8494 if (p_imdisable)
8495 im_set_active(FALSE);
Bram Moolenaar725a9622011-10-12 16:57:13 +02008496 else if (State & INSERT)
8497 /* When the option is set from an autocommand, it may need to take
8498 * effect right away. */
8499 im_set_active(curbuf->b_p_iminsert == B_IMODE_IM);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008500 }
8501#endif
8502
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00008503#ifdef FEAT_SPELL
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00008504 /* 'spell' */
8505 else if ((int *)varp == &curwin->w_p_spell)
8506 {
8507 if (curwin->w_p_spell)
8508 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02008509 char_u *errmsg = did_set_spelllang(curwin);
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00008510 if (errmsg != NULL)
8511 EMSG(_(errmsg));
8512 }
8513 }
8514#endif
8515
Bram Moolenaar071d4272004-06-13 20:20:40 +00008516#ifdef FEAT_FKMAP
8517 else if ((int *)varp == &p_altkeymap)
8518 {
8519 if (old_value != p_altkeymap)
8520 {
8521 if (!p_altkeymap)
8522 {
8523 p_hkmap = p_fkmap;
8524 p_fkmap = 0;
8525 }
8526 else
8527 {
8528 p_fkmap = p_hkmap;
8529 p_hkmap = 0;
8530 }
8531 (void)init_chartab();
8532 }
8533 }
8534
8535 /*
8536 * In case some second language keymapping options have changed, check
8537 * and correct the setting in a consistent way.
8538 */
8539
8540 /*
8541 * If hkmap or fkmap are set, reset Arabic keymapping.
8542 */
8543 if ((p_hkmap || p_fkmap) && p_altkeymap)
8544 {
8545 p_altkeymap = p_fkmap;
8546# ifdef FEAT_ARABIC
8547 curwin->w_p_arab = FALSE;
8548# endif
8549 (void)init_chartab();
8550 }
8551
8552 /*
8553 * If hkmap set, reset Farsi keymapping.
8554 */
8555 if (p_hkmap && p_altkeymap)
8556 {
8557 p_altkeymap = 0;
8558 p_fkmap = 0;
8559# ifdef FEAT_ARABIC
8560 curwin->w_p_arab = FALSE;
8561# endif
8562 (void)init_chartab();
8563 }
8564
8565 /*
8566 * If fkmap set, reset Hebrew keymapping.
8567 */
8568 if (p_fkmap && !p_altkeymap)
8569 {
8570 p_altkeymap = 1;
8571 p_hkmap = 0;
8572# ifdef FEAT_ARABIC
8573 curwin->w_p_arab = FALSE;
8574# endif
8575 (void)init_chartab();
8576 }
8577#endif
8578
8579#ifdef FEAT_ARABIC
8580 if ((int *)varp == &curwin->w_p_arab)
8581 {
8582 if (curwin->w_p_arab)
8583 {
8584 /*
8585 * 'arabic' is set, handle various sub-settings.
8586 */
8587 if (!p_tbidi)
8588 {
8589 /* set rightleft mode */
8590 if (!curwin->w_p_rl)
8591 {
8592 curwin->w_p_rl = TRUE;
8593 changed_window_setting();
8594 }
8595
8596 /* Enable Arabic shaping (major part of what Arabic requires) */
8597 if (!p_arshape)
8598 {
8599 p_arshape = TRUE;
8600 redraw_later_clear();
8601 }
8602 }
8603
8604 /* Arabic requires a utf-8 encoding, inform the user if its not
8605 * set. */
8606 if (STRCMP(p_enc, "utf-8") != 0)
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008607 {
Bram Moolenaar496c5262009-03-18 14:42:00 +00008608 static char *w_arabic = N_("W17: Arabic requires UTF-8, do ':set encoding=utf-8'");
8609
Bram Moolenaar8820b482017-03-16 17:23:31 +01008610 msg_source(HL_ATTR(HLF_W));
8611 MSG_ATTR(_(w_arabic), HL_ATTR(HLF_W));
Bram Moolenaar496c5262009-03-18 14:42:00 +00008612#ifdef FEAT_EVAL
8613 set_vim_var_string(VV_WARNINGMSG, (char_u *)_(w_arabic), -1);
8614#endif
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008615 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008616
8617# ifdef FEAT_MBYTE
8618 /* set 'delcombine' */
8619 p_deco = TRUE;
8620# endif
8621
8622# ifdef FEAT_KEYMAP
8623 /* Force-set the necessary keymap for arabic */
8624 set_option_value((char_u *)"keymap", 0L, (char_u *)"arabic",
8625 OPT_LOCAL);
8626# endif
8627# ifdef FEAT_FKMAP
8628 p_altkeymap = 0;
8629 p_hkmap = 0;
8630 p_fkmap = 0;
8631 (void)init_chartab();
8632# endif
8633 }
8634 else
8635 {
8636 /*
8637 * 'arabic' is reset, handle various sub-settings.
8638 */
8639 if (!p_tbidi)
8640 {
8641 /* reset rightleft mode */
8642 if (curwin->w_p_rl)
8643 {
8644 curwin->w_p_rl = FALSE;
8645 changed_window_setting();
8646 }
8647
8648 /* 'arabicshape' isn't reset, it is a global option and
8649 * another window may still need it "on". */
8650 }
8651
8652 /* 'delcombine' isn't reset, it is a global option and another
8653 * window may still want it "on". */
8654
8655# ifdef FEAT_KEYMAP
8656 /* Revert to the default keymap */
8657 curbuf->b_p_iminsert = B_IMODE_NONE;
8658 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
8659# endif
8660 }
Bram Moolenaar801f8b82009-07-29 13:42:05 +00008661 }
8662
Bram Moolenaar319bdbd2009-09-11 13:20:33 +00008663#endif
8664
Bram Moolenaar61be73b2016-04-29 22:59:22 +02008665#ifdef FEAT_TERMGUICOLORS
8666 /* 'termguicolors' */
8667 else if ((int *)varp == &p_tgc)
Bram Moolenaar8a633e32016-04-21 21:10:14 +02008668 {
8669# ifdef FEAT_GUI
8670 if (!gui.in_use && !gui.starting)
8671# endif
8672 highlight_gui_started();
8673 }
8674#endif
8675
Bram Moolenaar071d4272004-06-13 20:20:40 +00008676 /*
8677 * End of handling side effects for bool options.
8678 */
8679
Bram Moolenaar53744302015-07-17 17:38:22 +02008680 /* after handling side effects, call autocommand */
8681
Bram Moolenaar071d4272004-06-13 20:20:40 +00008682 options[opt_idx].flags |= P_WAS_SET;
8683
Bram Moolenaar53744302015-07-17 17:38:22 +02008684#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
8685 if (!starting)
8686 {
8687 char_u buf_old[2], buf_new[2], buf_type[7];
Bram Moolenaarfb9bc482015-07-17 22:04:48 +02008688 vim_snprintf((char *)buf_old, 2, "%d", old_value ? TRUE: FALSE);
8689 vim_snprintf((char *)buf_new, 2, "%d", value ? TRUE: FALSE);
8690 vim_snprintf((char *)buf_type, 7, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar53744302015-07-17 17:38:22 +02008691 set_vim_var_string(VV_OPTION_NEW, buf_new, -1);
8692 set_vim_var_string(VV_OPTION_OLD, buf_old, -1);
8693 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
8694 apply_autocmds(EVENT_OPTIONSET, (char_u *) options[opt_idx].fullname, NULL, FALSE, NULL);
8695 reset_v_option_vars();
8696 }
8697#endif
8698
Bram Moolenaar071d4272004-06-13 20:20:40 +00008699 comp_col(); /* in case 'ruler' or 'showcmd' changed */
Bram Moolenaar913077c2012-03-28 19:59:04 +02008700 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01008701 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02008702 curwin->w_set_curswant = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008703 check_redraw(options[opt_idx].flags);
8704
8705 return NULL;
8706}
8707
8708/*
8709 * Set the value of a number option, and take care of side effects.
8710 * Returns NULL for success, or an error message for an error.
8711 */
8712 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01008713set_num_option(
8714 int opt_idx, /* index in options[] table */
8715 char_u *varp, /* pointer to the option variable */
8716 long value, /* new value */
8717 char_u *errbuf, /* buffer for error messages */
8718 size_t errbuflen, /* length of "errbuf" */
8719 int opt_flags) /* OPT_LOCAL, OPT_GLOBAL and
Bram Moolenaar071d4272004-06-13 20:20:40 +00008720 OPT_MODELINE */
8721{
8722 char_u *errmsg = NULL;
8723 long old_value = *(long *)varp;
8724 long old_Rows = Rows; /* remember old Rows */
8725 long old_Columns = Columns; /* remember old Columns */
8726 long *pp = (long *)varp;
8727
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008728 /* Disallow changing some options from secure mode. */
8729 if ((secure
8730#ifdef HAVE_SANDBOX
8731 || sandbox != 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00008732#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008733 ) && (options[opt_idx].flags & P_SECURE))
8734 return e_secure;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008735
8736 *pp = value;
8737#ifdef FEAT_EVAL
8738 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008739 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008740#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008741#ifdef FEAT_GUI
8742 need_mouse_correct = TRUE;
8743#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008744
Bram Moolenaar14f24742012-08-08 18:01:05 +02008745 if (curbuf->b_p_sw < 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008746 {
8747 errmsg = e_positive;
8748 curbuf->b_p_sw = curbuf->b_p_ts;
8749 }
8750
8751 /*
8752 * Number options that need some action when changed
8753 */
8754#ifdef FEAT_WINDOWS
8755 if (pp == &p_wh || pp == &p_hh)
8756 {
8757 if (p_wh < 1)
8758 {
8759 errmsg = e_positive;
8760 p_wh = 1;
8761 }
8762 if (p_wmh > p_wh)
8763 {
8764 errmsg = e_winheight;
8765 p_wh = p_wmh;
8766 }
8767 if (p_hh < 0)
8768 {
8769 errmsg = e_positive;
8770 p_hh = 0;
8771 }
8772
8773 /* Change window height NOW */
Bram Moolenaar459ca562016-11-10 18:16:33 +01008774 if (!ONE_WINDOW)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008775 {
8776 if (pp == &p_wh && curwin->w_height < p_wh)
8777 win_setheight((int)p_wh);
8778 if (pp == &p_hh && curbuf->b_help && curwin->w_height < p_hh)
8779 win_setheight((int)p_hh);
8780 }
8781 }
8782
8783 /* 'winminheight' */
8784 else if (pp == &p_wmh)
8785 {
8786 if (p_wmh < 0)
8787 {
8788 errmsg = e_positive;
8789 p_wmh = 0;
8790 }
8791 if (p_wmh > p_wh)
8792 {
8793 errmsg = e_winheight;
8794 p_wmh = p_wh;
8795 }
8796 win_setminheight();
8797 }
8798
Bram Moolenaar44a2f922016-03-19 22:11:51 +01008799# ifdef FEAT_WINDOWS
Bram Moolenaar592e0a22004-07-03 16:05:59 +00008800 else if (pp == &p_wiw)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008801 {
8802 if (p_wiw < 1)
8803 {
8804 errmsg = e_positive;
8805 p_wiw = 1;
8806 }
8807 if (p_wmw > p_wiw)
8808 {
8809 errmsg = e_winwidth;
8810 p_wiw = p_wmw;
8811 }
8812
8813 /* Change window width NOW */
Bram Moolenaar459ca562016-11-10 18:16:33 +01008814 if (!ONE_WINDOW && curwin->w_width < p_wiw)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008815 win_setwidth((int)p_wiw);
8816 }
8817
8818 /* 'winminwidth' */
8819 else if (pp == &p_wmw)
8820 {
8821 if (p_wmw < 0)
8822 {
8823 errmsg = e_positive;
8824 p_wmw = 0;
8825 }
8826 if (p_wmw > p_wiw)
8827 {
8828 errmsg = e_winwidth;
8829 p_wmw = p_wiw;
8830 }
8831 win_setminheight();
8832 }
8833# endif
8834
8835#endif
8836
8837#ifdef FEAT_WINDOWS
8838 /* (re)set last window status line */
8839 else if (pp == &p_ls)
8840 {
8841 last_status(FALSE);
8842 }
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00008843
8844 /* (re)set tab page line */
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00008845 else if (pp == &p_stal)
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00008846 {
8847 shell_new_rows(); /* recompute window positions and heights */
8848 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008849#endif
8850
8851#ifdef FEAT_GUI
8852 else if (pp == &p_linespace)
8853 {
Bram Moolenaar02743632005-07-25 20:42:36 +00008854 /* Recompute gui.char_height and resize the Vim window to keep the
8855 * same number of lines. */
8856 if (gui.in_use && gui_mch_adjust_charheight() == OK)
Bram Moolenaar3964b7e2006-03-27 20:59:33 +00008857 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008858 }
8859#endif
8860
8861#ifdef FEAT_FOLDING
8862 /* 'foldlevel' */
8863 else if (pp == &curwin->w_p_fdl)
8864 {
8865 if (curwin->w_p_fdl < 0)
8866 curwin->w_p_fdl = 0;
8867 newFoldLevel();
8868 }
8869
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008870 /* 'foldminlines' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008871 else if (pp == &curwin->w_p_fml)
8872 {
8873 foldUpdateAll(curwin);
8874 }
8875
8876 /* 'foldnestmax' */
8877 else if (pp == &curwin->w_p_fdn)
8878 {
8879 if (foldmethodIsSyntax(curwin) || foldmethodIsIndent(curwin))
8880 foldUpdateAll(curwin);
8881 }
8882
8883 /* 'foldcolumn' */
8884 else if (pp == &curwin->w_p_fdc)
8885 {
8886 if (curwin->w_p_fdc < 0)
8887 {
8888 errmsg = e_positive;
8889 curwin->w_p_fdc = 0;
8890 }
8891 else if (curwin->w_p_fdc > 12)
8892 {
8893 errmsg = e_invarg;
8894 curwin->w_p_fdc = 12;
8895 }
8896 }
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008897#endif /* FEAT_FOLDING */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008898
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008899#if defined(FEAT_FOLDING) || defined(FEAT_CINDENT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008900 /* 'shiftwidth' or 'tabstop' */
8901 else if (pp == &curbuf->b_p_sw || pp == &curbuf->b_p_ts)
8902 {
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008903# ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00008904 if (foldmethodIsIndent(curwin))
8905 foldUpdateAll(curwin);
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008906# endif
8907# ifdef FEAT_CINDENT
8908 /* When 'shiftwidth' changes, or it's zero and 'tabstop' changes:
8909 * parse 'cinoptions'. */
8910 if (pp == &curbuf->b_p_sw || curbuf->b_p_sw == 0)
8911 parse_cino(curbuf);
8912# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008913 }
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008914#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008915
Bram Moolenaar362e1a32006-03-06 23:29:24 +00008916#ifdef FEAT_MBYTE
8917 /* 'maxcombine' */
8918 else if (pp == &p_mco)
8919 {
8920 if (p_mco > MAX_MCO)
8921 p_mco = MAX_MCO;
8922 else if (p_mco < 0)
8923 p_mco = 0;
8924 screenclear(); /* will re-allocate the screen */
8925 }
8926#endif
8927
Bram Moolenaar071d4272004-06-13 20:20:40 +00008928 else if (pp == &curbuf->b_p_iminsert)
8929 {
8930 if (curbuf->b_p_iminsert < 0 || curbuf->b_p_iminsert > B_IMODE_LAST)
8931 {
8932 errmsg = e_invarg;
8933 curbuf->b_p_iminsert = B_IMODE_NONE;
8934 }
8935 p_iminsert = curbuf->b_p_iminsert;
8936 if (termcap_active) /* don't do this in the alternate screen */
8937 showmode();
8938#if defined(FEAT_WINDOWS) && defined(FEAT_KEYMAP)
8939 /* Show/unshow value of 'keymap' in status lines. */
8940 status_redraw_curbuf();
8941#endif
8942 }
8943
Bram Moolenaar4399ef42005-02-12 14:29:27 +00008944 else if (pp == &p_window)
8945 {
8946 if (p_window < 1)
8947 p_window = 1;
8948 else if (p_window >= Rows)
8949 p_window = Rows - 1;
8950 }
8951
Bram Moolenaar071d4272004-06-13 20:20:40 +00008952 else if (pp == &curbuf->b_p_imsearch)
8953 {
8954 if (curbuf->b_p_imsearch < -1 || curbuf->b_p_imsearch > B_IMODE_LAST)
8955 {
8956 errmsg = e_invarg;
8957 curbuf->b_p_imsearch = B_IMODE_NONE;
8958 }
8959 p_imsearch = curbuf->b_p_imsearch;
8960 }
8961
8962#ifdef FEAT_TITLE
8963 /* if 'titlelen' has changed, redraw the title */
8964 else if (pp == &p_titlelen)
8965 {
8966 if (p_titlelen < 0)
8967 {
8968 errmsg = e_positive;
8969 p_titlelen = 85;
8970 }
8971 if (starting != NO_SCREEN && old_value != p_titlelen)
8972 need_maketitle = TRUE;
8973 }
8974#endif
8975
8976 /* if p_ch changed value, change the command line height */
8977 else if (pp == &p_ch)
8978 {
8979 if (p_ch < 1)
8980 {
8981 errmsg = e_positive;
8982 p_ch = 1;
8983 }
Bram Moolenaar719939c2007-09-25 12:51:28 +00008984 if (p_ch > Rows - min_rows() + 1)
8985 p_ch = Rows - min_rows() + 1;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008986
8987 /* Only compute the new window layout when startup has been
8988 * completed. Otherwise the frame sizes may be wrong. */
8989 if (p_ch != old_value && full_screen
8990#ifdef FEAT_GUI
8991 && !gui.starting
8992#endif
8993 )
Bram Moolenaarc6fe9192006-04-09 21:54:49 +00008994 command_height();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008995 }
8996
8997 /* when 'updatecount' changes from zero to non-zero, open swap files */
8998 else if (pp == &p_uc)
8999 {
9000 if (p_uc < 0)
9001 {
9002 errmsg = e_positive;
9003 p_uc = 100;
9004 }
9005 if (p_uc && !old_value)
9006 ml_open_files();
9007 }
Bram Moolenaar860cae12010-06-05 23:22:07 +02009008#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +02009009 else if (pp == &curwin->w_p_cole)
Bram Moolenaar860cae12010-06-05 23:22:07 +02009010 {
Bram Moolenaarf5963f72010-07-23 22:10:27 +02009011 if (curwin->w_p_cole < 0)
Bram Moolenaar860cae12010-06-05 23:22:07 +02009012 {
9013 errmsg = e_positive;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02009014 curwin->w_p_cole = 0;
Bram Moolenaar860cae12010-06-05 23:22:07 +02009015 }
Bram Moolenaarf5963f72010-07-23 22:10:27 +02009016 else if (curwin->w_p_cole > 3)
Bram Moolenaar860cae12010-06-05 23:22:07 +02009017 {
9018 errmsg = e_invarg;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02009019 curwin->w_p_cole = 3;
Bram Moolenaar860cae12010-06-05 23:22:07 +02009020 }
9021 }
9022#endif
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00009023#ifdef MZSCHEME_GUI_THREADS
Bram Moolenaar325b7a22004-07-05 15:58:32 +00009024 else if (pp == &p_mzq)
9025 mzvim_reset_timer();
9026#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009027
Bram Moolenaarf42dd3c2017-01-28 16:06:38 +01009028#if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3)
9029 /* 'pyxversion' */
9030 else if (pp == &p_pyx)
9031 {
9032 if (p_pyx != 0 && p_pyx != 2 && p_pyx != 3)
9033 errmsg = e_invarg;
9034 }
9035#endif
9036
Bram Moolenaar071d4272004-06-13 20:20:40 +00009037 /* sync undo before 'undolevels' changes */
9038 else if (pp == &p_ul)
9039 {
9040 /* use the old value, otherwise u_sync() may not work properly */
9041 p_ul = old_value;
Bram Moolenaar779b74b2006-04-10 14:55:34 +00009042 u_sync(TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009043 p_ul = value;
9044 }
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01009045 else if (pp == &curbuf->b_p_ul)
9046 {
9047 /* use the old value, otherwise u_sync() may not work properly */
9048 curbuf->b_p_ul = old_value;
9049 u_sync(TRUE);
9050 curbuf->b_p_ul = value;
9051 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009052
Bram Moolenaar592e0a22004-07-03 16:05:59 +00009053#ifdef FEAT_LINEBREAK
9054 /* 'numberwidth' must be positive */
9055 else if (pp == &curwin->w_p_nuw)
9056 {
9057 if (curwin->w_p_nuw < 1)
9058 {
9059 errmsg = e_positive;
9060 curwin->w_p_nuw = 1;
9061 }
9062 if (curwin->w_p_nuw > 10)
9063 {
9064 errmsg = e_invarg;
9065 curwin->w_p_nuw = 10;
9066 }
Bram Moolenaar1e7813a2015-03-31 18:31:03 +02009067 curwin->w_nrwidth_line_count = 0; /* trigger a redraw */
Bram Moolenaar592e0a22004-07-03 16:05:59 +00009068 }
9069#endif
9070
Bram Moolenaar1a384422010-07-14 19:53:30 +02009071 else if (pp == &curbuf->b_p_tw)
9072 {
9073 if (curbuf->b_p_tw < 0)
9074 {
9075 errmsg = e_positive;
9076 curbuf->b_p_tw = 0;
9077 }
9078#ifdef FEAT_SYN_HL
9079# ifdef FEAT_WINDOWS
9080 {
9081 win_T *wp;
9082 tabpage_T *tp;
9083
9084 FOR_ALL_TAB_WINDOWS(tp, wp)
9085 check_colorcolumn(wp);
9086 }
9087# else
9088 check_colorcolumn(curwin);
9089# endif
9090#endif
9091 }
9092
Bram Moolenaar071d4272004-06-13 20:20:40 +00009093 /*
9094 * Check the bounds for numeric options here
9095 */
9096 if (Rows < min_rows() && full_screen)
9097 {
9098 if (errbuf != NULL)
9099 {
Bram Moolenaar555b2802005-05-19 21:08:39 +00009100 vim_snprintf((char *)errbuf, errbuflen,
9101 _("E593: Need at least %d lines"), min_rows());
Bram Moolenaar071d4272004-06-13 20:20:40 +00009102 errmsg = errbuf;
9103 }
9104 Rows = min_rows();
9105 }
9106 if (Columns < MIN_COLUMNS && full_screen)
9107 {
9108 if (errbuf != NULL)
9109 {
Bram Moolenaar555b2802005-05-19 21:08:39 +00009110 vim_snprintf((char *)errbuf, errbuflen,
9111 _("E594: Need at least %d columns"), MIN_COLUMNS);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009112 errmsg = errbuf;
9113 }
9114 Columns = MIN_COLUMNS;
9115 }
Bram Moolenaare057d402013-06-30 17:51:51 +02009116 limit_screen_size();
Bram Moolenaar071d4272004-06-13 20:20:40 +00009117
Bram Moolenaar071d4272004-06-13 20:20:40 +00009118 /*
9119 * If the screen (shell) height has been changed, assume it is the
9120 * physical screenheight.
9121 */
9122 if (old_Rows != Rows || old_Columns != Columns)
9123 {
9124 /* Changing the screen size is not allowed while updating the screen. */
9125 if (updating_screen)
9126 *pp = old_value;
9127 else if (full_screen
9128#ifdef FEAT_GUI
9129 && !gui.starting
9130#endif
9131 )
9132 set_shellsize((int)Columns, (int)Rows, TRUE);
9133 else
9134 {
9135 /* Postpone the resizing; check the size and cmdline position for
9136 * messages. */
9137 check_shellsize();
9138 if (cmdline_row > Rows - p_ch && Rows > p_ch)
9139 cmdline_row = Rows - p_ch;
9140 }
Bram Moolenaard68071d2006-05-02 22:08:30 +00009141 if (p_window >= Rows || !option_was_set((char_u *)"window"))
Bram Moolenaar4399ef42005-02-12 14:29:27 +00009142 p_window = Rows - 1;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009143 }
9144
Bram Moolenaar071d4272004-06-13 20:20:40 +00009145 if (curbuf->b_p_ts <= 0)
9146 {
9147 errmsg = e_positive;
9148 curbuf->b_p_ts = 8;
9149 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009150 if (p_tm < 0)
9151 {
9152 errmsg = e_positive;
9153 p_tm = 0;
9154 }
9155 if ((curwin->w_p_scr <= 0
9156 || (curwin->w_p_scr > curwin->w_height
9157 && curwin->w_height > 0))
9158 && full_screen)
9159 {
9160 if (pp == &(curwin->w_p_scr))
9161 {
9162 if (curwin->w_p_scr != 0)
9163 errmsg = e_scroll;
9164 win_comp_scroll(curwin);
9165 }
9166 /* If 'scroll' became invalid because of a side effect silently adjust
9167 * it. */
9168 else if (curwin->w_p_scr <= 0)
9169 curwin->w_p_scr = 1;
9170 else /* curwin->w_p_scr > curwin->w_height */
9171 curwin->w_p_scr = curwin->w_height;
9172 }
Bram Moolenaar991e10f2008-10-02 20:48:41 +00009173 if (p_hi < 0)
9174 {
9175 errmsg = e_positive;
9176 p_hi = 0;
9177 }
Bram Moolenaar78159bb2014-06-25 11:48:54 +02009178 else if (p_hi > 10000)
9179 {
9180 errmsg = e_invarg;
9181 p_hi = 10000;
9182 }
Bram Moolenaarfbc0d2e2013-05-19 19:40:29 +02009183 if (p_re < 0 || p_re > 2)
9184 {
9185 errmsg = e_invarg;
9186 p_re = 0;
9187 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009188 if (p_report < 0)
9189 {
9190 errmsg = e_positive;
9191 p_report = 1;
9192 }
Bram Moolenaar1e015462005-09-25 22:16:38 +00009193 if ((p_sj < -100 || p_sj >= Rows) && full_screen)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009194 {
9195 if (Rows != old_Rows) /* Rows changed, just adjust p_sj */
9196 p_sj = Rows / 2;
9197 else
9198 {
9199 errmsg = e_scroll;
9200 p_sj = 1;
9201 }
9202 }
9203 if (p_so < 0 && full_screen)
9204 {
9205 errmsg = e_scroll;
9206 p_so = 0;
9207 }
9208 if (p_siso < 0 && full_screen)
9209 {
9210 errmsg = e_positive;
9211 p_siso = 0;
9212 }
9213#ifdef FEAT_CMDWIN
9214 if (p_cwh < 1)
9215 {
9216 errmsg = e_positive;
9217 p_cwh = 1;
9218 }
9219#endif
9220 if (p_ut < 0)
9221 {
9222 errmsg = e_positive;
9223 p_ut = 2000;
9224 }
9225 if (p_ss < 0)
9226 {
9227 errmsg = e_positive;
9228 p_ss = 0;
9229 }
9230
9231 /* May set global value for local option. */
9232 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
9233 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = *pp;
9234
9235 options[opt_idx].flags |= P_WAS_SET;
9236
Bram Moolenaar53744302015-07-17 17:38:22 +02009237#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
9238 if (!starting && errmsg == NULL)
9239 {
9240 char_u buf_old[11], buf_new[11], buf_type[7];
Bram Moolenaarfb9bc482015-07-17 22:04:48 +02009241 vim_snprintf((char *)buf_old, 10, "%ld", old_value);
9242 vim_snprintf((char *)buf_new, 10, "%ld", value);
9243 vim_snprintf((char *)buf_type, 7, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar53744302015-07-17 17:38:22 +02009244 set_vim_var_string(VV_OPTION_NEW, buf_new, -1);
9245 set_vim_var_string(VV_OPTION_OLD, buf_old, -1);
9246 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
9247 apply_autocmds(EVENT_OPTIONSET, (char_u *) options[opt_idx].fullname, NULL, FALSE, NULL);
9248 reset_v_option_vars();
9249 }
9250#endif
9251
Bram Moolenaar071d4272004-06-13 20:20:40 +00009252 comp_col(); /* in case 'columns' or 'ls' changed */
Bram Moolenaar913077c2012-03-28 19:59:04 +02009253 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01009254 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02009255 curwin->w_set_curswant = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009256 check_redraw(options[opt_idx].flags);
9257
9258 return errmsg;
9259}
9260
9261/*
9262 * Called after an option changed: check if something needs to be redrawn.
9263 */
9264 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01009265check_redraw(long_u flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009266{
9267 /* Careful: P_RCLR and P_RALL are a combination of other P_ flags */
Bram Moolenaar70b2a562012-01-10 22:26:17 +01009268 int doclear = (flags & P_RCLR) == P_RCLR;
9269 int all = ((flags & P_RALL) == P_RALL || doclear);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009270
9271#ifdef FEAT_WINDOWS
9272 if ((flags & P_RSTAT) || all) /* mark all status lines dirty */
9273 status_redraw_all();
9274#endif
9275
9276 if ((flags & P_RBUF) || (flags & P_RWIN) || all)
9277 changed_window_setting();
9278 if (flags & P_RBUF)
9279 redraw_curbuf_later(NOT_VALID);
Bram Moolenaara2477fd2016-12-03 15:13:20 +01009280 if (flags & P_RWINONLY)
9281 redraw_later(NOT_VALID);
Bram Moolenaar70b2a562012-01-10 22:26:17 +01009282 if (doclear)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009283 redraw_all_later(CLEAR);
9284 else if (all)
9285 redraw_all_later(NOT_VALID);
9286}
9287
9288/*
9289 * Find index for option 'arg'.
9290 * Return -1 if not found.
9291 */
9292 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009293findoption(char_u *arg)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009294{
9295 int opt_idx;
9296 char *s, *p;
9297 static short quick_tab[27] = {0, 0}; /* quick access table */
9298 int is_term_opt;
9299
9300 /*
9301 * For first call: Initialize the quick-access table.
9302 * It contains the index for the first option that starts with a certain
9303 * letter. There are 26 letters, plus the first "t_" option.
9304 */
9305 if (quick_tab[1] == 0)
9306 {
9307 p = options[0].fullname;
9308 for (opt_idx = 1; (s = options[opt_idx].fullname) != NULL; opt_idx++)
9309 {
9310 if (s[0] != p[0])
9311 {
9312 if (s[0] == 't' && s[1] == '_')
9313 quick_tab[26] = opt_idx;
9314 else
9315 quick_tab[CharOrdLow(s[0])] = opt_idx;
9316 }
9317 p = s;
9318 }
9319 }
9320
9321 /*
9322 * Check for name starting with an illegal character.
9323 */
9324#ifdef EBCDIC
9325 if (!islower(arg[0]))
9326#else
9327 if (arg[0] < 'a' || arg[0] > 'z')
9328#endif
9329 return -1;
9330
9331 is_term_opt = (arg[0] == 't' && arg[1] == '_');
9332 if (is_term_opt)
9333 opt_idx = quick_tab[26];
9334 else
9335 opt_idx = quick_tab[CharOrdLow(arg[0])];
9336 for ( ; (s = options[opt_idx].fullname) != NULL; opt_idx++)
9337 {
9338 if (STRCMP(arg, s) == 0) /* match full name */
9339 break;
9340 }
9341 if (s == NULL && !is_term_opt)
9342 {
9343 opt_idx = quick_tab[CharOrdLow(arg[0])];
9344 for ( ; options[opt_idx].fullname != NULL; opt_idx++)
9345 {
9346 s = options[opt_idx].shortname;
9347 if (s != NULL && STRCMP(arg, s) == 0) /* match short name */
9348 break;
9349 s = NULL;
9350 }
9351 }
9352 if (s == NULL)
9353 opt_idx = -1;
9354 return opt_idx;
9355}
9356
Bram Moolenaar325b7a22004-07-05 15:58:32 +00009357#if defined(FEAT_EVAL) || defined(FEAT_TCL) || defined(FEAT_MZSCHEME)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009358/*
9359 * Get the value for an option.
9360 *
9361 * Returns:
9362 * Number or Toggle option: 1, *numval gets value.
9363 * String option: 0, *stringval gets allocated string.
9364 * Hidden Number or Toggle option: -1.
9365 * hidden String option: -2.
9366 * unknown option: -3.
9367 */
9368 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009369get_option_value(
9370 char_u *name,
9371 long *numval,
9372 char_u **stringval, /* NULL when only checking existence */
9373 int opt_flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009374{
9375 int opt_idx;
9376 char_u *varp;
9377
9378 opt_idx = findoption(name);
9379 if (opt_idx < 0) /* unknown option */
Bram Moolenaare353c402017-02-04 19:49:16 +01009380 {
9381 int key;
9382
9383 if (STRLEN(name) == 4 && name[0] == 't' && name[1] == '_'
9384 && (key = find_key_option(name)) != 0)
9385 {
9386 char_u key_name[2];
9387 char_u *p;
9388
9389 if (key < 0)
9390 {
9391 key_name[0] = KEY2TERMCAP0(key);
9392 key_name[1] = KEY2TERMCAP1(key);
9393 }
9394 else
9395 {
9396 key_name[0] = KS_KEY;
9397 key_name[1] = (key & 0xff);
9398 }
9399 p = find_termcode(key_name);
9400 if (p != NULL)
9401 {
9402 if (stringval != NULL)
9403 *stringval = vim_strsave(p);
9404 return 0;
9405 }
9406 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009407 return -3;
Bram Moolenaare353c402017-02-04 19:49:16 +01009408 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009409
9410 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
9411
9412 if (options[opt_idx].flags & P_STRING)
9413 {
9414 if (varp == NULL) /* hidden option */
9415 return -2;
9416 if (stringval != NULL)
9417 {
9418#ifdef FEAT_CRYPT
9419 /* never return the value of the crypt key */
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00009420 if ((char_u **)varp == &curbuf->b_p_key
9421 && **(char_u **)(varp) != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009422 *stringval = vim_strsave((char_u *)"*****");
9423 else
9424#endif
9425 *stringval = vim_strsave(*(char_u **)(varp));
9426 }
9427 return 0;
9428 }
9429
9430 if (varp == NULL) /* hidden option */
9431 return -1;
9432 if (options[opt_idx].flags & P_NUM)
9433 *numval = *(long *)varp;
9434 else
9435 {
9436 /* Special case: 'modified' is b_changed, but we also want to consider
9437 * it set when 'ff' or 'fenc' changed. */
9438 if ((int *)varp == &curbuf->b_changed)
9439 *numval = curbufIsChanged();
9440 else
Bram Moolenaar2acfbed2016-07-01 23:14:02 +02009441 *numval = (long) *(int *)varp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009442 }
9443 return 1;
9444}
9445#endif
9446
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009447#if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009448/*
9449 * Returns the option attributes and its value. Unlike the above function it
9450 * will return either global value or local value of the option depending on
9451 * what was requested, but it will never return global value if it was
9452 * requested to return local one and vice versa. Neither it will return
9453 * buffer-local value if it was requested to return window-local one.
9454 *
9455 * Pretends that option is absent if it is not present in the requested scope
9456 * (i.e. has no global, window-local or buffer-local value depending on
9457 * opt_type). Uses
9458 *
9459 * Returned flags:
Bram Moolenaar75a8d742014-05-07 15:10:21 +02009460 * 0 hidden or unknown option, also option that does not have requested
9461 * type (see SREQ_* in vim.h)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009462 * see SOPT_* in vim.h for other flags
9463 *
9464 * Possible opt_type values: see SREQ_* in vim.h
9465 */
9466 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009467get_option_value_strict(
9468 char_u *name,
9469 long *numval,
9470 char_u **stringval, /* NULL when only obtaining attributes */
9471 int opt_type,
9472 void *from)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009473{
9474 int opt_idx;
Bram Moolenaar68001862013-05-11 13:45:05 +02009475 char_u *varp = NULL;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009476 struct vimoption *p;
9477 int r = 0;
9478
9479 opt_idx = findoption(name);
9480 if (opt_idx < 0)
9481 return 0;
9482
9483 p = &(options[opt_idx]);
9484
9485 /* Hidden option */
9486 if (p->var == NULL)
9487 return 0;
9488
9489 if (p->flags & P_BOOL)
9490 r |= SOPT_BOOL;
9491 else if (p->flags & P_NUM)
9492 r |= SOPT_NUM;
9493 else if (p->flags & P_STRING)
9494 r |= SOPT_STRING;
9495
9496 if (p->indir == PV_NONE)
9497 {
9498 if (opt_type == SREQ_GLOBAL)
9499 r |= SOPT_GLOBAL;
9500 else
9501 return 0; /* Did not request global-only option */
9502 }
9503 else
9504 {
9505 if (p->indir & PV_BOTH)
9506 r |= SOPT_GLOBAL;
9507 else if (opt_type == SREQ_GLOBAL)
9508 return 0; /* Requested global option */
9509
9510 if (p->indir & PV_WIN)
9511 {
9512 if (opt_type == SREQ_BUF)
9513 return 0; /* Did not request window-local option */
9514 else
9515 r |= SOPT_WIN;
9516 }
9517 else if (p->indir & PV_BUF)
9518 {
9519 if (opt_type == SREQ_WIN)
9520 return 0; /* Did not request buffer-local option */
9521 else
9522 r |= SOPT_BUF;
9523 }
9524 }
9525
9526 if (stringval == NULL)
9527 return r;
9528
9529 if (opt_type == SREQ_GLOBAL)
9530 varp = p->var;
9531 else
9532 {
9533 if (opt_type == SREQ_BUF)
9534 {
9535 /* Special case: 'modified' is b_changed, but we also want to
9536 * consider it set when 'ff' or 'fenc' changed. */
9537 if (p->indir == PV_MOD)
9538 {
9539 *numval = bufIsChanged((buf_T *) from);
9540 varp = NULL;
9541 }
9542#ifdef FEAT_CRYPT
9543 else if (p->indir == PV_KEY)
9544 {
9545 /* never return the value of the crypt key */
9546 *stringval = NULL;
9547 varp = NULL;
9548 }
9549#endif
9550 else
9551 {
9552 aco_save_T aco;
9553 aucmd_prepbuf(&aco, (buf_T *) from);
9554 varp = get_varp(p);
9555 aucmd_restbuf(&aco);
9556 }
9557 }
9558 else if (opt_type == SREQ_WIN)
9559 {
9560 win_T *save_curwin;
9561 save_curwin = curwin;
9562 curwin = (win_T *) from;
9563 curbuf = curwin->w_buffer;
9564 varp = get_varp(p);
9565 curwin = save_curwin;
9566 curbuf = curwin->w_buffer;
9567 }
9568 if (varp == p->var)
9569 return (r | SOPT_UNSET);
9570 }
9571
9572 if (varp != NULL)
9573 {
9574 if (p->flags & P_STRING)
9575 *stringval = vim_strsave(*(char_u **)(varp));
9576 else if (p->flags & P_NUM)
9577 *numval = *(long *) varp;
9578 else
9579 *numval = *(int *)varp;
9580 }
9581
9582 return r;
9583}
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009584
9585/*
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009586 * Iterate over options. First argument is a pointer to a pointer to a
9587 * structure inside options[] array, second is option type like in the above
9588 * function.
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009589 *
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009590 * If first argument points to NULL it is assumed that iteration just started
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009591 * and caller needs the very first value.
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009592 * If first argument points to the end marker function returns NULL and sets
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009593 * first argument to NULL.
9594 *
9595 * Returns full option name for current option on each call.
9596 */
9597 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009598option_iter_next(void **option, int opt_type)
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009599{
9600 struct vimoption *ret = NULL;
9601 do
9602 {
9603 if (*option == NULL)
9604 *option = (void *) options;
9605 else if (((struct vimoption *) (*option))->fullname == NULL)
9606 {
9607 *option = NULL;
9608 return NULL;
9609 }
9610 else
9611 *option = (void *) (((struct vimoption *) (*option)) + 1);
9612
9613 ret = ((struct vimoption *) (*option));
9614
9615 /* Hidden option */
9616 if (ret->var == NULL)
9617 {
9618 ret = NULL;
9619 continue;
9620 }
9621
9622 switch (opt_type)
9623 {
9624 case SREQ_GLOBAL:
9625 if (!(ret->indir == PV_NONE || ret->indir & PV_BOTH))
9626 ret = NULL;
9627 break;
9628 case SREQ_BUF:
9629 if (!(ret->indir & PV_BUF))
9630 ret = NULL;
9631 break;
9632 case SREQ_WIN:
9633 if (!(ret->indir & PV_WIN))
9634 ret = NULL;
9635 break;
9636 default:
Bram Moolenaar95f09602016-11-10 20:01:45 +01009637 internal_error("option_iter_next()");
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009638 return NULL;
9639 }
9640 }
9641 while (ret == NULL);
9642
9643 return (char_u *)ret->fullname;
9644}
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009645#endif
9646
Bram Moolenaar071d4272004-06-13 20:20:40 +00009647/*
9648 * Set the value of option "name".
9649 * Use "string" for string options, use "number" for other options.
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009650 *
9651 * Returns NULL on success or error message on error.
Bram Moolenaar071d4272004-06-13 20:20:40 +00009652 */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009653 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009654set_option_value(
9655 char_u *name,
9656 long number,
9657 char_u *string,
9658 int opt_flags) /* OPT_LOCAL or 0 (both) */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009659{
9660 int opt_idx;
9661 char_u *varp;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00009662 long_u flags;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009663
9664 opt_idx = findoption(name);
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00009665 if (opt_idx < 0)
Bram Moolenaare353c402017-02-04 19:49:16 +01009666 {
9667 int key;
9668
9669 if (STRLEN(name) == 4 && name[0] == 't' && name[1] == '_'
9670 && (key = find_key_option(name)) != 0)
9671 {
9672 char_u key_name[2];
9673
9674 if (key < 0)
9675 {
9676 key_name[0] = KEY2TERMCAP0(key);
9677 key_name[1] = KEY2TERMCAP1(key);
9678 }
9679 else
9680 {
9681 key_name[0] = KS_KEY;
9682 key_name[1] = (key & 0xff);
9683 }
9684 add_termcode(key_name, string, FALSE);
9685 if (full_screen)
9686 ttest(FALSE);
9687 redraw_all_later(CLEAR);
9688 return NULL;
9689 }
9690
Bram Moolenaar071d4272004-06-13 20:20:40 +00009691 EMSG2(_("E355: Unknown option: %s"), name);
Bram Moolenaare353c402017-02-04 19:49:16 +01009692 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009693 else
9694 {
9695 flags = options[opt_idx].flags;
9696#ifdef HAVE_SANDBOX
9697 /* Disallow changing some options in the sandbox */
9698 if (sandbox > 0 && (flags & P_SECURE))
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009699 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00009700 EMSG(_(e_sandbox));
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009701 return NULL;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009702 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009703#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009704 if (flags & P_STRING)
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009705 return set_string_option(opt_idx, string, opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009706 else
9707 {
Bram Moolenaarb3163762008-07-08 15:15:08 +00009708 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009709 if (varp != NULL) /* hidden option is not changed */
9710 {
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009711 if (number == 0 && string != NULL)
9712 {
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009713 int idx;
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009714
9715 /* Either we are given a string or we are setting option
9716 * to zero. */
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009717 for (idx = 0; string[idx] == '0'; ++idx)
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009718 ;
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009719 if (string[idx] != NUL || idx == 0)
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009720 {
9721 /* There's another character after zeros or the string
9722 * is empty. In both cases, we are trying to set a
9723 * num option using a string. */
9724 EMSG3(_("E521: Number required: &%s = '%s'"),
9725 name, string);
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009726 return NULL; /* do nothing as we hit an error */
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009727
9728 }
9729 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009730 if (flags & P_NUM)
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009731 return set_num_option(opt_idx, varp, number,
Bram Moolenaar555b2802005-05-19 21:08:39 +00009732 NULL, 0, opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009733 else
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009734 return set_bool_option(opt_idx, varp, (int)number,
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009735 opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009736 }
9737 }
9738 }
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009739 return NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009740}
9741
9742/*
9743 * Get the terminal code for a terminal option.
9744 * Returns NULL when not found.
9745 */
9746 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009747get_term_code(char_u *tname)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009748{
9749 int opt_idx;
9750 char_u *varp;
9751
9752 if (tname[0] != 't' || tname[1] != '_' ||
9753 tname[2] == NUL || tname[3] == NUL)
9754 return NULL;
9755 if ((opt_idx = findoption(tname)) >= 0)
9756 {
9757 varp = get_varp(&(options[opt_idx]));
9758 if (varp != NULL)
9759 varp = *(char_u **)(varp);
9760 return varp;
9761 }
9762 return find_termcode(tname + 2);
9763}
9764
9765 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009766get_highlight_default(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009767{
9768 int i;
9769
9770 i = findoption((char_u *)"hl");
9771 if (i >= 0)
9772 return options[i].def_val[VI_DEFAULT];
9773 return (char_u *)NULL;
9774}
9775
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00009776#if defined(FEAT_MBYTE) || defined(PROTO)
9777 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009778get_encoding_default(void)
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00009779{
9780 int i;
9781
9782 i = findoption((char_u *)"enc");
9783 if (i >= 0)
9784 return options[i].def_val[VI_DEFAULT];
9785 return (char_u *)NULL;
9786}
9787#endif
9788
Bram Moolenaar071d4272004-06-13 20:20:40 +00009789/*
9790 * Translate a string like "t_xx", "<t_xx>" or "<S-Tab>" to a key number.
9791 */
9792 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009793find_key_option(char_u *arg)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009794{
9795 int key;
9796 int modifiers;
9797
9798 /*
9799 * Don't use get_special_key_code() for t_xx, we don't want it to call
9800 * add_termcap_entry().
9801 */
9802 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
9803 key = TERMCAP2KEY(arg[2], arg[3]);
9804 else
9805 {
9806 --arg; /* put arg at the '<' */
9807 modifiers = 0;
Bram Moolenaar35a4cfa2016-08-14 16:07:48 +02009808 key = find_special_key(&arg, &modifiers, TRUE, TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009809 if (modifiers) /* can't handle modifiers here */
9810 key = 0;
9811 }
9812 return key;
9813}
9814
9815/*
9816 * if 'all' == 0: show changed options
9817 * if 'all' == 1: show all normal options
9818 * if 'all' == 2: show all terminal options
9819 */
9820 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01009821showoptions(
9822 int all,
9823 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009824{
9825 struct vimoption *p;
9826 int col;
9827 int isterm;
9828 char_u *varp;
9829 struct vimoption **items;
9830 int item_count;
9831 int run;
9832 int row, rows;
9833 int cols;
9834 int i;
9835 int len;
9836
9837#define INC 20
9838#define GAP 3
9839
9840 items = (struct vimoption **)alloc((unsigned)(sizeof(struct vimoption *) *
9841 PARAM_COUNT));
9842 if (items == NULL)
9843 return;
9844
9845 /* Highlight title */
9846 if (all == 2)
9847 MSG_PUTS_TITLE(_("\n--- Terminal codes ---"));
9848 else if (opt_flags & OPT_GLOBAL)
9849 MSG_PUTS_TITLE(_("\n--- Global option values ---"));
9850 else if (opt_flags & OPT_LOCAL)
9851 MSG_PUTS_TITLE(_("\n--- Local option values ---"));
9852 else
9853 MSG_PUTS_TITLE(_("\n--- Options ---"));
9854
9855 /*
9856 * do the loop two times:
9857 * 1. display the short items
9858 * 2. display the long items (only strings and numbers)
9859 */
9860 for (run = 1; run <= 2 && !got_int; ++run)
9861 {
9862 /*
9863 * collect the items in items[]
9864 */
9865 item_count = 0;
9866 for (p = &options[0]; p->fullname != NULL; p++)
9867 {
9868 varp = NULL;
9869 isterm = istermoption(p);
9870 if (opt_flags != 0)
9871 {
9872 if (p->indir != PV_NONE && !isterm)
9873 varp = get_varp_scope(p, opt_flags);
9874 }
9875 else
9876 varp = get_varp(p);
9877 if (varp != NULL
9878 && ((all == 2 && isterm)
9879 || (all == 1 && !isterm)
9880 || (all == 0 && !optval_default(p, varp))))
9881 {
9882 if (p->flags & P_BOOL)
9883 len = 1; /* a toggle option fits always */
9884 else
9885 {
9886 option_value2string(p, opt_flags);
9887 len = (int)STRLEN(p->fullname) + vim_strsize(NameBuff) + 1;
9888 }
9889 if ((len <= INC - GAP && run == 1) ||
9890 (len > INC - GAP && run == 2))
9891 items[item_count++] = p;
9892 }
9893 }
9894
9895 /*
9896 * display the items
9897 */
9898 if (run == 1)
9899 {
9900 cols = (Columns + GAP - 3) / INC;
9901 if (cols == 0)
9902 cols = 1;
9903 rows = (item_count + cols - 1) / cols;
9904 }
9905 else /* run == 2 */
9906 rows = item_count;
9907 for (row = 0; row < rows && !got_int; ++row)
9908 {
9909 msg_putchar('\n'); /* go to next line */
9910 if (got_int) /* 'q' typed in more */
9911 break;
9912 col = 0;
9913 for (i = row; i < item_count; i += rows)
9914 {
9915 msg_col = col; /* make columns */
9916 showoneopt(items[i], opt_flags);
9917 col += INC;
9918 }
9919 out_flush();
9920 ui_breakcheck();
9921 }
9922 }
9923 vim_free(items);
9924}
9925
9926/*
9927 * Return TRUE if option "p" has its default value.
9928 */
9929 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009930optval_default(struct vimoption *p, char_u *varp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009931{
9932 int dvi;
9933
9934 if (varp == NULL)
9935 return TRUE; /* hidden option is always at default */
9936 dvi = ((p->flags & P_VI_DEF) || p_cp) ? VI_DEFAULT : VIM_DEFAULT;
9937 if (p->flags & P_NUM)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00009938 return (*(long *)varp == (long)(long_i)p->def_val[dvi]);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009939 if (p->flags & P_BOOL)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00009940 /* the cast to long is required for Manx C, long_i is
9941 * needed for MSVC */
9942 return (*(int *)varp == (int)(long)(long_i)p->def_val[dvi]);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009943 /* P_STRING */
9944 return (STRCMP(*(char_u **)varp, p->def_val[dvi]) == 0);
9945}
9946
9947/*
9948 * showoneopt: show the value of one option
9949 * must not be called with a hidden option!
9950 */
9951 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01009952showoneopt(
9953 struct vimoption *p,
9954 int opt_flags) /* OPT_LOCAL or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009955{
Bram Moolenaar26a60b42005-02-22 08:49:11 +00009956 char_u *varp;
9957 int save_silent = silent_mode;
9958
9959 silent_mode = FALSE;
9960 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009961
9962 varp = get_varp_scope(p, opt_flags);
9963
9964 /* for 'modified' we also need to check if 'ff' or 'fenc' changed. */
9965 if ((p->flags & P_BOOL) && ((int *)varp == &curbuf->b_changed
9966 ? !curbufIsChanged() : !*(int *)varp))
9967 MSG_PUTS("no");
9968 else if ((p->flags & P_BOOL) && *(int *)varp < 0)
9969 MSG_PUTS("--");
9970 else
9971 MSG_PUTS(" ");
9972 MSG_PUTS(p->fullname);
9973 if (!(p->flags & P_BOOL))
9974 {
9975 msg_putchar('=');
9976 /* put value string in NameBuff */
9977 option_value2string(p, opt_flags);
9978 msg_outtrans(NameBuff);
9979 }
Bram Moolenaar26a60b42005-02-22 08:49:11 +00009980
9981 silent_mode = save_silent;
9982 info_message = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009983}
9984
9985/*
9986 * Write modified options as ":set" commands to a file.
9987 *
9988 * There are three values for "opt_flags":
9989 * OPT_GLOBAL: Write global option values and fresh values of
9990 * buffer-local options (used for start of a session
9991 * file).
9992 * OPT_GLOBAL + OPT_LOCAL: Idem, add fresh values of window-local options for
9993 * curwin (used for a vimrc file).
9994 * OPT_LOCAL: Write buffer-local option values for curbuf, fresh
9995 * and local values for window-local options of
9996 * curwin. Local values are also written when at the
9997 * default value, because a modeline or autocommand
9998 * may have set them when doing ":edit file" and the
9999 * user has set them back at the default or fresh
10000 * value.
10001 * When "local_only" is TRUE, don't write fresh
10002 * values, only local values (for ":mkview").
10003 * (fresh value = value used for a new buffer or window for a local option).
10004 *
10005 * Return FAIL on error, OK otherwise.
10006 */
10007 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010008makeset(FILE *fd, int opt_flags, int local_only)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010009{
10010 struct vimoption *p;
10011 char_u *varp; /* currently used value */
10012 char_u *varp_fresh; /* local value */
10013 char_u *varp_local = NULL; /* fresh value */
10014 char *cmd;
10015 int round;
Bram Moolenaar7fd16022007-09-06 14:35:35 +000010016 int pri;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010017
10018 /*
10019 * The options that don't have a default (terminal name, columns, lines)
10020 * are never written. Terminal options are also not written.
Bram Moolenaar7fd16022007-09-06 14:35:35 +000010021 * Do the loop over "options[]" twice: once for options with the
10022 * P_PRI_MKRC flag and once without.
Bram Moolenaar071d4272004-06-13 20:20:40 +000010023 */
Bram Moolenaar7fd16022007-09-06 14:35:35 +000010024 for (pri = 1; pri >= 0; --pri)
10025 {
10026 for (p = &options[0]; !istermoption(p); p++)
10027 if (!(p->flags & P_NO_MKRC)
10028 && !istermoption(p)
10029 && ((pri == 1) == ((p->flags & P_PRI_MKRC) != 0)))
Bram Moolenaar071d4272004-06-13 20:20:40 +000010030 {
10031 /* skip global option when only doing locals */
10032 if (p->indir == PV_NONE && !(opt_flags & OPT_GLOBAL))
10033 continue;
10034
10035 /* Do not store options like 'bufhidden' and 'syntax' in a vimrc
10036 * file, they are always buffer-specific. */
10037 if ((opt_flags & OPT_GLOBAL) && (p->flags & P_NOGLOB))
10038 continue;
10039
10040 /* Global values are only written when not at the default value. */
10041 varp = get_varp_scope(p, opt_flags);
10042 if ((opt_flags & OPT_GLOBAL) && optval_default(p, varp))
10043 continue;
10044
10045 round = 2;
10046 if (p->indir != PV_NONE)
10047 {
10048 if (p->var == VAR_WIN)
10049 {
10050 /* skip window-local option when only doing globals */
10051 if (!(opt_flags & OPT_LOCAL))
10052 continue;
10053 /* When fresh value of window-local option is not at the
10054 * default, need to write it too. */
10055 if (!(opt_flags & OPT_GLOBAL) && !local_only)
10056 {
10057 varp_fresh = get_varp_scope(p, OPT_GLOBAL);
10058 if (!optval_default(p, varp_fresh))
10059 {
10060 round = 1;
10061 varp_local = varp;
10062 varp = varp_fresh;
10063 }
10064 }
10065 }
10066 }
10067
10068 /* Round 1: fresh value for window-local options.
10069 * Round 2: other values */
10070 for ( ; round <= 2; varp = varp_local, ++round)
10071 {
10072 if (round == 1 || (opt_flags & OPT_GLOBAL))
10073 cmd = "set";
10074 else
10075 cmd = "setlocal";
10076
10077 if (p->flags & P_BOOL)
10078 {
10079 if (put_setbool(fd, cmd, p->fullname, *(int *)varp) == FAIL)
10080 return FAIL;
10081 }
10082 else if (p->flags & P_NUM)
10083 {
10084 if (put_setnum(fd, cmd, p->fullname, (long *)varp) == FAIL)
10085 return FAIL;
10086 }
10087 else /* P_STRING */
10088 {
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010089#if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD)
10090 int do_endif = FALSE;
10091
Bram Moolenaar071d4272004-06-13 20:20:40 +000010092 /* Don't set 'syntax' and 'filetype' again if the value is
10093 * already right, avoids reloading the syntax file. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010094 if (
10095# if defined(FEAT_SYN_HL)
10096 p->indir == PV_SYN
10097# if defined(FEAT_AUTOCMD)
10098 ||
10099# endif
10100# endif
10101# if defined(FEAT_AUTOCMD)
Bram Moolenaar15bfa092008-07-24 16:45:38 +000010102 p->indir == PV_FT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010103# endif
Bram Moolenaar15bfa092008-07-24 16:45:38 +000010104 )
Bram Moolenaar071d4272004-06-13 20:20:40 +000010105 {
10106 if (fprintf(fd, "if &%s != '%s'", p->fullname,
10107 *(char_u **)(varp)) < 0
10108 || put_eol(fd) < 0)
10109 return FAIL;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010110 do_endif = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010111 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010112#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010113 if (put_setstring(fd, cmd, p->fullname, (char_u **)varp,
10114 (p->flags & P_EXPAND) != 0) == FAIL)
10115 return FAIL;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010116#if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD)
10117 if (do_endif)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010118 {
10119 if (put_line(fd, "endif") == FAIL)
10120 return FAIL;
10121 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010122#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010123 }
10124 }
10125 }
Bram Moolenaar7fd16022007-09-06 14:35:35 +000010126 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000010127 return OK;
10128}
10129
10130#if defined(FEAT_FOLDING) || defined(PROTO)
10131/*
10132 * Generate set commands for the local fold options only. Used when
10133 * 'sessionoptions' or 'viewoptions' contains "folds" but not "options".
10134 */
10135 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010136makefoldset(FILE *fd)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010137{
10138 if (put_setstring(fd, "setlocal", "fdm", &curwin->w_p_fdm, FALSE) == FAIL
10139# ifdef FEAT_EVAL
10140 || put_setstring(fd, "setlocal", "fde", &curwin->w_p_fde, FALSE)
10141 == FAIL
10142# endif
10143 || put_setstring(fd, "setlocal", "fmr", &curwin->w_p_fmr, FALSE)
10144 == FAIL
10145 || put_setstring(fd, "setlocal", "fdi", &curwin->w_p_fdi, FALSE)
10146 == FAIL
10147 || put_setnum(fd, "setlocal", "fdl", &curwin->w_p_fdl) == FAIL
10148 || put_setnum(fd, "setlocal", "fml", &curwin->w_p_fml) == FAIL
10149 || put_setnum(fd, "setlocal", "fdn", &curwin->w_p_fdn) == FAIL
10150 || put_setbool(fd, "setlocal", "fen", curwin->w_p_fen) == FAIL
10151 )
10152 return FAIL;
10153
10154 return OK;
10155}
10156#endif
10157
10158 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010159put_setstring(
10160 FILE *fd,
10161 char *cmd,
10162 char *name,
10163 char_u **valuep,
10164 int expand)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010165{
10166 char_u *s;
Bram Moolenaarf8441472011-04-28 17:24:58 +020010167 char_u *buf;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010168
10169 if (fprintf(fd, "%s %s=", cmd, name) < 0)
10170 return FAIL;
10171 if (*valuep != NULL)
10172 {
10173 /* Output 'pastetoggle' as key names. For other
10174 * options some characters have to be escaped with
10175 * CTRL-V or backslash */
10176 if (valuep == &p_pt)
10177 {
10178 s = *valuep;
10179 while (*s != NUL)
Bram Moolenaar7d96acd2008-06-09 15:07:54 +000010180 if (put_escstr(fd, str2special(&s, FALSE), 2) == FAIL)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010181 return FAIL;
10182 }
10183 else if (expand)
10184 {
Bram Moolenaarf8441472011-04-28 17:24:58 +020010185 buf = alloc(MAXPATHL);
10186 if (buf == NULL)
10187 return FAIL;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010188 home_replace(NULL, *valuep, buf, MAXPATHL, FALSE);
10189 if (put_escstr(fd, buf, 2) == FAIL)
Bram Moolenaarf8441472011-04-28 17:24:58 +020010190 {
10191 vim_free(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010192 return FAIL;
Bram Moolenaarf8441472011-04-28 17:24:58 +020010193 }
10194 vim_free(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010195 }
10196 else if (put_escstr(fd, *valuep, 2) == FAIL)
10197 return FAIL;
10198 }
10199 if (put_eol(fd) < 0)
10200 return FAIL;
10201 return OK;
10202}
10203
10204 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010205put_setnum(
10206 FILE *fd,
10207 char *cmd,
10208 char *name,
10209 long *valuep)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010210{
10211 long wc;
10212
10213 if (fprintf(fd, "%s %s=", cmd, name) < 0)
10214 return FAIL;
10215 if (wc_use_keyname((char_u *)valuep, &wc))
10216 {
10217 /* print 'wildchar' and 'wildcharm' as a key name */
10218 if (fputs((char *)get_special_key_name((int)wc, 0), fd) < 0)
10219 return FAIL;
10220 }
10221 else if (fprintf(fd, "%ld", *valuep) < 0)
10222 return FAIL;
10223 if (put_eol(fd) < 0)
10224 return FAIL;
10225 return OK;
10226}
10227
10228 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010229put_setbool(
10230 FILE *fd,
10231 char *cmd,
10232 char *name,
10233 int value)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010234{
Bram Moolenaar893de922007-10-02 18:40:57 +000010235 if (value < 0) /* global/local option using global value */
10236 return OK;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010237 if (fprintf(fd, "%s %s%s", cmd, value ? "" : "no", name) < 0
10238 || put_eol(fd) < 0)
10239 return FAIL;
10240 return OK;
10241}
10242
10243/*
10244 * Clear all the terminal options.
10245 * If the option has been allocated, free the memory.
10246 * Terminal options are never hidden or indirect.
10247 */
10248 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010249clear_termoptions(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010250{
Bram Moolenaar071d4272004-06-13 20:20:40 +000010251 /*
10252 * Reset a few things before clearing the old options. This may cause
10253 * outputting a few things that the terminal doesn't understand, but the
10254 * screen will be cleared later, so this is OK.
10255 */
10256#ifdef FEAT_MOUSE_TTY
10257 mch_setmouse(FALSE); /* switch mouse off */
10258#endif
10259#ifdef FEAT_TITLE
10260 mch_restore_title(3); /* restore window titles */
10261#endif
10262#if defined(FEAT_XCLIPBOARD) && defined(FEAT_GUI)
10263 /* When starting the GUI close the display opened for the clipboard.
10264 * After restoring the title, because that will need the display. */
10265 if (gui.starting)
10266 clear_xterm_clip();
10267#endif
Bram Moolenaarcea912a2016-10-12 14:20:24 +020010268 stoptermcap(); /* stop termcap mode */
Bram Moolenaar071d4272004-06-13 20:20:40 +000010269
Bram Moolenaarf461c8e2005-06-25 23:04:51 +000010270 free_termoptions();
10271}
10272
10273 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010274free_termoptions(void)
Bram Moolenaarf461c8e2005-06-25 23:04:51 +000010275{
10276 struct vimoption *p;
10277
Bram Moolenaar071d4272004-06-13 20:20:40 +000010278 for (p = &options[0]; p->fullname != NULL; p++)
10279 if (istermoption(p))
10280 {
10281 if (p->flags & P_ALLOCED)
10282 free_string_option(*(char_u **)(p->var));
10283 if (p->flags & P_DEF_ALLOCED)
10284 free_string_option(p->def_val[VI_DEFAULT]);
10285 *(char_u **)(p->var) = empty_option;
10286 p->def_val[VI_DEFAULT] = empty_option;
10287 p->flags &= ~(P_ALLOCED|P_DEF_ALLOCED);
10288 }
10289 clear_termcodes();
10290}
10291
10292/*
Bram Moolenaar363cb672009-07-22 12:28:17 +000010293 * Free the string for one term option, if it was allocated.
10294 * Set the string to empty_option and clear allocated flag.
10295 * "var" points to the option value.
10296 */
10297 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010298free_one_termoption(char_u *var)
Bram Moolenaar363cb672009-07-22 12:28:17 +000010299{
10300 struct vimoption *p;
10301
10302 for (p = &options[0]; p->fullname != NULL; p++)
10303 if (p->var == var)
10304 {
10305 if (p->flags & P_ALLOCED)
10306 free_string_option(*(char_u **)(p->var));
10307 *(char_u **)(p->var) = empty_option;
10308 p->flags &= ~P_ALLOCED;
10309 break;
10310 }
10311}
10312
10313/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000010314 * Set the terminal option defaults to the current value.
10315 * Used after setting the terminal name.
10316 */
10317 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010318set_term_defaults(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010319{
10320 struct vimoption *p;
10321
10322 for (p = &options[0]; p->fullname != NULL; p++)
10323 {
10324 if (istermoption(p) && p->def_val[VI_DEFAULT] != *(char_u **)(p->var))
10325 {
10326 if (p->flags & P_DEF_ALLOCED)
10327 {
10328 free_string_option(p->def_val[VI_DEFAULT]);
10329 p->flags &= ~P_DEF_ALLOCED;
10330 }
10331 p->def_val[VI_DEFAULT] = *(char_u **)(p->var);
10332 if (p->flags & P_ALLOCED)
10333 {
10334 p->flags |= P_DEF_ALLOCED;
10335 p->flags &= ~P_ALLOCED; /* don't free the value now */
10336 }
10337 }
10338 }
10339}
10340
10341/*
10342 * return TRUE if 'p' starts with 't_'
10343 */
10344 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010345istermoption(struct vimoption *p)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010346{
10347 return (p->fullname[0] == 't' && p->fullname[1] == '_');
10348}
10349
10350/*
10351 * Compute columns for ruler and shown command. 'sc_col' is also used to
10352 * decide what the maximum length of a message on the status line can be.
10353 * If there is a status line for the last window, 'sc_col' is independent
10354 * of 'ru_col'.
10355 */
10356
10357#define COL_RULER 17 /* columns needed by standard ruler */
10358
10359 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010360comp_col(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010361{
10362#if defined(FEAT_CMDL_INFO) && defined(FEAT_WINDOWS)
Bram Moolenaar459ca562016-11-10 18:16:33 +010010363 int last_has_status = (p_ls == 2 || (p_ls == 1 && !ONE_WINDOW));
Bram Moolenaar071d4272004-06-13 20:20:40 +000010364
10365 sc_col = 0;
10366 ru_col = 0;
10367 if (p_ru)
10368 {
10369#ifdef FEAT_STL_OPT
10370 ru_col = (ru_wid ? ru_wid : COL_RULER) + 1;
10371#else
10372 ru_col = COL_RULER + 1;
10373#endif
10374 /* no last status line, adjust sc_col */
10375 if (!last_has_status)
10376 sc_col = ru_col;
10377 }
10378 if (p_sc)
10379 {
10380 sc_col += SHOWCMD_COLS;
10381 if (!p_ru || last_has_status) /* no need for separating space */
10382 ++sc_col;
10383 }
10384 sc_col = Columns - sc_col;
10385 ru_col = Columns - ru_col;
10386 if (sc_col <= 0) /* screen too narrow, will become a mess */
10387 sc_col = 1;
10388 if (ru_col <= 0)
10389 ru_col = 1;
10390#else
10391 sc_col = Columns;
10392 ru_col = Columns;
10393#endif
10394}
10395
10396/*
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010397 * Unset local option value, similar to ":set opt<".
10398 */
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010399 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010400unset_global_local_option(char_u *name, void *from)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010401{
10402 struct vimoption *p;
10403 int opt_idx;
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010404 buf_T *buf = (buf_T *)from;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010405
10406 opt_idx = findoption(name);
Bram Moolenaarbd8539a2015-08-11 18:53:03 +020010407 if (opt_idx < 0)
10408 return;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010409 p = &(options[opt_idx]);
10410
10411 switch ((int)p->indir)
10412 {
10413 /* global option with local value: use local value if it's been set */
10414 case PV_EP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010415 clear_string_option(&buf->b_p_ep);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010416 break;
10417 case PV_KP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010418 clear_string_option(&buf->b_p_kp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010419 break;
10420 case PV_PATH:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010421 clear_string_option(&buf->b_p_path);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010422 break;
10423 case PV_AR:
10424 buf->b_p_ar = -1;
10425 break;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010426 case PV_BKC:
10427 clear_string_option(&buf->b_p_bkc);
10428 buf->b_bkc_flags = 0;
10429 break;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010430 case PV_TAGS:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010431 clear_string_option(&buf->b_p_tags);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010432 break;
Bram Moolenaar0f6562e2015-11-24 18:48:14 +010010433 case PV_TC:
10434 clear_string_option(&buf->b_p_tc);
10435 buf->b_tc_flags = 0;
10436 break;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010437#ifdef FEAT_FIND_ID
10438 case PV_DEF:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010439 clear_string_option(&buf->b_p_def);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010440 break;
10441 case PV_INC:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010442 clear_string_option(&buf->b_p_inc);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010443 break;
10444#endif
10445#ifdef FEAT_INS_EXPAND
10446 case PV_DICT:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010447 clear_string_option(&buf->b_p_dict);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010448 break;
10449 case PV_TSR:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010450 clear_string_option(&buf->b_p_tsr);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010451 break;
10452#endif
Bram Moolenaar9be7c042017-01-14 14:28:30 +010010453 case PV_FP:
10454 clear_string_option(&buf->b_p_fp);
10455 break;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010456#ifdef FEAT_QUICKFIX
10457 case PV_EFM:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010458 clear_string_option(&buf->b_p_efm);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010459 break;
10460 case PV_GP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010461 clear_string_option(&buf->b_p_gp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010462 break;
10463 case PV_MP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010464 clear_string_option(&buf->b_p_mp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010465 break;
10466#endif
10467#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10468 case PV_BEXPR:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010469 clear_string_option(&buf->b_p_bexpr);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010470 break;
10471#endif
10472#if defined(FEAT_CRYPT)
10473 case PV_CM:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010474 clear_string_option(&buf->b_p_cm);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010475 break;
10476#endif
10477#ifdef FEAT_STL_OPT
10478 case PV_STL:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010479 clear_string_option(&((win_T *)from)->w_p_stl);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010480 break;
10481#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010482 case PV_UL:
10483 buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
10484 break;
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010485#ifdef FEAT_LISP
10486 case PV_LW:
10487 clear_string_option(&buf->b_p_lw);
10488 break;
10489#endif
Bram Moolenaar2c7292d2017-03-05 17:43:31 +010010490#ifdef FEAT_MBYTE
10491 case PV_MENC:
10492 clear_string_option(&buf->b_p_menc);
10493 break;
10494#endif
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010495 }
10496}
10497
10498/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000010499 * Get pointer to option variable, depending on local or global scope.
10500 */
10501 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +010010502get_varp_scope(struct vimoption *p, int opt_flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010503{
10504 if ((opt_flags & OPT_GLOBAL) && p->indir != PV_NONE)
10505 {
10506 if (p->var == VAR_WIN)
10507 return (char_u *)GLOBAL_WO(get_varp(p));
10508 return p->var;
10509 }
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010510 if ((opt_flags & OPT_LOCAL) && ((int)p->indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +000010511 {
10512 switch ((int)p->indir)
10513 {
Bram Moolenaar9be7c042017-01-14 14:28:30 +010010514 case PV_FP: return (char_u *)&(curbuf->b_p_fp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010515#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010516 case PV_EFM: return (char_u *)&(curbuf->b_p_efm);
10517 case PV_GP: return (char_u *)&(curbuf->b_p_gp);
10518 case PV_MP: return (char_u *)&(curbuf->b_p_mp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010519#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010520 case PV_EP: return (char_u *)&(curbuf->b_p_ep);
10521 case PV_KP: return (char_u *)&(curbuf->b_p_kp);
10522 case PV_PATH: return (char_u *)&(curbuf->b_p_path);
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010523 case PV_AR: return (char_u *)&(curbuf->b_p_ar);
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010524 case PV_TAGS: return (char_u *)&(curbuf->b_p_tags);
Bram Moolenaar0f6562e2015-11-24 18:48:14 +010010525 case PV_TC: return (char_u *)&(curbuf->b_p_tc);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010526#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010527 case PV_DEF: return (char_u *)&(curbuf->b_p_def);
10528 case PV_INC: return (char_u *)&(curbuf->b_p_inc);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010529#endif
10530#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010531 case PV_DICT: return (char_u *)&(curbuf->b_p_dict);
10532 case PV_TSR: return (char_u *)&(curbuf->b_p_tsr);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010533#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000010534#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10535 case PV_BEXPR: return (char_u *)&(curbuf->b_p_bexpr);
10536#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020010537#if defined(FEAT_CRYPT)
10538 case PV_CM: return (char_u *)&(curbuf->b_p_cm);
10539#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010540#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010541 case PV_STL: return (char_u *)&(curwin->w_p_stl);
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010542#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010543 case PV_UL: return (char_u *)&(curbuf->b_p_ul);
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010544#ifdef FEAT_LISP
10545 case PV_LW: return (char_u *)&(curbuf->b_p_lw);
10546#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010547 case PV_BKC: return (char_u *)&(curbuf->b_p_bkc);
Bram Moolenaar2c7292d2017-03-05 17:43:31 +010010548#ifdef FEAT_MBYTE
10549 case PV_MENC: return (char_u *)&(curbuf->b_p_menc);
10550#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010551 }
10552 return NULL; /* "cannot happen" */
10553 }
10554 return get_varp(p);
10555}
10556
10557/*
10558 * Get pointer to option variable.
10559 */
10560 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +010010561get_varp(struct vimoption *p)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010562{
10563 /* hidden option, always return NULL */
10564 if (p->var == NULL)
10565 return NULL;
10566
10567 switch ((int)p->indir)
10568 {
10569 case PV_NONE: return p->var;
10570
10571 /* global option with local value: use local value if it's been set */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010572 case PV_EP: return *curbuf->b_p_ep != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010573 ? (char_u *)&curbuf->b_p_ep : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010574 case PV_KP: return *curbuf->b_p_kp != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010575 ? (char_u *)&curbuf->b_p_kp : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010576 case PV_PATH: return *curbuf->b_p_path != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010577 ? (char_u *)&(curbuf->b_p_path) : p->var;
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010578 case PV_AR: return curbuf->b_p_ar >= 0
Bram Moolenaar071d4272004-06-13 20:20:40 +000010579 ? (char_u *)&(curbuf->b_p_ar) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010580 case PV_TAGS: return *curbuf->b_p_tags != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010581 ? (char_u *)&(curbuf->b_p_tags) : p->var;
Bram Moolenaar0f6562e2015-11-24 18:48:14 +010010582 case PV_TC: return *curbuf->b_p_tc != NUL
10583 ? (char_u *)&(curbuf->b_p_tc) : p->var;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010584 case PV_BKC: return *curbuf->b_p_bkc != NUL
10585 ? (char_u *)&(curbuf->b_p_bkc) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010586#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010587 case PV_DEF: return *curbuf->b_p_def != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010588 ? (char_u *)&(curbuf->b_p_def) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010589 case PV_INC: return *curbuf->b_p_inc != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010590 ? (char_u *)&(curbuf->b_p_inc) : p->var;
10591#endif
10592#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010593 case PV_DICT: return *curbuf->b_p_dict != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010594 ? (char_u *)&(curbuf->b_p_dict) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010595 case PV_TSR: return *curbuf->b_p_tsr != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010596 ? (char_u *)&(curbuf->b_p_tsr) : p->var;
10597#endif
Bram Moolenaar9be7c042017-01-14 14:28:30 +010010598 case PV_FP: return *curbuf->b_p_fp != NUL
10599 ? (char_u *)&(curbuf->b_p_fp) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010600#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010601 case PV_EFM: return *curbuf->b_p_efm != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010602 ? (char_u *)&(curbuf->b_p_efm) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010603 case PV_GP: return *curbuf->b_p_gp != NUL
10604 ? (char_u *)&(curbuf->b_p_gp) : p->var;
10605 case PV_MP: return *curbuf->b_p_mp != NUL
10606 ? (char_u *)&(curbuf->b_p_mp) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010607#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000010608#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10609 case PV_BEXPR: return *curbuf->b_p_bexpr != NUL
10610 ? (char_u *)&(curbuf->b_p_bexpr) : p->var;
10611#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020010612#if defined(FEAT_CRYPT)
10613 case PV_CM: return *curbuf->b_p_cm != NUL
10614 ? (char_u *)&(curbuf->b_p_cm) : p->var;
10615#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010616#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010617 case PV_STL: return *curwin->w_p_stl != NUL
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010618 ? (char_u *)&(curwin->w_p_stl) : p->var;
10619#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010620 case PV_UL: return curbuf->b_p_ul != NO_LOCAL_UNDOLEVEL
10621 ? (char_u *)&(curbuf->b_p_ul) : p->var;
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010622#ifdef FEAT_LISP
10623 case PV_LW: return *curbuf->b_p_lw != NUL
10624 ? (char_u *)&(curbuf->b_p_lw) : p->var;
10625#endif
Bram Moolenaar2c7292d2017-03-05 17:43:31 +010010626#ifdef FEAT_MBYTE
10627 case PV_MENC: return *curbuf->b_p_menc != NUL
10628 ? (char_u *)&(curbuf->b_p_menc) : p->var;
10629#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010630
10631#ifdef FEAT_ARABIC
10632 case PV_ARAB: return (char_u *)&(curwin->w_p_arab);
10633#endif
10634 case PV_LIST: return (char_u *)&(curwin->w_p_list);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010635#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +000010636 case PV_SPELL: return (char_u *)&(curwin->w_p_spell);
10637#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010638#ifdef FEAT_SYN_HL
10639 case PV_CUC: return (char_u *)&(curwin->w_p_cuc);
10640 case PV_CUL: return (char_u *)&(curwin->w_p_cul);
Bram Moolenaar1a384422010-07-14 19:53:30 +020010641 case PV_CC: return (char_u *)&(curwin->w_p_cc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010642#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010643#ifdef FEAT_DIFF
10644 case PV_DIFF: return (char_u *)&(curwin->w_p_diff);
10645#endif
10646#ifdef FEAT_FOLDING
10647 case PV_FDC: return (char_u *)&(curwin->w_p_fdc);
10648 case PV_FEN: return (char_u *)&(curwin->w_p_fen);
10649 case PV_FDI: return (char_u *)&(curwin->w_p_fdi);
10650 case PV_FDL: return (char_u *)&(curwin->w_p_fdl);
10651 case PV_FDM: return (char_u *)&(curwin->w_p_fdm);
10652 case PV_FML: return (char_u *)&(curwin->w_p_fml);
10653 case PV_FDN: return (char_u *)&(curwin->w_p_fdn);
10654# ifdef FEAT_EVAL
10655 case PV_FDE: return (char_u *)&(curwin->w_p_fde);
10656 case PV_FDT: return (char_u *)&(curwin->w_p_fdt);
10657# endif
10658 case PV_FMR: return (char_u *)&(curwin->w_p_fmr);
10659#endif
10660 case PV_NU: return (char_u *)&(curwin->w_p_nu);
Bram Moolenaar64486672010-05-16 15:46:46 +020010661 case PV_RNU: return (char_u *)&(curwin->w_p_rnu);
Bram Moolenaar592e0a22004-07-03 16:05:59 +000010662#ifdef FEAT_LINEBREAK
10663 case PV_NUW: return (char_u *)&(curwin->w_p_nuw);
10664#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010665#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +000010666 case PV_WFH: return (char_u *)&(curwin->w_p_wfh);
Bram Moolenaar97b2ad32006-03-18 21:40:56 +000010667 case PV_WFW: return (char_u *)&(curwin->w_p_wfw);
10668#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010669#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
10670 case PV_PVW: return (char_u *)&(curwin->w_p_pvw);
10671#endif
10672#ifdef FEAT_RIGHTLEFT
10673 case PV_RL: return (char_u *)&(curwin->w_p_rl);
10674 case PV_RLC: return (char_u *)&(curwin->w_p_rlc);
10675#endif
10676 case PV_SCROLL: return (char_u *)&(curwin->w_p_scr);
10677 case PV_WRAP: return (char_u *)&(curwin->w_p_wrap);
10678#ifdef FEAT_LINEBREAK
10679 case PV_LBR: return (char_u *)&(curwin->w_p_lbr);
Bram Moolenaar597a4222014-06-25 14:39:50 +020010680 case PV_BRI: return (char_u *)&(curwin->w_p_bri);
10681 case PV_BRIOPT: return (char_u *)&(curwin->w_p_briopt);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010682#endif
10683#ifdef FEAT_SCROLLBIND
10684 case PV_SCBIND: return (char_u *)&(curwin->w_p_scb);
10685#endif
Bram Moolenaar860cae12010-06-05 23:22:07 +020010686#ifdef FEAT_CURSORBIND
10687 case PV_CRBIND: return (char_u *)&(curwin->w_p_crb);
10688#endif
10689#ifdef FEAT_CONCEAL
Bram Moolenaare4f25e42017-07-07 11:54:15 +020010690 case PV_COCU: return (char_u *)&(curwin->w_p_cocu);
10691 case PV_COLE: return (char_u *)&(curwin->w_p_cole);
10692#endif
10693#ifdef FEAT_TERMINAL
Bram Moolenaar1b0675c2017-07-15 14:04:01 +020010694 case PV_TK: return (char_u *)&(curwin->w_p_tk);
Bram Moolenaare4f25e42017-07-07 11:54:15 +020010695 case PV_TMS: return (char_u *)&(curwin->w_p_tms);
Bram Moolenaar860cae12010-06-05 23:22:07 +020010696#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010697
10698 case PV_AI: return (char_u *)&(curbuf->b_p_ai);
10699 case PV_BIN: return (char_u *)&(curbuf->b_p_bin);
10700#ifdef FEAT_MBYTE
10701 case PV_BOMB: return (char_u *)&(curbuf->b_p_bomb);
10702#endif
10703#if defined(FEAT_QUICKFIX)
10704 case PV_BH: return (char_u *)&(curbuf->b_p_bh);
10705 case PV_BT: return (char_u *)&(curbuf->b_p_bt);
10706#endif
10707 case PV_BL: return (char_u *)&(curbuf->b_p_bl);
10708 case PV_CI: return (char_u *)&(curbuf->b_p_ci);
10709#ifdef FEAT_CINDENT
10710 case PV_CIN: return (char_u *)&(curbuf->b_p_cin);
10711 case PV_CINK: return (char_u *)&(curbuf->b_p_cink);
10712 case PV_CINO: return (char_u *)&(curbuf->b_p_cino);
10713#endif
10714#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
10715 case PV_CINW: return (char_u *)&(curbuf->b_p_cinw);
10716#endif
10717#ifdef FEAT_COMMENTS
10718 case PV_COM: return (char_u *)&(curbuf->b_p_com);
10719#endif
10720#ifdef FEAT_FOLDING
10721 case PV_CMS: return (char_u *)&(curbuf->b_p_cms);
10722#endif
10723#ifdef FEAT_INS_EXPAND
10724 case PV_CPT: return (char_u *)&(curbuf->b_p_cpt);
10725#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010726#ifdef FEAT_COMPL_FUNC
10727 case PV_CFU: return (char_u *)&(curbuf->b_p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +000010728 case PV_OFU: return (char_u *)&(curbuf->b_p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010729#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010730 case PV_EOL: return (char_u *)&(curbuf->b_p_eol);
Bram Moolenaar34d72d42015-07-17 14:18:08 +020010731 case PV_FIXEOL: return (char_u *)&(curbuf->b_p_fixeol);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010732 case PV_ET: return (char_u *)&(curbuf->b_p_et);
10733#ifdef FEAT_MBYTE
10734 case PV_FENC: return (char_u *)&(curbuf->b_p_fenc);
10735#endif
10736 case PV_FF: return (char_u *)&(curbuf->b_p_ff);
10737#ifdef FEAT_AUTOCMD
10738 case PV_FT: return (char_u *)&(curbuf->b_p_ft);
10739#endif
10740 case PV_FO: return (char_u *)&(curbuf->b_p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +000010741 case PV_FLP: return (char_u *)&(curbuf->b_p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010742 case PV_IMI: return (char_u *)&(curbuf->b_p_iminsert);
10743 case PV_IMS: return (char_u *)&(curbuf->b_p_imsearch);
10744 case PV_INF: return (char_u *)&(curbuf->b_p_inf);
10745 case PV_ISK: return (char_u *)&(curbuf->b_p_isk);
10746#ifdef FEAT_FIND_ID
10747# ifdef FEAT_EVAL
10748 case PV_INEX: return (char_u *)&(curbuf->b_p_inex);
10749# endif
10750#endif
10751#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
10752 case PV_INDE: return (char_u *)&(curbuf->b_p_inde);
10753 case PV_INDK: return (char_u *)&(curbuf->b_p_indk);
10754#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010755#ifdef FEAT_EVAL
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +000010756 case PV_FEX: return (char_u *)&(curbuf->b_p_fex);
10757#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010758#ifdef FEAT_CRYPT
10759 case PV_KEY: return (char_u *)&(curbuf->b_p_key);
10760#endif
10761#ifdef FEAT_LISP
10762 case PV_LISP: return (char_u *)&(curbuf->b_p_lisp);
10763#endif
10764 case PV_ML: return (char_u *)&(curbuf->b_p_ml);
10765 case PV_MPS: return (char_u *)&(curbuf->b_p_mps);
10766 case PV_MA: return (char_u *)&(curbuf->b_p_ma);
10767 case PV_MOD: return (char_u *)&(curbuf->b_changed);
10768 case PV_NF: return (char_u *)&(curbuf->b_p_nf);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010769 case PV_PI: return (char_u *)&(curbuf->b_p_pi);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010770#ifdef FEAT_TEXTOBJ
10771 case PV_QE: return (char_u *)&(curbuf->b_p_qe);
10772#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010773 case PV_RO: return (char_u *)&(curbuf->b_p_ro);
10774#ifdef FEAT_SMARTINDENT
10775 case PV_SI: return (char_u *)&(curbuf->b_p_si);
10776#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010777 case PV_SN: return (char_u *)&(curbuf->b_p_sn);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010778 case PV_STS: return (char_u *)&(curbuf->b_p_sts);
10779#ifdef FEAT_SEARCHPATH
10780 case PV_SUA: return (char_u *)&(curbuf->b_p_sua);
10781#endif
10782 case PV_SWF: return (char_u *)&(curbuf->b_p_swf);
10783#ifdef FEAT_SYN_HL
Bram Moolenaar3b56eb32005-07-11 22:40:32 +000010784 case PV_SMC: return (char_u *)&(curbuf->b_p_smc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010785 case PV_SYN: return (char_u *)&(curbuf->b_p_syn);
10786#endif
10787#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +020010788 case PV_SPC: return (char_u *)&(curwin->w_s->b_p_spc);
10789 case PV_SPF: return (char_u *)&(curwin->w_s->b_p_spf);
10790 case PV_SPL: return (char_u *)&(curwin->w_s->b_p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010791#endif
10792 case PV_SW: return (char_u *)&(curbuf->b_p_sw);
10793 case PV_TS: return (char_u *)&(curbuf->b_p_ts);
10794 case PV_TW: return (char_u *)&(curbuf->b_p_tw);
10795 case PV_TX: return (char_u *)&(curbuf->b_p_tx);
Bram Moolenaar55debbe2010-05-23 23:34:36 +020010796#ifdef FEAT_PERSISTENT_UNDO
10797 case PV_UDF: return (char_u *)&(curbuf->b_p_udf);
10798#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010799 case PV_WM: return (char_u *)&(curbuf->b_p_wm);
10800#ifdef FEAT_KEYMAP
10801 case PV_KMAP: return (char_u *)&(curbuf->b_p_keymap);
10802#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020010803#ifdef FEAT_SIGNS
10804 case PV_SCL: return (char_u *)&(curwin->w_p_scl);
10805#endif
Bram Moolenaar95f09602016-11-10 20:01:45 +010010806 default: IEMSG(_("E356: get_varp ERROR"));
Bram Moolenaar071d4272004-06-13 20:20:40 +000010807 }
10808 /* always return a valid pointer to avoid a crash! */
10809 return (char_u *)&(curbuf->b_p_wm);
10810}
10811
10812/*
10813 * Get the value of 'equalprg', either the buffer-local one or the global one.
10814 */
10815 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +010010816get_equalprg(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010817{
10818 if (*curbuf->b_p_ep == NUL)
10819 return p_ep;
10820 return curbuf->b_p_ep;
10821}
10822
10823#if defined(FEAT_WINDOWS) || defined(PROTO)
10824/*
10825 * Copy options from one window to another.
10826 * Used when splitting a window.
10827 */
10828 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010829win_copy_options(win_T *wp_from, win_T *wp_to)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010830{
10831 copy_winopt(&wp_from->w_onebuf_opt, &wp_to->w_onebuf_opt);
10832 copy_winopt(&wp_from->w_allbuf_opt, &wp_to->w_allbuf_opt);
10833# ifdef FEAT_RIGHTLEFT
10834# ifdef FEAT_FKMAP
10835 /* Is this right? */
10836 wp_to->w_farsi = wp_from->w_farsi;
10837# endif
10838# endif
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020010839#if defined(FEAT_LINEBREAK)
10840 briopt_check(wp_to);
10841#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010842}
10843#endif
10844
10845/*
10846 * Copy the options from one winopt_T to another.
10847 * Doesn't free the old option values in "to", use clear_winopt() for that.
10848 * The 'scroll' option is not copied, because it depends on the window height.
10849 * The 'previewwindow' option is reset, there can be only one preview window.
10850 */
10851 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010852copy_winopt(winopt_T *from, winopt_T *to)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010853{
10854#ifdef FEAT_ARABIC
10855 to->wo_arab = from->wo_arab;
10856#endif
10857 to->wo_list = from->wo_list;
10858 to->wo_nu = from->wo_nu;
Bram Moolenaar64486672010-05-16 15:46:46 +020010859 to->wo_rnu = from->wo_rnu;
Bram Moolenaar592e0a22004-07-03 16:05:59 +000010860#ifdef FEAT_LINEBREAK
10861 to->wo_nuw = from->wo_nuw;
10862#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010863#ifdef FEAT_RIGHTLEFT
10864 to->wo_rl = from->wo_rl;
10865 to->wo_rlc = vim_strsave(from->wo_rlc);
10866#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010867#ifdef FEAT_STL_OPT
10868 to->wo_stl = vim_strsave(from->wo_stl);
10869#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010870 to->wo_wrap = from->wo_wrap;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010871#ifdef FEAT_DIFF
10872 to->wo_wrap_save = from->wo_wrap_save;
10873#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010874#ifdef FEAT_LINEBREAK
10875 to->wo_lbr = from->wo_lbr;
Bram Moolenaar597a4222014-06-25 14:39:50 +020010876 to->wo_bri = from->wo_bri;
10877 to->wo_briopt = vim_strsave(from->wo_briopt);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010878#endif
10879#ifdef FEAT_SCROLLBIND
10880 to->wo_scb = from->wo_scb;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010881 to->wo_scb_save = from->wo_scb_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010882#endif
Bram Moolenaar4161dcc2010-12-02 15:33:21 +010010883#ifdef FEAT_CURSORBIND
10884 to->wo_crb = from->wo_crb;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010885 to->wo_crb_save = from->wo_crb_save;
Bram Moolenaar4161dcc2010-12-02 15:33:21 +010010886#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010887#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +000010888 to->wo_spell = from->wo_spell;
10889#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010890#ifdef FEAT_SYN_HL
10891 to->wo_cuc = from->wo_cuc;
10892 to->wo_cul = from->wo_cul;
Bram Moolenaar1a384422010-07-14 19:53:30 +020010893 to->wo_cc = vim_strsave(from->wo_cc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010894#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010895#ifdef FEAT_DIFF
10896 to->wo_diff = from->wo_diff;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010897 to->wo_diff_saved = from->wo_diff_saved;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010898#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010899#ifdef FEAT_CONCEAL
10900 to->wo_cocu = vim_strsave(from->wo_cocu);
Bram Moolenaard497a302010-07-23 22:27:03 +020010901 to->wo_cole = from->wo_cole;
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010902#endif
Bram Moolenaare4f25e42017-07-07 11:54:15 +020010903#ifdef FEAT_TERMINAL
Bram Moolenaar0daf8432017-07-15 15:16:40 +020010904 to->wo_tk = vim_strsave(from->wo_tk);
Bram Moolenaare4f25e42017-07-07 11:54:15 +020010905 to->wo_tms = vim_strsave(from->wo_tms);
10906#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010907#ifdef FEAT_FOLDING
10908 to->wo_fdc = from->wo_fdc;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010909 to->wo_fdc_save = from->wo_fdc_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010910 to->wo_fen = from->wo_fen;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010911 to->wo_fen_save = from->wo_fen_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010912 to->wo_fdi = vim_strsave(from->wo_fdi);
10913 to->wo_fml = from->wo_fml;
10914 to->wo_fdl = from->wo_fdl;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010915 to->wo_fdl_save = from->wo_fdl_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010916 to->wo_fdm = vim_strsave(from->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010917 to->wo_fdm_save = from->wo_diff_saved
10918 ? vim_strsave(from->wo_fdm_save) : empty_option;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010919 to->wo_fdn = from->wo_fdn;
10920# ifdef FEAT_EVAL
10921 to->wo_fde = vim_strsave(from->wo_fde);
10922 to->wo_fdt = vim_strsave(from->wo_fdt);
10923# endif
10924 to->wo_fmr = vim_strsave(from->wo_fmr);
10925#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020010926#ifdef FEAT_SIGNS
10927 to->wo_scl = vim_strsave(from->wo_scl);
10928#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010929 check_winopt(to); /* don't want NULL pointers */
10930}
10931
10932/*
10933 * Check string options in a window for a NULL value.
10934 */
10935 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010936check_win_options(win_T *win)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010937{
10938 check_winopt(&win->w_onebuf_opt);
10939 check_winopt(&win->w_allbuf_opt);
10940}
10941
10942/*
10943 * Check for NULL pointers in a winopt_T and replace them with empty_option.
10944 */
Bram Moolenaar8dc907d2014-06-25 14:44:10 +020010945 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010946check_winopt(winopt_T *wop UNUSED)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010947{
10948#ifdef FEAT_FOLDING
10949 check_string_option(&wop->wo_fdi);
10950 check_string_option(&wop->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010951 check_string_option(&wop->wo_fdm_save);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010952# ifdef FEAT_EVAL
10953 check_string_option(&wop->wo_fde);
10954 check_string_option(&wop->wo_fdt);
10955# endif
10956 check_string_option(&wop->wo_fmr);
10957#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020010958#ifdef FEAT_SIGNS
10959 check_string_option(&wop->wo_scl);
10960#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010961#ifdef FEAT_RIGHTLEFT
10962 check_string_option(&wop->wo_rlc);
10963#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010964#ifdef FEAT_STL_OPT
10965 check_string_option(&wop->wo_stl);
10966#endif
Bram Moolenaar1a384422010-07-14 19:53:30 +020010967#ifdef FEAT_SYN_HL
10968 check_string_option(&wop->wo_cc);
10969#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010970#ifdef FEAT_CONCEAL
10971 check_string_option(&wop->wo_cocu);
10972#endif
Bram Moolenaare4f25e42017-07-07 11:54:15 +020010973#ifdef FEAT_TERMINAL
Bram Moolenaar0daf8432017-07-15 15:16:40 +020010974 check_string_option(&wop->wo_tk);
Bram Moolenaare4f25e42017-07-07 11:54:15 +020010975 check_string_option(&wop->wo_tms);
10976#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +020010977#ifdef FEAT_LINEBREAK
10978 check_string_option(&wop->wo_briopt);
10979#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010980}
10981
10982/*
10983 * Free the allocated memory inside a winopt_T.
10984 */
Bram Moolenaar071d4272004-06-13 20:20:40 +000010985 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010986clear_winopt(winopt_T *wop UNUSED)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010987{
10988#ifdef FEAT_FOLDING
10989 clear_string_option(&wop->wo_fdi);
10990 clear_string_option(&wop->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010991 clear_string_option(&wop->wo_fdm_save);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010992# ifdef FEAT_EVAL
10993 clear_string_option(&wop->wo_fde);
10994 clear_string_option(&wop->wo_fdt);
10995# endif
10996 clear_string_option(&wop->wo_fmr);
10997#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020010998#ifdef FEAT_SIGNS
10999 clear_string_option(&wop->wo_scl);
11000#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +020011001#ifdef FEAT_LINEBREAK
11002 clear_string_option(&wop->wo_briopt);
11003#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011004#ifdef FEAT_RIGHTLEFT
11005 clear_string_option(&wop->wo_rlc);
11006#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000011007#ifdef FEAT_STL_OPT
11008 clear_string_option(&wop->wo_stl);
11009#endif
Bram Moolenaar1a384422010-07-14 19:53:30 +020011010#ifdef FEAT_SYN_HL
11011 clear_string_option(&wop->wo_cc);
11012#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020011013#ifdef FEAT_CONCEAL
11014 clear_string_option(&wop->wo_cocu);
11015#endif
Bram Moolenaare4f25e42017-07-07 11:54:15 +020011016#ifdef FEAT_TERMINAL
Bram Moolenaar0daf8432017-07-15 15:16:40 +020011017 clear_string_option(&wop->wo_tk);
Bram Moolenaare4f25e42017-07-07 11:54:15 +020011018 clear_string_option(&wop->wo_tms);
11019#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011020}
11021
11022/*
11023 * Copy global option values to local options for one buffer.
11024 * Used when creating a new buffer and sometimes when entering a buffer.
11025 * flags:
11026 * BCO_ENTER We will enter the buf buffer.
11027 * BCO_ALWAYS Always copy the options, but only set b_p_initialized when
11028 * appropriate.
11029 * BCO_NOHELP Don't copy the values to a help buffer.
11030 */
11031 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011032buf_copy_options(buf_T *buf, int flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011033{
11034 int should_copy = TRUE;
11035 char_u *save_p_isk = NULL; /* init for GCC */
11036 int dont_do_help;
11037 int did_isk = FALSE;
11038
11039 /*
Bram Moolenaar071d4272004-06-13 20:20:40 +000011040 * Skip this when the option defaults have not been set yet. Happens when
11041 * main() allocates the first buffer.
11042 */
11043 if (p_cpo != NULL)
11044 {
11045 /*
11046 * Always copy when entering and 'cpo' contains 'S'.
11047 * Don't copy when already initialized.
11048 * Don't copy when 'cpo' contains 's' and not entering.
11049 * 'S' BCO_ENTER initialized 's' should_copy
11050 * yes yes X X TRUE
11051 * yes no yes X FALSE
11052 * no X yes X FALSE
11053 * X no no yes FALSE
11054 * X no no no TRUE
11055 * no yes no X TRUE
11056 */
11057 if ((vim_strchr(p_cpo, CPO_BUFOPTGLOB) == NULL || !(flags & BCO_ENTER))
11058 && (buf->b_p_initialized
11059 || (!(flags & BCO_ENTER)
11060 && vim_strchr(p_cpo, CPO_BUFOPT) != NULL)))
11061 should_copy = FALSE;
11062
11063 if (should_copy || (flags & BCO_ALWAYS))
11064 {
11065 /* Don't copy the options specific to a help buffer when
11066 * BCO_NOHELP is given or the options were initialized already
11067 * (jumping back to a help file with CTRL-T or CTRL-O) */
11068 dont_do_help = ((flags & BCO_NOHELP) && buf->b_help)
11069 || buf->b_p_initialized;
11070 if (dont_do_help) /* don't free b_p_isk */
11071 {
11072 save_p_isk = buf->b_p_isk;
11073 buf->b_p_isk = NULL;
11074 }
11075 /*
11076 * Always free the allocated strings.
11077 * If not already initialized, set 'readonly' and copy 'fileformat'.
11078 */
11079 if (!buf->b_p_initialized)
11080 {
11081 free_buf_options(buf, TRUE);
11082 buf->b_p_ro = FALSE; /* don't copy readonly */
11083 buf->b_p_tx = p_tx;
11084#ifdef FEAT_MBYTE
11085 buf->b_p_fenc = vim_strsave(p_fenc);
11086#endif
Bram Moolenaare8ef3a02016-10-12 17:45:29 +020011087 switch (*p_ffs)
11088 {
11089 case 'm':
11090 buf->b_p_ff = vim_strsave((char_u *)FF_MAC); break;
11091 case 'd':
11092 buf->b_p_ff = vim_strsave((char_u *)FF_DOS); break;
11093 case 'u':
11094 buf->b_p_ff = vim_strsave((char_u *)FF_UNIX); break;
11095 default:
11096 buf->b_p_ff = vim_strsave(p_ff);
11097 }
11098 if (buf->b_p_ff != NULL)
11099 buf->b_start_ffc = *buf->b_p_ff;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011100#if defined(FEAT_QUICKFIX)
11101 buf->b_p_bh = empty_option;
11102 buf->b_p_bt = empty_option;
11103#endif
11104 }
11105 else
11106 free_buf_options(buf, FALSE);
11107
11108 buf->b_p_ai = p_ai;
11109 buf->b_p_ai_nopaste = p_ai_nopaste;
11110 buf->b_p_sw = p_sw;
11111 buf->b_p_tw = p_tw;
11112 buf->b_p_tw_nopaste = p_tw_nopaste;
11113 buf->b_p_tw_nobin = p_tw_nobin;
11114 buf->b_p_wm = p_wm;
11115 buf->b_p_wm_nopaste = p_wm_nopaste;
11116 buf->b_p_wm_nobin = p_wm_nobin;
11117 buf->b_p_bin = p_bin;
Bram Moolenaare8bb2552005-07-08 22:26:47 +000011118#ifdef FEAT_MBYTE
11119 buf->b_p_bomb = p_bomb;
11120#endif
Bram Moolenaarb388be02015-07-22 22:19:38 +020011121 buf->b_p_fixeol = p_fixeol;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011122 buf->b_p_et = p_et;
11123 buf->b_p_et_nobin = p_et_nobin;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020011124 buf->b_p_et_nopaste = p_et_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011125 buf->b_p_ml = p_ml;
11126 buf->b_p_ml_nobin = p_ml_nobin;
11127 buf->b_p_inf = p_inf;
Bram Moolenaar3bab9392017-04-07 15:42:25 +020011128 buf->b_p_swf = cmdmod.noswapfile ? FALSE : p_swf;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011129#ifdef FEAT_INS_EXPAND
11130 buf->b_p_cpt = vim_strsave(p_cpt);
11131#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000011132#ifdef FEAT_COMPL_FUNC
11133 buf->b_p_cfu = vim_strsave(p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +000011134 buf->b_p_ofu = vim_strsave(p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000011135#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011136 buf->b_p_sts = p_sts;
11137 buf->b_p_sts_nopaste = p_sts_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011138 buf->b_p_sn = p_sn;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011139#ifdef FEAT_COMMENTS
11140 buf->b_p_com = vim_strsave(p_com);
11141#endif
11142#ifdef FEAT_FOLDING
11143 buf->b_p_cms = vim_strsave(p_cms);
11144#endif
11145 buf->b_p_fo = vim_strsave(p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +000011146 buf->b_p_flp = vim_strsave(p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011147 buf->b_p_nf = vim_strsave(p_nf);
11148 buf->b_p_mps = vim_strsave(p_mps);
11149#ifdef FEAT_SMARTINDENT
11150 buf->b_p_si = p_si;
11151#endif
11152 buf->b_p_ci = p_ci;
11153#ifdef FEAT_CINDENT
11154 buf->b_p_cin = p_cin;
11155 buf->b_p_cink = vim_strsave(p_cink);
11156 buf->b_p_cino = vim_strsave(p_cino);
11157#endif
11158#ifdef FEAT_AUTOCMD
11159 /* Don't copy 'filetype', it must be detected */
11160 buf->b_p_ft = empty_option;
11161#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011162 buf->b_p_pi = p_pi;
11163#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
11164 buf->b_p_cinw = vim_strsave(p_cinw);
11165#endif
11166#ifdef FEAT_LISP
11167 buf->b_p_lisp = p_lisp;
11168#endif
11169#ifdef FEAT_SYN_HL
11170 /* Don't copy 'syntax', it must be set */
11171 buf->b_p_syn = empty_option;
Bram Moolenaar3b56eb32005-07-11 22:40:32 +000011172 buf->b_p_smc = p_smc;
Bram Moolenaarb8060fe2016-01-19 22:29:28 +010011173 buf->b_s.b_syn_isk = empty_option;
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000011174#endif
11175#ifdef FEAT_SPELL
Bram Moolenaard5784f92010-10-13 14:05:35 +020011176 buf->b_s.b_p_spc = vim_strsave(p_spc);
Bram Moolenaar860cae12010-06-05 23:22:07 +020011177 (void)compile_cap_prog(&buf->b_s);
11178 buf->b_s.b_p_spf = vim_strsave(p_spf);
11179 buf->b_s.b_p_spl = vim_strsave(p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011180#endif
11181#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
11182 buf->b_p_inde = vim_strsave(p_inde);
11183 buf->b_p_indk = vim_strsave(p_indk);
11184#endif
Bram Moolenaar9be7c042017-01-14 14:28:30 +010011185 buf->b_p_fp = empty_option;
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +000011186#if defined(FEAT_EVAL)
11187 buf->b_p_fex = vim_strsave(p_fex);
11188#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011189#ifdef FEAT_CRYPT
11190 buf->b_p_key = vim_strsave(p_key);
11191#endif
11192#ifdef FEAT_SEARCHPATH
11193 buf->b_p_sua = vim_strsave(p_sua);
11194#endif
11195#ifdef FEAT_KEYMAP
11196 buf->b_p_keymap = vim_strsave(p_keymap);
11197 buf->b_kmap_state |= KEYMAP_INIT;
11198#endif
11199 /* This isn't really an option, but copying the langmap and IME
11200 * state from the current buffer is better than resetting it. */
11201 buf->b_p_iminsert = p_iminsert;
11202 buf->b_p_imsearch = p_imsearch;
11203
11204 /* options that are normally global but also have a local value
11205 * are not copied, start using the global value */
11206 buf->b_p_ar = -1;
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010011207 buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020011208 buf->b_p_bkc = empty_option;
11209 buf->b_bkc_flags = 0;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011210#ifdef FEAT_QUICKFIX
11211 buf->b_p_gp = empty_option;
11212 buf->b_p_mp = empty_option;
11213 buf->b_p_efm = empty_option;
11214#endif
11215 buf->b_p_ep = empty_option;
11216 buf->b_p_kp = empty_option;
11217 buf->b_p_path = empty_option;
11218 buf->b_p_tags = empty_option;
Bram Moolenaar0f6562e2015-11-24 18:48:14 +010011219 buf->b_p_tc = empty_option;
11220 buf->b_tc_flags = 0;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011221#ifdef FEAT_FIND_ID
11222 buf->b_p_def = empty_option;
11223 buf->b_p_inc = empty_option;
11224# ifdef FEAT_EVAL
11225 buf->b_p_inex = vim_strsave(p_inex);
11226# endif
11227#endif
11228#ifdef FEAT_INS_EXPAND
11229 buf->b_p_dict = empty_option;
11230 buf->b_p_tsr = empty_option;
11231#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000011232#ifdef FEAT_TEXTOBJ
11233 buf->b_p_qe = vim_strsave(p_qe);
11234#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000011235#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
11236 buf->b_p_bexpr = empty_option;
11237#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020011238#if defined(FEAT_CRYPT)
11239 buf->b_p_cm = empty_option;
11240#endif
Bram Moolenaar55debbe2010-05-23 23:34:36 +020011241#ifdef FEAT_PERSISTENT_UNDO
11242 buf->b_p_udf = p_udf;
11243#endif
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010011244#ifdef FEAT_LISP
11245 buf->b_p_lw = empty_option;
11246#endif
Bram Moolenaar2c7292d2017-03-05 17:43:31 +010011247#ifdef FEAT_MBYTE
11248 buf->b_p_menc = empty_option;
11249#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011250
11251 /*
11252 * Don't copy the options set by ex_help(), use the saved values,
11253 * when going from a help buffer to a non-help buffer.
11254 * Don't touch these at all when BCO_NOHELP is used and going from
11255 * or to a help buffer.
11256 */
11257 if (dont_do_help)
11258 buf->b_p_isk = save_p_isk;
11259 else
11260 {
11261 buf->b_p_isk = vim_strsave(p_isk);
11262 did_isk = TRUE;
11263 buf->b_p_ts = p_ts;
11264 buf->b_help = FALSE;
11265#ifdef FEAT_QUICKFIX
11266 if (buf->b_p_bt[0] == 'h')
11267 clear_string_option(&buf->b_p_bt);
11268#endif
11269 buf->b_p_ma = p_ma;
11270 }
11271 }
11272
11273 /*
11274 * When the options should be copied (ignoring BCO_ALWAYS), set the
11275 * flag that indicates that the options have been initialized.
11276 */
11277 if (should_copy)
11278 buf->b_p_initialized = TRUE;
11279 }
11280
11281 check_buf_options(buf); /* make sure we don't have NULLs */
11282 if (did_isk)
11283 (void)buf_init_chartab(buf, FALSE);
11284}
11285
11286/*
11287 * Reset the 'modifiable' option and its default value.
11288 */
11289 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011290reset_modifiable(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011291{
11292 int opt_idx;
11293
11294 curbuf->b_p_ma = FALSE;
11295 p_ma = FALSE;
11296 opt_idx = findoption((char_u *)"ma");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000011297 if (opt_idx >= 0)
11298 options[opt_idx].def_val[VI_DEFAULT] = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011299}
11300
11301/*
11302 * Set the global value for 'iminsert' to the local value.
11303 */
11304 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011305set_iminsert_global(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011306{
11307 p_iminsert = curbuf->b_p_iminsert;
11308}
11309
11310/*
11311 * Set the global value for 'imsearch' to the local value.
11312 */
11313 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011314set_imsearch_global(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011315{
11316 p_imsearch = curbuf->b_p_imsearch;
11317}
11318
11319#if defined(FEAT_CMDL_COMPL) || defined(PROTO)
11320static int expand_option_idx = -1;
11321static char_u expand_option_name[5] = {'t', '_', NUL, NUL, NUL};
11322static int expand_option_flags = 0;
11323
11324 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011325set_context_in_set_cmd(
11326 expand_T *xp,
11327 char_u *arg,
11328 int opt_flags) /* OPT_GLOBAL and/or OPT_LOCAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011329{
11330 int nextchar;
11331 long_u flags = 0; /* init for GCC */
11332 int opt_idx = 0; /* init for GCC */
11333 char_u *p;
11334 char_u *s;
11335 int is_term_option = FALSE;
11336 int key;
11337
11338 expand_option_flags = opt_flags;
11339
11340 xp->xp_context = EXPAND_SETTINGS;
11341 if (*arg == NUL)
11342 {
11343 xp->xp_pattern = arg;
11344 return;
11345 }
11346 p = arg + STRLEN(arg) - 1;
11347 if (*p == ' ' && *(p - 1) != '\\')
11348 {
11349 xp->xp_pattern = p + 1;
11350 return;
11351 }
11352 while (p > arg)
11353 {
11354 s = p;
11355 /* count number of backslashes before ' ' or ',' */
11356 if (*p == ' ' || *p == ',')
11357 {
11358 while (s > arg && *(s - 1) == '\\')
11359 --s;
11360 }
11361 /* break at a space with an even number of backslashes */
11362 if (*p == ' ' && ((p - s) & 1) == 0)
11363 {
11364 ++p;
11365 break;
11366 }
11367 --p;
11368 }
Bram Moolenaar2a7b9ee2009-06-16 15:50:33 +000011369 if (STRNCMP(p, "no", 2) == 0 && STRNCMP(p, "novice", 6) != 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011370 {
11371 xp->xp_context = EXPAND_BOOL_SETTINGS;
11372 p += 2;
11373 }
11374 if (STRNCMP(p, "inv", 3) == 0)
11375 {
11376 xp->xp_context = EXPAND_BOOL_SETTINGS;
11377 p += 3;
11378 }
11379 xp->xp_pattern = arg = p;
11380 if (*arg == '<')
11381 {
11382 while (*p != '>')
11383 if (*p++ == NUL) /* expand terminal option name */
11384 return;
11385 key = get_special_key_code(arg + 1);
11386 if (key == 0) /* unknown name */
11387 {
11388 xp->xp_context = EXPAND_NOTHING;
11389 return;
11390 }
11391 nextchar = *++p;
11392 is_term_option = TRUE;
11393 expand_option_name[2] = KEY2TERMCAP0(key);
11394 expand_option_name[3] = KEY2TERMCAP1(key);
11395 }
11396 else
11397 {
11398 if (p[0] == 't' && p[1] == '_')
11399 {
11400 p += 2;
11401 if (*p != NUL)
11402 ++p;
11403 if (*p == NUL)
11404 return; /* expand option name */
11405 nextchar = *++p;
11406 is_term_option = TRUE;
11407 expand_option_name[2] = p[-2];
11408 expand_option_name[3] = p[-1];
11409 }
11410 else
11411 {
11412 /* Allow * wildcard */
11413 while (ASCII_ISALNUM(*p) || *p == '_' || *p == '*')
11414 p++;
11415 if (*p == NUL)
11416 return;
11417 nextchar = *p;
11418 *p = NUL;
11419 opt_idx = findoption(arg);
11420 *p = nextchar;
11421 if (opt_idx == -1 || options[opt_idx].var == NULL)
11422 {
11423 xp->xp_context = EXPAND_NOTHING;
11424 return;
11425 }
11426 flags = options[opt_idx].flags;
11427 if (flags & P_BOOL)
11428 {
11429 xp->xp_context = EXPAND_NOTHING;
11430 return;
11431 }
11432 }
11433 }
11434 /* handle "-=" and "+=" */
11435 if ((nextchar == '-' || nextchar == '+' || nextchar == '^') && p[1] == '=')
11436 {
11437 ++p;
11438 nextchar = '=';
11439 }
11440 if ((nextchar != '=' && nextchar != ':')
11441 || xp->xp_context == EXPAND_BOOL_SETTINGS)
11442 {
11443 xp->xp_context = EXPAND_UNSUCCESSFUL;
11444 return;
11445 }
11446 if (xp->xp_context != EXPAND_BOOL_SETTINGS && p[1] == NUL)
11447 {
11448 xp->xp_context = EXPAND_OLD_SETTING;
11449 if (is_term_option)
11450 expand_option_idx = -1;
11451 else
11452 expand_option_idx = opt_idx;
11453 xp->xp_pattern = p + 1;
11454 return;
11455 }
11456 xp->xp_context = EXPAND_NOTHING;
11457 if (is_term_option || (flags & P_NUM))
11458 return;
11459
11460 xp->xp_pattern = p + 1;
11461
11462 if (flags & P_EXPAND)
11463 {
11464 p = options[opt_idx].var;
11465 if (p == (char_u *)&p_bdir
11466 || p == (char_u *)&p_dir
11467 || p == (char_u *)&p_path
Bram Moolenaarf6fee0e2016-02-21 23:02:49 +010011468 || p == (char_u *)&p_pp
Bram Moolenaar071d4272004-06-13 20:20:40 +000011469 || p == (char_u *)&p_rtp
11470#ifdef FEAT_SEARCHPATH
11471 || p == (char_u *)&p_cdpath
11472#endif
11473#ifdef FEAT_SESSION
11474 || p == (char_u *)&p_vdir
11475#endif
11476 )
11477 {
11478 xp->xp_context = EXPAND_DIRECTORIES;
11479 if (p == (char_u *)&p_path
11480#ifdef FEAT_SEARCHPATH
11481 || p == (char_u *)&p_cdpath
11482#endif
11483 )
11484 xp->xp_backslash = XP_BS_THREE;
11485 else
11486 xp->xp_backslash = XP_BS_ONE;
11487 }
11488 else
11489 {
11490 xp->xp_context = EXPAND_FILES;
11491 /* for 'tags' need three backslashes for a space */
11492 if (p == (char_u *)&p_tags)
11493 xp->xp_backslash = XP_BS_THREE;
11494 else
11495 xp->xp_backslash = XP_BS_ONE;
11496 }
11497 }
11498
11499 /* For an option that is a list of file names, find the start of the
11500 * last file name. */
11501 for (p = arg + STRLEN(arg) - 1; p > xp->xp_pattern; --p)
11502 {
11503 /* count number of backslashes before ' ' or ',' */
11504 if (*p == ' ' || *p == ',')
11505 {
11506 s = p;
11507 while (s > xp->xp_pattern && *(s - 1) == '\\')
11508 --s;
11509 if ((*p == ' ' && (xp->xp_backslash == XP_BS_THREE && (p - s) < 3))
11510 || (*p == ',' && (flags & P_COMMA) && ((p - s) & 1) == 0))
11511 {
11512 xp->xp_pattern = p + 1;
11513 break;
11514 }
11515 }
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +000011516
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000011517#ifdef FEAT_SPELL
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +000011518 /* for 'spellsuggest' start at "file:" */
11519 if (options[opt_idx].var == (char_u *)&p_sps
11520 && STRNCMP(p, "file:", 5) == 0)
11521 {
11522 xp->xp_pattern = p + 5;
11523 break;
11524 }
11525#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011526 }
11527
11528 return;
11529}
11530
11531 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011532ExpandSettings(
11533 expand_T *xp,
11534 regmatch_T *regmatch,
11535 int *num_file,
11536 char_u ***file)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011537{
11538 int num_normal = 0; /* Nr of matching non-term-code settings */
11539 int num_term = 0; /* Nr of matching terminal code settings */
11540 int opt_idx;
11541 int match;
11542 int count = 0;
11543 char_u *str;
11544 int loop;
11545 int is_term_opt;
11546 char_u name_buf[MAX_KEY_NAME_LEN];
11547 static char *(names[]) = {"all", "termcap"};
11548 int ic = regmatch->rm_ic; /* remember the ignore-case flag */
11549
11550 /* do this loop twice:
11551 * loop == 0: count the number of matching options
11552 * loop == 1: copy the matching options into allocated memory
11553 */
11554 for (loop = 0; loop <= 1; ++loop)
11555 {
11556 regmatch->rm_ic = ic;
11557 if (xp->xp_context != EXPAND_BOOL_SETTINGS)
11558 {
Bram Moolenaar2c4278f2009-05-17 11:33:22 +000011559 for (match = 0; match < (int)(sizeof(names) / sizeof(char *));
11560 ++match)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011561 if (vim_regexec(regmatch, (char_u *)names[match], (colnr_T)0))
11562 {
11563 if (loop == 0)
11564 num_normal++;
11565 else
11566 (*file)[count++] = vim_strsave((char_u *)names[match]);
11567 }
11568 }
11569 for (opt_idx = 0; (str = (char_u *)options[opt_idx].fullname) != NULL;
11570 opt_idx++)
11571 {
11572 if (options[opt_idx].var == NULL)
11573 continue;
11574 if (xp->xp_context == EXPAND_BOOL_SETTINGS
11575 && !(options[opt_idx].flags & P_BOOL))
11576 continue;
11577 is_term_opt = istermoption(&options[opt_idx]);
11578 if (is_term_opt && num_normal > 0)
11579 continue;
11580 match = FALSE;
11581 if (vim_regexec(regmatch, str, (colnr_T)0)
11582 || (options[opt_idx].shortname != NULL
11583 && vim_regexec(regmatch,
11584 (char_u *)options[opt_idx].shortname, (colnr_T)0)))
11585 match = TRUE;
11586 else if (is_term_opt)
11587 {
11588 name_buf[0] = '<';
11589 name_buf[1] = 't';
11590 name_buf[2] = '_';
11591 name_buf[3] = str[2];
11592 name_buf[4] = str[3];
11593 name_buf[5] = '>';
11594 name_buf[6] = NUL;
11595 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11596 {
11597 match = TRUE;
11598 str = name_buf;
11599 }
11600 }
11601 if (match)
11602 {
11603 if (loop == 0)
11604 {
11605 if (is_term_opt)
11606 num_term++;
11607 else
11608 num_normal++;
11609 }
11610 else
11611 (*file)[count++] = vim_strsave(str);
11612 }
11613 }
11614 /*
11615 * Check terminal key codes, these are not in the option table
11616 */
11617 if (xp->xp_context != EXPAND_BOOL_SETTINGS && num_normal == 0)
11618 {
11619 for (opt_idx = 0; (str = get_termcode(opt_idx)) != NULL; opt_idx++)
11620 {
11621 if (!isprint(str[0]) || !isprint(str[1]))
11622 continue;
11623
11624 name_buf[0] = 't';
11625 name_buf[1] = '_';
11626 name_buf[2] = str[0];
11627 name_buf[3] = str[1];
11628 name_buf[4] = NUL;
11629
11630 match = FALSE;
11631 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11632 match = TRUE;
11633 else
11634 {
11635 name_buf[0] = '<';
11636 name_buf[1] = 't';
11637 name_buf[2] = '_';
11638 name_buf[3] = str[0];
11639 name_buf[4] = str[1];
11640 name_buf[5] = '>';
11641 name_buf[6] = NUL;
11642
11643 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11644 match = TRUE;
11645 }
11646 if (match)
11647 {
11648 if (loop == 0)
11649 num_term++;
11650 else
11651 (*file)[count++] = vim_strsave(name_buf);
11652 }
11653 }
11654
11655 /*
11656 * Check special key names.
11657 */
11658 regmatch->rm_ic = TRUE; /* ignore case here */
11659 for (opt_idx = 0; (str = get_key_name(opt_idx)) != NULL; opt_idx++)
11660 {
11661 name_buf[0] = '<';
11662 STRCPY(name_buf + 1, str);
11663 STRCAT(name_buf, ">");
11664
11665 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11666 {
11667 if (loop == 0)
11668 num_term++;
11669 else
11670 (*file)[count++] = vim_strsave(name_buf);
11671 }
11672 }
11673 }
11674 if (loop == 0)
11675 {
11676 if (num_normal > 0)
11677 *num_file = num_normal;
11678 else if (num_term > 0)
11679 *num_file = num_term;
11680 else
11681 return OK;
11682 *file = (char_u **)alloc((unsigned)(*num_file * sizeof(char_u *)));
11683 if (*file == NULL)
11684 {
11685 *file = (char_u **)"";
11686 return FAIL;
11687 }
11688 }
11689 }
11690 return OK;
11691}
11692
11693 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011694ExpandOldSetting(int *num_file, char_u ***file)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011695{
11696 char_u *var = NULL; /* init for GCC */
11697 char_u *buf;
11698
11699 *num_file = 0;
11700 *file = (char_u **)alloc((unsigned)sizeof(char_u *));
11701 if (*file == NULL)
11702 return FAIL;
11703
11704 /*
11705 * For a terminal key code expand_option_idx is < 0.
11706 */
11707 if (expand_option_idx < 0)
11708 {
11709 var = find_termcode(expand_option_name + 2);
11710 if (var == NULL)
11711 expand_option_idx = findoption(expand_option_name);
11712 }
11713
11714 if (expand_option_idx >= 0)
11715 {
11716 /* put string of option value in NameBuff */
11717 option_value2string(&options[expand_option_idx], expand_option_flags);
11718 var = NameBuff;
11719 }
11720 else if (var == NULL)
11721 var = (char_u *)"";
11722
11723 /* A backslash is required before some characters. This is the reverse of
11724 * what happens in do_set(). */
11725 buf = vim_strsave_escaped(var, escape_chars);
11726
11727 if (buf == NULL)
11728 {
11729 vim_free(*file);
11730 *file = NULL;
11731 return FAIL;
11732 }
11733
11734#ifdef BACKSLASH_IN_FILENAME
11735 /* For MS-Windows et al. we don't double backslashes at the start and
11736 * before a file name character. */
Bram Moolenaar91acfff2017-03-12 19:22:36 +010011737 for (var = buf; *var != NUL; MB_PTR_ADV(var))
Bram Moolenaar071d4272004-06-13 20:20:40 +000011738 if (var[0] == '\\' && var[1] == '\\'
11739 && expand_option_idx >= 0
11740 && (options[expand_option_idx].flags & P_EXPAND)
11741 && vim_isfilec(var[2])
11742 && (var[2] != '\\' || (var == buf && var[4] != '\\')))
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +000011743 STRMOVE(var, var + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011744#endif
11745
11746 *file[0] = buf;
11747 *num_file = 1;
11748 return OK;
11749}
11750#endif
11751
11752/*
11753 * Get the value for the numeric or string option *opp in a nice format into
11754 * NameBuff[]. Must not be called with a hidden option!
11755 */
11756 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011757option_value2string(
11758 struct vimoption *opp,
11759 int opt_flags) /* OPT_GLOBAL and/or OPT_LOCAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011760{
11761 char_u *varp;
11762
11763 varp = get_varp_scope(opp, opt_flags);
11764
11765 if (opp->flags & P_NUM)
11766 {
11767 long wc = 0;
11768
11769 if (wc_use_keyname(varp, &wc))
11770 STRCPY(NameBuff, get_special_key_name((int)wc, 0));
11771 else if (wc != 0)
11772 STRCPY(NameBuff, transchar((int)wc));
11773 else
11774 sprintf((char *)NameBuff, "%ld", *(long *)varp);
11775 }
11776 else /* P_STRING */
11777 {
11778 varp = *(char_u **)(varp);
11779 if (varp == NULL) /* just in case */
11780 NameBuff[0] = NUL;
11781#ifdef FEAT_CRYPT
11782 /* don't show the actual value of 'key', only that it's set */
Bram Moolenaareb3593b2006-04-22 22:33:57 +000011783 else if (opp->var == (char_u *)&p_key && *varp)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011784 STRCPY(NameBuff, "*****");
11785#endif
11786 else if (opp->flags & P_EXPAND)
11787 home_replace(NULL, varp, NameBuff, MAXPATHL, FALSE);
11788 /* Translate 'pastetoggle' into special key names */
11789 else if ((char_u **)opp->var == &p_pt)
11790 str2specialbuf(p_pt, NameBuff, MAXPATHL);
11791 else
Bram Moolenaarce0842a2005-07-18 21:58:11 +000011792 vim_strncpy(NameBuff, varp, MAXPATHL - 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011793 }
11794}
11795
11796/*
11797 * Return TRUE if "varp" points to 'wildchar' or 'wildcharm' and it can be
11798 * printed as a keyname.
11799 * "*wcp" is set to the value of the option if it's 'wildchar' or 'wildcharm'.
11800 */
11801 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011802wc_use_keyname(char_u *varp, long *wcp)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011803{
11804 if (((long *)varp == &p_wc) || ((long *)varp == &p_wcm))
11805 {
11806 *wcp = *(long *)varp;
11807 if (IS_SPECIAL(*wcp) || find_special_key_in_table((int)*wcp) >= 0)
11808 return TRUE;
11809 }
11810 return FALSE;
11811}
11812
Bram Moolenaar01615492015-02-03 13:00:38 +010011813#if defined(FEAT_LANGMAP) || defined(PROTO)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011814/*
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011815 * Any character has an equivalent 'langmap' character. This is used for
11816 * keyboards that have a special language mode that sends characters above
11817 * 128 (although other characters can be translated too). The "to" field is a
11818 * Vim command character. This avoids having to switch the keyboard back to
11819 * ASCII mode when leaving Insert mode.
11820 *
11821 * langmap_mapchar[] maps any of 256 chars to an ASCII char used for Vim
11822 * commands.
11823 * When FEAT_MBYTE is defined langmap_mapga.ga_data is a sorted table of
11824 * langmap_entry_T. This does the same as langmap_mapchar[] for characters >=
11825 * 256.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011826 */
Bram Moolenaar01615492015-02-03 13:00:38 +010011827# if defined(FEAT_MBYTE) || defined(PROTO)
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011828/*
11829 * With multi-byte support use growarray for 'langmap' chars >= 256
11830 */
11831typedef struct
11832{
11833 int from;
11834 int to;
11835} langmap_entry_T;
11836
11837static garray_T langmap_mapga;
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +010011838static void langmap_set_entry(int from, int to);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011839
11840/*
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011841 * Search for an entry in "langmap_mapga" for "from". If found set the "to"
11842 * field. If not found insert a new entry at the appropriate location.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011843 */
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011844 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011845langmap_set_entry(int from, int to)
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011846{
11847 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
Bram Moolenaarcc448b32010-07-14 16:52:17 +020011848 int a = 0;
11849 int b = langmap_mapga.ga_len;
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011850
11851 /* Do a binary search for an existing entry. */
11852 while (a != b)
11853 {
11854 int i = (a + b) / 2;
11855 int d = entries[i].from - from;
11856
11857 if (d == 0)
11858 {
11859 entries[i].to = to;
11860 return;
11861 }
11862 if (d < 0)
11863 a = i + 1;
11864 else
11865 b = i;
11866 }
11867
11868 if (ga_grow(&langmap_mapga, 1) != OK)
11869 return; /* out of memory */
11870
11871 /* insert new entry at position "a" */
11872 entries = (langmap_entry_T *)(langmap_mapga.ga_data) + a;
11873 mch_memmove(entries + 1, entries,
11874 (langmap_mapga.ga_len - a) * sizeof(langmap_entry_T));
11875 ++langmap_mapga.ga_len;
11876 entries[0].from = from;
11877 entries[0].to = to;
11878}
11879
11880/*
11881 * Apply 'langmap' to multi-byte character "c" and return the result.
11882 */
11883 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011884langmap_adjust_mb(int c)
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011885{
11886 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
11887 int a = 0;
11888 int b = langmap_mapga.ga_len;
11889
11890 while (a != b)
11891 {
11892 int i = (a + b) / 2;
11893 int d = entries[i].from - c;
11894
11895 if (d == 0)
11896 return entries[i].to; /* found matching entry */
11897 if (d < 0)
11898 a = i + 1;
11899 else
11900 b = i;
11901 }
11902 return c; /* no entry found, return "c" unmodified */
11903}
11904# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011905
11906 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011907langmap_init(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011908{
11909 int i;
11910
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011911 for (i = 0; i < 256; i++)
11912 langmap_mapchar[i] = i; /* we init with a one-to-one map */
11913# ifdef FEAT_MBYTE
11914 ga_init2(&langmap_mapga, sizeof(langmap_entry_T), 8);
11915# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011916}
11917
11918/*
11919 * Called when langmap option is set; the language map can be
11920 * changed at any time!
11921 */
11922 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011923langmap_set(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011924{
11925 char_u *p;
11926 char_u *p2;
11927 int from, to;
11928
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011929#ifdef FEAT_MBYTE
11930 ga_clear(&langmap_mapga); /* clear the previous map first */
11931#endif
11932 langmap_init(); /* back to one-to-one map */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011933
11934 for (p = p_langmap; p[0] != NUL; )
11935 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011936 for (p2 = p; p2[0] != NUL && p2[0] != ',' && p2[0] != ';';
Bram Moolenaar91acfff2017-03-12 19:22:36 +010011937 MB_PTR_ADV(p2))
Bram Moolenaar071d4272004-06-13 20:20:40 +000011938 {
11939 if (p2[0] == '\\' && p2[1] != NUL)
11940 ++p2;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011941 }
11942 if (p2[0] == ';')
11943 ++p2; /* abcd;ABCD form, p2 points to A */
11944 else
11945 p2 = NULL; /* aAbBcCdD form, p2 is NULL */
11946 while (p[0])
11947 {
Bram Moolenaar6af05062010-05-14 17:32:58 +020011948 if (p[0] == ',')
11949 {
11950 ++p;
11951 break;
11952 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011953 if (p[0] == '\\' && p[1] != NUL)
11954 ++p;
11955#ifdef FEAT_MBYTE
11956 from = (*mb_ptr2char)(p);
11957#else
11958 from = p[0];
11959#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011960 to = NUL;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011961 if (p2 == NULL)
11962 {
Bram Moolenaar91acfff2017-03-12 19:22:36 +010011963 MB_PTR_ADV(p);
Bram Moolenaar6af05062010-05-14 17:32:58 +020011964 if (p[0] != ',')
11965 {
11966 if (p[0] == '\\')
11967 ++p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011968#ifdef FEAT_MBYTE
Bram Moolenaar6af05062010-05-14 17:32:58 +020011969 to = (*mb_ptr2char)(p);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011970#else
Bram Moolenaar6af05062010-05-14 17:32:58 +020011971 to = p[0];
Bram Moolenaar071d4272004-06-13 20:20:40 +000011972#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011973 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011974 }
11975 else
11976 {
Bram Moolenaar6af05062010-05-14 17:32:58 +020011977 if (p2[0] != ',')
11978 {
11979 if (p2[0] == '\\')
11980 ++p2;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011981#ifdef FEAT_MBYTE
Bram Moolenaar6af05062010-05-14 17:32:58 +020011982 to = (*mb_ptr2char)(p2);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011983#else
Bram Moolenaar6af05062010-05-14 17:32:58 +020011984 to = p2[0];
Bram Moolenaar071d4272004-06-13 20:20:40 +000011985#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011986 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011987 }
11988 if (to == NUL)
11989 {
11990 EMSG2(_("E357: 'langmap': Matching character missing for %s"),
11991 transchar(from));
11992 return;
11993 }
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011994
11995#ifdef FEAT_MBYTE
11996 if (from >= 256)
11997 langmap_set_entry(from, to);
11998 else
11999#endif
12000 langmap_mapchar[from & 255] = to;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012001
12002 /* Advance to next pair */
Bram Moolenaar91acfff2017-03-12 19:22:36 +010012003 MB_PTR_ADV(p);
Bram Moolenaar6af05062010-05-14 17:32:58 +020012004 if (p2 != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012005 {
Bram Moolenaar91acfff2017-03-12 19:22:36 +010012006 MB_PTR_ADV(p2);
Bram Moolenaar071d4272004-06-13 20:20:40 +000012007 if (*p == ';')
12008 {
12009 p = p2;
12010 if (p[0] != NUL)
12011 {
12012 if (p[0] != ',')
12013 {
12014 EMSG2(_("E358: 'langmap': Extra characters after semicolon: %s"), p);
12015 return;
12016 }
12017 ++p;
12018 }
12019 break;
12020 }
12021 }
12022 }
12023 }
12024}
12025#endif
12026
12027/*
12028 * Return TRUE if format option 'x' is in effect.
12029 * Take care of no formatting when 'paste' is set.
12030 */
12031 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012032has_format_option(int x)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012033{
12034 if (p_paste)
12035 return FALSE;
12036 return (vim_strchr(curbuf->b_p_fo, x) != NULL);
12037}
12038
12039/*
12040 * Return TRUE if "x" is present in 'shortmess' option, or
12041 * 'shortmess' contains 'a' and "x" is present in SHM_A.
12042 */
12043 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012044shortmess(int x)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012045{
Bram Moolenaar7f29f7a2012-02-29 13:51:37 +010012046 return p_shm != NULL &&
12047 ( vim_strchr(p_shm, x) != NULL
Bram Moolenaar071d4272004-06-13 20:20:40 +000012048 || (vim_strchr(p_shm, 'a') != NULL
12049 && vim_strchr((char_u *)SHM_A, x) != NULL));
12050}
12051
12052/*
12053 * paste_option_changed() - Called after p_paste was set or reset.
12054 */
12055 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012056paste_option_changed(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012057{
12058 static int old_p_paste = FALSE;
12059 static int save_sm = 0;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012060 static int save_sta = 0;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012061#ifdef FEAT_CMDL_INFO
12062 static int save_ru = 0;
12063#endif
12064#ifdef FEAT_RIGHTLEFT
12065 static int save_ri = 0;
12066 static int save_hkmap = 0;
12067#endif
12068 buf_T *buf;
12069
12070 if (p_paste)
12071 {
12072 /*
12073 * Paste switched from off to on.
12074 * Save the current values, so they can be restored later.
12075 */
12076 if (!old_p_paste)
12077 {
12078 /* save options for each buffer */
Bram Moolenaar29323592016-07-24 22:04:11 +020012079 FOR_ALL_BUFFERS(buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012080 {
12081 buf->b_p_tw_nopaste = buf->b_p_tw;
12082 buf->b_p_wm_nopaste = buf->b_p_wm;
12083 buf->b_p_sts_nopaste = buf->b_p_sts;
12084 buf->b_p_ai_nopaste = buf->b_p_ai;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012085 buf->b_p_et_nopaste = buf->b_p_et;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012086 }
12087
12088 /* save global options */
12089 save_sm = p_sm;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012090 save_sta = p_sta;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012091#ifdef FEAT_CMDL_INFO
12092 save_ru = p_ru;
12093#endif
12094#ifdef FEAT_RIGHTLEFT
12095 save_ri = p_ri;
12096 save_hkmap = p_hkmap;
12097#endif
12098 /* save global values for local buffer options */
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012099 p_ai_nopaste = p_ai;
12100 p_et_nopaste = p_et;
12101 p_sts_nopaste = p_sts;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012102 p_tw_nopaste = p_tw;
12103 p_wm_nopaste = p_wm;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012104 }
12105
12106 /*
12107 * Always set the option values, also when 'paste' is set when it is
12108 * already on.
12109 */
12110 /* set options for each buffer */
Bram Moolenaar29323592016-07-24 22:04:11 +020012111 FOR_ALL_BUFFERS(buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012112 {
12113 buf->b_p_tw = 0; /* textwidth is 0 */
12114 buf->b_p_wm = 0; /* wrapmargin is 0 */
12115 buf->b_p_sts = 0; /* softtabstop is 0 */
12116 buf->b_p_ai = 0; /* no auto-indent */
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012117 buf->b_p_et = 0; /* no expandtab */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012118 }
12119
12120 /* set global options */
12121 p_sm = 0; /* no showmatch */
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012122 p_sta = 0; /* no smarttab */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012123#ifdef FEAT_CMDL_INFO
12124# ifdef FEAT_WINDOWS
12125 if (p_ru)
12126 status_redraw_all(); /* redraw to remove the ruler */
12127# endif
12128 p_ru = 0; /* no ruler */
12129#endif
12130#ifdef FEAT_RIGHTLEFT
12131 p_ri = 0; /* no reverse insert */
12132 p_hkmap = 0; /* no Hebrew keyboard */
12133#endif
12134 /* set global values for local buffer options */
12135 p_tw = 0;
12136 p_wm = 0;
12137 p_sts = 0;
12138 p_ai = 0;
12139 }
12140
12141 /*
12142 * Paste switched from on to off: Restore saved values.
12143 */
12144 else if (old_p_paste)
12145 {
12146 /* restore options for each buffer */
Bram Moolenaar29323592016-07-24 22:04:11 +020012147 FOR_ALL_BUFFERS(buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012148 {
12149 buf->b_p_tw = buf->b_p_tw_nopaste;
12150 buf->b_p_wm = buf->b_p_wm_nopaste;
12151 buf->b_p_sts = buf->b_p_sts_nopaste;
12152 buf->b_p_ai = buf->b_p_ai_nopaste;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012153 buf->b_p_et = buf->b_p_et_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012154 }
12155
12156 /* restore global options */
12157 p_sm = save_sm;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012158 p_sta = save_sta;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012159#ifdef FEAT_CMDL_INFO
12160# ifdef FEAT_WINDOWS
12161 if (p_ru != save_ru)
12162 status_redraw_all(); /* redraw to draw the ruler */
12163# endif
12164 p_ru = save_ru;
12165#endif
12166#ifdef FEAT_RIGHTLEFT
12167 p_ri = save_ri;
12168 p_hkmap = save_hkmap;
12169#endif
12170 /* set global values for local buffer options */
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012171 p_ai = p_ai_nopaste;
12172 p_et = p_et_nopaste;
12173 p_sts = p_sts_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012174 p_tw = p_tw_nopaste;
12175 p_wm = p_wm_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012176 }
12177
12178 old_p_paste = p_paste;
12179}
12180
12181/*
12182 * vimrc_found() - Called when a ".vimrc" or "VIMINIT" has been found.
12183 *
12184 * Reset 'compatible' and set the values for options that didn't get set yet
12185 * to the Vim defaults.
12186 * Don't do this if the 'compatible' option has been set or reset before.
Bram Moolenaar910f66f2006-04-05 20:41:53 +000012187 * When "fname" is not NULL, use it to set $"envname" when it wasn't set yet.
Bram Moolenaar071d4272004-06-13 20:20:40 +000012188 */
12189 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012190vimrc_found(char_u *fname, char_u *envname)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012191{
Bram Moolenaar910f66f2006-04-05 20:41:53 +000012192 int opt_idx;
Bram Moolenaar4c3f5362006-04-11 21:38:50 +000012193 int dofree = FALSE;
Bram Moolenaar910f66f2006-04-05 20:41:53 +000012194 char_u *p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012195
12196 if (!option_was_set((char_u *)"cp"))
12197 {
12198 p_cp = FALSE;
12199 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
12200 if (!(options[opt_idx].flags & (P_WAS_SET|P_VI_DEF)))
12201 set_option_default(opt_idx, OPT_FREE, FALSE);
12202 didset_options();
Bram Moolenaare68c25c2015-08-25 15:39:55 +020012203 didset_options2();
Bram Moolenaar071d4272004-06-13 20:20:40 +000012204 }
Bram Moolenaar910f66f2006-04-05 20:41:53 +000012205
12206 if (fname != NULL)
12207 {
12208 p = vim_getenv(envname, &dofree);
12209 if (p == NULL)
12210 {
12211 /* Set $MYVIMRC to the first vimrc file found. */
12212 p = FullName_save(fname, FALSE);
12213 if (p != NULL)
12214 {
12215 vim_setenv(envname, p);
12216 vim_free(p);
12217 }
12218 }
12219 else if (dofree)
12220 vim_free(p);
12221 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000012222}
12223
12224/*
12225 * Set 'compatible' on or off. Called for "-C" and "-N" command line arg.
12226 */
12227 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012228change_compatible(int on)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012229{
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000012230 int opt_idx;
12231
Bram Moolenaar071d4272004-06-13 20:20:40 +000012232 if (p_cp != on)
12233 {
12234 p_cp = on;
12235 compatible_set();
12236 }
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000012237 opt_idx = findoption((char_u *)"cp");
12238 if (opt_idx >= 0)
12239 options[opt_idx].flags |= P_WAS_SET;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012240}
12241
12242/*
12243 * Return TRUE when option "name" has been set.
Bram Moolenaar1a4a75c2013-07-28 16:03:06 +020012244 * Only works correctly for global options.
Bram Moolenaar071d4272004-06-13 20:20:40 +000012245 */
12246 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012247option_was_set(char_u *name)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012248{
12249 int idx;
12250
12251 idx = findoption(name);
12252 if (idx < 0) /* unknown option */
12253 return FALSE;
12254 if (options[idx].flags & P_WAS_SET)
12255 return TRUE;
12256 return FALSE;
12257}
12258
12259/*
Bram Moolenaar15d55de2012-12-05 14:43:02 +010012260 * Reset the flag indicating option "name" was set.
12261 */
12262 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012263reset_option_was_set(char_u *name)
Bram Moolenaar15d55de2012-12-05 14:43:02 +010012264{
12265 int idx = findoption(name);
12266
12267 if (idx >= 0)
12268 options[idx].flags &= ~P_WAS_SET;
12269}
12270
12271/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000012272 * compatible_set() - Called when 'compatible' has been set or unset.
12273 *
12274 * When 'compatible' set: Set all relevant options (those that have the P_VIM)
12275 * flag) to a Vi compatible value.
12276 * When 'compatible' is unset: Set all options that have a different default
12277 * for Vim (without the P_VI_DEF flag) to that default.
12278 */
12279 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012280compatible_set(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012281{
12282 int opt_idx;
12283
12284 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
12285 if ( ((options[opt_idx].flags & P_VIM) && p_cp)
12286 || (!(options[opt_idx].flags & P_VI_DEF) && !p_cp))
12287 set_option_default(opt_idx, OPT_FREE, p_cp);
12288 didset_options();
Bram Moolenaare68c25c2015-08-25 15:39:55 +020012289 didset_options2();
Bram Moolenaar071d4272004-06-13 20:20:40 +000012290}
12291
12292#ifdef FEAT_LINEBREAK
12293
12294# if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
12295 /* Borland C++ screws up loop optimisation here (negri) */
Bram Moolenaar8f999f12005-01-25 22:12:55 +000012296 #pragma option -O-l
Bram Moolenaar071d4272004-06-13 20:20:40 +000012297# endif
12298
12299/*
12300 * fill_breakat_flags() -- called when 'breakat' changes value.
12301 */
12302 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012303fill_breakat_flags(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012304{
Bram Moolenaarac6e65f2005-08-29 22:25:38 +000012305 char_u *p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012306 int i;
12307
12308 for (i = 0; i < 256; i++)
12309 breakat_flags[i] = FALSE;
12310
12311 if (p_breakat != NULL)
Bram Moolenaarac6e65f2005-08-29 22:25:38 +000012312 for (p = p_breakat; *p; p++)
12313 breakat_flags[*p] = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012314}
12315
12316# if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
Bram Moolenaar8f999f12005-01-25 22:12:55 +000012317 #pragma option -O.l
Bram Moolenaar071d4272004-06-13 20:20:40 +000012318# endif
12319
12320#endif
12321
12322/*
12323 * Check an option that can be a range of string values.
12324 *
12325 * Return OK for correct value, FAIL otherwise.
12326 * Empty is always OK.
12327 */
12328 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012329check_opt_strings(
12330 char_u *val,
12331 char **values,
12332 int list) /* when TRUE: accept a list of values */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012333{
12334 return opt_strings_flags(val, values, NULL, list);
12335}
12336
12337/*
12338 * Handle an option that can be a range of string values.
12339 * Set a flag in "*flagp" for each string present.
12340 *
12341 * Return OK for correct value, FAIL otherwise.
12342 * Empty is always OK.
12343 */
12344 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012345opt_strings_flags(
12346 char_u *val, /* new value */
12347 char **values, /* array of valid string values */
12348 unsigned *flagp,
12349 int list) /* when TRUE: accept a list of values */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012350{
12351 int i;
12352 int len;
12353 unsigned new_flags = 0;
12354
12355 while (*val)
12356 {
12357 for (i = 0; ; ++i)
12358 {
12359 if (values[i] == NULL) /* val not found in values[] */
12360 return FAIL;
12361
12362 len = (int)STRLEN(values[i]);
12363 if (STRNCMP(values[i], val, len) == 0
12364 && ((list && val[len] == ',') || val[len] == NUL))
12365 {
12366 val += len + (val[len] == ',');
12367 new_flags |= (1 << i);
12368 break; /* check next item in val list */
12369 }
12370 }
12371 }
12372 if (flagp != NULL)
12373 *flagp = new_flags;
12374
12375 return OK;
12376}
12377
12378/*
12379 * Read the 'wildmode' option, fill wim_flags[].
12380 */
12381 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012382check_opt_wim(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012383{
12384 char_u new_wim_flags[4];
12385 char_u *p;
12386 int i;
12387 int idx = 0;
12388
12389 for (i = 0; i < 4; ++i)
12390 new_wim_flags[i] = 0;
12391
12392 for (p = p_wim; *p; ++p)
12393 {
12394 for (i = 0; ASCII_ISALPHA(p[i]); ++i)
12395 ;
12396 if (p[i] != NUL && p[i] != ',' && p[i] != ':')
12397 return FAIL;
12398 if (i == 7 && STRNCMP(p, "longest", 7) == 0)
12399 new_wim_flags[idx] |= WIM_LONGEST;
12400 else if (i == 4 && STRNCMP(p, "full", 4) == 0)
12401 new_wim_flags[idx] |= WIM_FULL;
12402 else if (i == 4 && STRNCMP(p, "list", 4) == 0)
12403 new_wim_flags[idx] |= WIM_LIST;
12404 else
12405 return FAIL;
12406 p += i;
12407 if (*p == NUL)
12408 break;
12409 if (*p == ',')
12410 {
12411 if (idx == 3)
12412 return FAIL;
12413 ++idx;
12414 }
12415 }
12416
12417 /* fill remaining entries with last flag */
12418 while (idx < 3)
12419 {
12420 new_wim_flags[idx + 1] = new_wim_flags[idx];
12421 ++idx;
12422 }
12423
12424 /* only when there are no errors, wim_flags[] is changed */
12425 for (i = 0; i < 4; ++i)
12426 wim_flags[i] = new_wim_flags[i];
12427 return OK;
12428}
12429
12430/*
12431 * Check if backspacing over something is allowed.
12432 */
12433 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012434can_bs(
12435 int what) /* BS_INDENT, BS_EOL or BS_START */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012436{
12437 switch (*p_bs)
12438 {
12439 case '2': return TRUE;
12440 case '1': return (what != BS_START);
12441 case '0': return FALSE;
12442 }
12443 return vim_strchr(p_bs, what) != NULL;
12444}
12445
12446/*
12447 * Save the current values of 'fileformat' and 'fileencoding', so that we know
12448 * the file must be considered changed when the value is different.
12449 */
12450 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012451save_file_ff(buf_T *buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012452{
12453 buf->b_start_ffc = *buf->b_p_ff;
12454 buf->b_start_eol = buf->b_p_eol;
12455#ifdef FEAT_MBYTE
Bram Moolenaar83eb8852007-08-12 13:51:26 +000012456 buf->b_start_bomb = buf->b_p_bomb;
12457
Bram Moolenaar071d4272004-06-13 20:20:40 +000012458 /* Only use free/alloc when necessary, they take time. */
12459 if (buf->b_start_fenc == NULL
12460 || STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0)
12461 {
12462 vim_free(buf->b_start_fenc);
12463 buf->b_start_fenc = vim_strsave(buf->b_p_fenc);
12464 }
12465#endif
12466}
12467
12468/*
12469 * Return TRUE if 'fileformat' and/or 'fileencoding' has a different value
12470 * from when editing started (save_file_ff() called).
Bram Moolenaar83eb8852007-08-12 13:51:26 +000012471 * Also when 'endofline' was changed and 'binary' is set, or when 'bomb' was
12472 * changed and 'binary' is not set.
Bram Moolenaar34d72d42015-07-17 14:18:08 +020012473 * Also when 'endofline' was changed and 'fixeol' is not set.
Bram Moolenaar164c60f2011-01-22 00:11:50 +010012474 * When "ignore_empty" is true don't consider a new, empty buffer to be
12475 * changed.
Bram Moolenaar071d4272004-06-13 20:20:40 +000012476 */
12477 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012478file_ff_differs(buf_T *buf, int ignore_empty)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012479{
Bram Moolenaar9cffde92007-07-24 07:51:18 +000012480 /* In a buffer that was never loaded the options are not valid. */
12481 if (buf->b_flags & BF_NEVERLOADED)
12482 return FALSE;
Bram Moolenaar164c60f2011-01-22 00:11:50 +010012483 if (ignore_empty
12484 && (buf->b_flags & BF_NEW)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012485 && buf->b_ml.ml_line_count == 1
12486 && *ml_get_buf(buf, (linenr_T)1, FALSE) == NUL)
12487 return FALSE;
12488 if (buf->b_start_ffc != *buf->b_p_ff)
12489 return TRUE;
Bram Moolenaar34d72d42015-07-17 14:18:08 +020012490 if ((buf->b_p_bin || !buf->b_p_fixeol) && buf->b_start_eol != buf->b_p_eol)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012491 return TRUE;
12492#ifdef FEAT_MBYTE
Bram Moolenaar83eb8852007-08-12 13:51:26 +000012493 if (!buf->b_p_bin && buf->b_start_bomb != buf->b_p_bomb)
12494 return TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012495 if (buf->b_start_fenc == NULL)
12496 return (*buf->b_p_fenc != NUL);
12497 return (STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0);
12498#else
12499 return FALSE;
12500#endif
12501}
12502
12503/*
12504 * return OK if "p" is a valid fileformat name, FAIL otherwise.
12505 */
12506 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012507check_ff_value(char_u *p)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012508{
12509 return check_opt_strings(p, p_ff_values, FALSE);
12510}
Bram Moolenaar14f24742012-08-08 18:01:05 +020012511
12512/*
12513 * Return the effective shiftwidth value for current buffer, using the
12514 * 'tabstop' value when 'shiftwidth' is zero.
12515 */
12516 long
Bram Moolenaar9b578142016-01-30 19:39:49 +010012517get_sw_value(buf_T *buf)
Bram Moolenaar14f24742012-08-08 18:01:05 +020012518{
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +010012519 return buf->b_p_sw ? buf->b_p_sw : buf->b_p_ts;
Bram Moolenaar14f24742012-08-08 18:01:05 +020012520}
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020012521
12522/*
12523 * Return the effective softtabstop value for the current buffer, using the
12524 * 'tabstop' value when 'softtabstop' is negative.
12525 */
12526 long
Bram Moolenaar9b578142016-01-30 19:39:49 +010012527get_sts_value(void)
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020012528{
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +010012529 return curbuf->b_p_sts < 0 ? get_sw_value(curbuf) : curbuf->b_p_sts;
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020012530}
Bram Moolenaar8c7694a2013-01-17 17:02:05 +010012531
12532/*
12533 * Check matchpairs option for "*initc".
12534 * If there is a match set "*initc" to the matching character and "*findc" to
12535 * the opposite character. Set "*backwards" to the direction.
12536 * When "switchit" is TRUE swap the direction.
12537 */
12538 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012539find_mps_values(
12540 int *initc,
12541 int *findc,
12542 int *backwards,
12543 int switchit)
Bram Moolenaar8c7694a2013-01-17 17:02:05 +010012544{
12545 char_u *ptr;
12546
12547 ptr = curbuf->b_p_mps;
12548 while (*ptr != NUL)
12549 {
12550#ifdef FEAT_MBYTE
12551 if (has_mbyte)
12552 {
12553 char_u *prev;
12554
12555 if (mb_ptr2char(ptr) == *initc)
12556 {
12557 if (switchit)
12558 {
12559 *findc = *initc;
12560 *initc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1);
12561 *backwards = TRUE;
12562 }
12563 else
12564 {
12565 *findc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1);
12566 *backwards = FALSE;
12567 }
12568 return;
12569 }
12570 prev = ptr;
12571 ptr += mb_ptr2len(ptr) + 1;
12572 if (mb_ptr2char(ptr) == *initc)
12573 {
12574 if (switchit)
12575 {
12576 *findc = *initc;
12577 *initc = mb_ptr2char(prev);
12578 *backwards = FALSE;
12579 }
12580 else
12581 {
12582 *findc = mb_ptr2char(prev);
12583 *backwards = TRUE;
12584 }
12585 return;
12586 }
12587 ptr += mb_ptr2len(ptr);
12588 }
12589 else
12590#endif
12591 {
12592 if (*ptr == *initc)
12593 {
12594 if (switchit)
12595 {
12596 *backwards = TRUE;
12597 *findc = *initc;
12598 *initc = ptr[2];
12599 }
12600 else
12601 {
12602 *backwards = FALSE;
12603 *findc = ptr[2];
12604 }
12605 return;
12606 }
12607 ptr += 2;
12608 if (*ptr == *initc)
12609 {
12610 if (switchit)
12611 {
12612 *backwards = FALSE;
12613 *findc = *initc;
12614 *initc = ptr[-2];
12615 }
12616 else
12617 {
12618 *backwards = TRUE;
12619 *findc = ptr[-2];
12620 }
12621 return;
12622 }
12623 ++ptr;
12624 }
12625 if (*ptr == ',')
12626 ++ptr;
12627 }
12628}
Bram Moolenaar597a4222014-06-25 14:39:50 +020012629
12630#if defined(FEAT_LINEBREAK) || defined(PROTO)
12631/*
12632 * This is called when 'breakindentopt' is changed and when a window is
12633 * initialized.
12634 */
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012635 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012636briopt_check(win_T *wp)
Bram Moolenaar597a4222014-06-25 14:39:50 +020012637{
12638 char_u *p;
12639 int bri_shift = 0;
12640 long bri_min = 20;
12641 int bri_sbr = FALSE;
12642
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012643 p = wp->w_p_briopt;
Bram Moolenaar597a4222014-06-25 14:39:50 +020012644 while (*p != NUL)
12645 {
12646 if (STRNCMP(p, "shift:", 6) == 0
12647 && ((p[6] == '-' && VIM_ISDIGIT(p[7])) || VIM_ISDIGIT(p[6])))
12648 {
12649 p += 6;
12650 bri_shift = getdigits(&p);
12651 }
12652 else if (STRNCMP(p, "min:", 4) == 0 && VIM_ISDIGIT(p[4]))
12653 {
12654 p += 4;
12655 bri_min = getdigits(&p);
12656 }
12657 else if (STRNCMP(p, "sbr", 3) == 0)
12658 {
12659 p += 3;
12660 bri_sbr = TRUE;
12661 }
12662 if (*p != ',' && *p != NUL)
12663 return FAIL;
12664 if (*p == ',')
12665 ++p;
12666 }
12667
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012668 wp->w_p_brishift = bri_shift;
12669 wp->w_p_brimin = bri_min;
12670 wp->w_p_brisbr = bri_sbr;
Bram Moolenaar597a4222014-06-25 14:39:50 +020012671
12672 return OK;
12673}
12674#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020012675
12676/*
12677 * Get the local or global value of 'backupcopy'.
12678 */
12679 unsigned int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012680get_bkc_value(buf_T *buf)
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020012681{
12682 return buf->b_bkc_flags ? buf->b_bkc_flags : bkc_flags;
12683}
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020012684
12685#if defined(FEAT_SIGNS) || defined(PROTO)
12686/*
12687 * Return TRUE when window "wp" has a column to draw signs in.
12688 */
12689 int
12690signcolumn_on(win_T *wp)
12691{
12692 if (*wp->w_p_scl == 'n')
12693 return FALSE;
12694 if (*wp->w_p_scl == 'y')
12695 return TRUE;
12696 return (wp->w_buffer->b_signlist != NULL
12697# ifdef FEAT_NETBEANS_INTG
12698 || wp->w_buffer->b_has_sign_column
12699# endif
12700 );
12701}
12702#endif
Bram Moolenaarb5ae48e2016-08-12 22:23:25 +020012703
12704#if defined(FEAT_EVAL) || defined(PROTO)
12705/*
12706 * Get window or buffer local options.
12707 */
12708 dict_T *
12709get_winbuf_options(int bufopt)
12710{
12711 dict_T *d;
12712 int opt_idx;
12713
12714 d = dict_alloc();
12715 if (d == NULL)
12716 return NULL;
12717
12718 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
12719 {
12720 struct vimoption *opt = &options[opt_idx];
12721
12722 if ((bufopt && (opt->indir & PV_BUF))
12723 || (!bufopt && (opt->indir & PV_WIN)))
12724 {
12725 char_u *varp = get_varp(opt);
12726
12727 if (varp != NULL)
12728 {
12729 if (opt->flags & P_STRING)
12730 dict_add_nr_str(d, opt->fullname, 0L, *(char_u **)varp);
Bram Moolenaar789a5c02016-09-12 19:51:11 +020012731 else if (opt->flags & P_NUM)
12732 dict_add_nr_str(d, opt->fullname, *(long *)varp, NULL);
Bram Moolenaarb5ae48e2016-08-12 22:23:25 +020012733 else
Bram Moolenaar789a5c02016-09-12 19:51:11 +020012734 dict_add_nr_str(d, opt->fullname, *(int *)varp, NULL);
Bram Moolenaarb5ae48e2016-08-12 22:23:25 +020012735 }
12736 }
12737 }
12738
12739 return d;
12740}
12741#endif