📄 option.c
字号:
#if defined(UNIX) && defined(USE_SYSTEM) && !defined(__EMX__)
(char_u *)"\"",
#else
(char_u *)"",
#endif
(char_u *)0L}},
{"shiftround", "sr", P_BOOL|P_VI_DEF|P_VIM,
(char_u *)&p_sr,
{(char_u *)FALSE, (char_u *)0L}},
{"shiftwidth", "sw", P_NUM|P_IND|P_VI_DEF,
(char_u *)PV_SW,
{(char_u *)8L, (char_u *)0L}},
{"shortmess", "shm", P_STRING|P_VI_DEF|P_VIM,
(char_u *)&p_shm,
{(char_u *)"", (char_u *)0L}},
{"shortname", "sn", P_BOOL|P_IND|P_VI_DEF,
#ifdef SHORT_FNAME
(char_u *)NULL,
#else
(char_u *)PV_SN,
#endif
{(char_u *)FALSE, (char_u *)0L}},
{"showbreak", "sbr", P_STRING|P_VI_DEF|P_RALL,
(char_u *)&p_sbr,
{(char_u *)"", (char_u *)0L}},
{"showcmd", "sc", P_BOOL|P_VIM,
(char_u *)&p_sc,
{(char_u *)FALSE,
#ifdef UNIX
(char_u *)FALSE
#else
(char_u *)TRUE
#endif
}},
{"showfulltag", "sft", P_BOOL|P_VI_DEF,
(char_u *)&p_sft,
{(char_u *)FALSE, (char_u *)0L}},
{"showmatch", "sm", P_BOOL|P_VI_DEF,
(char_u *)&p_sm,
{(char_u *)FALSE, (char_u *)0L}},
{"showmode", "smd", P_BOOL|P_VIM,
(char_u *)&p_smd,
{(char_u *)FALSE, (char_u *)TRUE}},
{"sidescroll", "ss", P_NUM|P_VI_DEF,
(char_u *)&p_ss,
{(char_u *)0L, (char_u *)0L}},
{"slowopen", "slow", P_BOOL|P_VI_DEF,
(char_u *)NULL,
{(char_u *)FALSE, (char_u *)0L}},
{"smartcase", "scs", P_BOOL|P_VI_DEF|P_VIM,
(char_u *)&p_scs,
{(char_u *)FALSE, (char_u *)0L}},
{"smartindent", "si", P_BOOL|P_IND|P_VI_DEF|P_VIM,
#ifdef SMARTINDENT
(char_u *)PV_SI,
#else
(char_u *)NULL,
#endif
{(char_u *)FALSE, (char_u *)0L}},
{"smarttab", "sta", P_BOOL|P_VI_DEF|P_VIM,
(char_u *)&p_sta,
{(char_u *)FALSE, (char_u *)0L}},
{"softtabstop", "sts", P_NUM|P_IND|P_VI_DEF|P_VIM,
(char_u *)PV_STS,
{(char_u *)0L, (char_u *)0L}},
{"sourceany", NULL, P_BOOL|P_VI_DEF,
(char_u *)NULL,
{(char_u *)FALSE, (char_u *)0L}},
{"splitbelow", "sb", P_BOOL|P_VI_DEF,
(char_u *)&p_sb,
{(char_u *)FALSE, (char_u *)0L}},
{"startofline", "sol", P_BOOL|P_VI_DEF|P_VIM,
(char_u *)&p_sol,
{(char_u *)TRUE, (char_u *)0L}},
{"suffixes", "su", P_STRING|P_VI_DEF|P_COMMA,
(char_u *)&p_su,
{(char_u *)".bak,~,.o,.h,.info,.swp",
(char_u *)0L}},
{"swapfile", "swf", P_BOOL|P_IND|P_VI_DEF|P_RSTAT,
(char_u *)PV_SWF,
{(char_u *)TRUE, (char_u *)0L}},
{"swapsync", "sws", P_STRING|P_VI_DEF,
(char_u *)&p_sws,
{(char_u *)"fsync", (char_u *)0L}},
{"syntax", "syn", P_STRING|P_IND|P_ALLOCED|P_VI_DEF,
#ifdef SYNTAX_HL
(char_u *)PV_SYN,
{(char_u *)"", (char_u *)0L}
#else
(char_u *)NULL,
{(char_u *)0L, (char_u *)0L}
#endif
},
{"tabstop", "ts", P_NUM|P_IND|P_VI_DEF|P_RBUF,
(char_u *)PV_TS,
{(char_u *)8L, (char_u *)0L}},
{"tagbsearch", "tbs", P_BOOL|P_VI_DEF,
(char_u *)&p_tbs,
{(char_u *)TRUE, (char_u *)0L}},
{"taglength", "tl", P_NUM|P_VI_DEF,
(char_u *)&p_tl,
{(char_u *)0L, (char_u *)0L}},
{"tagrelative", "tr", P_BOOL|P_VIM,
(char_u *)&p_tr,
{(char_u *)FALSE, (char_u *)TRUE}},
{"tags", "tag", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA,
(char_u *)&p_tags,
{
#ifdef EMACS_TAGS
(char_u *)"./tags,./TAGS,tags,TAGS",
#else
(char_u *)"./tags,tags",
#endif
(char_u *)0L}},
{"tagstack", "tgst", P_BOOL|P_VI_DEF,
(char_u *)NULL,
{(char_u *)TRUE, (char_u *)0L}},
{"term", NULL, P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL,
(char_u *)&T_NAME,
{(char_u *)"", (char_u *)0L}},
{"terse", NULL, P_BOOL|P_VI_DEF,
(char_u *)&p_terse,
{(char_u *)FALSE, (char_u *)0L}},
{"textauto", "ta", P_BOOL|P_VIM,
(char_u *)&p_ta,
{(char_u *)TA_DFLT, (char_u *)TRUE}},
{"textmode", "tx", P_BOOL|P_IND|P_VI_DEF,
(char_u *)PV_TX,
{
#ifdef USE_CRNL
(char_u *)TRUE,
#else
(char_u *)FALSE,
#endif
(char_u *)0L}},
{"textwidth", "tw", P_NUM|P_IND|P_VI_DEF|P_VIM,
(char_u *)PV_TW,
{(char_u *)0L, (char_u *)0L}},
{"tildeop", "top", P_BOOL|P_VI_DEF|P_VIM,
(char_u *)&p_to,
{(char_u *)FALSE, (char_u *)0L}},
{"timeout", "to", P_BOOL|P_VI_DEF,
(char_u *)&p_timeout,
{(char_u *)TRUE, (char_u *)0L}},
{"timeoutlen", "tm", P_NUM|P_VI_DEF,
(char_u *)&p_tm,
{(char_u *)1000L, (char_u *)0L}},
{"title", NULL, P_BOOL|P_VI_DEF,
(char_u *)&p_title,
{(char_u *)FALSE, (char_u *)0L}},
{"titlelen", NULL, P_NUM|P_VI_DEF,
(char_u *)&p_titlelen,
{(char_u *)85L, (char_u *)0L}},
{"titlestring", NULL, P_STRING|P_VI_DEF,
(char_u *)&p_titlestring,
{(char_u *)"", (char_u *)0L}},
{"ttimeout", NULL, P_BOOL|P_VI_DEF|P_VIM,
(char_u *)&p_ttimeout,
{(char_u *)FALSE, (char_u *)0L}},
{"ttimeoutlen", "ttm", P_NUM|P_VI_DEF,
(char_u *)&p_ttm,
{(char_u *)-1L, (char_u *)0L}},
{"ttybuiltin", "tbi", P_BOOL|P_VI_DEF,
(char_u *)&p_tbi,
{(char_u *)TRUE, (char_u *)0L}},
{"ttyfast", "tf", P_BOOL|P_NO_MKRC|P_VI_DEF,
(char_u *)&p_tf,
{(char_u *)FALSE, (char_u *)0L}},
{"ttyscroll", "tsl", P_NUM|P_VI_DEF,
(char_u *)&p_ttyscroll,
{(char_u *)999L, (char_u *)0L}},
{"ttytype", "tty", P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL,
(char_u *)&T_NAME,
{(char_u *)"", (char_u *)0L}},
{"ttymouse", "ttym", P_STRING|P_NODEFAULT|P_NO_MKRC|P_VI_DEF,
(char_u *)&p_ttym,
{(char_u *)"", (char_u *)0L}},
{"undolevels", "ul", P_NUM|P_VI_DEF,
(char_u *)&p_ul,
{
#if defined(UNIX) || defined(WIN32) || defined(OS2)
(char_u *)1000L,
#else
(char_u *)100L,
#endif
(char_u *)0L}},
{"updatecount", "uc", P_NUM|P_VI_DEF,
(char_u *)&p_uc,
{(char_u *)200L, (char_u *)0L}},
{"updatetime", "ut", P_NUM|P_VI_DEF,
(char_u *)&p_ut,
{(char_u *)4000L, (char_u *)0L}},
{"verbose", "vbs", P_NUM|P_VI_DEF,
(char_u *)&p_verbose,
{(char_u *)0L, (char_u *)0L}},
{"viminfo", "vi", P_STRING|P_VI_DEF|P_COMMA,
#ifdef VIMINFO
(char_u *)&p_viminfo,
#else
(char_u *)NULL,
#endif /* VIMINFO */
{(char_u *)"", (char_u *)0L}},
{"visualbell", "vb", P_BOOL|P_VI_DEF,
(char_u *)&p_vb,
{(char_u *)FALSE, (char_u *)0L}},
{"w300", NULL, P_NUM|P_VI_DEF,
(char_u *)NULL,
{(char_u *)0L, (char_u *)0L}},
{"w1200", NULL, P_NUM|P_VI_DEF,
(char_u *)NULL,
{(char_u *)0L, (char_u *)0L}},
{"w9600", NULL, P_NUM|P_VI_DEF,
(char_u *)NULL,
{(char_u *)0L, (char_u *)0L}},
{"warn", NULL, P_BOOL|P_VI_DEF,
(char_u *)&p_warn,
{(char_u *)TRUE, (char_u *)0L}},
{"weirdinvert", "wiv", P_BOOL|P_VI_DEF|P_RALL,
(char_u *)&p_wiv,
{(char_u *)FALSE, (char_u *)0L}},
{"whichwrap", "ww", P_STRING|P_VIM|P_COMMA,
(char_u *)&p_ww,
{(char_u *)"", (char_u *)"b,s"}},
{"wildchar", "wc", P_NUM|P_VIM,
(char_u *)&p_wc,
{(char_u *)(long)Ctrl('E'), (char_u *)(long)TAB}},
{"wildignore", "wig", P_STRING|P_VI_DEF|P_COMMA,
#ifdef WILDIGNORE
(char_u *)&p_wig,
#else
(char_u *)NULL,
#endif
{(char_u *)"", (char_u *)0L}},
{"wildmode", "wim", P_STRING|P_VI_DEF|P_COMMA,
(char_u *)&p_wim,
{(char_u *)"full", (char_u *)0L}},
{"winaltkeys", "wak", P_STRING|P_VI_DEF,
#if defined(USE_GUI_WIN32) || defined(USE_GUI_MOTIF)
(char_u *)&p_wak,
{(char_u *)"menu", (char_u *)0L}
#else
(char_u *)NULL,
{(char_u *)NULL, (char_u *)0L}
#endif
},
{"window", "wi", P_NUM|P_VI_DEF,
(char_u *)NULL,
{(char_u *)0L, (char_u *)0L}},
{"winheight", "wh", P_NUM|P_VI_DEF,
(char_u *)&p_wh,
{(char_u *)1L, (char_u *)0L}},
{"winminheight", "wmh", P_NUM|P_VI_DEF,
(char_u *)&p_wmh,
{(char_u *)1L, (char_u *)0L}},
{"wrap", NULL, P_BOOL|P_IND|P_VI_DEF|P_RBUF,
(char_u *)PV_WRAP,
{(char_u *)TRUE, (char_u *)0L}},
{"wrapmargin", "wm", P_NUM|P_IND|P_VI_DEF,
(char_u *)PV_WM,
{(char_u *)0L, (char_u *)0L}},
{"wrapscan", "ws", P_BOOL|P_VI_DEF,
(char_u *)&p_ws,
{(char_u *)TRUE, (char_u *)0L}},
{"writeany", "wa", P_BOOL|P_VI_DEF,
(char_u *)&p_wa,
{(char_u *)FALSE, (char_u *)0L}},
{"writebackup", "wb", P_BOOL|P_VI_DEF|P_VIM,
(char_u *)&p_wb,
{
#ifdef WRITEBACKUP
(char_u *)TRUE,
#else
(char_u *)FALSE,
#endif
(char_u *)0L}},
{"writedelay", "wd", P_NUM|P_VI_DEF,
(char_u *)&p_wd,
{(char_u *)0L, (char_u *)0L}},
/* terminal output codes */
#define p_term(sss, vvv) {sss, NULL, P_STRING|P_VI_DEF|P_RALL, \
(char_u *)&vvv, \
{(char_u *)"", (char_u *)0L}},
p_term("t_AB", T_CAB)
p_term("t_AF", T_CAF)
p_term("t_AL", T_CAL)
p_term("t_al", T_AL)
p_term("t_bc", T_BC)
p_term("t_cd", T_CD)
p_term("t_ce", T_CE)
p_term("t_cl", T_CL)
p_term("t_cm", T_CM)
p_term("t_Co", T_CCO)
p_term("t_CS", T_CCS)
p_term("t_cs", T_CS)
p_term("t_da", T_DA)
p_term("t_db", T_DB)
p_term("t_DL", T_CDL)
p_term("t_dl", T_DL)
p_term("t_ke", T_KE)
p_term("t_ks", T_KS)
p_term("t_le", T_LE)
p_term("t_mb", T_MB)
p_term("t_md", T_MD)
p_term("t_me", T_ME)
p_term("t_mr", T_MR)
p_term("t_ms", T_MS)
p_term("t_nd", T_ND)
p_term("t_op", T_OP)
p_term("t_RI", T_CRI)
p_term("t_Sb", T_CSB)
p_term("t_Sf", T_CSF)
p_term("t_se", T_SE)
p_term("t_so", T_SO)
p_term("t_sr", T_SR)
p_term("t_te", T_TE)
p_term("t_ti", T_TI)
p_term("t_ue", T_UE)
p_term("t_us", T_US)
p_term("t_vb", T_VB)
p_term("t_ve", T_VE)
p_term("t_vi", T_VI)
p_term("t_vs", T_VS)
p_term("t_xs", T_XS)
p_term("t_ZH", T_CZH)
p_term("t_ZR", T_CZR)
/* terminal key codes are not in here */
{NULL, NULL, 0, NULL, {NULL, NULL}} /* end marker */
};
#define PARAM_COUNT (sizeof(options) / sizeof(struct vimoption))
static char *(p_bg_values[]) = {"light", "dark", NULL};
static char *(p_nf_values[]) = {"octal", "hex", NULL};
static char *(p_ff_values[]) = {FF_UNIX, FF_DOS, FF_MAC, NULL};
#ifdef MULTI_BYTE
static char *(p_fe_values[]) = {FE_ANSI, FE_UNICODE, FE_DBJPN, FE_DBKOR,
FE_DBCHT, FE_DBCHS, FE_HEBREW, FE_FARSI , NULL};
#endif
#if defined(USE_GUI_WIN32) || defined(USE_GUI_MOTIF)
static char *(p_wak_values[]) = {"yes", "menu", "no", NULL};
#endif
static char *(p_sessopt_values[]) = {"resize", "winsize", "options", NULL};
static char *(p_mousem_values[]) = {"extend", "popup", "mac", NULL};
static char *(p_slm_values[]) = {"mouse", "key", "cmd", NULL};
static char *(p_sel_values[]) = {"inclusive", "exclusive", "old", NULL};
static char *(p_km_values[]) = {"startsel", "stopsel", NULL};
static char *(p_bsdir_values[]) = {"current", "last", "buffer", NULL};
static void set_option_default __ARGS((int, int));
static void set_options_default __ARGS((int dofree));
static void illegal_char __ARGS((char_u *, int));
static void did_set_title __ARGS((int icon));
static char_u *option_expand __ARGS((int));
static void set_string_option __ARGS((int opt_idx, char_u *value));
static char_u *did_set_string_option __ARGS((int opt_idx, char_u **varp, int new_value_alloced, char_u *oldval, char_u *errbuf));
static char_u *set_bool_option __ARGS((int opt_idx, char_u *varp, int value));
static char_u *set_num_option __ARGS((int opt_idx, char_u *varp, long value, char_u *errbuf));
static void check_redraw __ARGS((int flags));
static int findoption __ARGS((char_u *));
static int find_key_option __ARGS((char_u *));
static void showoptions __ARGS((int));
static int option_not_default __ARGS((struct vimoption *));
static void showoneopt __ARGS((struct vimoption *));
static int istermoption __ARGS((struct vimoption *));
static char_u *get_varp __ARGS((struct vimoption *));
static void option_value2string __ARGS((struct vimoption *));
#ifdef HAVE_LANGMAP
static void langmap_init __ARGS((void));
static void langmap_set __ARGS((void));
#endif
static void paste_option_changed __ARGS((void));
static void compatible_set __ARGS((void));
static void fill_breakat_flags __ARGS((void));
static int check_opt_strings __ARGS((char_u *val, char **values, int));
static int check_opt_wim __ARGS((void));
/*
* Initialize the options, first part.
*
* Called only once from main(), just after creating the first buffer.
*/
void
set_init_1()
{
char_u *p;
int opt_idx;
long n;
#ifdef HAVE_LANGMAP
langmap_init();
#endif
/* Be Vi compatible by default */
p_cp = TRUE;
/*
* Find default value for 'shell' option.
*/
if ((p = mch_getenv((char_u *)"SHELL")) != NULL
#if defined(MSDOS) || defined(WIN32) || defined(OS2)
# ifdef __EMX__
|| (p = mch_getenv((char_u *)"EMXSHELL")) != NULL
# endif
|| (p = mch_getenv((char_u *)"COMSPEC")) != NULL
# ifdef WIN32
|| (p = default_shell()) != NULL
# endif
#endif
)
{
set_string_default("sh", p);
}
/*
* 'maxmemtot' and 'maxmem' may have to be adjusted for available memory
*/
opt_idx = findoption((char_u *)"maxmemtot");
if (options[opt_idx].def_val[VI_DEFAULT] == (char_u *)0L)
{
n = (mch_avail_mem(FALSE) >> 11);
options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n;
opt_idx = findoption((char_u *)"maxmem");
if ((long)options[opt_idx].def_val[VI_DEFAULT] > n
|| (long)options[opt_idx].def_val[VI_DEFAULT] == 0L)
options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n;
}
#ifdef USE_GUI_WIN32
/* force 'shortname' for Win32s */
if (gui_is_win32s())
options[findoption((char_u *)"shortname")].def_val[VI_DEFAULT] =
(char_u *)TRUE;
#endif
/*
* set all the options (except the terminal options) to their default value
*/
set_options_default(FALSE);
#ifdef USE_GUI
if (found_reverse_arg)
set_option_value((char_u *)"bg", 0L, (char_u *)"dark");
#endif
curbuf->b_p_initialized = TRUE;
check_buf_options(curbuf);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -