3

My :set tags? option says:

./tags;,tags,./vimtags

What does the semicolon after the ./tags mean? When I use vim -u NONE it is set to

./tags,tags

And when I grep my packages to see what plugins set it to include the semicolon I see that two do it:

vim-sensible by tpope does this:

if has('path_extra')
  setglobal tags-=./tags tags-=./tags; tags^=./tags;
endif

And vim-easytags also seems to set it to ./tags; by default.

Why is this? I reckon the authors of these libraries know what they are doing. However :h 'tags' doesn't help me at all.

5

The answer for this is :h file-searching:

11. File Searching                                      file-searching

{not available when compiled without the |+path_extra| feature}

The file searching is currently used for the 'path', 'cdpath' and 'tags'
options, for finddir() and findfile().  Other commands use wildcards
which is slightly different.

There are three different types of searching:

1) Downward search:                                     starstar
   Downward search uses the wildcards '*', '**' and possibly others
   supported by your operating system.  '*' and '**' are handled inside Vim,
   so they work on all operating systems.

...

2) Upward search:
   Here you can give a directory and then search the directory tree upward for
   a file.  You could give stop-directories to limit the upward search.  The
   stop-directories are appended to the path (for the 'path' option) or to
   the filename (for the 'tags' option) with a ';'.  If you want several
   stop-directories separate them with ';'.  If you want no stop-directory
   ("search upward till the root directory) just use ';'. 
        /usr/include/sys;/usr
   will search in: 
           /usr/include/sys
           /usr/include
           /usr

So, with this ./tags;, if Vim finds a tags file in the directory of the current file, it won't look any further.

  • Ok, wow, you really need to know your :h in order to find something like this – hgiesel Jan 31 '17 at 1:40
  • @hgiesel yep. In this case, I remembered that tags is pretty similar to 'path', and :h 'path' has this line: 'Search upwards and downwards in a directory tree using "*", "**" and ";". See |file-searching| for info and syntax.' – muru Jan 31 '17 at 1:52
  • @hgiesel Looks like you could also have found this by skimming the output of :helpgrep tags looking for a semi-colon. For me it's one of the first matches in the default help files. – Rich Jan 31 '17 at 11:01
  • I just noticed, that the file-searching article talks about things like ./tags;tags, by which I mean, no extra comma. With tagfiles() I've made sure, that ./tags;,tags actually doesn't have the effect which is described in file-searching (it will the tags file from the parent and the parent's parent directory), only ./tags;tags will work. – hgiesel Jan 31 '17 at 13:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.