Hi,
On 10/17/06, David Thompson <[EMAIL PROTECTED]> wrote:
--- Max Dyckhoff <[EMAIL PROTECTED]> wrote:
> > --- David Thompson [mailto:[EMAIL PROTECTED] wrote:
> > Does vim support a special type of 'iskeyword' setting for
> > Ctrl-] searching for tags?
> >
> > Here is my problem: after adding filenames to my tags file,
> > I now want to use the convenience of Ctrl-] to jump to files
> > as well as identifiers.
> >
>
> You could just use 'gf' to open the file under the cursor, assuming that it
lies in
> your path. ^wgf will open it in a new split, just like ^w^] does for tags.
>
> If that isn't an acceptable solution, I don't have any other suggestions.
Well, I did solve the problem with a rather ugly function
that sets & resets iskeyword for one tag lookup.
But I was hoping vim might have a better way to use iskeyword
in a contextual manner specific just for tags.
Here is my solution:
I still use normal Ctrl-] for identifiers, but now use Ctrl-\
to tag on a filename. It works pretty well, especially since
the ] and \ keys are next to each other on my QWERTY keyboard.
In my ~/.vimrc, I added,
" map Ctrl-\ to do Ctrl-] on filenames
nnoremap <silent> <C-\> :call TagFilename()<CR>
function! TagFilename()
let old_iskeyword = &iskeyword
setlocal iskeyword+=\.,/
let fname = expand('<cword>')
If you use expand("<cfile>"), then you don't need to change the
'iskeyword' setting. For example, you can use the following map:
nnoremap <silent> <C-\> :tag expand("<cfile>:t")<CR>
- Yegappan
let &l:iskeyword = old_iskeyword
let v:errmsg = ""
silent! execute ":tag ".fname
if v:errmsg != ""
echohl ErrorMsg
echo v:errmsg
echohl None
endif
endfunc