Browse files

Support for automatic recursion using ctags -R

  • Loading branch information...
xolox committed Aug 10, 2010
1 parent 8084725 commit 0d9567900f23e8ca243db16df80004aa7c658623
Showing with 34 additions and 6 deletions.
  1. +10 −0
  2. +18 −4 autoload.vim
  3. +6 −2 easytags.vim
@@ -68,6 +68,16 @@ As I explained above the plug-in by default doesn't update or highlight your tag
Note: Like the `g:easytags_always_enabled` option, if you change this option it won't apply until you restart Vim, so you'll have to set this option in your [vimrc script][vimrc].
### The `g:easytags_autorecurse` option
When the `:UpdateTags` command is executed automatically or without arguments, it defaults to updating just the tags for the current file. If you'd rather have it recursively scan everything below the directory of the current file then set this option to true (1):
:let g:easytags_autorecurse = 1
You have to explicitly enable this option because it should only be used while navigating around small directory trees. Imagine always having this option enabled and then having to edit a file in e.g. the root of your home directory: The `easytags.vim` plug-in would freeze Vim for a long time while you'd have to wait for Exuberant Cags to scan thousands of files...
Note that when you enable this option the `easytags.vim` might ignore other options like `g:easytags_resolve_links`. This is an implementation detail which I intend to fix.
### The `g:easytags_resolve_links` option
UNIX has [symbolic links]( and [hard links](, both of which conflict with the concept of having one unique location for every identifier. With regards to hard links there's not much anyone can do, but because I use symbolic links quite a lot I've added this option. It's disabled by default since it has a small performance impact and might not do what unknowing users expect it to: When you enable this option the plug-in will resolve symbolic links in pathnames, which means your tags file will only contain entries with [canonical pathnames]( To enable this option (which I strongly suggest doing when you run UNIX and use symbolic links) execute the following Vim command:
@@ -67,8 +67,16 @@ function! s:check_cfile(silent, filter_tags, have_args) " {{{3
if a:have_args
return ''
let cfile = s:resolve(expand('%:p'))
let silent = a:silent || a:filter_tags
if g:easytags_autorecurse
let cdir = s:resolve(expand('%:p:h'))
if !isdirectory(cdir)
if silent | return '' | endif
throw "The directory of the current file doesn't exist yet!"
return cdir
let cfile = s:resolve(expand('%:p'))
if cfile == '' || !filereadable(cfile)
if silent | return '' | endif
throw "You'll need to save your file before using :UpdateTags!"
@@ -92,9 +100,14 @@ function! s:prep_cmdline(cfile, tagsfile, firstrun, arguments) " {{{3
call add(cmdline, '-f-')
if a:cfile != ''
let filetype = easytags#to_ctags_ft(&filetype)
call add(cmdline, shellescape('--language-force=' . filetype))
call add(cmdline, shellescape(a:cfile))
if g:easytags_autorecurse
call add(cmdline, '-R')
call add(cmdline, shellescape(a:cfile))
let filetype = easytags#to_ctags_ft(&filetype)
call add(cmdline, shellescape('--language-force=' . filetype))
call add(cmdline, shellescape(a:cfile))
for fname in a:arguments
let matches = split(expand(fname), "\n")
@@ -108,6 +121,7 @@ endfunction
function! s:run_ctags(starttime, cfile, tagsfile, firstrun, cmdline) " {{{3
let output = []
if a:cmdline != ''
call xolox#debug("%s: Executing %s", s:script, a:cmdline)
let output = xolox#shell#execute(a:cmdline, 1)
catch /^Vim\%((\a\+)\)\=:E117/
@@ -1,10 +1,10 @@
" Vim plug-in
" Author: Peter Odding <>
" Last Change: August 9, 2010
" Last Change: August 10, 2010
" URL:
" Requires: Exuberant Ctags (
" License: MIT
" Version: 2.0
" Version: 2.1
" Support for automatic update using the GLVS plug-in.
" GetLatestVimScripts: 3114 1 :AutoInstall:
@@ -42,6 +42,10 @@ if !exists('g:easytags_ignored_filetypes')
let g:easytags_ignored_filetypes = '^tex$'
if !exists('g:easytags_autorecurse')
let g:easytags_autorecurse = 0
function! s:InitEasyTags(version)
" Check that the location of Exuberant Ctags has been configured or that the
" correct version of the program exists in one of its default locations.

0 comments on commit 0d95679

Please sign in to comment.