vimwiki

Personal wiki for vim
git clone https://github.com/vimwiki/vimwiki.git
Log | Files | Refs | README | LICENSE

commit e44b188a497576393fab62d021e9f87c3ffe3a85
parent a62bebceb20258e235812d9fba51efadeb37e8e8
Author: Ivan Tishchenko <ivan.tishchenko@dsr-company.con>
Date:   Tue,  6 Jan 2015 23:13:28 +0300

:VimwikiGenerateTags

Diffstat:
Mautoload/vimwiki/base.vim | 33+++++++++++++++++++++++++++++++++
Mdoc/vimwiki.txt | 5+++++
Mftplugin/vimwiki.vim | 2++
3 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim @@ -2105,6 +2105,39 @@ function! vimwiki#base#get_tags(metadata) "{{{ return keys(tags) endfunction " }}} +" vimwiki#base#generate_tags +" Similar to vimwiki#base#generate_links. In the current buffer, appends +" tags and references to all their instances. If no arguments (tags) are +" specified, outputs all tags. +function! vimwiki#base#generate_tags(...) abort "{{{ + let need_all_tags = (a:0 == 0) + let specific_tags = a:000 + + let metadata = vimwiki#base#load_tags_metadata() + + call append(line('$'), [ + \ '', + \ substitute(g:vimwiki_rxH1_Template, '__Header__', 'Generated Tags', '') ]) + + call sort(metadata) + + let bullet = repeat(' ', vimwiki#lst#get_list_margin()). + \ vimwiki#lst#default_symbol().' ' + let current_tag = '' + for entry in metadata + if need_all_tags || index(specific_tags, entry.tagname) != -1 + if entry.tagname != current_tag + let current_tag = entry.tagname + call append(line('$'), [ + \ '', + \ substitute(g:vimwiki_rxH2_Template, '__Header__', entry.tagname, ''), + \ '' ]) + endif + call append(line('$'), bullet . '[[' . entry.link . ']]') + endif + endfor +endfunction " }}} + " }}} " Command completion functions {{{ diff --git a/doc/vimwiki.txt b/doc/vimwiki.txt @@ -712,6 +712,11 @@ il A single list item. Searches over the pages in current wiki and finds all locations of a given tag. Supports |cmdline-completion|. +*:VimwikiGenerateTags* + Similar to |:VimwikiGenerateLinks|. In the current buffer, appends tags + and references to all their instances. Supports |cmdline-completion|. If + no arguments (tags) are specified, outputs all tags. + ============================================================================== 5. Wiki syntax *vimwiki-syntax* diff --git a/ftplugin/vimwiki.vim b/ftplugin/vimwiki.vim @@ -306,6 +306,8 @@ command! -buffer VimwikiDiaryPrevDay call vimwiki#diary#goto_prev_day() command! -buffer VimwikiRebuildTags call vimwiki#base#update_tags(1) command! -buffer -nargs=* -complete=custom,vimwiki#base#complete_tags \ VimwikiSearchTags VimwikiSearch /:<args>:/ +command! -buffer -nargs=* -complete=custom,vimwiki#base#complete_tags + \ VimwikiGenerateTags call vimwiki#base#generate_tags(<f-args>) " COMMANDS }}}