I have generated a tags file of a .bib
bibliography file (referenced in a .tex
file) and lines containing bibkeys in the .bib
file such as the following correctly identify the bibkeys as tags.
@Article{abc123,
and @InBook{def123&233,
The .tex
file that utilizes these bibkeys is always structured so:
\cite{abc123}
or \cite{def123&233}
That is, the bibkeys are always used within {
and }
.
While cursor is under abc123
, pressing Ctrl]
successfully navigates to that line in the .bib
file. However, when the cursor is on def123
, pressing Ctrl]
returns an error because VIM tries to jump to tag def123
which is not generated. The tag generated is only for the whole set of characters between {
and ,
which is def123&233
in this example -- the entire bibkey. Is there a way to have VIM correctly navigate tags that contain &
? That is, while jumping to a tag, the tag to be considered may very well contain &
.
Currently, my workaround is to visually select in the inner of {
via vi{
and then press Ctrl]
or g]
from within the .tex
file where these references are cited.
I tried to map this sequence of keypresses to a keyboard shortcut via
nmap <leader>t vi{ <C-]>
but this sequence of key presses does not seem to be captured by this mapping and the .bib
file is not navigated to.
Vim lets you decide what constitutes a keyword character with :help 'iskeyword'
:
:set iskeyword+=& " a literal &
:set iskeyword+=38 " OR a decimal &
That option is used for <C-]>
but also for many other features, so YMMV.
Since your problem is with .tex
files (plaintex
filetype by default) you should set that option only in that context. This is best done in a dedicated filetype plugin:
" in after/ftplugin/plaintex.vim
setlocal iskeyword+=&