I never want to use 'ignorecase' when searching for a tag. If the
cursor is over the symbol "cat" and I type Ctrl-], I want to find
the definition of "cat", not of "Cat" or "CAT". Similarly, I don't
want tag-name expansion to ignore case.
However, I do like to use 'smartcase' (which requires setting
'ignorecase') for searching with "/" or "?".
I've patched the copy of Vim I use at work to ignore the setting of
'ignorecase' for tag searches and to always search case-sensitively.
I would like not to have to keep doing this but I realize that
changing the default behavior of tag searches is a non-starter.
Consequently, I propose a new option, 'tagignorecase':
*'tagignorecase'* *'tic'*
'tagignorecase' 'tic' string (default "")
global
{not in Vi}
This option specifies how case is handled when searching
the tags file:
<empty> Follow the 'ignorecase' option
ignorecase Ignore case
noignorecase Do not ignore case
A patch is attached. The patch applies to too much--it includes
some runtime files that are managed by their owners--but I think it
covers everything that would need to be changed to include this
option.
I've been thinking more about the name. I chose 'tagignorecase'
because it is similar to almost all the other options that control
case sensitivity. However, those are all boolean options. I think
a better name might be 'tagcase'. It captures the meaning without
the implication that it is a boolean.
Since this is still at the early proposal stage, I just left the
original name in the proposal and in the patch.
Regards,
Gary
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
diff -r 30042ddff503 runtime/doc/options.txt
--- a/runtime/doc/options.txt Tue Oct 13 23:30:05 2015 +0200
+++ b/runtime/doc/options.txt Fri Oct 16 08:41:30 2015 -0700
@@ -7284,19 +7284,22 @@
< [The whitespace before and after the '0' must be a single <Tab>]
When a binary search was done and no match was found in any of the
- files listed in 'tags', and 'ignorecase' is set or a pattern is used
+ files listed in 'tags', and case is ignored or a pattern is used
instead of a normal tag name, a retry is done with a linear search.
Tags in unsorted tags files, and matches with different case will only
be found in the retry.
If a tag file indicates that it is case-fold sorted, the second,
- linear search can be avoided for the 'ignorecase' case. Use a value
- of '2' in the "!_TAG_FILE_SORTED" line for this. A tag file can be
- case-fold sorted with the -f switch to "sort" in most unices, as in
- the command: "sort -f -o tags tags". For "Exuberant ctags" version
- 5.x or higher (at least 5.5) the --sort=foldcase switch can be used
- for this as well. Note that case must be folded to uppercase for this
- to work.
+ linear search can be avoided when case is ignored. Use a value of '2'
+ in the "!_TAG_FILE_SORTED" line for this. A tag file can be case-fold
+ sorted with the -f switch to "sort" in most unices, as in the command:
+ "sort -f -o tags tags". For "Exuberant ctags" version 5.x or higher
+ (at least 5.5) the --sort=foldcase switch can be used for this as
+ well. Note that case must be folded to uppercase for this to work.
+
+ By default, tag searches are case-sensitive. Case is ignored when
+ 'ignorecase' is set and 'tagignorecase' is empty, or when
+ 'tagignorecase' is "ignorecase".
When 'tagbsearch' is off, tags searching is slower when a full match
exists, but faster when no full match exists. Tags in unsorted tags
@@ -7308,6 +7311,16 @@
command-line completion and ":help").
{Vi: always uses binary search in some versions}
+ *'tagignorecase'* *'tic'*
+'tagignorecase' 'tic' string (default "")
+ global
+ {not in Vi}
+ This option specifies how case is handled when searching the tags
+ file:
+ <empty> Follow the 'ignorecase' option
+ ignorecase Ignore case
+ noignorecase Do not ignore case
+
*'taglength'* *'tl'*
'taglength' 'tl' number (default 0)
global
diff -r 30042ddff503 runtime/doc/quickref.txt
--- a/runtime/doc/quickref.txt Tue Oct 13 23:30:05 2015 +0200
+++ b/runtime/doc/quickref.txt Fri Oct 16 08:41:30 2015 -0700
@@ -899,6 +899,7 @@
'tabpagemax' 'tpm' maximum number of tab pages for |-p| and "tab all"
'tabstop' 'ts' number of spaces that <Tab> in file uses
'tagbsearch' 'tbs' use binary searching in tags files
+'tagignorecase' 'tic' ignore case in tag searches or follow 'ignorecase'
'taglength' 'tl' number of significant characters for a tag
'tagrelative' 'tr' file names in tag file are relative
'tags' 'tag' list of file names used by the tag command
diff -r 30042ddff503 runtime/doc/tagsrch.txt
--- a/runtime/doc/tagsrch.txt Tue Oct 13 23:30:05 2015 +0200
+++ b/runtime/doc/tagsrch.txt Fri Oct 16 08:41:30 2015 -0700
@@ -85,8 +85,10 @@
":tag {ident}".
The ignore-case matches are not found for a ":tag" command when the
-'ignorecase' option is off. They are found when a pattern is used (starting
-with a "/") and for ":tselect", also when 'ignorecase' is off. Note that
+'ignorecase' option is off and 'tagignorecase' is empty or when
+'tagignorecase' is "noignorecase". They are found when a pattern is used
+(starting with a "/") and for ":tselect", also when 'ignorecase' is off and
+'tagignorecase' is empty or when 'tagignorecase' is "noignorecase". Note that
using ignore-case tag searching disables binary searching in the tags file,
which causes a slowdown. This can be avoided by fold-case sorting the tag
file. See the 'tagbsearch' option for an explanation.
@@ -440,12 +442,14 @@
The next file in the list is not used when:
- A matching static tag for the current buffer has been found.
- A matching global tag has been found.
-This also depends on the 'ignorecase' option. If it is off, and the tags file
-only has a match without matching case, the next tags file is searched for a
-match with matching case. If no tag with matching case is found, the first
-match without matching case is used. If 'ignorecase' is on, and a matching
-global tag with or without matching case is found, this one is used, no
-further tags files are searched.
+This also depends on whether case is ignored. Case is ignored when
+'ignorecase' is set and 'tagignorecase' is empty, or when 'tagignorecase' is
+"ignorecase". If case is not ignored, and the tags file only has a match
+without matching case, the next tags file is searched for a match with
+matching case. If no tag with matching case is found, the first match without
+matching case is used. If case is ignored, and a matching global tag with or
+without matching case is found, this one is used, no further tags files are
+searched.
When a tag file name starts with "./", the '.' is replaced with the path of
the current file. This makes it possible to use a tags file in the directory
@@ -579,8 +583,10 @@
binary searching for the tags file:
!_TAG_FILE_SORTED<Tab>1<Tab>{anything} ~
-A tag file may be case-fold sorted to avoid a linear search when 'ignorecase'
-is on. See 'tagbsearch' for details. The value '2' should be used then:
+A tag file may be case-fold sorted to avoid a linear search when case is
+ignored. (Case is ignored when 'ignorecase' is set and 'tagignorecase' is
+empty, or when 'tagignorecase' is "ignorecase".) See 'tagbsearch' for
+details. The value '2' should be used then:
!_TAG_FILE_SORTED<Tab>2<Tab>{anything} ~
The other tag that Vim recognizes, but only when compiled with the
diff -r 30042ddff503 runtime/optwin.vim
--- a/runtime/optwin.vim Tue Oct 13 23:30:05 2015 +0200
+++ b/runtime/optwin.vim Fri Oct 16 08:41:30 2015 -0700
@@ -291,6 +291,8 @@
call <SID>OptionG("tag", &tag)
call append("$", "tagrelative\tfile names in a tags file are relative to the tags file")
call <SID>BinOptionG("tr", &tr)
+call append("$", "tagignorecase\tignore case when searching in tags files or follow 'ignorecase'")
+call <SID>OptionG("tic", &tic)
call append("$", "tagstack\ta :tag command will use the tagstack")
call <SID>BinOptionG("tgst", &tgst)
call append("$", "showfulltag\twhen completing tags in Insert mode show more info")
diff -r 30042ddff503 runtime/syntax/vim.vim
--- a/runtime/syntax/vim.vim Tue Oct 13 23:30:05 2015 +0200
+++ b/runtime/syntax/vim.vim Fri Oct 16 08:41:30 2015 -0700
@@ -31,7 +31,7 @@
syn keyword vimOption contained acd ambw ari aw backupext beval biosk breakindent bsdir cb cfu cinkeys cmdheight colorcolumn completefunc copyindent cryptmethod cscopeverbose csverb debug dict dir eb enc errorbells expandtab fdl fenc fileencodings fkmap foldenable foldminlines formatprg gdefault gp guifontset helpfile hidden hl ignorecase imcmdline imsf indentexpr is isp keywordprg laststatus lisp loadplugins macatsui maxcombine mef mls modelines mousehide mp nu omnifunc paragraphs penc pm printdevice printoptions quoteescape remap rightleftcmd rtp sbo scrolljump sel shell shelltype shortname shq sm so spellfile spr st sts swapsync syn tag tb termbidi tgst titleold top ttimeoutlen ttyscroll ul ur verbosefile visualbell wcm wi wildmenu winfixwidth wm wrapscan
syn keyword vimOption contained ai anti arshape awa backupskip bex bioskey breakindentopt bsk cc ch cino cmdwinheight columns completeopt cot cscopepathcomp cspc cuc deco dictionary directory ed encoding errorfile exrc fdls fencs fileformat flp foldexpr foldnestmax fp gfm grepformat guifontwide helpheight highlight hlg im imd imstatusfunc indentkeys isf isprint km lazyredraw lispwords lpl magic maxfuncdepth menuitems mm modifiable mousem mps number opendevice paste pex pmbcs printencoding prompt rdt renderoptions rl ru sbr scrolloff selection shellcmdflag shellxescape showbreak si smartcase softtabstop spelllang sps sta su swb synmaxcol tagbsearch tbi termencoding thesaurus titlestring tpm ttm ttytype undodir ut vfile vop wd wic wildmode winheight wmh write
syn keyword vimOption contained akm antialias autochdir background balloondelay bexpr bk bri bt ccv charconvert cinoptions cmp com concealcursor cp cscopeprg csprg cul def diff display edcompatible endofline errorformat fcl fdm fex fileformats fml foldignore foldopen fs gfn grepprg guiheadroom helplang history hls imactivatefunc imdisable inc indk isfname joinspaces kmp lbr list ls makeef maxmapdepth mfd mmd modified mousemodel msm numberwidth operatorfunc pastetoggle pexpr pmbfn printexpr pt re report rlc ruf sc scrollopt selectmode shellpipe shellxquote showcmd sidescroll smartindent sol spellsuggest sr stal sua swf syntax taglength tbidi terse tildeop tl tr tty tw undofile vb vi wa weirdinvert wig wildoptions winminheight wmnu writeany
-syn keyword vimOption contained al ar autoindent backspace ballooneval bg bkc briopt bufhidden cd ci cinw cms comments conceallevel cpo cscopequickfix csqf cursorbind define diffexpr dy ef eol esckeys fcs fdn ff fileignorecase fmr foldlevel foldtext fsync gfs gtl guioptions hf hk hlsearch imactivatekey imi include inex isi js kp lcs listchars lsp makeprg maxmem mh mmp more mouses mzq nuw opfunc patchexpr pfn popt printfont pumheight readonly restorescreen rnu ruler scb scs sessionoptions shellquote shiftround showfulltag sidescrolloff smarttab sp spf srr startofline suffixes switchbuf ta tagrelative tbis textauto timeout tm ts ttybuiltin tx undolevels vbs viewdir wak wfh wildchar wim winminwidth wmw writebackup
+syn keyword vimOption contained al ar autoindent backspace ballooneval bg bkc briopt bufhidden cd ci cinw cms comments conceallevel cpo cscopequickfix csqf cursorbind define diffexpr dy ef eol esckeys fcs fdn ff fileignorecase fmr foldlevel foldtext fsync gfs gtl guioptions hf hk hlsearch imactivatekey imi include inex isi js kp lcs listchars lsp makeprg maxmem mh mmp more mouses mzq nuw opfunc patchexpr pfn popt printfont pumheight readonly restorescreen rnu ruler scb scs sessionoptions shellquote shiftround showfulltag sidescrolloff smarttab sp spf srr startofline suffixes switchbuf ta tagignorecase tagrelative tbis textauto tic timeout tm ts ttybuiltin tx undolevels vbs viewdir wak wfh wildchar wim winminwidth wmw writebackup
syn keyword vimOption contained aleph arab autoread backup balloonexpr bh bl brk buflisted cdpath cin cinwords co commentstring confirm cpoptions cscoperelative csre cursorcolumn delcombine diffopt ea efm ep et fdc fdo ffs filetype fo foldlevelstart formatexpr ft gfw gtt guipty hh hkmap ic imaf iminsert includeexpr inf isident key langmap linebreak lm lw mat maxmempattern mis mmt mouse mouseshape mzquantum odev osfiletype patchmode ph preserveindent printheader pvh redrawtime revins ro rulerformat scr sect sft shellredir shiftwidth showmatch siso smc spc spl ss statusline suffixesadd sws tabline tags tbs textmode timeoutlen to tsl ttyfast uc undoreload vdir viewoptions warn wfw wildcharm winaltkeys winwidth wop writedelay
syn keyword vimOption contained allowrevins arabic autowrite backupcopy bdir bin bomb browsedir buftype cedit cindent clipboard cocu compatible consk cpt cscopetag cst cursorline dex digraph ead ei equalalways eventignore fde fdt fic fillchars foldclose foldmarker formatlistpat gcr ghr guicursor guitablabel hi hkmapp icon imak ims incsearch infercase isk keymap langmenu lines lmap lz matchpairs maxmemtot mkspellmem mod mousef mouset nf oft pa path pheader previewheight printmbcharset pvw regexpengine ri rop runtimepath scroll sections sh shellslash shm showmode sj smd spell splitbelow ssl stl sw sxe tabpagemax tagstack tenc textwidth title toolbar tsr ttym udf updatecount ve viminfo wb wh wildignore window wiv wrap ws
syn keyword vimOption contained altkeymap arabicshape autowriteall backupdir bdlay binary breakat bs casemap cf cink cm cole complete conskey crb cscopetagorder csto cwh dg dip eadirection ek equalprg ex fdi fen fileencoding fk foldcolumn foldmethod formatoptions gd go guifont guitabtooltip hid hkp iconstring imc imsearch inde insertmode iskeyword keymodel langnoremap linespace lnr ma matchtime mco ml modeline mousefocus mousetime nrformats ofu para pdev pi previewwindow printmbfont qe relativenumber rightleft rs sb scrollbind secure shcf shelltemp shortmess showtabline slm sn spellcapcheck splitright ssop stmp swapfile sxq tabstop tal term tf titlelen toolbariconsize ttimeout ttymouse udir updatetime verbose virtualedit wc whichwrap wildignorecase winfixheight wiw wrapmargin ww
diff -r 30042ddff503 src/option.c
--- a/src/option.c Tue Oct 13 23:30:05 2015 +0200
+++ b/src/option.c Fri Oct 16 08:41:30 2015 -0700
@@ -2577,6 +2577,9 @@
{(char_u *)TRUE, (char_u *)0L}
#endif
SCRIPTID_INIT},
+ {"tagignorecase","tic", P_STRING|P_VI_DEF,
+ (char_u *)&p_tic, PV_NONE,
+ {(char_u *)"", (char_u *)NULL} SCRIPTID_INIT},
{"taglength", "tl", P_NUM|P_VI_DEF,
(char_u *)&p_tl, PV_NONE,
{(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
@@ -5335,6 +5338,7 @@
(void)opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE);
#endif
(void)opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE);
+ (void)opt_strings_flags(p_tic, p_tic_values, &tic_flags, FALSE);
#ifdef FEAT_VIRTUALEDIT
(void)opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE);
#endif
@@ -7016,6 +7020,13 @@
errmsg = e_invarg;
}
+ /* 'tagignorecase' */
+ else if (varp == &p_tic)
+ {
+ if (opt_strings_flags(p_tic, p_tic_values, &tic_flags, FALSE) != OK)
+ errmsg = e_invarg;
+ }
+
#ifdef FEAT_MBYTE
/* 'casemap' */
else if (varp == &p_cmp)
diff -r 30042ddff503 src/option.h
--- a/src/option.h Tue Oct 13 23:30:05 2015 +0200
+++ b/src/option.h Fri Oct 16 08:41:30 2015 -0700
@@ -804,6 +804,13 @@
#define SWB_NEWTAB 0x008
#define SWB_VSPLIT 0x010
EXTERN int p_tbs; /* 'tagbsearch' */
+EXTERN char_u *p_tic; /* 'tagignorecase' */
+EXTERN unsigned tic_flags;
+#ifdef IN_OPTION_C
+static char *(p_tic_values[]) = {"ignorecase", "noignorecase", NULL};
+#endif
+#define TIC_IGNORECASE 0x01
+#define TIC_NOIGNORECASE 0x02
EXTERN long p_tl; /* 'taglength' */
EXTERN int p_tr; /* 'tagrelative' */
EXTERN char_u *p_tags; /* 'tags' */
diff -r 30042ddff503 src/tag.c
--- a/src/tag.c Tue Oct 13 23:30:05 2015 +0200
+++ b/src/tag.c Fri Oct 16 08:41:30 2015 -0700
@@ -1385,6 +1385,16 @@
int use_cscope = (flags & TAG_CSCOPE);
#endif
int verbose = (flags & TAG_VERBOSE);
+ int save_p_ic = p_ic;
+
+ /*
+ * Change the value of 'ignorecase' according to 'tagignorecase' for the
+ * duration of this function.
+ */
+ if (tic_flags == TIC_IGNORECASE)
+ p_ic = TRUE;
+ else if (tic_flags == TIC_NOIGNORECASE)
+ p_ic = FALSE;
help_save = curbuf->b_help;
orgpat.pat = pat;
@@ -2552,6 +2562,8 @@
vim_free(saved_pat);
#endif
+ p_ic = save_p_ic;
+
return retval;
}