Vim Notes - Tags Fuzzy Finder
Vim Notes stores the list of known tags in a dedicated file, named tags. Unfortunately, its format isn't compatible with standard tags-files.
This note shows how to create a second tags-file compatible with CtrlP, a fuzzy finder for VIM. In the video below I created a new note with tags and then I recalled the note from the CtrlP fuzzy prompt.
Tweet of Seve_py/1542594453046706177
Generating the proper tags-file requires ctags binary for Windows, which can be downloaded here. In my main .vimrc, I enabled the option that checks if another .vimrc exists in the current folder.
set exrc " source folder specific .vimrc
This configuration is then sourced and it sets ctags.exe to run when VIM opens or when a buffer will be saved to a disk file.
...
let g:homedirw32 = fnamemodify('~',':p')
"" don't show these files when :SearchNotes
set wildignore+=*.pickle,tags,*.ctags,notetags,*.ini
set autochdir
let g:notes_tagsindex="tags"
"" CTRLP config
"" CTRLP tags for vim-notes
set tags=notetags
set autochdir
if has('win32') || has('win64')
let g:ctrlp_user_command = 'dir %s /-n /b /s /a-d' " Windows
endif
let g:ctrlp_show_hidden = 0
let g:ctrlp_use_readdir = 1
"" run ctags.exe when VIM opens or after a buffer has been saved
augroup notes
au BufWritePost,VimEnter *.txt
\ silent execute '!'.g:homedirw32.'\\bin\\ctags.exe -R -f notetags --options='.expand("%:p:h").'\\Notes.ctags'
augroup END
The ctags options file (Notes.ctags) defines the regular expression that matches all the tags inside my notes.
--exclude=.*
--exclude=*.ini
--exclude=*.ctags
--langdef=Notes
--map-Notes=+.txt
--kinddef-Notes=t,tag,tag
--regex-Notes=/(^|\s)@([0-9a-zA-Z_-]+)/\2/t