From 90885f6c953e8d647b92f5551c926cd935d3d7c8 Mon Sep 17 00:00:00 2001 From: Leeiio Date: Mon, 30 Aug 2010 00:58:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0vimwiki=E5=88=B01.1=E7=89=88?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .VimballRecord | 1 + autoload/vimwiki.vim | 594 +++++++++-- autoload/vimwiki_diary.vim | 79 +- autoload/vimwiki_html.vim | 598 +++++++---- autoload/vimwiki_lst.vim | 26 +- autoload/vimwiki_tbl.vim | 251 ++++- doc/tags | 43 +- doc/tags-cn | 123 +++ doc/vimwiki.cnx | 2026 ++++++++++++++++++++++++++++++++++++ doc/vimwiki.txt | 533 +++++++--- ftplugin/vimwiki.vim | 166 ++- plugin/vimwiki.vim | 121 +-- syntax/vimwiki.vim | 203 ++-- syntax/vimwiki_default.vim | 23 +- syntax/vimwiki_media.vim | 11 +- vimrc | 4 +- 16 files changed, 4115 insertions(+), 687 deletions(-) create mode 100644 doc/vimwiki.cnx diff --git a/.VimballRecord b/.VimballRecord index 3d5129c..2e10c55 100644 --- a/.VimballRecord +++ b/.VimballRecord @@ -1,3 +1,4 @@ vimwiki-0-9-9.vba: call delete('/Users/Leeiio/.vim/syntax/vimwiki.vim')|call delete('/Users/Leeiio/.vim/syntax/vimwiki_default.vim')|call delete('/Users/Leeiio/.vim/syntax/vimwiki_media.vim')|call delete('/Users/Leeiio/.vim/ftplugin/vimwiki.vim')|call delete('/Users/Leeiio/.vim/plugin/vimwiki.vim')|call delete('/Users/Leeiio/.vim/autoload/vimwiki_diary.vim')|call delete('/Users/Leeiio/.vim/autoload/vimwiki_html.vim')|call delete('/Users/Leeiio/.vim/autoload/vimwiki_lst.vim')|call delete('/Users/Leeiio/.vim/autoload/vimwiki_tbl.vim')|call delete('/Users/Leeiio/.vim/autoload/vimwiki.vim')|call delete('/Users/Leeiio/.vim/doc/tags')|call delete('/Users/Leeiio/.vim/doc/vimwiki.txt') conque_1.1.vba: call delete('/Users/Leeiio/.vim/autoload/conque_term.vim')|call delete('/Users/Leeiio/.vim/doc/conque_term.txt')|call delete('/Users/Leeiio/.vim/plugin/conque_term.vim')|call delete('/Users/Leeiio/.vim/syntax/conque_term.vim') xmledit-1.9.1.vba: call delete('/Users/Leeiio/.vim/ftplugin/xml.vim')|call delete('/Users/Leeiio/.vim/doc/xml-plugin.txt') +vimwiki-1-1.vba: call delete('/Users/Leeiio/.vim/autoload/vimwiki.vim')|call delete('/Users/Leeiio/.vim/autoload/vimwiki_diary.vim')|call delete('/Users/Leeiio/.vim/autoload/vimwiki_html.vim')|call delete('/Users/Leeiio/.vim/autoload/vimwiki_lst.vim')|call delete('/Users/Leeiio/.vim/autoload/vimwiki_tbl.vim')|call delete('/Users/Leeiio/.vim/doc/vimwiki.txt')|call delete('/Users/Leeiio/.vim/ftplugin/vimwiki.vim')|call delete('/Users/Leeiio/.vim/plugin/vimwiki.vim')|call delete('/Users/Leeiio/.vim/syntax/vimwiki.vim')|call delete('/Users/Leeiio/.vim/syntax/vimwiki_default.vim')|call delete('/Users/Leeiio/.vim/syntax/vimwiki_media.vim') diff --git a/autoload/vimwiki.vim b/autoload/vimwiki.vim index 80e6b0f..c023ce2 100644 --- a/autoload/vimwiki.vim +++ b/autoload/vimwiki.vim @@ -1,3 +1,4 @@ +" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79 " Vimwiki autoload plugin file " Author: Maxim Kim " Home: http://code.google.com/p/vimwiki/ @@ -17,20 +18,14 @@ let s:badsymbols = '['.g:vimwiki_badsyms.g:vimwiki_stripsym.'<>|?*:"]' " MISC helper functions {{{ -" This function is double defined. -" TODO: refactor common functions into new module. -function! s:chomp_slash(str) "{{{ +function! vimwiki#chomp_slash(str) "{{{ return substitute(a:str, '[/\\]\+$', '', '') endfunction "}}} -function! s:is_windows() - return has("win32") || has("win64") || has("win95") || has("win16") -endfunction - function! vimwiki#mkdir(path) "{{{ let path = expand(a:path) if !isdirectory(path) && exists("*mkdir") - let path = s:chomp_slash(path) + let path = vimwiki#chomp_slash(path) if s:is_windows() && !empty(g:vimwiki_w32_dir_enc) let path = iconv(path, &enc, g:vimwiki_w32_dir_enc) endif @@ -53,7 +48,7 @@ function! vimwiki#subdir(path, filename)"{{{ let path = expand(a:path) let filename = expand(a:filename) let idx = 0 - while path[idx] == filename[idx] + while path[idx] ==? filename[idx] let idx = idx + 1 endwhile @@ -70,7 +65,7 @@ function! vimwiki#current_subdir()"{{{ endfunction"}}} function! vimwiki#open_link(cmd, link, ...) "{{{ - if s:is_link_to_non_wiki_file(a:link) + if vimwiki#is_non_wiki_link(a:link) call s:edit_file(a:cmd, a:link) else if a:0 @@ -79,7 +74,18 @@ function! vimwiki#open_link(cmd, link, ...) "{{{ let vimwiki_prev_link = [expand('%:p'), getpos('.')] endif - call s:edit_file(a:cmd, VimwikiGet('path').a:link.VimwikiGet('ext')) + if vimwiki#is_link_to_dir(a:link) + if g:vimwiki_dir_link == '' + call s:edit_file(a:cmd, VimwikiGet('path').a:link) + else + call s:edit_file(a:cmd, + \ VimwikiGet('path').a:link. + \ g:vimwiki_dir_link. + \ VimwikiGet('ext')) + endif + else + call s:edit_file(a:cmd, VimwikiGet('path').a:link.VimwikiGet('ext')) + endif if exists('vimwiki_prev_link') let b:vimwiki_prev_link = vimwiki_prev_link @@ -88,6 +94,84 @@ function! vimwiki#open_link(cmd, link, ...) "{{{ endfunction " }}} +function! vimwiki#select(wnum)"{{{ + if a:wnum < 1 || a:wnum > len(g:vimwiki_list) + return + endif + if &ft == 'vimwiki' + let b:vimwiki_idx = g:vimwiki_current_idx + endif + let g:vimwiki_current_idx = a:wnum - 1 +endfunction +" }}} + +function! vimwiki#generate_links()"{{{ + let links = s:get_links('*'.VimwikiGet('ext')) + + " We don't want link to itself. + let cur_link = expand('%:t:r') + call filter(links, 'v:val != cur_link') + + if len(links) + call append(line('$'), '= Generated Links =') + endif + + call sort(links) + + for link in links + if s:is_wiki_word(link) + call append(line('$'), '- '.link) + else + call append(line('$'), '- [['.link.']]') + endif + endfor +endfunction " }}} + +function! vimwiki#goto(key) "{{{ + call s:edit_file(':e', + \ VimwikiGet('path'). + \ a:key. + \ VimwikiGet('ext')) +endfunction "}}} + +function! s:is_windows() "{{{ + return has("win32") || has("win64") || has("win95") || has("win16") +endfunction "}}} + +function! s:get_links(pat) "{{{ + " search all wiki files in 'path' and its subdirs. + let subdir = vimwiki#current_subdir() + + " if current wiki is temporary -- was added by an arbitrary wiki file then do + " not search wiki files in subdirectories. Or it would hang the system if + " wiki file was created in $HOME or C:/ dirs. + if VimwikiGet('temp') + let search_dirs = '' + else + let search_dirs = '**/' + endif + let globlinks = glob(VimwikiGet('path').subdir.search_dirs.a:pat) + + " remove extensions (and backup extensions too: .wiki~) + let globlinks = substitute(globlinks, '\'.VimwikiGet('ext').'\~\?', "", "g") + let links = split(globlinks, '\n') + + " remove paths + let rem_path = escape(expand(VimwikiGet('path')).subdir, '\') + call map(links, 'substitute(v:val, rem_path, "", "g")') + + " Remove trailing slashes. + call map(links, 'substitute(v:val, "[/\\\\]*$", "", "g")') + + return links +endfunction "}}} + +" Builtin cursor doesn't work right with unicode characters. +function! s:cursor(lnum, cnum) "{{{ + exe a:lnum + exe 'normal! 0'.a:cnum.'|' +endfunction "}}} + function! s:filename(link) "{{{ let result = vimwiki#safe_link(a:link) if a:link =~ '|' @@ -100,7 +184,7 @@ endfunction " }}} function! s:is_wiki_word(str) "{{{ - if a:str =~ g:vimwiki_word1 && a:str !~ '[[:space:]\\/]' + if a:str =~ g:vimwiki_rxWikiWord && a:str !~ '[[:space:]\\/]' return 1 endif return 0 @@ -164,15 +248,24 @@ function! s:strip_word(word) "{{{ endfunction " }}} -function! s:is_link_to_non_wiki_file(word) "{{{ - " Check if word is link to a non-wiki file. - " The easiest way is to check if it has extension like .txt or .html - if a:word =~ '\.\w\{1,4}$' +function! vimwiki#is_non_wiki_link(lnk) "{{{ + let exts = '.\+\.\%('. + \ join(split(g:vimwiki_file_exts, '\s*,\s*'), '\|'). + \ '\)$' + if a:lnk =~ exts return 1 endif return 0 -endfunction -" }}} +endfunction "}}} + +function! vimwiki#is_link_to_dir(link) "{{{ + " Check if link is to a directory. + " It should be ended with \ or /. + if a:link =~ '.\+[/\\]$' + return 1 + endif + return 0 +endfunction " }}} function! s:print_wiki_list() "{{{ let idx = 0 @@ -191,17 +284,6 @@ function! s:print_wiki_list() "{{{ endfunction " }}} -function! vimwiki#select(wnum)"{{{ - if a:wnum < 1 || a:wnum > len(g:vimwiki_list) - return - endif - if &ft == 'vimwiki' - let b:vimwiki_idx = g:vimwiki_current_idx - endif - let g:vimwiki_current_idx = a:wnum - 1 -endfunction -" }}} - function! s:update_wiki_link(fname, old, new) " {{{ echo "Updating links in ".a:fname let has_updates = 0 @@ -224,19 +306,23 @@ endfunction function! s:update_wiki_links_dir(dir, old_fname, new_fname) " {{{ let old_fname = substitute(a:old_fname, '[/\\]', '[/\\\\]', 'g') let new_fname = a:new_fname + let old_fname_r = old_fname + let new_fname_r = new_fname - if !s:is_wiki_word(new_fname) - let new_fname = '[['.new_fname.']]' + if !s:is_wiki_word(new_fname) && s:is_wiki_word(old_fname) + let new_fname_r = '[['.new_fname.']]' endif + if !s:is_wiki_word(old_fname) - let old_fname = '\[\['.vimwiki#unsafe_link(old_fname). - \ '\%(|.*\)\?\%(\]\[.*\)\?\]\]' + let old_fname_r = '\[\[\zs'.vimwiki#unsafe_link(old_fname). + \ '\ze\%(|.*\)\?\%(\]\[.*\)\?\]\]' else - let old_fname = '\<'.old_fname.'\>' + let old_fname_r = '\<'.old_fname.'\>' endif + let files = split(glob(VimwikiGet('path').a:dir.'*'.VimwikiGet('ext')), '\n') for fname in files - call s:update_wiki_link(fname, old_fname, new_fname) + call s:update_wiki_link(fname, old_fname_r, new_fname_r) endfor endfunction " }}} @@ -278,8 +364,7 @@ function! s:update_wiki_links(old_fname, new_fname) " {{{ \ new_dir.old_fname, new_dir.new_fname) let idx = idx + 1 endwhile -endfunction -" }}} +endfunction " }}} function! s:get_wiki_buffers() "{{{ let blist = [] @@ -295,60 +380,178 @@ function! s:get_wiki_buffers() "{{{ let bcount = bcount + 1 endwhile return blist -endfunction -" }}} +endfunction " }}} function! s:open_wiki_buffer(item) "{{{ call s:edit_file('e', a:item[0]) if !empty(a:item[1]) call setbufvar(a:item[0], "vimwiki_prev_link", a:item[1]) endif -endfunction -" }}} +endfunction " }}} " }}} " SYNTAX highlight {{{ -function! vimwiki#WikiHighlightWords() "{{{ - " search all wiki files in 'path' and its subdirs. - let subdir = vimwiki#current_subdir() - let wikies = glob(VimwikiGet('path').subdir.'**/*'.VimwikiGet('ext')) +function! vimwiki#highlight_links() "{{{ + try + syntax clear VimwikiNoExistsLink + syntax clear VimwikiNoExistsLinkT + syntax clear VimwikiLink + syntax clear VimwikiLinkT + catch + endtry - " remove .wiki extensions - let wikies = substitute(wikies, '\'.VimwikiGet('ext'), "", "g") - let g:vimwiki_wikiwords = split(wikies, '\n') + "" use max highlighting - could be quite slow if there are too many wikifiles + if VimwikiGet('maxhi') + " Every WikiWord is nonexistent + if g:vimwiki_camel_case + execute 'syntax match VimwikiNoExistsLink /'.g:vimwiki_rxWikiWord.'/ display' + execute 'syntax match VimwikiNoExistsLinkT /'.g:vimwiki_rxWikiWord.'/ display contained' + endif + execute 'syntax match VimwikiNoExistsLink /'.g:vimwiki_rxWikiLink1.'/ display contains=VimwikiNoLinkChar' + execute 'syntax match VimwikiNoExistsLink /'.g:vimwiki_rxWikiLink2.'/ display contains=VimwikiNoLinkChar' - " remove backup files (.wiki~) - call filter(g:vimwiki_wikiwords, 'v:val !~ ''.*\~$''') + execute 'syntax match VimwikiNoExistsLinkT /'.g:vimwiki_rxWikiLink1.'/ display contained' + execute 'syntax match VimwikiNoExistsLinkT /'.g:vimwiki_rxWikiLink2.'/ display contained' - " remove paths - let rem_path = escape(expand(VimwikiGet('path')).subdir, '\') - call map(g:vimwiki_wikiwords, 'substitute(v:val, rem_path, "", "g")') + " till we find them in vimwiki's path + call s:highlight_existed_links() + else + " A WikiWord (unqualifiedWikiName) + execute 'syntax match VimwikiLink /\<'.g:vimwiki_rxWikiWord.'\>/' + " A [[bracketed wiki word]] + execute 'syntax match VimwikiLink /'.g:vimwiki_rxWikiLink1.'/ display contains=VimwikiLinkChar' + execute 'syntax match VimwikiLink /'.g:vimwiki_rxWikiLink2.'/ display contains=VimwikiLinkChar' + + execute 'syntax match VimwikiLinkT /\<'.g:vimwiki_rxWikiWord.'\>/ display contained' + execute 'syntax match VimwikiLinkT /'.g:vimwiki_rxWikiLink1.'/ display contained' + execute 'syntax match VimwikiLinkT /'.g:vimwiki_rxWikiLink2.'/ display contained' + endif + + execute 'syntax match VimwikiLink `'.g:vimwiki_rxWeblink.'` display contains=@NoSpell' +endfunction "}}} + +function! s:highlight_existed_links() "{{{ + let links = s:get_links('*'.VimwikiGet('ext')) " Links with subdirs should be highlighted for linux and windows separators " Change \ or / to [/\\] let os_p = '[/\\]' let os_p2 = escape(os_p, '\') - call map(g:vimwiki_wikiwords, 'substitute(v:val, os_p, os_p2, "g")') + call map(links, 'substitute(v:val, os_p, os_p2, "g")') - for word in g:vimwiki_wikiwords + for link in links if g:vimwiki_camel_case && - \ word =~ g:vimwiki_word1 && !s:is_link_to_non_wiki_file(word) - execute 'syntax match VimwikiWord /\%(^\|[^!]\)\@<=\<'.word.'\>/' - endif - execute 'syntax match VimwikiWord /\[\[\<'. - \ vimwiki#unsafe_link(word). - \ '\>\%(|\+.*\)*\]\]/' - execute 'syntax match VimwikiWord /\[\[\<'. - \ vimwiki#unsafe_link(word). - \ '\>\]\[.\+\]\]/' + \ link =~ g:vimwiki_rxWikiWord && !vimwiki#is_non_wiki_link(link) + execute 'syntax match VimwikiLink /!\@/ display' + endif + execute 'syntax match VimwikiLink /\[\['. + \ escape(vimwiki#unsafe_link(link), '~&$.*'). + \ '\%(|\+.\{-}\)\{-}\]\]/ display contains=VimwikiLinkChar' + execute 'syntax match VimwikiLink /\[\['. + \ escape(vimwiki#unsafe_link(link), '~&$.*'). + \ '\]\[.\{-1,}\]\]/ display contains=VimwikiLinkChar' + + execute 'syntax match VimwikiLinkT /\[\['. + \ escape(vimwiki#unsafe_link(link), '~&$.*'). + \ '\%(|\+.\{-}\)\{-}\]\]/ display contained' + execute 'syntax match VimwikiLinkT /\[\['. + \ escape(vimwiki#unsafe_link(link), '~&$.*'). + \ '\]\[.\{-1,}\]\]/ display contained' endfor - execute 'syntax match VimwikiWord /\[\[.\+\.\%(jpg\|png\|gif\)\%(|\+.*\)*\]\]/' - execute 'syntax match VimwikiWord /\[\[.\+\.\%(jpg\|png\|gif\)\]\[.\+\]\]/' -endfunction -" }}} + execute 'syntax match VimwikiLink /\[\[.\+\.\%(jpg\|png\|gif\)\%(|\+.*\)*\]\]/ display contains=VimwikiLinkChar' + execute 'syntax match VimwikiLink /\[\[.\+\.\%(jpg\|png\|gif\)\]\[.\+\]\]/ display contains=VimwikiLinkChar' + + execute 'syntax match VimwikiLinkT /\[\[.\+\.\%(jpg\|png\|gif\)\%(|\+.*\)*\]\]/ display contained' + execute 'syntax match VimwikiLinkT /\[\[.\+\.\%(jpg\|png\|gif\)\]\[.\+\]\]/ display contained' + + " Issue 103: Always highlight links to non-wiki files as existed. + execute 'syntax match VimwikiLink /\[\[.\+\.\%('. + \join(split(g:vimwiki_file_exts, '\s*,\s*'), '\|'). + \'\)\%(|\+.*\)*\]\]/ display contains=VimwikiLinkChar' + execute 'syntax match VimwikiLink /\[\[.\+\.\%('. + \join(split(g:vimwiki_file_exts, '\s*,\s*'), '\|'). + \'\)\]\[.\+\]\]/ display contains=VimwikiLinkChar' + + execute 'syntax match VimwikiLinkT /\[\[.\+\.\%('. + \join(split(g:vimwiki_file_exts, '\s*,\s*'), '\|'). + \'\)\%(|\+.*\)*\]\]/ display contained' + execute 'syntax match VimwikiLinkT /\[\[.\+\.\%('. + \join(split(g:vimwiki_file_exts, '\s*,\s*'), '\|'). + \'\)\]\[.\+\]\]/ display contained' + + " highlight dirs + let dirs = s:get_links('*/') + call map(dirs, 'substitute(v:val, os_p, os_p2, "g")') + for dir in dirs + execute 'syntax match VimwikiLink /\[\['. + \ escape(vimwiki#unsafe_link(dir), '~&$.*'). + \ '[/\\]*\%(|\+.*\)*\]\]/ display contains=VimwikiLinkChar' + execute 'syntax match VimwikiLink /\[\['. + \ escape(vimwiki#unsafe_link(dir), '~&$.*'). + \ '[/\\]*\%(\]\[\+.*\)*\]\]/ display contains=VimwikiLinkChar' + + execute 'syntax match VimwikiLinkT /\[\['. + \ escape(vimwiki#unsafe_link(dir), '~&$.*'). + \ '[/\\]*\%(|\+.*\)*\]\]/ display contained' + execute 'syntax match VimwikiLinkT /\[\['. + \ escape(vimwiki#unsafe_link(dir), '~&$.*'). + \ '[/\\]*\%(\]\[\+.*\)*\]\]/ display contained' + endfor +endfunction "}}} + +function! vimwiki#setup_colors() "{{{ + + function! s:set_visible_ignore_color() "{{{ + if !exists("g:colors_name") || g:colors_name == 'default' + if &background == 'light' + hi VimwikiIgnore guifg=#d0d0d0 + else + hi VimwikiIgnore guifg=#505050 + endif + else + hi link VimwikiIgnore Normal + endif + endfunction "}}} + + let hlfg_ignore = vimwiki#get_hl_param('Ignore', 'guifg') + let hlbg_normal = vimwiki#get_hl_param('Normal', 'guibg') + if hlfg_ignore == 'bg' || hlfg_ignore == hlbg_normal + call s:set_visible_ignore_color() + else + hi link VimwikiIgnore Ignore + endif + + if g:vimwiki_hl_headers == 0 + hi def link VimwikiHeader Title + return + endif + + if &background == 'light' + hi def VimwikiHeader1 guibg=bg guifg=#aa5858 gui=bold ctermfg=DarkRed + hi def VimwikiHeader2 guibg=bg guifg=#507030 gui=bold ctermfg=DarkGreen + hi def VimwikiHeader3 guibg=bg guifg=#1030a0 gui=bold ctermfg=DarkBlue + hi def VimwikiHeader4 guibg=bg guifg=#103040 gui=bold ctermfg=Black + hi def VimwikiHeader5 guibg=bg guifg=#505050 gui=bold ctermfg=Black + hi def VimwikiHeader6 guibg=bg guifg=#636363 gui=bold ctermfg=Black + else + hi def VimwikiHeader1 guibg=bg guifg=#e08090 gui=bold ctermfg=Red + hi def VimwikiHeader2 guibg=bg guifg=#80e090 gui=bold ctermfg=Green + hi def VimwikiHeader3 guibg=bg guifg=#6090e0 gui=bold ctermfg=Blue + hi def VimwikiHeader4 guibg=bg guifg=#c0c0f0 gui=bold ctermfg=White + hi def VimwikiHeader5 guibg=bg guifg=#e0e0f0 gui=bold ctermfg=White + hi def VimwikiHeader6 guibg=bg guifg=#f0f0f0 gui=bold ctermfg=White + endif +endfunction "}}} + +function vimwiki#get_hl_param(hgroup, hparam) "{{{ + redir => hlstatus + exe "silent hi ".a:hgroup + redir END + return matchstr(hlstatus, a:hparam.'\s*=\s*\zs\S\+') +endfunction "}}} -function! vimwiki#hl_exists(hl)"{{{ +function! vimwiki#hl_exists(hl) "{{{ if !hlexists(a:hl) return 0 endif @@ -388,26 +591,38 @@ function! vimwiki#nested_syntax(filetype, start, end, textSnipHl) abort "{{{ else unlet b:current_syntax endif - execute 'syntax region textSnip'.ft.' - \ matchgroup='.a:textSnipHl.' - \ start="'.a:start.'" end="'.a:end.'" - \ contains=@'.group + execute 'syntax region textSnip'.ft. + \ ' matchgroup='.a:textSnipHl. + \ ' start="'.a:start.'" end="'.a:end.'"'. + \ ' contains=@'.group.' keepend' + + " A workaround to Issue 115: Nested Perl syntax highlighting differs from + " regular one. + " Perl syntax file has perlFunctionName which is usually has no effect due to + " 'contained' flag. Now we have 'syntax include' that makes all the groups + " included as 'contained' into specific group. + " Here perlFunctionName (with quite an angry regexp "\h\w*[^:]") clashes with + " the rest syntax rules as now it has effect being really 'contained'. + " Clear it! + if ft =~ 'perl' + syntax clear perlFunctionName + endif endfunction "}}} "}}} " WIKI functions {{{ -function! vimwiki#WikiNextWord() "{{{ - call s:search_word(g:vimwiki_rxWikiWord.'\|'.g:vimwiki_rxWeblink, '') +function! vimwiki#find_next_link() "{{{ + call s:search_word(g:vimwiki_rxWikiLink.'\|'.g:vimwiki_rxWeblink, '') endfunction " }}} -function! vimwiki#WikiPrevWord() "{{{ - call s:search_word(g:vimwiki_rxWikiWord.'\|'.g:vimwiki_rxWeblink, 'b') +function! vimwiki#find_prev_link() "{{{ + call s:search_word(g:vimwiki_rxWikiLink.'\|'.g:vimwiki_rxWeblink, 'b') endfunction " }}} -function! vimwiki#WikiFollowWord(split) "{{{ +function! vimwiki#follow_link(split) "{{{ if a:split == "split" let cmd = ":split " elseif a:split == "vsplit" @@ -416,11 +631,11 @@ function! vimwiki#WikiFollowWord(split) "{{{ let cmd = ":e " endif - let link = s:strip_word(s:get_word_at_cursor(g:vimwiki_rxWikiWord)) + let link = s:strip_word(s:get_word_at_cursor(g:vimwiki_rxWikiLink)) if link == "" let weblink = s:strip_word(s:get_word_at_cursor(g:vimwiki_rxWeblink)) if weblink != "" - call VimwikiWeblinkHandler(weblink) + call VimwikiWeblinkHandler(escape(weblink, '#')) else execute "normal! \n" endif @@ -430,20 +645,18 @@ function! vimwiki#WikiFollowWord(split) "{{{ let subdir = vimwiki#current_subdir() call vimwiki#open_link(cmd, subdir.link) -endfunction -" }}} +endfunction " }}} -function! vimwiki#WikiGoBackWord() "{{{ +function! vimwiki#go_back_link() "{{{ if exists("b:vimwiki_prev_link") " go back to saved WikiWord let prev_word = b:vimwiki_prev_link execute ":e ".substitute(prev_word[0], '\s', '\\\0', 'g') call setpos('.', prev_word[1]) endif -endfunction -" }}} +endfunction " }}} -function! vimwiki#WikiGoHome(index) "{{{ +function! vimwiki#goto_index(index) "{{{ call vimwiki#select(a:index) call vimwiki#mkdir(VimwikiGet('path')) @@ -451,17 +664,15 @@ function! vimwiki#WikiGoHome(index) "{{{ execute ':e '.fnameescape( \ VimwikiGet('path').VimwikiGet('index').VimwikiGet('ext')) catch /E37/ " catch 'No write since last change' error - " this is really unsecure!!! - execute ':'.VimwikiGet('gohome').' '. + execute ':split '. \ VimwikiGet('path'). \ VimwikiGet('index'). \ VimwikiGet('ext') catch /E325/ " catch 'ATTENTION' error (:h E325) endtry -endfunction -"}}} +endfunction "}}} -function! vimwiki#WikiDeleteWord() "{{{ +function! vimwiki#delete_link() "{{{ "" file system funcs "" Delete WikiWord you are in from filesystem let val = input('Delete ['.expand('%').'] (y/n)? ', "") @@ -481,10 +692,9 @@ function! vimwiki#WikiDeleteWord() "{{{ if expand('%:p') != "" execute "e" endif -endfunction -"}}} +endfunction "}}} -function! vimwiki#WikiRenameWord() "{{{ +function! vimwiki#rename_link() "{{{ "" Rename WikiWord, update all links to renamed WikiWord let subdir = vimwiki#current_subdir() let old_fname = subdir.expand('%:t') @@ -509,18 +719,17 @@ function! vimwiki#WikiRenameWord() "{{{ return endif - let new_link = subdir.new_link - " check new_fname - it should be 'good', not empty if substitute(new_link, '\s', '', 'g') == '' echomsg 'vimwiki: Cannot rename to an empty filename!' return endif - if s:is_link_to_non_wiki_file(new_link) + if vimwiki#is_non_wiki_link(new_link) echomsg 'vimwiki: Cannot rename to a filename with extension (ie .txt .html)!' return endif + let new_link = subdir.new_link let new_link = s:strip_word(new_link) let new_fname = VimwikiGet('path').s:filename(new_link).VimwikiGet('ext') @@ -583,16 +792,15 @@ function! vimwiki#WikiRenameWord() "{{{ echomsg old_fname." is renamed to ".new_fname let &more = setting_more -endfunction -" }}} +endfunction " }}} -function! vimwiki#WikiUISelect()"{{{ +function! vimwiki#ui_select()"{{{ call s:print_wiki_list() let idx = input("Select Wiki (specify number): ") if idx == "" return endif - call vimwiki#WikiGoHome(idx) + call vimwiki#goto_index(idx) endfunction "}}} @@ -601,7 +809,7 @@ endfunction " TEXT OBJECTS functions {{{ function! vimwiki#TO_header(inner, visual) "{{{ - if !search('^\(=\+\)[^=]\+\1\s*$', 'bcW') + if !search('^\(=\+\).\+\1\s*$', 'bcW') return endif @@ -618,7 +826,7 @@ function! vimwiki#TO_header(inner, visual) "{{{ if a:visual && is_header_selected if level > 1 let level -= 1 - call search('^\(=\{'.level.'\}\)[^=]\+\1\s*$', 'bcW') + call search('^\(=\{'.level.'\}\).\+\1\s*$', 'bcW') else let advance = 1 endif @@ -630,7 +838,7 @@ function! vimwiki#TO_header(inner, visual) "{{{ call cursor(sel_end + advance, 0) endif - if search('^\(=\{1,'.level.'}\)[^=]\+\1\s*$', 'W') + if search('^\(=\{1,'.level.'}\).\+\1\s*$', 'W') call cursor(line('.') - 1, 0) else call cursor(line('$'), 0) @@ -643,6 +851,184 @@ function! vimwiki#TO_header(inner, visual) "{{{ endfunction "}}} +function! vimwiki#TO_table_cell(inner, visual) "{{{ + if col('.') == col('$')-1 + return + endif + + if a:visual + normal! `> + let sel_end = getpos('.') + normal! `< + let sel_start = getpos('.') + + let firsttime = sel_start == sel_end + + if firsttime + if !search('|\|\(-+-\)', 'cb', line('.')) + return + endif + if getline('.')[virtcol('.')] == '+' + normal! l + endif + if a:inner + normal! 2l + endif + let sel_start = getpos('.') + endif + + normal! `> + call search('|\|\(-+-\)', '', line('.')) + if getline('.')[virtcol('.')] == '+' + normal! l + endif + if a:inner + if firsttime || abs(sel_end[2] - getpos('.')[2]) != 2 + normal! 2h + endif + endif + let sel_end = getpos('.') + + call setpos('.', sel_start) + exe "normal! \" + call setpos('.', sel_end) + + " XXX: WORKAROUND. + " if blockwise selection is ended at | character then pressing j to extend + " selection furhter fails. But if we shake the cursor left and right then + " it works. + normal! hl + else + if !search('|\|\(-+-\)', 'cb', line('.')) + return + endif + if a:inner + normal! 2l + endif + normal! v + call search('|\|\(-+-\)', '', line('.')) + if !a:inner && getline('.')[virtcol('.')-1] == '|' + normal! h + elseif a:inner + normal! 2h + endif + endif +endfunction "}}} + +function! vimwiki#TO_table_col(inner, visual) "{{{ + let t_rows = vimwiki_tbl#get_rows(line('.')) + if empty(t_rows) + return + endif + + " TODO: refactor it! + if a:visual + normal! `> + let sel_end = getpos('.') + normal! `< + let sel_start = getpos('.') + + let firsttime = sel_start == sel_end + + if firsttime + " place cursor to the top row of the table + call s:cursor(t_rows[0][0], virtcol('.')) + " do not accept the match at cursor position if cursor is next to column + " separator of the table separator (^ is a cursor): + " |-----^-+-------| + " | bla | bla | + " |-------+-------| + " or it will select wrong column. + if strpart(getline('.'), virtcol('.')-1) =~ '^-+' + let s_flag = 'b' + else + let s_flag = 'cb' + endif + " search the column separator backwards + if !search('|\|\(-+-\)', s_flag, line('.')) + return + endif + " -+- column separator is matched --> move cursor to the + sign + if getline('.')[virtcol('.')] == '+' + normal! l + endif + " inner selection --> reduce selection + if a:inner + normal! 2l + endif + let sel_start = getpos('.') + endif + + normal! `> + if !firsttime && getline('.')[virtcol('.')] == '|' + normal! l + elseif a:inner && getline('.')[virtcol('.')+1] =~ '[|+]' + normal! 2l + endif + " search for the next column separator + call search('|\|\(-+-\)', '', line('.')) + " Outer selection selects a column without border on the right. So we move + " our cursor left if the previous search finds | border, not -+-. + if getline('.')[virtcol('.')] != '+' + normal! h + endif + if a:inner + " reduce selection a bit more if inner. + normal! h + endif + " expand selection to the bottom line of the table + call s:cursor(t_rows[-1][0], virtcol('.')) + let sel_end = getpos('.') + + call setpos('.', sel_start) + exe "normal! \" + call setpos('.', sel_end) + + else + " place cursor to the top row of the table + call s:cursor(t_rows[0][0], virtcol('.')) + " do not accept the match at cursor position if cursor is next to column + " separator of the table separator (^ is a cursor): + " |-----^-+-------| + " | bla | bla | + " |-------+-------| + " or it will select wrong column. + if strpart(getline('.'), virtcol('.')-1) =~ '^-+' + let s_flag = 'b' + else + let s_flag = 'cb' + endif + " search the column separator backwards + if !search('|\|\(-+-\)', s_flag, line('.')) + return + endif + " -+- column separator is matched --> move cursor to the + sign + if getline('.')[virtcol('.')] == '+' + normal! l + endif + " inner selection --> reduce selection + if a:inner + normal! 2l + endif + + exe "normal! \" + + " search for the next column separator + call search('|\|\(-+-\)', '', line('.')) + " Outer selection selects a column without border on the right. So we move + " our cursor left if the previous search finds | border, not -+-. + if getline('.')[virtcol('.')] != '+' + normal! h + endif + " reduce selection a bit more if inner. + if a:inner + normal! h + endif + " expand selection to the bottom line of the table + call s:cursor(t_rows[-1][0], virtcol('.')) + endif +endfunction "}}} + function! vimwiki#count_first_sym(line) "{{{ let first_sym = matchstr(a:line, '\S') return len(matchstr(a:line, first_sym.'\+')) diff --git a/autoload/vimwiki_diary.vim b/autoload/vimwiki_diary.vim index 25d8d33..9803cc1 100644 --- a/autoload/vimwiki_diary.vim +++ b/autoload/vimwiki_diary.vim @@ -1,3 +1,4 @@ +" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79 " Vimwiki autoload plugin file " Desc: Handle diary notes " Author: Maxim Kim @@ -61,7 +62,7 @@ function! s:get_diary_range(lines, header) "{{{ let idx += 1 endfor - let ln_end = idx - 1 + let ln_end = idx return [ln_start, ln_end] endfunction "}}} @@ -85,10 +86,10 @@ endfunction "}}} function! s:get_links() "{{{ let rx = '\d\{4}-\d\d-\d\d' - let s_links = glob(VimwikiGet('path').VimwikiGet('diary_rel_path').'*.wiki') + let s_links = glob(VimwikiGet('path').VimwikiGet('diary_rel_path'). + \ '*'.VimwikiGet('ext')) - "let s_links = substitute(s_links, '\'.VimwikiGet('ext'), "", "g") - let s_links = substitute(s_links, '\.wiki', "", "g") + let s_links = substitute(s_links, '\'.VimwikiGet('ext'), "", "g") let links = split(s_links, '\n') " remove backup files (.wiki~) @@ -98,10 +99,24 @@ function! s:get_links() "{{{ call map(links, 'fnamemodify(v:val, ":t")') call filter(links, 'v:val =~ "'.escape(rx, '\').'"') - call map(links, '"[[".v:val."]]"') return links endfunction "}}} +function! s:get_position_links(link) "{{{ + let idx = -1 + let links = [] + if a:link =~ '\d\{4}-\d\d-\d\d' + let links = s:get_links() + " include 'today' into links + if index(links, s:diary_date_link()) == -1 + call add(links, s:diary_date_link()) + endif + call sort(links) + let idx = index(links, a:link) + endif + return [idx, links] +endfunction "}}} + function! s:format_links(links) "{{{ let lines = [] let line = '| ' @@ -136,6 +151,7 @@ function! s:add_link(page, header, link) "{{{ if ln_start == -1 call insert(lines, '= '.a:header.' =') let ln_start = 1 + let ln_end = 1 endif " removing 'old' links @@ -147,6 +163,7 @@ function! s:add_link(page, header, link) "{{{ " get all diary links from filesystem let links = s:get_links() + call map(links, '"[[".v:val."]]"') " add current link if index(links, link) == -1 @@ -191,7 +208,7 @@ function! vimwiki_diary#make_note(index, ...) "{{{ call vimwiki#open_link(':e ', link, s:diary_index()) endfunction "}}} -" Calendar.vim callback. +" Calendar.vim callback function. function! vimwiki_diary#calendar_action(day, month, year, week, dir) "{{{ let day = s:prefix_zero(a:day) let month = s:prefix_zero(a:month) @@ -212,5 +229,53 @@ function! vimwiki_diary#calendar_action(day, month, year, week, dir) "{{{ " Create diary note for a selected date in default wiki. call vimwiki_diary#make_note(1, link) -endfunction +endfunction "}}} + +" Calendar.vim sign function. +function vimwiki_diary#calendar_sign(day, month, year) "{{{ + let day = s:prefix_zero(a:day) + let month = s:prefix_zero(a:month) + let sfile = VimwikiGet('path').VimwikiGet('diary_rel_path'). + \ a:year.'-'.month.'-'.day.VimwikiGet('ext') + return filereadable(expand(sfile)) +endfunction "}}} + +function! vimwiki_diary#goto_next_day() "{{{ + let link = '' + let [idx, links] = s:get_position_links(expand('%:t:r')) + if idx == (len(links) - 1) + return + endif + + if idx != -1 && idx < len(links) - 1 + let link = VimwikiGet('diary_rel_path').links[idx+1] + else + " goto today + let link = VimwikiGet('diary_rel_path').s:diary_date_link() + endif + + if len(link) + call vimwiki#open_link(':e ', link) + endif +endfunction "}}} + +function! vimwiki_diary#goto_prev_day() "{{{ + let link = '' + let [idx, links] = s:get_position_links(expand('%:t:r')) + + if idx == 0 + return + endif + + if idx > 0 + let link = VimwikiGet('diary_rel_path').links[idx-1] + else + " goto today + let link = VimwikiGet('diary_rel_path').s:diary_date_link() + endif + + if len(link) + call vimwiki#open_link(':e ', link) + endif +endfunction "}}} diff --git a/autoload/vimwiki_html.vim b/autoload/vimwiki_html.vim index f422b5e..1efa539 100644 --- a/autoload/vimwiki_html.vim +++ b/autoload/vimwiki_html.vim @@ -1,3 +1,4 @@ +" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79 " Vimwiki autoload plugin file " Export to HTML " Author: Maxim Kim @@ -28,7 +29,7 @@ function! s:syntax_supported() " {{{ endfunction " }}} function! s:remove_blank_lines(lines) " {{{ - while a:lines[-1] =~ '^\s*$' + while !empty(a:lines) && a:lines[-1] =~ '^\s*$' call remove(a:lines, -1) endwhile endfunction "}}} @@ -47,14 +48,6 @@ function! s:is_img_link(lnk) "{{{ return 0 endfunction "}}} -function! s:is_non_wiki_link(lnk) "{{{ - " TODO: Add more file extensions here - if a:lnk =~ '.\+\.\%(pdf\|txt\|doc\|rtf\|xls\)$' - return 1 - endif - return 0 -endfunction "}}} - function! s:has_abs_path(fname) "{{{ if a:fname =~ '\(^.:\)\|\(^/\)' return 1 @@ -69,7 +62,7 @@ function! s:create_default_CSS(path) " {{{ call vimwiki#mkdir(fnamemodify(css_full_name, ':p:h')) let lines = [] - call add(lines, 'body {font-family: Arial, sans-serif; margin: 1em 2em 1em 2em; font-size: 100%; line-height: 130%;}') + call add(lines, 'body {font-family: Tahoma, sans-serif; margin: 1em 2em 1em 2em; font-size: 100%; line-height: 130%;}') call add(lines, 'h1, h2, h3, h4, h5, h6 {font-family: Trebuchet MS, serif; margin-top: 1.5em; margin-bottom: 0.5em;}') call add(lines, 'h1 {font-size: 2.0em; color: #a77070;}') call add(lines, 'h2 {font-size: 1.6em; color: #779977;}') @@ -94,21 +87,20 @@ function! s:create_default_CSS(path) " {{{ call add(lines, '.justleft {text-align: left;}') call add(lines, '.justright {text-align: right;}') call add(lines, '.justcenter {text-align: center;}') + call add(lines, '.center {margin-left: auto; margin-right: auto;}') call writefile(lines, css_full_name) echomsg "Default style.css is created." endif endfunction "}}} -function! s:get_html_header(wikifile, subdir, charset) "{{{ +function! s:get_html_header(title, subdir, charset) "{{{ let lines=[] - let title = fnamemodify(a:wikifile, ":t:r") - if VimwikiGet('html_header') != "" && !s:warn_html_header try let lines = readfile(expand(VimwikiGet('html_header'))) - call map(lines, 'substitute(v:val, "%title%", "'. title .'", "g")') + call map(lines, 'substitute(v:val, "%title%", "'. a:title .'", "g")') call map(lines, 'substitute(v:val, "%root_path%", "'. \ s:root_path(a:subdir) .'", "g")') return lines @@ -132,7 +124,7 @@ function! s:get_html_header(wikifile, subdir, charset) "{{{ call add(lines, '') call add(lines, '') - call add(lines, ''.title.'') + call add(lines, ''.a:title.'') call add(lines, '') call add(lines, '') @@ -147,12 +139,6 @@ function! s:get_html_footer() "{{{ if VimwikiGet('html_footer') != "" && !s:warn_html_footer try let lines = readfile(expand(VimwikiGet('html_footer'))) - if exists("*strftime") - if !exists('g:vimwiki_timestamp_format') - let g:vimwiki_timestamp_format = '%Y-%m-%d %H:%M:%S' - endif - call map(lines, 'substitute(v:val, "%time_stamp%", "'. strftime(g:vimwiki_timestamp_format) .'", "g")') - endif return lines catch /E484/ let s:warn_html_footer = 1 @@ -171,11 +157,17 @@ function! s:get_html_footer() "{{{ endfunction "}}} function! s:safe_html(line) "{{{ - "" change dangerous html symbols: < > & + "" htmlize symbols: < > & let line = substitute(a:line, '&', '\&', 'g') - let line = substitute(line, '<', '\<', 'g') - let line = substitute(line, '>', '\>', 'g') + + let tags = join(split(g:vimwiki_valid_html_tags, '\s*,\s*'), '\|') + let line = substitute(line,'<\%(/\?\%(' + \.tags.'\)\%(\s\{-1}\S\{-}\)\{-}/\?>\)\@!', + \'\<', 'g') + let line = substitute(line,'\%(', + \'\>', 'g') return line endfunction "}}} @@ -263,9 +255,18 @@ function! s:trim(string) "{{{ return res endfunction "}}} -" toc_list is list of [level, header_text, header_id] -" ex: [[1, "Header", "toc1"], [2, "Header2", "toc2"], ...] function! s:get_html_toc(toc_list) "{{{ + " toc_list is list of [level, header_text, header_id] + " ex: [[1, "Header", "toc1"], [2, "Header2", "toc2"], ...] + function! s:close_list(toc, plevel, level) "{{{ + let plevel = a:plevel + while plevel > a:level + call add(a:toc, '') + let plevel -= 1 + endwhile + return plevel + endfunction "}}} + if empty(a:toc_list) return [] endif @@ -277,34 +278,47 @@ function! s:get_html_toc(toc_list) "{{{ if level > plevel call add(toc, '
    ') elseif level < plevel - call add(toc, '
') + let plevel = s:close_list(toc, plevel, level) endif - call add(toc, '
  • '.text.'
  • ') + + let toc_text = s:process_tags_remove_links(text) + let toc_text = s:process_tags_typefaces(toc_text) + call add(toc, '
  • '.toc_text.'
  • ') let plevel = level endfor - while level > 0 - call add(toc, '') - let level -= 1 - endwhile + call s:close_list(toc, level, 0) call add(toc, '') return toc endfunction "}}} -" insert placeholder's contents into dest. -function! s:process_placeholders(dest, placeholders, type, ins_content) "{{{ +" insert toc into dest. +function! s:process_toc(dest, placeholders, toc) "{{{ if !empty(a:placeholders) for [placeholder, row, idx] in a:placeholders let [type, param] = placeholder - if type == a:type - let ins_content = a:ins_content[:] + if type == 'toc' + let toc = a:toc[:] if !empty(param) - call insert(ins_content, '

    '.param.'

    ') + call insert(toc, '

    '.param.'

    ') endif - let shift = idx * len(ins_content) - call extend(a:dest, ins_content, row + shift) + let shift = idx * len(toc) + call extend(a:dest, toc, row + shift) + endif + endfor + endif +endfunction "}}} + +" get title. +function! s:process_title(placeholders, default_title) "{{{ + if !empty(a:placeholders) + for [placeholder, row, idx] in a:placeholders + let [type, param] = placeholder + if type == 'title' && !empty(param) + return param endif endfor endif + return a:default_title endfunction "}}} "}}} @@ -342,6 +356,70 @@ function! s:tag_pre(value) "{{{ return ''.s:mid(a:value, 3).'' endfunction "}}} +function! s:tag_internal_link(value) "{{{ + " Make This is a link + " from [[This is a link]] + " Make This is a link + " from [[link|This is a link]] + " Make This is a link + " from [[link][This is a link]] + " TODO: rename function -- it makes not only internal links. + " TODO: refactor it. + + function! s:linkify(src, caption, style) "{{{ + if a:style == '' + let style_str = '' + else + let style_str = ' style="'.a:style.'"' + endif + + if s:is_img_link(a:caption) + let link = ''. + \ '' + elseif vimwiki#is_non_wiki_link(a:src) + let link = ''.a:caption.'' + elseif s:is_img_link(a:src) + let link = ''.a:caption.'' + elseif vimwiki#is_link_to_dir(a:src) + if g:vimwiki_dir_link == '' + let link = ''.a:caption.'' + else + let link = ''.a:caption.'' + endif + else + let link = ''.a:caption.'' + endif + + return link + endfunction "}}} + + let value = s:mid(a:value, 2) + + let line = '' + if value =~ '|' + let link_parts = split(value, "|", 1) + else + let link_parts = split(value, "][", 1) + endif + + + if len(link_parts) > 1 + if len(link_parts) < 3 + let style = "" + else + let style = link_parts[2] + endif + + let line = s:linkify(link_parts[0], link_parts[1], style) + + else + let line = s:linkify(value, value, '') + endif + return line +endfunction "}}} + function! s:tag_external_link(value) "{{{ "" Make link desc "" from [link link desc] @@ -375,16 +453,39 @@ function! s:tag_external_link(value) "{{{ return line endfunction "}}} -function! s:tag_internal_link(value) "{{{ - " Make This is a link - " from [[This is a link]] - " Make This is a link - " from [[link|This is a link]] - " Make This is a link - " from [[link][This is a link]] - " TODO: rename function -- it makes not only internal links. - " TODO: refactor it. +function! s:tag_wikiword_link(value) "{{{ + " Make WikiWord from WikiWord + if a:value[0] == '!' + return a:value[1:] + elseif g:vimwiki_camel_case + let line = ''.a:value.'' + return line + else + return a:value + endif +endfunction "}}} + +function! s:tag_barebone_link(value) "{{{ + "" Make http://habamax.ru + "" from http://habamax.ru + if s:is_img_link(a:value) + let line = '' + else + let line = ''.a:value.'' + endif + return line +endfunction "}}} + +function! s:tag_no_wikiword_link(value) "{{{ + if a:value[0] == '!' + return a:value[1:] + else + return a:value + endif +endfunction "}}} + +function! s:tag_remove_internal_link(value) "{{{ let value = s:mid(a:value, 2) let line = '' @@ -400,53 +501,31 @@ function! s:tag_internal_link(value) "{{{ else let style = link_parts[2] endif - - if s:is_img_link(link_parts[1]) - let line = '' - elseif len(link_parts) < 3 - if s:is_non_wiki_link(link_parts[0]) - let line = ''.link_parts[1].'' - else - let line = ''.link_parts[1].'' - endif - elseif s:is_img_link(link_parts[0]) - let line = ''.
-            \ link_parts[1].'' - endif + let line = link_parts[1] else - if s:is_img_link(value) - let line = '' - elseif s:is_non_wiki_link(link_parts[0]) - let line = ''.value.'' - else - let line = ''.value.'' - endif + let line = value endif return line endfunction "}}} -function! s:tag_wikiword_link(value) "{{{ - " Make WikiWord from WikiWord - " if first symbol is ! then remove it and make no link. - if a:value[0] == '!' - return a:value[1:] - else - let line = ''.a:value.'' - return line - endif -endfunction "}}} - -function! s:tag_barebone_link(value) "{{{ - "" Make http://habamax.ru - "" from http://habamax.ru +function! s:tag_remove_external_link(value) "{{{ + let value = s:mid(a:value, 1) - if s:is_img_link(a:value) - let line = '' + let line = '' + if s:is_web_link(value) + let lnkElements = split(value) + let head = lnkElements[0] + let rest = join(lnkElements[1:]) + if rest=="" + let rest=head + endif + let line = rest + elseif s:is_img_link(value) + let line = '' else - let line = ''.a:value.'' + " [alskfj sfsf] shouldn't be a link. So return it as it was -- + " enclosed in [...] + let line = '['.value.']' endif return line endfunction "}}} @@ -478,13 +557,16 @@ function! s:make_tag(line, regexp, func) "{{{ return res_line endfunction "}}} -function! s:process_inline_tags(line) "{{{ +function! s:process_tags_remove_links(line) " {{{ let line = a:line - let line = s:make_tag(line, '\[\[.\{-}\]\]', 's:tag_internal_link') - let line = s:make_tag(line, '\[.\{-}\]', 's:tag_external_link') - let line = s:make_tag(line, g:vimwiki_rxWeblink, 's:tag_barebone_link') - let line = s:make_tag(line, '!\?'.g:vimwiki_rxWikiWord, - \ 's:tag_wikiword_link') + let line = s:make_tag(line, '\[\[.\{-}\]\]', 's:tag_remove_internal_link') + let line = s:make_tag(line, '\[.\{-}\]', 's:tag_remove_external_link') + return line +endfunction " }}} + +function! s:process_tags_typefaces(line) "{{{ + let line = a:line + let line = s:make_tag(line, g:vimwiki_rxNoWikiWord, 's:tag_no_wikiword_link') let line = s:make_tag(line, g:vimwiki_rxItalic, 's:tag_em') let line = s:make_tag(line, g:vimwiki_rxBold, 's:tag_strong') let line = s:make_tag(line, g:vimwiki_rxTodo, 's:tag_todo') @@ -496,12 +578,27 @@ function! s:process_inline_tags(line) "{{{ \ 's:tag_pre') return line endfunction " }}} + +function! s:process_tags_links(line) " {{{ + let line = a:line + let line = s:make_tag(line, '\[\[.\{-}\]\]', 's:tag_internal_link') + let line = s:make_tag(line, '\[.\{-}\]', 's:tag_external_link') + let line = s:make_tag(line, g:vimwiki_rxWeblink, 's:tag_barebone_link') + let line = s:make_tag(line, g:vimwiki_rxWikiWord, 's:tag_wikiword_link') + return line +endfunction " }}} + +function! s:process_inline_tags(line) "{{{ + let line = s:process_tags_links(a:line) + let line = s:process_tags_typefaces(line) + return line +endfunction " }}} "}}} " BLOCK TAGS {{{ function! s:close_tag_pre(pre, ldest) "{{{ - if a:pre - call insert(a:ldest, "") + if a:pre[0] + call insert(a:ldest, "") return 0 endif return a:pre @@ -524,16 +621,62 @@ function! s:close_tag_para(para, ldest) "{{{ endfunction "}}} function! s:close_tag_table(table, ldest) "{{{ - if len(a:table) - call insert(a:ldest, "") - return [] + " The first element of table list is a string which tells us if table should be centered. + " The rest elements are rows which are lists of columns: + " ['center', + " ['col1', 'col2', 'col3'], + " ['col1', 'col2', 'col3'], + " ['col1', 'col2', 'col3'] + " ] + let table = a:table + let ldest = a:ldest + if len(table) + if table[0] == 'center' + call add(ldest, "") + else + call add(ldest, "
    ") + endif + + " Empty lists are table separators. + " Search for the last empty list. All the above rows would be a table header. + " We should exclude the first element of the table list as it is a text tag + " that shows if table should be centered or not. + let head = 0 + for idx in range(len(table)-1, 1, -1) + if empty(table[idx]) + let head = idx + break + endif + endfor + if head > 0 + for row in table[1 : head-1] + if !empty(filter(row, '!empty(v:val)')) + call add(ldest, '') + call extend(ldest, map(row, '""')) + call add(ldest, '') + endif + endfor + for row in table[head+1 :] + call add(ldest, '') + call extend(ldest, map(row, '""')) + call add(ldest, '') + endfor + else + for row in table[1 :] + call add(ldest, '') + call extend(ldest, map(row, '""')) + call add(ldest, '') + endfor + endif + call add(ldest, "
    ".s:process_inline_tags(v:val)."
    ".s:process_inline_tags(v:val)."
    ".s:process_inline_tags(v:val)."
    ") + let table = [] endif - return a:table + return table endfunction "}}} function! s:close_tag_list(lists, ldest) "{{{ while len(a:lists) - let item = remove(a:lists, -1) + let item = remove(a:lists, 0) call insert(a:ldest, item[0]) endwhile endfunction! "}}} @@ -547,10 +690,11 @@ function! s:close_tag_def_list(deflist, ldest) "{{{ endfunction! "}}} function! s:process_tag_pre(line, pre) "{{{ + " pre is the list of [is_in_pre, indent_of_pre] let lines = [] let pre = a:pre let processed = 0 - if !pre && a:line =~ '{{{[^\(}}}\)]*\s*$' + if !pre[0] && a:line =~ '^\s*{{{[^\(}}}\)]*\s*$' let class = matchstr(a:line, '{{{\zs.*$') let class = substitute(class, '\s\+$', '', 'g') if class != "" @@ -558,15 +702,15 @@ function! s:process_tag_pre(line, pre) "{{{ else call add(lines, "
    ")
         endif
    -    let pre = 1
    +    let pre = [1, len(matchstr(a:line, '^\s*\ze{{{'))]
         let processed = 1
    -  elseif pre && a:line =~ '^}}}\s*$'
    -    let pre = 0
    +  elseif pre[0] && a:line =~ '^\s*}}}\s*$'
    +    let pre = [0, 0]
         call add(lines, "
    ") let processed = 1 - elseif pre + elseif pre[0] let processed = 1 - call add(lines, a:line) + call add(lines, substitute(a:line, '^\s\{'.pre[1].'}', '', '')) endif return [processed, lines, pre] endfunction "}}} @@ -575,7 +719,6 @@ function! s:process_tag_quote(line, quote) "{{{ let lines = [] let quote = a:quote let processed = 0 - " if a:line =~ '^\s\{4,}[^[:blank:]*#]' if a:line =~ '^\s\{4,}\S' if !quote call add(lines, "
    ") @@ -583,9 +726,6 @@ function! s:process_tag_quote(line, quote) "{{{ endif let processed = 1 call add(lines, substitute(a:line, '^\s*', '', '')) - elseif quote && a:line =~ '^\s*$' - let processed = 1 - call add(lines, a:line) elseif quote call add(lines, "
    ") let quote = 0 @@ -611,10 +751,15 @@ function! s:process_tag_list(line, lists) "{{{ return [st_tag, en_tag] endfunction "}}} - " Do not process line that starts from *bold* text as list item. - let pos = match(a:line, g:vimwiki_rxBold) - if pos != -1 && strpart(a:line, 0, pos) =~ '^\s*$' - return [0, []] + let in_list = (len(a:lists) > 0) + + " If it is not list yet then do not process line that starts from *bold* + " text. + if !in_list + let pos = match(a:line, g:vimwiki_rxBold) + if pos != -1 && strpart(a:line, 0, pos) =~ '^\s*$' + return [0, []] + endif endif let lines = [] @@ -637,7 +782,6 @@ function! s:process_tag_list(line, lists) "{{{ let lstRegExp = '' endif - let in_list = (len(a:lists) > 0) if lstSym != '' " To get proper indent level 'retab' the line -- change all tabs " to spaces*tabstop @@ -680,10 +824,7 @@ function! s:process_tag_list(line, lists) "{{{ endif let processed = 1 else - while len(a:lists) - let item = remove(a:lists, -1) - call add(lines, item[0]) - endwhile + call s:close_tag_list(a:lists, lines) endif return [processed, lines] endfunction "}}} @@ -750,6 +891,12 @@ function! s:process_tag_h(line, id) "{{{ let h_level = 1 endif if h_level > 0 + let a:id[h_level] += 1 + " reset higher level ids + for level in range(h_level+1, 6) + let a:id[level] = 0 + endfor + let centered = 0 if a:line =~ '^\s\+' let centered = 1 @@ -757,8 +904,14 @@ function! s:process_tag_h(line, id) "{{{ let line = s:trim(line) - let h_text = s:trim(strpart(line, h_level, len(line) - h_level * 2)) - let h_id = 'toc'.a:id + let h_number = '' + for l in range(1, h_level-1) + let h_number .= a:id[l].'.' + endfor + let h_number .= a:id[h_level] + + let h_id = 'toc_'.h_number + let h_part = '' let processed = 1 endif @@ -783,66 +947,56 @@ function! s:process_tag_hr(line) "{{{ endfunction "}}} function! s:process_tag_table(line, table) "{{{ - " XXX: This should be refactored!!! + function! s:table_empty_cell(value) "{{{ + if a:value =~ '^\s*$' + return ' ' + endif + return a:value + endfunction "}}} + + function! s:table_add_row(table, line) "{{{ + if empty(a:table) + if a:line =~ '^\s\+' + let row = ['center', []] + else + let row = ['normal', []] + endif + else + let row = [[]] + endif + return row + endfunction "}}} + let table = a:table let lines = [] let processed = 0 - if a:line =~ '^\s*|[-+]\+|\s*$' && len(table) - call add(table, []) + if a:line =~ '^\s*|[-+]\+|\s*$' + call extend(table, s:table_add_row(a:table, a:line)) let processed = 1 elseif a:line =~ '^\s*|.\+|\s*$' - if empty(table) - let table = [[]] - else - call add(table, []) - endif - let processed = 1 - - call extend(table[-1], split(a:line, '\s*|\s*')) - - elseif len(table) - call add(lines, "") + call extend(table, s:table_add_row(a:table, a:line)) - let head = 0 - for idx in range(len(table)) - if empty(table[idx]) - let head = idx - break - endif - endfor - if head > 0 - for row in table[: head-1] - call add(lines, '') - call extend(lines, map(row, '""')) - call add(lines, '') - endfor - for row in table[head+1 :] - call add(lines, '') - call extend(lines, map(row, '""')) - call add(lines, '') - endfor - else - for row in table - call add(lines, '') - call extend(lines, map(row, '""')) - call add(lines, '') - endfor - endif - call add(lines, "
    ".v:val."
    ".v:val."
    ".v:val."
    ") - let table = [] + let processed = 1 + let cells = split(a:line, '\s*|\s*', 1)[1: -2] + call map(cells, 's:table_empty_cell(v:val)') + call extend(table[-1], cells) + else + let table = s:close_tag_table(table, lines) endif return [processed, lines, table] endfunction "}}} "}}} +" }}} + " WIKI2HTML "{{{ function! s:parse_line(line, state) " {{{ let state = {} let state.para = a:state.para let state.quote = a:state.quote - let state.pre = a:state.pre + let state.pre = a:state.pre[:] let state.table = a:state.table[:] let state.lists = a:state.lists[:] let state.deflist = a:state.deflist @@ -856,6 +1010,23 @@ function! s:parse_line(line, state) " {{{ let processed = 0 + " nohtml -- placeholder + if !processed + if line =~ '^\s*%nohtml' + let processed = 1 + let state.placeholder = ['nohtml'] + endif + endif + + " title -- placeholder + if !processed + if line =~ '^\s*%title' + let processed = 1 + let param = matchstr(line, '^\s*%title\s\zs.*') + let state.placeholder = ['title', param] + endif + endif + " toc -- placeholder "{{{ if !processed if line =~ '^\s*%toc' @@ -869,9 +1040,10 @@ function! s:parse_line(line, state) " {{{ " pres "{{{ if !processed let [processed, lines, state.pre] = s:process_tag_pre(line, state.pre) - if processed && len(state.lists) - call s:close_tag_list(state.lists, lines) - endif + " pre is just fine to be in the list -- do not close list item here. + " if processed && len(state.lists) + " call s:close_tag_list(state.lists, lines) + " endif if processed && len(state.table) let state.table = s:close_tag_table(state.table, lines) endif @@ -894,7 +1066,7 @@ function! s:parse_line(line, state) " {{{ if processed && state.quote let state.quote = s:close_tag_quote(state.quote, lines) endif - if processed && state.pre + if processed && state.pre[0] let state.pre = s:close_tag_pre(state.pre, lines) endif if processed && len(state.table) @@ -922,17 +1094,23 @@ function! s:parse_line(line, state) " {{{ let state.pre = s:close_tag_pre(state.pre, res_lines) let state.quote = s:close_tag_quote(state.quote, res_lines) - let line = s:make_tag(line, g:vimwiki_rxTodo, 's:tag_todo') + let line = s:process_inline_tags(line) call add(res_lines, line) " gather information for table of contents call add(state.toc, [h_level, h_text, h_id]) - let state.toc_id += 1 endif endif "}}} + " tables "{{{ + if !processed + let [processed, lines, state.table] = s:process_tag_table(line, state.table) + call extend(res_lines, lines) + endif + "}}} + " quotes "{{{ if !processed let [processed, lines, state.quote] = s:process_tag_quote(line, state.quote) @@ -945,7 +1123,7 @@ function! s:parse_line(line, state) " {{{ if processed && len(state.table) let state.table = s:close_tag_table(state.table, lines) endif - if processed && state.pre + if processed && state.pre[0] let state.pre = s:close_tag_pre(state.pre, lines) endif if processed && state.para @@ -958,16 +1136,6 @@ function! s:parse_line(line, state) " {{{ endif "}}} - " tables "{{{ - if !processed - let [processed, lines, state.table] = s:process_tag_table(line, state.table) - - call map(lines, 's:process_inline_tags(v:val)') - - call extend(res_lines, lines) - endif - "}}} - " horizontal rules "{{{ if !processed let [processed, line] = s:process_tag_hr(line) @@ -999,7 +1167,7 @@ function! s:parse_line(line, state) " {{{ if processed && state.quote let state.quote = s:close_tag_quote(state.quote, res_lines) endif - if processed && state.pre + if processed && state.pre[0] let state.pre = s:close_tag_pre(state.pre, res_lines) endif if processed && len(state.table) @@ -1031,11 +1199,14 @@ function! vimwiki_html#Wiki2HTML(path, wikifile) "{{{ let wikifile = fnamemodify(a:wikifile, ":p") let subdir = vimwiki#subdir(VimwikiGet('path'), wikifile) + let lsource = s:remove_comments(readfile(wikifile)) + let ldest = [] + let path = expand(a:path).subdir call vimwiki#mkdir(path) - let lsource = s:remove_comments(readfile(wikifile)) - let ldest = s:get_html_header(wikifile, subdir, &fileencoding) + " nohtml placeholder -- to skip html generation. + let nohtml = 0 " for table of contents placeholders. let placeholders = [] @@ -1044,13 +1215,13 @@ function! vimwiki_html#Wiki2HTML(path, wikifile) "{{{ let state = {} let state.para = 0 let state.quote = 0 - let state.pre = 0 + let state.pre = [0, 0] " [in_pre, indent_pre] let state.table = [] let state.deflist = 0 let state.lists = [] let state.placeholder = [] let state.toc = [] - let state.toc_id = 1 + let state.toc_id = {1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0 } for line in lsource let oldquote = state.quote @@ -1059,40 +1230,48 @@ function! vimwiki_html#Wiki2HTML(path, wikifile) "{{{ " Hack: There could be a lot of empty strings before s:process_tag_quote " find out `quote` is over. So we should delete them all. Think of the way " to refactor it out. - if (oldquote != state.quote) && ldest[-1] =~ '^\s*$' + if oldquote != state.quote call s:remove_blank_lines(ldest) endif if !empty(state.placeholder) - call add(placeholders, [state.placeholder, len(ldest), len(placeholders)]) - let state.placeholder = [] + if state.placeholder[0] == 'nohtml' + let nohtml = 1 + break + else + call add(placeholders, [state.placeholder, len(ldest), len(placeholders)]) + let state.placeholder = [] + endif endif call extend(ldest, lines) endfor - let toc = s:get_html_toc(state.toc) - call s:process_placeholders(ldest, placeholders, 'toc', toc) + if !nohtml + let toc = s:get_html_toc(state.toc) + call s:process_toc(ldest, placeholders, toc) + call s:remove_blank_lines(ldest) + + "" process end of file + "" close opened tags if any + let lines = [] + call s:close_tag_quote(state.quote, lines) + call s:close_tag_para(state.para, lines) + call s:close_tag_pre(state.pre, lines) + call s:close_tag_list(state.lists, lines) + call s:close_tag_def_list(state.deflist, lines) + call s:close_tag_table(state.table, lines) + call extend(ldest, lines) - call s:remove_blank_lines(ldest) + let title = s:process_title(placeholders, fnamemodify(a:wikifile, ":t:r")) + call extend(ldest, s:get_html_header(title, subdir, &fileencoding), 0) + call extend(ldest, s:get_html_footer()) - "" process end of file - "" close opened tags if any - let lines = [] - call s:close_tag_quote(state.quote, lines) - call s:close_tag_para(state.para, lines) - call s:close_tag_pre(state.pre, lines) - call s:close_tag_list(state.lists, lines) - call s:close_tag_def_list(state.deflist, lines) - call s:close_tag_table(state.table, lines) - call extend(ldest, lines) - - call extend(ldest, s:get_html_footer()) - - "" make html file. - let wwFileNameOnly = fnamemodify(wikifile, ":t:r") - call writefile(ldest, path.wwFileNameOnly.'.html') + "" make html file. + let wwFileNameOnly = fnamemodify(wikifile, ":t:r") + call writefile(ldest, path.wwFileNameOnly.'.html') + endif endfunction "}}} function! vimwiki_html#WikiAll2HTML(path) "{{{ @@ -1102,9 +1281,12 @@ function! vimwiki_html#WikiAll2HTML(path) "{{{ endif echomsg 'Saving vimwiki files...' + let save_eventignore = &eventignore + let &eventignore = "all" let cur_buf = bufname('%') bufdo call s:save_vimwiki_buffer() exe 'buffer '.cur_buf + let &eventignore = save_eventignore let path = expand(a:path) call vimwiki#mkdir(path) diff --git a/autoload/vimwiki_lst.vim b/autoload/vimwiki_lst.vim index fd6a8af..fcdfe36 100644 --- a/autoload/vimwiki_lst.vim +++ b/autoload/vimwiki_lst.vim @@ -1,3 +1,4 @@ +" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79 " Vimwiki autoload plugin file " Todo lists related stuff here. " Author: Maxim Kim @@ -39,7 +40,6 @@ endfunction "}}} " Get regexp of the list item with checkbox. function! s:rx_cb_list_item() "{{{ - " return s:rx_list_item().'\s*\zs\[.\?\]' return s:rx_list_item().'\s*\zs\[.\?\]' endfunction "}}} @@ -181,9 +181,7 @@ function! s:get_sibling_items(lnum) "{{{ let lnum = a:lnum let ind = s:get_level(lnum) - while s:get_level(lnum) >= ind && - \ lnum != 0 - + while lnum != 0 && s:get_level(lnum) >= ind if s:get_level(lnum) == ind && s:is_cb_list_item(lnum) call add(result, lnum) endif @@ -191,9 +189,7 @@ function! s:get_sibling_items(lnum) "{{{ endwhile let lnum = s:prev_list_item(a:lnum) - while s:get_level(lnum) >= ind && - \ lnum != 0 - + while lnum != 0 && s:get_level(lnum) >= ind if s:get_level(lnum) == ind && s:is_cb_list_item(lnum) call add(result, lnum) endif @@ -226,7 +222,7 @@ function! s:create_cb_list_item(lnum) "{{{ let m = matchstr(line, s:rx_list_item()) if m != '' let li_content = substitute(strpart(line, len(m)), '^\s*', '', '') - let line = m.'[ ] '.li_content + let line = substitute(m, '\s*$', ' ', '').'[ ] '.li_content call setline(a:lnum, line) endif endfunction "}}} @@ -237,9 +233,9 @@ function! s:all_siblings_checked(lnum) "{{{ let cnt = 0 let siblings = s:get_sibling_items(a:lnum) for lnum in siblings - let cnt += s:get_state(lnum)/100.0 + let cnt += s:get_state(lnum) endfor - let result = (cnt*100.0)/len(siblings) + let result = cnt/len(siblings) return result endfunction "}}} @@ -320,7 +316,7 @@ function! vimwiki_lst#ToggleListItem(line1, line2) "{{{ endfunction "}}} -function! vimwiki_lst#insertCR() "{{{ +function! vimwiki_lst#kbd_cr() "{{{ " This function is heavily relies on proper 'set comments' option. let cr = "\" if getline('.') =~ s:rx_cb_list_item() @@ -329,7 +325,7 @@ function! vimwiki_lst#insertCR() "{{{ return cr endfunction "}}} -function! vimwiki_lst#insertOo(cmd) "{{{ +function! vimwiki_lst#kbd_oO(cmd) "{{{ " cmd should be 'o' or 'O' let beg_lnum = foldclosed('.') @@ -342,11 +338,13 @@ function! vimwiki_lst#insertOo(cmd) "{{{ let lnum = line('.') endif + " let line = substitute(m, '\s*$', ' ', '').'[ ] '.li_content + let m = matchstr(line, s:rx_list_item()) let res = '' if line =~ s:rx_cb_list_item() - let res = matchstr(line, s:rx_list_item()).'[ ] ' + let res = substitute(m, '\s*$', ' ', '').'[ ] ' elseif line =~ s:rx_list_item() - let res = matchstr(line, s:rx_list_item()) + let res = substitute(m, '\s*$', ' ', '') elseif &autoindent || &smartindent let res = matchstr(line, '^\s*') endif diff --git a/autoload/vimwiki_tbl.vim b/autoload/vimwiki_tbl.vim index fb174ed..251c0ae 100644 --- a/autoload/vimwiki_tbl.vim +++ b/autoload/vimwiki_tbl.vim @@ -1,3 +1,4 @@ +" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79 " Vimwiki autoload plugin file " Desc: Tables " | Easily | manageable | text | tables | ! | @@ -18,7 +19,25 @@ let s:textwidth = &tw " Misc functions {{{ function! s:wide_len(str) "{{{ - return strlen(substitute(a:str, '.', 'x', 'g')) + " vim73 has new function that gives correct string width. + if exists("*strdisplaywidth") + return strdisplaywidth(a:str) + endif + + " get str display width in vim ver < 7.2 + if !g:vimwiki_CJK_length + let ret = strlen(substitute(a:str, '.', 'x', 'g')) + else + let savemodified = &modified + let save_cursor = getpos('.') + exe "norm! o\" + call setline(line("."), a:str) + let ret = virtcol("$") - 1 + d + call setpos('.', save_cursor) + let &modified = savemodified + endif + return ret endfunction "}}} function! s:is_table(line) "{{{ @@ -26,14 +45,31 @@ function! s:is_table(line) "{{{ endfunction "}}} function! s:is_separator(line) "{{{ - return a:line =~ '^\s*|\s*-\+' + return a:line =~ '^\s*[|+]\s*--[-|+]\+' endfunction "}}} function! s:is_last_column(lnum, cnum) "{{{ return strpart(getline(a:lnum), a:cnum - 1) =~ '^[^|]*|\s*$' endfunction "}}} -function! s:count_separators(lnum) "{{{ +function! s:is_first_column(lnum, cnum) "{{{ + let line = strpart(getline(a:lnum), 0, a:cnum - 1) + return line =~ '^\s*|[^|]*$' || line =~ '^\s*$' +endfunction "}}} + +function! s:count_separators_up(lnum) "{{{ + let lnum = a:lnum - 1 + while lnum > 1 + if !s:is_separator(getline(lnum)) + break + endif + let lnum -= 1 + endwhile + + return (a:lnum-lnum) +endfunction "}}} + +function! s:count_separators_down(lnum) "{{{ let lnum = a:lnum + 1 while lnum < line('$') if !s:is_separator(getline(lnum)) @@ -78,19 +114,38 @@ function! s:create_row_sep(cols) "{{{ endfunction "}}} function! s:get_values(line) "{{{ - let cells = [] - let cnt = 0 - let idx = 0 - while idx != -1 && idx < strlen(a:line) - 1 - let cell = matchstr(a:line, '|\zs[^|]\+\ze|', idx) - let cell = substitute(cell, '^\s*\(.\{-}\)\s*$', '\1', 'g') - call add(cells, [cnt, cell]) - let cnt += 1 - let idx = matchend(a:line, '|\zs[^|]\+\ze|', idx) - endwhile - return cells + return split(a:line, '\s*|\s*', 1)[1:-2] +endfunction "}}} + +function! s:col_count(lnum) "{{{ + let line = getline(a:lnum) + if !s:is_separator(line) + return len(split(line, '\s*|\s*', 1)[1:-2]) + else + return len(split(line, '-+-', 1)) + endif endfunction "}}} +function! s:get_indent(lnum) "{{{ + if !s:is_table(getline(a:lnum)) + return + endif + + let indent = 0 + + let lnum = a:lnum - 1 + while lnum > 1 + let line = getline(lnum) + if !s:is_table(line) + let indent = indent(lnum+1) + break + endif + let lnum -= 1 + endwhile + + return indent +endfunction " }}} + function! s:get_rows(lnum) "{{{ if !s:is_table(getline(a:lnum)) return @@ -131,29 +186,57 @@ function! s:get_cell_max_lens(lnum) "{{{ if s:is_separator(row) continue endif - for [idx, cell] in s:get_values(row) + let cells = s:get_values(row) + for idx in range(len(cells)) + let value = cells[idx] if has_key(max_lens, idx) - let max_lens[idx] = max([s:wide_len(cell), max_lens[idx]]) + let max_lens[idx] = max([s:wide_len(value), max_lens[idx]]) else - let max_lens[idx] = s:wide_len(cell) + let max_lens[idx] = s:wide_len(value) endif endfor endfor return max_lens endfunction "}}} -function! s:get_aligned_rows(lnum, max_lens) "{{{ +function! s:get_aligned_rows(lnum, col1, col2) "{{{ + let max_lens = s:get_cell_max_lens(a:lnum) let rows = [] for [lnum, row] in s:get_rows(a:lnum) if s:is_separator(row) - let new_row = s:fmt_sep(a:max_lens) + let new_row = s:fmt_sep(max_lens, a:col1, a:col2) else - let new_row = s:fmt_row(row, a:max_lens) + let new_row = s:fmt_row(row, max_lens, a:col1, a:col2) endif call add(rows, [lnum, new_row]) endfor return rows endfunction "}}} + +" Number of the current column. Starts from 0. +function! s:cur_column() "{{{ + let line = getline('.') + if !s:is_table(line) + return -1 + endif + if s:is_separator(line) + let sep = '[+|]' + else + let sep = '|' + endif + + let curs_pos = col('.') + let mpos = match(line, '|', 0) + let col = -1 + while mpos < curs_pos && mpos != -1 + let mpos = match(line, sep, mpos+1) + if mpos != -1 + let col += 1 + endif + endwhile + return col +endfunction "}}} + " }}} " Format functions {{{ @@ -169,14 +252,20 @@ function! s:fmt_cell(cell, max_len) "{{{ return cell endfunction "}}} -function! s:fmt_row(line, max_lens) "{{{ +function! s:fmt_row(line, max_lens, col1, col2) "{{{ let new_line = '|' - let values = s:get_values(a:line) - for [idx, cell] in values - let new_line .= s:fmt_cell(cell, a:max_lens[idx]).'|' + let cells = s:get_values(a:line) + for idx in range(len(cells)) + if idx == a:col1 + let idx = a:col2 + elseif idx == a:col2 + let idx = a:col1 + endif + let value = cells[idx] + let new_line .= s:fmt_cell(value, a:max_lens[idx]).'|' endfor - let idx = len(values) + let idx = len(cells) while idx < len(a:max_lens) let new_line .= s:fmt_cell('', a:max_lens[idx]).'|' let idx += 1 @@ -192,9 +281,14 @@ function! s:fmt_cell_sep(max_len) "{{{ endif endfunction "}}} -function! s:fmt_sep(max_lens) "{{{ +function! s:fmt_sep(max_lens, col1, col2) "{{{ let sep = '|' for idx in range(len(a:max_lens)) + if idx == a:col1 + let idx = a:col2 + elseif idx == a:col2 + let idx = a:col1 + endif let sep .= s:fmt_cell_sep(a:max_lens[idx]).'+' endfor let sep = substitute(sep, '+$', '|', '') @@ -207,7 +301,7 @@ function! s:kbd_create_new_row(cols, goto_first) "{{{ let cmd = "\o".s:create_empty_row(a:cols) let cmd .= "\:call vimwiki_tbl#format(line('.'))\" if a:goto_first - let cmd .= "0f|T|a" + let cmd .= "\0:call search('|', 'c', line('.'))\la" else let cmd .= "0".(col('.')-1)."lT|a" endif @@ -219,16 +313,27 @@ function! s:kbd_goto_next_row() "{{{ return cmd endfunction "}}} +function! s:kbd_goto_prev_row() "{{{ + let cmd = "\jt|T|a" + return cmd +endfunction "}}} + function! s:kbd_goto_next_col(last) "{{{ - if col('.') == 1 - let cmd = "\la" + if a:last + let seps = s:count_separators_down(line('.')) + let cmd = "\".seps."j0:call search('|', 'c', line('.'))\la" else - if a:last - let seps = s:count_separators(line('.')) - let cmd = "\".seps."j0f|F|la" - else - let cmd = "\f|la" - endif + let cmd = "\:call search('|', 'c', line('.'))\la" + endif + return cmd +endfunction "}}} + +function! s:kbd_goto_prev_col(first) "{{{ + if a:first + let seps = s:count_separators_up(line('.')) + let cmd = "\".seps."k$:call search('|', 'b', line('.'))\la" + else + let cmd = "\2F|la" endif return cmd endfunction "}}} @@ -264,15 +369,37 @@ function! vimwiki_tbl#kbd_tab() "{{{ return s:kbd_goto_next_col(last) endfunction "}}} -function! vimwiki_tbl#format(lnum) "{{{ +function! vimwiki_tbl#kbd_shift_tab() "{{{ + let lnum = line('.') + if !s:is_table(getline(lnum)) + return "\" + endif + + let first = s:is_first_column(lnum, col('.')) + if first && !s:is_table(getline(lnum-1)) + return "" + endif + return s:kbd_goto_prev_col(first) +endfunction "}}} + +function! vimwiki_tbl#format(lnum, ...) "{{{ let line = getline(a:lnum) if !s:is_table(line) return endif - let max_lens = s:get_cell_max_lens(a:lnum) + if a:0 == 2 + let col1 = a:1 + let col2 = a:2 + else + let col1 = 0 + let col2 = 0 + endif + + let indent = s:get_indent(a:lnum) - for [lnum, row] in s:get_aligned_rows(a:lnum, max_lens) + for [lnum, row] in s:get_aligned_rows(a:lnum, col1, col2) + let row = repeat(' ', indent).row call setline(lnum, row) endfor @@ -332,4 +459,52 @@ function! vimwiki_tbl#reset_tw(lnum) "{{{ let &tw = 0 endfunction "}}} +" TODO: move_column_left and move_column_right are good candidates to be +" refactored. +function! vimwiki_tbl#move_column_left() "{{{ + if !s:is_table(getline('.')) + return + endif + + let cur_col = s:cur_column() + if cur_col == -1 + return + endif + + if cur_col > 0 + call vimwiki_tbl#format(line('.'), cur_col-1, cur_col) + call cursor(line('.'), 1) + if !s:is_separator(getline('.')) + call search('\%(|[^|]\+\)\{'.(cur_col-1).'}| .', 'eW') + else + call search('|\%([^+]\++\)\{'.(cur_col-1).'}--', 'eW') + endif + endif +endfunction "}}} + +function! vimwiki_tbl#move_column_right() "{{{ + if !s:is_table(getline('.')) + return + endif + + let cur_col = s:cur_column() + if cur_col == -1 + return + endif + + if cur_col < s:col_count(line('.'))-1 + call vimwiki_tbl#format(line('.'), cur_col, cur_col+1) + call cursor(line('.'), 1) + if !s:is_separator(getline('.')) + call search('\%(|[^|]\+\)\{'.(cur_col+1).'}| .', 'eW') + else + call search('|\%([^+]\++\)\{'.(cur_col+1).'}--', 'eW') + endif + endif +endfunction "}}} + +function! vimwiki_tbl#get_rows(lnum) "{{{ + return s:get_rows(a:lnum) +endfunction "}}} + "}}} diff --git a/doc/tags b/doc/tags index 9d1c2d0..32d2aa1 100644 --- a/doc/tags +++ b/doc/tags @@ -59,22 +59,28 @@ :VWS vimwiki.txt /*:VWS* :Vimwiki2HTML vimwiki.txt /*:Vimwiki2HTML* :VimwikiAll2HTML vimwiki.txt /*:VimwikiAll2HTML* -:VimwikiDeleteWord vimwiki.txt /*:VimwikiDeleteWord* -:VimwikiFollowWord vimwiki.txt /*:VimwikiFollowWord* -:VimwikiGoBackWord vimwiki.txt /*:VimwikiGoBackWord* -:VimwikiGoHome vimwiki.txt /*:VimwikiGoHome* +:VimwikiDeleteLink vimwiki.txt /*:VimwikiDeleteLink* +:VimwikiDiaryNextDay vimwiki.txt /*:VimwikiDiaryNextDay* +:VimwikiDiaryPrevDay vimwiki.txt /*:VimwikiDiaryPrevDay* +:VimwikiFollowLink vimwiki.txt /*:VimwikiFollowLink* +:VimwikiGenerateLinks vimwiki.txt /*:VimwikiGenerateLinks* +:VimwikiGoBackLink vimwiki.txt /*:VimwikiGoBackLink* +:VimwikiGoto vimwiki.txt /*:VimwikiGoto* +:VimwikiIndex vimwiki.txt /*:VimwikiIndex* :VimwikiMakeDiaryNote vimwiki.txt /*:VimwikiMakeDiaryNote* -:VimwikiNextWord vimwiki.txt /*:VimwikiNextWord* -:VimwikiPrevWord vimwiki.txt /*:VimwikiPrevWord* -:VimwikiRenameWord vimwiki.txt /*:VimwikiRenameWord* +:VimwikiNextLink vimwiki.txt /*:VimwikiNextLink* +:VimwikiPrevLink vimwiki.txt /*:VimwikiPrevLink* +:VimwikiRenameLink vimwiki.txt /*:VimwikiRenameLink* :VimwikiSearch vimwiki.txt /*:VimwikiSearch* -:VimwikiSplitWord vimwiki.txt /*:VimwikiSplitWord* -:VimwikiTabGoHome vimwiki.txt /*:VimwikiTabGoHome* +:VimwikiSplitLink vimwiki.txt /*:VimwikiSplitLink* +:VimwikiTabIndex vimwiki.txt /*:VimwikiTabIndex* :VimwikiTabMakeDiaryNote vimwiki.txt /*:VimwikiTabMakeDiaryNote* :VimwikiTable vimwiki.txt /*:VimwikiTable* +:VimwikiTableMoveColumnLeft vimwiki.txt /*:VimwikiTableMoveColumnLeft* +:VimwikiTableMoveColumnRight vimwiki.txt /*:VimwikiTableMoveColumnRight* :VimwikiToggleListItem vimwiki.txt /*:VimwikiToggleListItem* :VimwikiUISelect vimwiki.txt /*:VimwikiUISelect* -:VimwikiVSplitWord vimwiki.txt /*:VimwikiVSplitWord* +:VimwikiVSplitLink vimwiki.txt /*:VimwikiVSplitLink* ConqueTerm conque_term.txt /*ConqueTerm* ExtractSnips() snipMate.txt /*ExtractSnips()* ExtractSnipsFile() snipMate.txt /*ExtractSnipsFile()* @@ -128,16 +134,22 @@ conque_term-todo conque_term.txt /*conque_term-todo* conque_term-usage conque_term.txt /*conque_term-usage* g:snippets_dir snipMate.txt /*g:snippets_dir* g:snips_author snipMate.txt /*g:snips_author* +g:vimwiki_CJK_length vimwiki.txt /*g:vimwiki_CJK_length* g:vimwiki_auto_checkbox vimwiki.txt /*g:vimwiki_auto_checkbox* g:vimwiki_badsyms vimwiki.txt /*g:vimwiki_badsyms* g:vimwiki_browsers vimwiki.txt /*g:vimwiki_browsers* g:vimwiki_camel_case vimwiki.txt /*g:vimwiki_camel_case* +g:vimwiki_conceallevel vimwiki.txt /*g:vimwiki_conceallevel* +g:vimwiki_dir_link vimwiki.txt /*g:vimwiki_dir_link* +g:vimwiki_file_exts vimwiki.txt /*g:vimwiki_file_exts* g:vimwiki_fold_lists vimwiki.txt /*g:vimwiki_fold_lists* g:vimwiki_fold_trailing_empty_lines vimwiki.txt /*g:vimwiki_fold_trailing_empty_lines* g:vimwiki_folding vimwiki.txt /*g:vimwiki_folding* g:vimwiki_global_ext vimwiki.txt /*g:vimwiki_global_ext* g:vimwiki_hl_cb_checked vimwiki.txt /*g:vimwiki_hl_cb_checked* g:vimwiki_hl_headers vimwiki.txt /*g:vimwiki_hl_headers* +g:vimwiki_html_header_numbering vimwiki.txt /*g:vimwiki_html_header_numbering* +g:vimwiki_html_header_numbering_sym vimwiki.txt /*g:vimwiki_html_header_numbering_sym* g:vimwiki_list vimwiki.txt /*g:vimwiki_list* g:vimwiki_list_ignore_newline vimwiki.txt /*g:vimwiki_list_ignore_newline* g:vimwiki_listsyms vimwiki.txt /*g:vimwiki_listsyms* @@ -148,6 +160,7 @@ g:vimwiki_table_auto_fmt vimwiki.txt /*g:vimwiki_table_auto_fmt* g:vimwiki_upper vimwiki.txt /*g:vimwiki_upper* g:vimwiki_use_calendar vimwiki.txt /*g:vimwiki_use_calendar* g:vimwiki_use_mouse vimwiki.txt /*g:vimwiki_use_mouse* +g:vimwiki_valid_html_tags vimwiki.txt /*g:vimwiki_valid_html_tags* g:vimwiki_w32_dir_enc vimwiki.txt /*g:vimwiki_w32_dir_enc* i_CTRL-R_ snipMate.txt /*i_CTRL-R_* list-snippets snipMate.txt /*list-snippets* @@ -191,11 +204,11 @@ taglist-todo taglist.txt /*taglist-todo* taglist-using taglist.txt /*taglist-using* taglist.txt taglist.txt /*taglist.txt* vimwiki vimwiki.txt /*vimwiki* -vimwiki-author vimwiki.txt /*vimwiki-author* vimwiki-calendar vimwiki.txt /*vimwiki-calendar* vimwiki-changelog vimwiki.txt /*vimwiki-changelog* vimwiki-commands vimwiki.txt /*vimwiki-commands* vimwiki-contents vimwiki.txt /*vimwiki-contents* +vimwiki-developers vimwiki.txt /*vimwiki-developers* vimwiki-diary vimwiki.txt /*vimwiki-diary* vimwiki-folding vimwiki.txt /*vimwiki-folding* vimwiki-global-commands vimwiki.txt /*vimwiki-global-commands* @@ -206,6 +219,7 @@ vimwiki-local-commands vimwiki.txt /*vimwiki-local-commands* vimwiki-local-mappings vimwiki.txt /*vimwiki-local-mappings* vimwiki-mappings vimwiki.txt /*vimwiki-mappings* vimwiki-multiple-wikies vimwiki.txt /*vimwiki-multiple-wikies* +vimwiki-nohtml vimwiki.txt /*vimwiki-nohtml* vimwiki-option-auto_export vimwiki.txt /*vimwiki-option-auto_export* vimwiki-option-css_name vimwiki.txt /*vimwiki-option-css_name* vimwiki-option-diary_header vimwiki.txt /*vimwiki-option-diary_header* @@ -213,7 +227,6 @@ vimwiki-option-diary_index vimwiki.txt /*vimwiki-option-diary_index* vimwiki-option-diary_link_count vimwiki.txt /*vimwiki-option-diary_link_count* vimwiki-option-diary_rel_path vimwiki.txt /*vimwiki-option-diary_rel_path* vimwiki-option-ext vimwiki.txt /*vimwiki-option-ext* -vimwiki-option-gohome vimwiki.txt /*vimwiki-option-gohome* vimwiki-option-html_footer vimwiki.txt /*vimwiki-option-html_footer* vimwiki-option-html_header vimwiki.txt /*vimwiki-option-html_header* vimwiki-option-index vimwiki.txt /*vimwiki-option-index* @@ -240,13 +253,18 @@ vimwiki-table-of-contents vimwiki.txt /*vimwiki-table-of-contents* vimwiki-tables vimwiki.txt /*vimwiki-tables* vimwiki-temporary-wiki vimwiki.txt /*vimwiki-temporary-wiki* vimwiki-text-objects vimwiki.txt /*vimwiki-text-objects* +vimwiki-title vimwiki.txt /*vimwiki-title* vimwiki-toc vimwiki.txt /*vimwiki-toc* vimwiki-todo-lists vimwiki.txt /*vimwiki-todo-lists* vimwiki.txt vimwiki.txt /*vimwiki.txt* vimwiki_- vimwiki.txt /*vimwiki_-* +vimwiki_ vimwiki.txt /*vimwiki_* +vimwiki_ vimwiki.txt /*vimwiki_* vimwiki_ vimwiki.txt /*vimwiki_* vimwiki_ vimwiki.txt /*vimwiki_* +vimwiki_ vimwiki.txt /*vimwiki_* vimwiki_ vimwiki.txt /*vimwiki_* +vimwiki_ vimwiki.txt /*vimwiki_* vimwiki_ vimwiki.txt /*vimwiki_* vimwiki_wd vimwiki.txt /*vimwiki_wd* vimwiki_wr vimwiki.txt /*vimwiki_wr* @@ -257,6 +275,7 @@ vimwiki_= vimwiki.txt /*vimwiki_=* vimwiki_gqq vimwiki.txt /*vimwiki_gqq* vimwiki_gww vimwiki.txt /*vimwiki_gww* vimwiki_i_ vimwiki.txt /*vimwiki_i_* +vimwiki_i_ vimwiki.txt /*vimwiki_i_* vimwiki_i_ vimwiki.txt /*vimwiki_i_* viwmiki-global-options vimwiki.txt /*viwmiki-global-options* viwmiki-local-options vimwiki.txt /*viwmiki-local-options* diff --git a/doc/tags-cn b/doc/tags-cn index 24df40e..4c4d0d2 100644 --- a/doc/tags-cn +++ b/doc/tags-cn @@ -1821,9 +1821,31 @@ $VIMRUNTIME starting.cnx /*$VIMRUNTIME* :TOhtml syntax.cnx /*:TOhtml* :Texplore pi_netrw.cnx /*:Texplore* :UseVimball pi_vimball.cnx /*:UseVimball* +:VWS vimwiki.cnx /*:VWS* :Vexplore pi_netrw.cnx /*:Vexplore* :VimballList pi_vimball.cnx /*:VimballList* :Vimuntar pi_tar.cnx /*:Vimuntar* +:Vimwiki2HTML vimwiki.cnx /*:Vimwiki2HTML* +:VimwikiAll2HTML vimwiki.cnx /*:VimwikiAll2HTML* +:VimwikiDeleteWord vimwiki.cnx /*:VimwikiDeleteWord* +:VimwikiFollowWord vimwiki.cnx /*:VimwikiFollowWord* +:VimwikiGenerateLinks vimwiki.cnx /*:VimwikiGenerateLinks* +:VimwikiGoBackWord vimwiki.cnx /*:VimwikiGoBackWord* +:VimwikiGoHome vimwiki.cnx /*:VimwikiGoHome* +:VimwikiMakeDiaryNote vimwiki.cnx /*:VimwikiMakeDiaryNote* +:VimwikiNextWord vimwiki.cnx /*:VimwikiNextWord* +:VimwikiPrevWord vimwiki.cnx /*:VimwikiPrevWord* +:VimwikiRenameWord vimwiki.cnx /*:VimwikiRenameWord* +:VimwikiSearch vimwiki.cnx /*:VimwikiSearch* +:VimwikiSplitWord vimwiki.cnx /*:VimwikiSplitWord* +:VimwikiTabGoHome vimwiki.cnx /*:VimwikiTabGoHome* +:VimwikiTabMakeDiaryNote vimwiki.cnx /*:VimwikiTabMakeDiaryNote* +:VimwikiTable vimwiki.cnx /*:VimwikiTable* +:VimwikiTableMoveColumnLeft vimwiki.cnx /*:VimwikiTableMoveColumnLeft* +:VimwikiTableMoveColumnRight vimwiki.cnx /*:VimwikiTableMoveColumnRight* +:VimwikiToggleListItem vimwiki.cnx /*:VimwikiToggleListItem* +:VimwikiUISelect vimwiki.cnx /*:VimwikiUISelect* +:VimwikiVSplitWord vimwiki.cnx /*:VimwikiVSplitWord* :X editing.cnx /*:X* :XMLent insert.cnx /*:XMLent* :XMLns insert.cnx /*:XMLns* @@ -4464,6 +4486,7 @@ VimLeave autocmd.cnx /*VimLeave* VimLeavePre autocmd.cnx /*VimLeavePre* VimResized autocmd.cnx /*VimResized* Vimball-copyright pi_vimball.cnx /*Vimball-copyright* +VimwikiWeblinkHandler vimwiki.cnx /*VimwikiWeblinkHandler* Virtual-Replace-mode insert.cnx /*Virtual-Replace-mode* VisVim if_ole.cnx /*VisVim* Visual visual.cnx /*Visual* @@ -5822,6 +5845,31 @@ g:vimsyn_folding syntax.cnx /*g:vimsyn_folding* g:vimsyn_maxlines syntax.cnx /*g:vimsyn_maxlines* g:vimsyn_minlines syntax.cnx /*g:vimsyn_minlines* g:vimsyn_noerror syntax.cnx /*g:vimsyn_noerror* +g:vimwiki_CJK_length vimwiki.cnx /*g:vimwiki_CJK_length* +g:vimwiki_auto_checkbox vimwiki.cnx /*g:vimwiki_auto_checkbox* +g:vimwiki_badsyms vimwiki.cnx /*g:vimwiki_badsyms* +g:vimwiki_browsers vimwiki.cnx /*g:vimwiki_browsers* +g:vimwiki_camel_case vimwiki.cnx /*g:vimwiki_camel_case* +g:vimwiki_dir_link vimwiki.cnx /*g:vimwiki_dir_link* +g:vimwiki_fold_lists vimwiki.cnx /*g:vimwiki_fold_lists* +g:vimwiki_fold_trailing_empty_lines vimwiki.cnx /*g:vimwiki_fold_trailing_empty_lines* +g:vimwiki_folding vimwiki.cnx /*g:vimwiki_folding* +g:vimwiki_global_ext vimwiki.cnx /*g:vimwiki_global_ext* +g:vimwiki_hl_cb_checked vimwiki.cnx /*g:vimwiki_hl_cb_checked* +g:vimwiki_hl_headers vimwiki.cnx /*g:vimwiki_hl_headers* +g:vimwiki_html_header_numbering vimwiki.cnx /*g:vimwiki_html_header_numbering* +g:vimwiki_html_header_numbering_sym vimwiki.cnx /*g:vimwiki_html_header_numbering_sym* +g:vimwiki_list vimwiki.cnx /*g:vimwiki_list* +g:vimwiki_list_ignore_newline vimwiki.cnx /*g:vimwiki_list_ignore_newline* +g:vimwiki_listsyms vimwiki.cnx /*g:vimwiki_listsyms* +g:vimwiki_lower vimwiki.cnx /*g:vimwiki_lower* +g:vimwiki_menu vimwiki.cnx /*g:vimwiki_menu* +g:vimwiki_stripsym vimwiki.cnx /*g:vimwiki_stripsym* +g:vimwiki_table_auto_fmt vimwiki.cnx /*g:vimwiki_table_auto_fmt* +g:vimwiki_upper vimwiki.cnx /*g:vimwiki_upper* +g:vimwiki_use_calendar vimwiki.cnx /*g:vimwiki_use_calendar* +g:vimwiki_use_mouse vimwiki.cnx /*g:vimwiki_use_mouse* +g:vimwiki_w32_dir_enc vimwiki.cnx /*g:vimwiki_w32_dir_enc* g:zip_nomax pi_zip.cnx /*g:zip_nomax* g:zip_shq pi_zip.cnx /*g:zip_shq* g:zip_unzipcmd pi_zip.cnx /*g:zip_unzipcmd* @@ -8276,6 +8324,78 @@ vimrc-intro usr_05.cnx /*vimrc-intro* vimrc-option-example starting.cnx /*vimrc-option-example* vimrc_example.vim usr_05.cnx /*vimrc_example.vim* vimtutor usr_01.cnx /*vimtutor* +vimwiki vimwiki.cnx /*vimwiki* +vimwiki-calendar vimwiki.cnx /*vimwiki-calendar* +vimwiki-changelog vimwiki.cnx /*vimwiki-changelog* +vimwiki-commands vimwiki.cnx /*vimwiki-commands* +vimwiki-contents vimwiki.cnx /*vimwiki-contents* +vimwiki-developers vimwiki.cnx /*vimwiki-developers* +vimwiki-diary vimwiki.cnx /*vimwiki-diary* +vimwiki-folding vimwiki.cnx /*vimwiki-folding* +vimwiki-global-commands vimwiki.cnx /*vimwiki-global-commands* +vimwiki-global-mappings vimwiki.cnx /*vimwiki-global-mappings* +vimwiki-help vimwiki.cnx /*vimwiki-help* +vimwiki-license vimwiki.cnx /*vimwiki-license* +vimwiki-local-commands vimwiki.cnx /*vimwiki-local-commands* +vimwiki-local-mappings vimwiki.cnx /*vimwiki-local-mappings* +vimwiki-mappings vimwiki.cnx /*vimwiki-mappings* +vimwiki-multiple-wikies vimwiki.cnx /*vimwiki-multiple-wikies* +vimwiki-nohtml vimwiki.cnx /*vimwiki-nohtml* +vimwiki-option-auto_export vimwiki.cnx /*vimwiki-option-auto_export* +vimwiki-option-css_name vimwiki.cnx /*vimwiki-option-css_name* +vimwiki-option-diary_header vimwiki.cnx /*vimwiki-option-diary_header* +vimwiki-option-diary_index vimwiki.cnx /*vimwiki-option-diary_index* +vimwiki-option-diary_link_count vimwiki.cnx /*vimwiki-option-diary_link_count* +vimwiki-option-diary_rel_path vimwiki.cnx /*vimwiki-option-diary_rel_path* +vimwiki-option-ext vimwiki.cnx /*vimwiki-option-ext* +vimwiki-option-gohome vimwiki.cnx /*vimwiki-option-gohome* +vimwiki-option-html_footer vimwiki.cnx /*vimwiki-option-html_footer* +vimwiki-option-html_header vimwiki.cnx /*vimwiki-option-html_header* +vimwiki-option-index vimwiki.cnx /*vimwiki-option-index* +vimwiki-option-maxhi vimwiki.cnx /*vimwiki-option-maxhi* +vimwiki-option-nested_syntaxes vimwiki.cnx /*vimwiki-option-nested_syntaxes* +vimwiki-option-path vimwiki.cnx /*vimwiki-option-path* +vimwiki-option-path_html vimwiki.cnx /*vimwiki-option-path_html* +vimwiki-option-syntax vimwiki.cnx /*vimwiki-option-syntax* +vimwiki-options vimwiki.cnx /*vimwiki-options* +vimwiki-placeholders vimwiki.cnx /*vimwiki-placeholders* +vimwiki-prerequisites vimwiki.cnx /*vimwiki-prerequisites* +vimwiki-syntax vimwiki.cnx /*vimwiki-syntax* +vimwiki-syntax-blockquotes vimwiki.cnx /*vimwiki-syntax-blockquotes* +vimwiki-syntax-comments vimwiki.cnx /*vimwiki-syntax-comments* +vimwiki-syntax-headers vimwiki.cnx /*vimwiki-syntax-headers* +vimwiki-syntax-links vimwiki.cnx /*vimwiki-syntax-links* +vimwiki-syntax-lists vimwiki.cnx /*vimwiki-syntax-lists* +vimwiki-syntax-paragraphs vimwiki.cnx /*vimwiki-syntax-paragraphs* +vimwiki-syntax-preformatted vimwiki.cnx /*vimwiki-syntax-preformatted* +vimwiki-syntax-tables vimwiki.cnx /*vimwiki-syntax-tables* +vimwiki-syntax-typefaces vimwiki.cnx /*vimwiki-syntax-typefaces* +vimwiki-table-mappings vimwiki.cnx /*vimwiki-table-mappings* +vimwiki-table-of-contents vimwiki.cnx /*vimwiki-table-of-contents* +vimwiki-tables vimwiki.cnx /*vimwiki-tables* +vimwiki-temporary-wiki vimwiki.cnx /*vimwiki-temporary-wiki* +vimwiki-text-objects vimwiki.cnx /*vimwiki-text-objects* +vimwiki-toc vimwiki.cnx /*vimwiki-toc* +vimwiki-todo-lists vimwiki.cnx /*vimwiki-todo-lists* +vimwiki.txt vimwiki.cnx /*vimwiki.txt* +vimwiki_- vimwiki.cnx /*vimwiki_-* +vimwiki_ vimwiki.cnx /*vimwiki_* +vimwiki_ vimwiki.cnx /*vimwiki_* +vimwiki_ vimwiki.cnx /*vimwiki_* +vimwiki_ vimwiki.cnx /*vimwiki_* +vimwiki_ vimwiki.cnx /*vimwiki_* +vimwiki_ vimwiki.cnx /*vimwiki_* +vimwiki_wd vimwiki.cnx /*vimwiki_wd* +vimwiki_wr vimwiki.cnx /*vimwiki_wr* +vimwiki_ vimwiki.cnx /*vimwiki_* +vimwiki_ vimwiki.cnx /*vimwiki_* +vimwiki_ vimwiki.cnx /*vimwiki_* +vimwiki_= vimwiki.cnx /*vimwiki_=* +vimwiki_gqq vimwiki.cnx /*vimwiki_gqq* +vimwiki_gww vimwiki.cnx /*vimwiki_gww* +vimwiki_i_ vimwiki.cnx /*vimwiki_i_* +vimwiki_i_ vimwiki.cnx /*vimwiki_i_* +vimwiki_i_ vimwiki.cnx /*vimwiki_i_* virtcol() eval.cnx /*virtcol()* visual-block visual.cnx /*visual-block* visual-change visual.cnx /*visual-change* @@ -8289,6 +8409,8 @@ visual-start visual.cnx /*visual-start* visual-use visual.cnx /*visual-use* visual.txt visual.cnx /*visual.txt* visualmode() eval.cnx /*visualmode()* +viwmiki-global-options vimwiki.cnx /*viwmiki-global-options* +viwmiki-local-options vimwiki.cnx /*viwmiki-local-options* vms os_vms.cnx /*vms* vms-authors os_vms.cnx /*vms-authors* vms-changes os_vms.cnx /*vms-changes* @@ -8526,3 +8648,4 @@ zz scroll.cnx /*zz* {} intro.cnx /*{}* } motion.cnx /*}* ~ change.cnx /*~* +粗体文本 vimwiki.cnx /*粗体文本* diff --git a/doc/vimwiki.cnx b/doc/vimwiki.cnx new file mode 100644 index 0000000..5b08eaa --- /dev/null +++ b/doc/vimwiki.cnx @@ -0,0 +1,2026 @@ +*vimwiki.txt* Vim 里的个人维基(Wiki) + + __ __ ___ __ __ _ _ ___ ___ _ ___ ~ + | | | || | | |_| || | _ | || | | | | || | ~ + | |_| || | | || || || || | | |_| || | ~ + | || | | || || | | _|| | ~ + | || | | || || | | |_ | | ~ + | | | | | ||_|| || _ || | | _ || | ~ + |___| |___| |_| |_||__| |__||___| |___| |_||___| ~ + + + 版本: 1.0 + 译者: 闲耘™(hotoo.cn[AT]gmail.com) + lizaib(biazil.x[AT]gmail.com) + 本文档的 v1.0 中文版在 v0.9.9 基础之上更新。 + +============================================================================== +目录 *vimwiki-contents* + + 1. 介绍 |vimwiki| + 2. 安装条件 |vimwiki-prerequisites| + 3. 映射 |vimwiki-mappings| + 3.1. 全局映射 |vimwiki-global-mappings| + 3.2. 局部映射 |vimwiki-local-mappings| + 3.3. 文本对象 |vimwiki-text-objects| + 4. 命令 |vimwiki-commands| + 4.1. 全局命令 |vimwiki-global-commands| + 4.2. 局部命令 |vimwiki-local-commands| + 5. Wiki 语法 |vimwiki-syntax| + 5.1. 字体 |vimwiki-syntax-typefaces| + 5.2. 链接 |vimwiki-syntax-links| + 5.3. 标题 |vimwiki-syntax-headers| + 5.4. 段落 |vimwiki-syntax-paragraphs| + 5.5. 列表 |vimwiki-syntax-lists| + 5.6. 表格 |vimwiki-syntax-tables| + 5.7. 预格式化文本 |vimwiki-syntax-preformatted| + 5.8. 块级引用 |vimwiki-syntax-blockquotes| + 5.9. 注释 |vimwiki-syntax-comments| + 6. 折叠/大纲 |vimwiki-folding| + 7. 占位符 |vimwiki-placeholders| + 8. 待办事项(TODO)列表 |vimwiki-todo-lists| + 9. 表格 |vimwiki-tables| + 10. 日记 |vimwiki-diary| + 11. 选项 |vimwiki-options| + 12. 帮助 |vimwiki-help| + 13. 开发者 |vimwiki-developers| + 14. 版本更新记录 |vimwiki-changelog| + 15. 许可证 |vimwiki-license| + + +============================================================================== +1. 介绍 *vimwiki* + +Vimwiki 是一个 Vim 中的个人 wiki -- 一个有它自己的高亮语法和链接的文本文件。 + +使用 vimwiki 你可以: + - 组织笔记和想法; + - 管理待办事项列表; + - 写文档。 + +通过按 ww (通常是 \ww)键来快速启动,进入 wiki 索引页。默认路径在: > + ~/vimwiki/index.wiki +< +参考下面示例: + += 我的知识库 = + * 我的紧急任务(MyUrgentTasks) -- 昨天应该完成的事!!! + * 古腾堡计划(ProjectGutenberg) -- 强大的好书。 + * 便条簿(ScratchPad) -- 各种临时的东西。 + + +注意:ProjectGutenberg, MyUrgentTasks 和 ScratchPad 将高亮成“错误”样式。 +这些驼峰形式的链接尚不存在。(驼峰形式就是两个以大写字母开头的单词组合成一个词) + +将光标放置在 ProjectGutenberg 上并按回车()键,你将进入 +ProjectGutenberg ,编辑并保存它,然后按退格键()可以回到上一个 wiki +文件。你现在就会看到不同了 -- ProjectGutenberg 高亮为一个链接。 + + +============================================================================== +2. 安装条件 *vimwiki-prerequisites* + +确保你的 vimrc 文件中有如下的设置: > + set nocompatible + filetype plugin on + syntax on + +离开这些设置 Vimwiki 将不能正常工作。 + + +============================================================================== +3. 映射 *vimwiki-mappings* + +下面是 vimwiki 的全局和局部映射。 + +------------------------------------------------------------------------------ +3.1. 全局映射 *vimwiki-global-mappings* + +[count]ww 或者 VimwikiGoHome + 打开第 [count] 个 wiki 索引文件。 + + ww 从 |g:vimwiki_list| 打开第一个 wiki。 + 1ww 同上,从 |g:vimwiki_list| 打开第一个 wiki。 + 2ww 从 |g:vimwiki_list| 打开第二个 wiki。 + 3ww 从 |g:vimwiki_list| 打开第三个 wiki。 + 依此类推: + 重映射: > + :map w VimwikiGoHome +< +更多可以参考|:VimwikiGoHome| + + +[count]wt 或者 VimwikiTabGoHome + 在新标签页中打开 第 [count] 个 wiki 索引文件。 + + wt 在标签页中打开 |g:vimwiki_list| 中的第一个 wiki。 + 1wt 同上,在标签页中打开 |g:vimwiki_list| 中的第一个 wiki。 + 2wt 在标签页中打开 |g:vimwiki_list| 中的第二个 wiki。 + 3wt 在标签页中打开 |g:vimwiki_list| 中的第三个 wiki。 + 依此类推: + 重映射: > + :map t VimwikiTabGoHome +< +参考|:VimwikiTabGoHome| + + +ws 或者 VimwikiUISelect + List and select available wikies. + 列出可选择的 wiki 列表。 + 重映射: > + :map wq VimwikiUISelect +< +参考|:VimwikiUISelect| + + +[count]ww 或者 VimwikiMakeDiaryNote + 打开今天第 [count] 个 wiki 日记文件。 + + ww 从 |g:vimwiki_list| 中打开今天第一个 wiki 日记文件。 + 1ww 同上,从 |g:vimwiki_list| 中打开今天第一个 wiki 日记文件。 + 2ww 从 |g:vimwiki_list| 中打开今天第二个 wiki 日记文件。 + 3ww 从 |g:vimwiki_list| 中打开今天第三个 wiki 日记文件。 + 依此类推: + 重映射: > + :map d VimwikiMakeDiaryNote +< +参考|:VimwikiMakeDiaryNote| + + +[count]wt 或者 VimwikiTabMakeDiaryNote + 在新标签页中打开今天第 [count] 个 wiki 日记文件。 + + wt 在标签页中打开|g:vimwiki_list|中的第一个 wiki 日记文件。 + 1wt 同上。 + 2wt 在标签页中打开|g:vimwiki_list|中的第二个 wiki 日记文件。 + 3wt 在标签页中打开|g:vimwiki_list|中的第三个 wiki 日记文件。 + 依此类推。 + 重映射: > + :map dt VimwikiTabMakeDiaryNote +< +参考|:VimwikiTabMakeDiaryNote| + + +------------------------------------------------------------------------------ +3.2. 局部映射(本地映射) + +NORMAL MODE *vimwiki-local-mappings* +(普通模式) + *vimwiki_* + 打开/创建 WikiWord。 + 映射到|:VimwikiFollowWord|。 + 重映射: > + :map wf VimwikiFollowWord +< + *vimwiki_* + 横向分栏窗口中打开/创建 WikiWord。 + 映射到|:VimwikiSplitWord|。 + 重映射: > + :map we VimwikiSplitWord +< + *vimwiki_* + 纵向分栏窗口中打开/创建 WikiWord。 + 映射到|:VimwikiVSplitWord|。 + 重映射: > + :map wq VimwikiVSplitWord +< + *vimwiki_* + 回到上一个 WikiWord + 映射到|:VimwikiGoBackWord|。 + 重映射: > + :map wb VimwikiGoBackWord +< + *vimwiki_* + 寻找并将光标定位到下一个 WikiWord + 映射到|:VimwikiNextWord|。 + 重映射: > + :map wn VimwikiNextWord +< + *vimwiki_* + 寻找并将光标定位到上一个 WikiWord + 映射到|:VimwikiPrevWord|。 + 映射到: > + :map wp VimwikiPrevWord +< + *vimwiki_wd* +wd 删除当前所在的 WikiWord。 + 映射到|:VimwikiDeleteWord|。 + 重映射: > + :map dd VimwikiDeleteWord +< + *vimwiki_wr* +wr 重命名当前所在的 WikiWord。 + 映射到|:VimwikiRenameWord|。 + 重映射: > + :map rr VimwikiRenameWord +< + *vimwiki_* + 切换列表项的开关(选中/反选) + (译注: 是中文输入法切换热键,可以参考下面的 + 重映射方法,不过 tt 也是插件 tasklist.vim 的 + 热键。) + 映射到|:VimwikiToggleListItem|。 + 重映射: > + :map tt VimwikiToggleListItem +< 参考 |vimwiki-todo-lists|。 + + *vimwiki_=* += 增加标题级别,如果需要则创建标题。 + vimwiki 里是没有缩进命令 '==' 的,所以请确定是否需要 + '=' 命令。 + + *vimwiki_-* +- 降低标题级别。 + + + *vimwiki_gqq* *vimwiki_gww* +gqq 格式化表格。 + 或 如果你在没有切换插入模式和普通模式的情况下改变了表格内容, +gww 这个表格可以重新格式化它。 + + + *vimwiki_* + 向左移动表格的当前列。 + 参考 |:VimwikiTableMoveColumnLeft| + + *vimwiki_* + 向右移动表格当前列。 + 参考 |:VimwikiTableMoveColumnRight| + + + + +仅在 |g:vimwiki_use_mouse| 设置为 1 的情况下有效。 +<2-LeftMouse> 双击鼠标打开/创建 WikiWord + + 横向分栏窗口中打开/创建 WikiWord + + 纵向分栏窗口中打开/创建 WikiWord + + 返回到上一个 WikiWord + +Note: <2-LeftMouse> 即仅双击左键。 + + + +INSERT MODE *vimwiki-table-mappings* +(插入模式) + *vimwiki_i_* + 转到表格单元格的下一行,如果在最后一行则创建一行。 + + + *vimwiki_i_* + 转到下一个表格单元格,如果在最后一个单元格,则创建一行。 + + + + *vimwiki_i_* + 插入
    并回车换行。 + + +------------------------------------------------------------------------------ +3.3. 文本对象 *vimwiki-text-objects* + +ah 一个包含前置空行的标题。 +ih 一个不包含前置空行的标题内部。 + +你可以使用 'vah' 来选择包含其内容的标题,或者使用 'dah' 来删除、或者可以用 +'yah' 来复制、或者也可以使用 'cah' 来修改这个标题。 + +a\ 表格中的一整个单元格(包括单元格边框)。 +i\ 表格单元格内部。 +ac 表格的一列(包括单元格边框)。 +ic 表格单元格内部。 + +============================================================================== +4. 命令 *vimwiki-commands* + +------------------------------------------------------------------------------ +4.1. 全局命令 *vimwiki-global-commands* + +*:VimwikiGoHome* + 打开当前 wiki 的索引文件。 + +*:VimwikiTabGoHome* + 在新标签页中打开当前 wiki 的索引文件。 + +*:VimwikiUISelect* + 打开所选择的 wiki 索引文件。 + +*:VimwikiMakeDiaryNote* + 打开当前 wiki 中今天的 wiki 日记文件。 + +*:VimwikiTabMakeDiaryNote* + 在新标签页中打开当前 wiki 中今天的 wiki 日志文件。 + +------------------------------------------------------------------------------ +4.2. 局部命令 *vimwiki-local-commands* + +*:VimwikiFollowWord* + 打开/创建 WikiWord。 + + +*:VimwikiGoBackWord* + 返回到跳转过来的上一个 WikiWord。 + + +*:VimwikiSplitWord* + 在纵向分栏窗口中打开/创建 WikiWord。 + + +*:VimwikiVSplitWord* + 在横向分栏窗口中打开/创建 WikiWord。 + + +*:VimwikiNextWord* + 寻找并将光标定位到下一个 WikiWord。 + + +*:VimwikiPrevWord* + 寻找并将光标定位到上一个 WikiWord。 + + +*:VimwikiDeleteWord* + 删除当前所在的 WikiWord。 + + +*:VimwikiRenameWord* + 重命名当前所在的 WikiWord。 + + +*:Vimwiki2HTML* + 将当前所在的 wiki 页面转换成 HTML 页面。 + + +*:VimwikiAll2HTML* + 将所有的 wiki 页面转换成 HTML。 + + +*:VimwikiToggleListItem* + 切换列表项的开关(选中/反选) + 参考 |vimwiki-todo-lists|. + + +*:VimwikiSearch* /pattern/ +*:VWS* /pattern/ + 在当前 wiki 中搜索 /pattern/。 + + +*:VimwikiTable* + 创建一个 5 列 2 行的表格。 + + :VimwikiTable cols rows + 创建一个指定列数和行数的表格。 + + :VimwikiTable cols + 创建一个指定列数和 2 行的表格。 + + +*:VimwikiTableMoveColumnLeft* , *:VimwikiTableMoveColumnRight* + 向左或向右移动当前列: + 例如: > + + | head1 | head2 | head3 | head4 | head5 | + |--------+--------+--------+--------+--------| + | value1 | value2 | value3 | value4 | value5 | + + + 光标在 'head1' 之上。 + :VimwikiTableMoveColumnRight + + | head2 | head1 | head3 | head4 | head5 | + |--------+--------+--------+--------+--------| + | value2 | value1 | value3 | value4 | value5 | + + 光标在 'head3' 之上。 + :VimwikiTableMoveColumnLeft + + | head2 | head3 | head1 | head4 | head5 | + |--------+--------+--------+--------+--------| + | value2 | value3 | value1 | value4 | value5 | +< + + 命令已分别映射到 快捷键上。 + + +*:VimwikiGenerateLinks* + 插入所有可用的链接到当前缓冲区。 + + +============================================================================== +5. Wiki 语法 *vimwiki-syntax* + +这里有许多不同的 wiki, 许多情况下它们有自己的语法,vimwiki 也不例外。默认的 +vimwiki 语法是 google 的 wiki 语法标记的子集。 + +MediaWiki 语法文件包含在这个发行版之中(不包含 MediaWiki 原始语法中那些花里胡哨 +的部分)。 +参考 |vimwiki-option-syntax|。 + + +------------------------------------------------------------------------------ +5.1. 字型 *vimwiki-syntax-typefaces* + +下面简单给了一些用来控制修饰文本字型的语法: > + *粗体文本* + _斜体文本_ + ~~删除线~~ + `代码 (无语法) 文本` + 上标^脚本^ + 下标,,脚本,, + +------------------------------------------------------------------------------ +5.2. 链接 *vimwiki-syntax-links* + +内部链接~ +WikiWords: > + CapitalizedWordsConnected + +你可以通过在前面加感叹号的方式来取消(驼峰式) WikiWord 链接。 > + !CapitalizedWordsConnected + +或者通过|g:vimwiki_camel_case|参数来完全禁用(驼峰式) WikiWord。 + +(WikiWord)里带空格的链接: > + [[This is a link]] +或: > + [[链接源地址|链接描述]] +或: > + [[链接源地址][链接描述]] + + +外部链接~ +纯链接: > + http://code.google.com/p/vimwiki + +带描述的链接: > + [http://habamax.ru/blog habamax 的主页] + + +图片及图片链接~ +Image link is the link with one of jpg, png or gif endings. +图片链接就是以 jpg, png 或 gif 结尾的链接。 +纯图片链接: > + http://someaddr.com/picture.jpg +在 html 中即: > + + +本地图片链接: > + [[images/pabloymoira.jpg]] +在 html 中即: > + +图片的路径(例如 images/pabloymoira.jpg)是相对于 +|vimwiki-option-path_html|的。 + +双中括号内的图片链接: > + [[http://habamax.ru/blog/wp-content/uploads/2009/01/2740254sm.jpg]] +在 html 中即: > + + +双中括号内带描述信息的图片链接: > + [[http://habamax.ru/blog/wp-content/uploads/2009/01/2740254sm.jpg|dance]] +在 html 中即: > + dance + +双中括号内带备用信息的图片链接: > + [[http://habamax.ru/blog/wp-content/uploads/2009/01/2740254sm.jpg|dance|]] +在 html 中即: > + dance + +双中括号内带备用信息和一些样式的图片链接: > + [[http://helloworld.com/blabla.jpg|cool stuff|width:150px; height: 120px;]] +在 html 中即: > + cool stuff + +双中括号内带样式,但不带备用信息的图片链接: > + [[http://helloworld.com/blabla.jpg||width:150px; height: 120px;]] +在 html 中即: > + + +缩略图链接: > + [http://someaddr.com/bigpicture.jpg http://someaddr.com/thumbnail.jpg] +或 > + [[http://someaddr.com/bigpicture.jpg|http://someaddr.com/thumbnail.jpg]] +在 html 中即: > + + + def hello(world): + for x in range(10): + print("Hello {0} number {1}".format(world, x)) +}}} + +导出的 HTML 结果是: > +
    + def hello(world):
    +     for x in range(10):
    +         print("Hello {0} number {1}".format(world, x))
    + 
    + +这就可以使用类似 google syntax highlighter 这样的 js +代码着色器这样有用的工具了。 + +可以设置 vimwiki 来高亮预格式化代码片段。 +参考 |vimwiki-option-nested_syntaxes| + +------------------------------------------------------------------------------ +5.8. 块级引用 *vimwiki-syntax-blockquotes* + +以 4 个以上空格开始的文本,就是一个引用块。 + + 这在 vimwiki 中是一个引用块,它在 vim 中不会被高亮,但是可以使用样式表让 + 它在 html 中高亮,块级引用通常用来引用其他来源的较长文本片段。 + +------------------------------------------------------------------------------ +5.9. 注释 *vimwiki-syntax-comments* + +在 之间的文本是一个注释。 +例如: > + +< + +============================================================================== +6. 代码折叠/大纲 *vimwiki-folding* + +Vimwiki 可以根据标题和列表项来折叠或显示大纲。 + +例如: += 我的当前任务 = + * [ ] 做某事 1 + * [ ] 做某事的子步骤 1.1 + * [ ] 做某事的子步骤 1.2 + * [ ] 做某事的子步骤 1.2.1 + * [ ] 做某事的子步骤 1.2.2 + * [ ] 做某事的子步骤 1.3 + * [ ] 做某事 2 + * [ ] 做某事 3 + +击 |zM| 键: += 我的当前任务 = [8] --------------------------------------~ + +击 |zr| 键: += 我的当前任务 =~ + * [ ] 做某事 1 [5] --------------------------------------~ + * [ ] 做某事 2~ + * [ ] 做某事 3~ + +击 |zr| 键更多次: += 我的当前任务 =~ + * [ ] 做某事 1~ + * [ ] 做某事的子步骤 1.1~ + * [ ] 做某事的子步骤 1.2 [2] -------------------------------~ + * [ ] 做某事的子步骤 1.3~ + * [ ] 做某事 2~ + * [ ] 做某事 3~ + +备注: 不论是否使用默认语法,只要是使用 |shiftwidth| 来缩进,在列表项是的折叠 +都会正常工作。对于 MediaWiki 来说,* 和 # 都应该放在第一列。 + +设置 |g:vimwiki_folding| 来启用/禁用折叠。 + +============================================================================== +7. 占位符 *vimwiki-placeholders* + +------------------------------------------------------------------------------ +%toc 目录 *vimwiki-toc* *vimwiki-table-of-contents* + +从某个 wiki 生成 html 时,可以添加目录到 html 页面中。 +只需要输入 > + + %toc + +到 wiki 页面。 +还可以给“目录”添加标题: > + + %toc 目录 + +或者 > + + %toc 随便什么 + + +------------------------------------------------------------------------------ +%nohtml *vimwiki-nohtml* + +如果不希望 wiki 被转为 html 页面, wiki 中输入: > + + %nohtml + + +============================================================================== +8. 待办事项列表(Todo lists) *vimwiki-todo-lists* + +可以(使用 Vimwiki)来做待办事项列表 -- 一个可以切换选中/反选的项目列表。 + +参考如下示例: += 可切换的待办列表项 = + * [X] 切换列表项开/关。 + * [X] 简单的在 [ ] 和 [X] 之间切换。 + * [X] 所有的列表子项将被适当的切换为开/关。 + * [X] 仅当当前行是列表项时,切换子项。 + * [X] 父列表项将受子列表项的切换影响。 + * [X] 同样支持编号列表项的切换。 + * [X] 添加高亮到列表项的复选框。 + * [X] 使用 o, O 和 创建新行时,新列表项会带 [ ]。(译注:没有带 [ ]) + + +在第一个列表项按 会切换所有的子项: +(译注: 一般是中文输入法的热键,可以自定义键盘映射) += 可切换的待办列表项 = + * [ ] 切换列表项开/关。 + * [ ] 简单的在 [ ] 和 [X] 之间切换。 + * [ ] 所有的列表子项将被适当的切换为开/关。 + * [ ] 仅当当前行是列表项时,切换子项。 + * [ ] 父列表项将受子列表项的切换影响。 + * [X] 同样支持编号列表项的切换。 + * [X] 添加高亮到列表项的复选框。 + * [X] 使用 o, O 和 创建新行时,新列表项会带 [ ]。 + +在第三个列表项是按 将切换自身和其父项: += 可切换的待办列表项 = + * [.] 切换列表项开/关。 + * [ ] 简单的在 [ ] 和 [X] 之间切换。 + * [X] 所有的列表子项将被适当的切换为开/关。 + * [ ] 仅当当前行是列表项时,切换子项。 + * [ ] 父列表项将受子列表项的切换影响。 + * [ ] 同样支持编号列表项的切换。 + * [ ] 添加高亮到列表项的复选框。 + * [ ] 使用 o, O 和 创建新行时,新列表项会带 [ ]。 + +父项会受子项的切换影响,[ ] 中的符号与子项百分比对照如 +(也可参考 |g:vimwiki_listsyms| ): + [ ] -- 0% + [.] -- 1-33% + [o] -- 34-66% + [O] -- 67-99% + [X] -- 100% + +在可视模式下,可以批量切换多个列表项。 + + +============================================================================== +9. 表格 *vimwiki-tables* + +使用 :VimwikiTable 命令默认创建 5 列 2 行的表格: > + + | | | | | | + |---+---+---+---+---| + | | | | | | +< + +表格会自动格式化,我们先加些文本到第一个表格单元中: > + + | 姓氏 | | | | | + |---+---+---+---+---| + | | | | | | +< + +无论按 , 还是离开插入模式,表格都将被格式化: > +(译注 I: 键会与其他使用 键的脚本(如snipMate)冲突,可以重新映射其他 +热键; +译注 II:0.9.9及之前版本对于双宽字符的格式化有问题,1.0 beta之后有修正。) +> + | 姓氏 | | | | | + |------+---+---+---+---| + | | | | | | +< + +你可以轻易的创建看起来不错的文本风格的表格,只需要按 键并输入新值: > + + | 姓氏 | 名字 | 年龄 | 城市 | 电子邮件 | + |------------+------------+------+------------+----------------------| + | Vladislav | Pokrishkin | 31 | 莫斯科 | vlad_pok@smail.com | + | James | Esfandiary | 27 | 伊斯坦布尔 | esfandiary@tmail.com | +< + +格式化表格可以使用 'gqq' 快捷键。 + + + +============================================================================== +10. 日记 *vimwiki-diary* + +日记功能可帮助你记录日常笔记,你能够非常容易地将分类的日记添加至Vimwiki中, +只要按下ww,即可以当前的日期为名来创建新的笔记, +这个新创建的笔记文件,会保存在diary目录中。 + +现在,你可以参考下面示例来创建你的日记: + 今天是2010-01-27。 + + 按 \w\w 打开日记首页。 + ~/vimwiki/diary.wiki is created. + + 2 把下面几行添加到 ~/vimwiki/diary/diary.wiki 文件中 + = Diary = + | [[2010-01-27]] | + + ~/vimwiki/diary/2010-01-27.wiki is created. + 这样,就生成了以当前日期命中的wiki日记文件,你可在这个日记中记录事项了。 + 要是你没做键盘映射,你可在Vim命令模式执行:VimwikiMakeDiaryNote,也可以进入日记页。 + ------------------------------------------- + + 撰写第二天的日记 + 按 \w\w 。 + + 打开~/vimwiki/diary/diary.wiki文件后,在 = Diary = 下的第一行增加第二天 + 的日期即可。 + + = Diary = + | [[2010-01-28]] | [[2010-01-27]] | + + ~/vimwiki/diary/2010-01-28.wiki is created. + 这样,就创建第二天的日记了,你可以添加信息在这个日记中。. +> +默认情况下在一行创建4个链接,所有的链接都以日期进行分类的。 + + +集成日历功能 *vimwiki-calendar* +------------------------------------------------------------------------------ +如果你已经安装了Calendar.vim插件,你可以使用它来创建笔记。 +在命令模式执行:Calendar,并按键,会在diary目录创建以当前日期为名.Wiki文件。 +嗯,这种方式创建的日记比前面的方法好多了。 + +Calendar.vim的插件,你可以在这下载:http://www.vim.org/scripts/script.php?script_id=52 + + +参考 |g:vimwiki_use_calendar| 选项用来启用/禁用日历。 + + + +============================================================================== +11. 选项 *vimwiki-options* +可以通过全局或者每个 wiki (局部)的选项来设置 vimwki,所有的全局选项都使用如下模板来设置: + let g:option_name=option_value + +你可以参考下面的|g:vimwiki_list|说明与实例,在_vimrc文件中配置相关参数。 + +------------------------------------------------------------------------------ +*g:vimwiki_list* *vimwiki-multiple-wikies* + +一般形式: + {'option1': 'value1', 'option2: 'value2', ...} + +请参考下面的例子: + let g:vimwiki_list = [{'path': '~/my_site/', 'path_html': '~/public_html/'}] + +打开Vimwiki时会定向到 ~/my_site/ 目录,而生成的网页文件会储存在 ~/public_html/ +目录。 + +下一个例子: + let g:vimwiki_list = [{'path': '~/my_site/', 'path_html': '~/public_html/'}, + \ {'path': '~/my_docs/', 'ext': '.mdox'}] +在上面的示例中,第二行表示增加了2个wiki,第二个会定向至 ~/my_docs/ +、ext、.mdox目录中。. + +在 g:vimwiki_list 设置空目录,其选项为如下: > + let g:vimwiki_list = [{}, + \ {'path': '~/my_docs/', 'ext': '.mdox'}] + +[注] 译者的设置如下: > + let g:vimwiki_list = [{'path': 'F:/File/My Dropbox/VimWiki/A0.WikiIndex/', + \ 'path_html': 'F:/File/My Dropbox/VimWiki/Z0.OutHtml', + \ 'html_header': 'F:/File/My Dropbox/VimWiki/Z0.Template/header.tpl',}] +< + +你也可以用 |Dictionary| 分隔来创建多个 Wiki。 > + + let wiki_1 = {} + let wiki_1.path = '~/my_docs/' + let wiki_1.html_header = '~/public_html/header.tpl' + let wiki_1.nested_syntaxes = {'python': 'python', 'c++': 'cpp'} + + let wiki_2 = {} + let wiki_2.path = '~/project_docs/' + let wiki_2.index = 'main' + + let g:vimwiki_list = [wiki_1, wiki_2] + +< + +PER WIKI OPTIONS *viwmiki-local-options* +(局部 WIKI 选项) + + +*vimwiki-option-path* +------------------------------------------------------------------------------ +选项 缺省值 +path ~/vimwiki/ + +描述 +定向至Wiki文件夹: + let g:vimwiki_list = [{'path': '~/my_site/'}] + + +*vimwiki-option-path_html* +------------------------------------------------------------------------------ +选项 缺省值 +path_html ~/vimwiki_html/ + +描述 +wiki转换为HTML网页格式的定向位置: + let g:vimwiki_list = [{'path': '~/my_site/', + \ 'path_html': '~/my_site_html/'}] + + +如果省略 path_html 的"/"号及"_html"选项,可能无法生成网页,例如下面的示例: > + let g:vimwiki_list = [{'path': '~/okidoki/'}] + +建议修改为 path_html = '~/okidoki_html/' + +*vimwiki-option-auto_export* +------------------------------------------------------------------------------ +选项 缺省值 值~ +auto_export 0 0, 1 + +描述 +执行保存wiki页时,若设置此项值为1时,将自动生成HTML文件 + let g:vimwiki_list = [{'path': '~/my_site/', 'auto_export': 1}] + +这会使你的HTML文件保持最新的! + +*vimwiki-option-index* +------------------------------------------------------------------------------ +选项 缺省值 +index index + +描述 +wiki的首页名 + let g:vimwiki_list = [{'path': '~/my_site/', 'index': 'main'}] + +NOTE: 不要添加文件扩展名! + + +*vimwiki-option-ext* +------------------------------------------------------------------------------ +选项 缺省值 +ext .wiki + +描述 +wiki文件扩展名 + let g:vimwiki_list = [{'path': '~/my_site/', + \ 'index': 'main', 'ext': '.document'}] + + +*vimwiki-option-syntax* +------------------------------------------------------------------------------ +选项 缺省值 值 +syntax default default, media + +描述 +Wiki语法加色 +你可以使用不同的标记语言(当前缺省的为vimwiki与MediaWiki的语法标记),但只有在Vimwiki预设标记 +不能转换HTML时才有效。 +使用MediaWiki的标记: > + let g:vimwiki_list = [{'path': '~/my_site/', 'syntax': 'media'}] +< + +*vimwiki-option-html_header* +------------------------------------------------------------------------------ +选项 缺省值 +html_header + +描述 +设置html文件头模板: + let g:vimwiki_list = [{'path': '~/my_site/', + \ 'html_header': '~/public_html/header.tpl'}] + +这个header.tpl模板代码,你可以参考下面的: > + + + + %title% + + + +
    + +变量说明 + %title% 显示wiki页的名字 + %root_path% 显示子目录链接 + + + +*vimwiki-option-html_footer* +------------------------------------------------------------------------------ +选项 缺省值 +html_footer + +描述 +设置html文件页脚模板: + let g:vimwiki_list = [{'path': '~/my_site/', + \ 'html_footer': '~/public_html/footer.tpl'}] + +可参考如下页脚模板footer.tpl文件代码: +
    + + + + +*vimwiki-option-css_name* +------------------------------------------------------------------------------ +选项 缺省值 +css_name style.css + +描述 +设置.css文件名: + let g:vimwiki_list = [{'path': '~/my_pages/', + \ 'css_name': 'main.css'}] + +或者 > + let g:vimwiki_list = [{'path': '~/my_pages/', + \ 'css_name': 'css/main.css'}] +< + +*vimwiki-option-gohome* +------------------------------------------------------------------------------ +选项 缺省值 值~ +gohome split split, vsplit, tabe + +描述 +这个选项与:VimwikiGoHome 命令的功能一样。 +比如“没有写入上次缓冲区”,然后执行 ww (或者 :VimwikiGoHome),vimwiki +索引文件将会分开窗口,即垂直分开或在一个新的tab窗口打开。 +例如: > + let g:vimwiki_list = [{'path': '~/my_site/', 'gohome': 'vsplit'}] +< + +*vimwiki-option-maxhi* +------------------------------------------------------------------------------ +选项 缺省值 值~ +maxhi 1 0, 1 + +描述~ +不存在WikiWord关键字,即红色高亮标记的关键字,会使操作比较慢,比如切换啥的。 +如果你想关闭文件系统总是检查WikiWord,你可以将maxhi的值设为0。 +例如: + let g:vimwiki_list = [{'path': '~/my_site/', 'maxhi': 0}] + + + + +*vimwiki-option-nested_syntaxes* +------------------------------------------------------------------------------ +选项 缺省值 值~ +nested_syntaxes {} 成对的高亮关键字,或者vim的文件类型 + +描述~ +你可以在Vim显示不同的语言语法高亮,像C++、Pytho等语法高亮。 +例如下面在你的 vimrc 中的设置: > + let wiki = {} + let wiki.path = '~/my_wiki/' + let wiki.nested_syntaxes = {'python': 'python', 'c++': 'cpp'} + let g:vimwiki_list = [wiki] + +设置 python、c++ 高亮: > + {{{class="brush: python" + for i in range(1, 5): + print(i) + }}} + + {{{class="brush: c++" + #include "helloworld.h" + int helloworld() + { + printf("hello world"); + } + }}} + +或者: > + {{{c++ + #include "helloworld.h" + int helloworld() + { + printf("hello world"); + } + }}} + + {{{python + for i in range(1, 5): + print(i) + }}} + + + +*vimwiki-option-diary_rel_path* +------------------------------------------------------------------------------ +选项 缺省值~ +diary_rel_path diary/ + +描述~ +|vimwiki-option-path|的路径用以重新载入日记文件夹。 + + +*vimwiki-option-diary_index* +------------------------------------------------------------------------------ +选项 缺省值 +diary_index diary + +描述~ +diary文件夹用来保存以日期命名的wiki文件,diary文件名可自定义别的文件名。 + + +*vimwiki-option-diary_header* +------------------------------------------------------------------------------ +选项 缺省值~ +diary_header Diary + +描述~ +在 |vimwik-option-diary_index| 中的名称将链接到以日期命名的 wiki 文件。 + + +*vimwiki-option-diary_link_count* +------------------------------------------------------------------------------ +Key Default value~ +diary_link_count 4 + +描述~ +每一行显示日期链接的最大数目。 +例如: += Diary = +| [[2010-01-30]] | [[2010-01-29]] | [[2010-01-28]] | [[2010-01-27]] | +| [[2010-01-26]] | [[2010-01-25]] | + + + + +GLOBAL OPTIONS *viwmiki-global-options* +(全局选项) + +使用: > + let g:option_name=option_value +来设置。 + +------------------------------------------------------------------------------ +*g:vimwiki_hl_headers* + +高亮标题颜色: =Reddish=, ==Greenish==, ===Blueish=== + +值 描述~ +1 使用预先定义的颜色高亮不同级别的标题。 +0 使用 |hl-Title| 或 VimwikiHeader1-VimwikiHeader6 (如果已定义 + 了颜色主题的话) + +缺省值为: 1 + + +------------------------------------------------------------------------------ +*g:vimwiki_hl_cb_checked* + +选中列表项可以高亮显示的颜色: + + * [X] 整行高亮,可将选项值设为1. + * [ ] 我希望 Vim 可以使用 strikethru(?). + +值 描述~ +1 用组名( |group-name| ) 为 "Comment" 的语法高亮选中的复选框。 +0 不要高亮 + +缺省值: 0 + + +------------------------------------------------------------------------------ +*g:vimwiki_global_ext* *vimwiki-temporary-wiki* + +如果一个扩展名是 wiki 的文件被打开,而它有所在的目录不在 |g:vimwiki_list| 列表中, +则: + +值 描述~ +1 标记这个目录为临时wiki. +0 不标记这个目录为临时wiki. + +缺省值: 1 + + +------------------------------------------------------------------------------ +*g:vimwiki_upper* *g:vimwiki_lower* + +这会影响WikiWord的检测。 +在默认情况下,WikiWord会检测使用英语、俄语的字母。 +你可以设置为你自己的: > + let g:vimwiki_upper = "A-Z\u0410-\u042f" + let g:vimwiki_lower = "a-z\u0430-\u044f" + + +------------------------------------------------------------------------------ +*g:vimwiki_auto_checkbox* + +如果开启,创建复选框会触发列表项目。. + +值 描述~ +0 不要创建复选框。 +1 创造复选框。 + +缺省值: 1 + +例如: +执行 (|:VimwikiToggleListItem|) 在一个列表项没有复选框来创建它: > + * List item +结果: > + * [ ] List item + + +------------------------------------------------------------------------------ +*g:vimwiki_menu* + +用 GUI 菜单来选择可用的 wiki。 + +值 描述~ +'' 没有菜单 +'Vimwiki' 顶层菜单"Vimwiki" +'Plugin.Vimwiki' "Vimwiki" 子菜单的顶层菜单 "Plugin" 等。 + +缺省值: 'Vimwiki' + +------------------------------------------------------------------------------ +*g:vimwiki_stripsym* + +更改脚本符号 -- 在Windows你不能使用 /*?<>" 作为文件名,所以 vimwiki 替换它们为 +自然符号。( _ 是缺省) : + let g:vimwiki_stripsym = '_' + +你可以将它更改为空格,例子: > + let g:vimwiki_stripsym = ' ' + +------------------------------------------------------------------------------ +*g:vimwiki_badsyms* + +你可能不喜欢文件名中包含空格(就像其他 vimwiki 用户一样),如果这样,你可以 +设置将那些坏字符转换为指定的字符 +|g:vimwiki_stripsym|: > + let g:vimwiki_badsyms = ' ' + +现在所有的 [[links with spaces]] 将被创建类似 'links_with_spaces' 这样的文件。 + +这个选项是 |g:vimwiki_stripsym| 的一个补充。 + +------------------------------------------------------------------------------ +*g:vimwiki_listsyms* + +列表复选框中 5 个字符的字符串(译注:用来表示列表项的完成度)。 +默认值是 ' .oOX'。 + +g:vimwiki_listsyms[0] 是完成 0% 的项。 +g:vimwiki_listsyms[4] 是完成 100% 的项。 + +------------------------------------------------------------------------------ +*g:vimwiki_use_mouse* + +从 |vimwiki-local-mappings| 处使用局部鼠标映射。 + +值 描述~ +0 不使用鼠标映射。 +1 使用鼠标映射。 + +默认值: 0 + +------------------------------------------------------------------------------ +*g:vimwiki_folding* + +启用/禁用 vimwiki 的折叠/大纲。 vimwiki 使用 'expr' 折叠方法(foldmethod),它 +很灵活但是性能很低。 + +值 描述~ +0 禁用折叠。 +1 启用折叠。 + +默认值: 0 + +------------------------------------------------------------------------------ +*g:vimwiki_fold_lists* + +启用/禁用 折叠子列表项。 + +值 描述~ +0 禁用子列表项的折叠功能。 +1 启用子列表项的折叠功能。 + +默认值: 0 + +------------------------------------------------------------------------------ +*g:vimwiki_fold_trailing_empty_lines* + +折叠,或不折叠那些已经折叠的行之间的空行。 + +值 描述~ +0 仅折叠一个空行,其他的空行不折叠。 +1 折叠所有的空行。 + +默认值: 0 + +------------------------------------------------------------------------------ +*g:vimwiki_camel_case* + +如果不希望 WikiWord 这样的驼峰式词组作为一个 Wiki 链接,可以更改这个设置。 + +值 描述~ +0 不要将驼峰式词组作为 Wiki 链接。 +1 将驼峰式词组作为 Wiki 链接。 + +默认值: 1 + +------------------------------------------------------------------------------ +*g:vimwiki_list_ignore_newline* + +这是与 HTML 相关的选项。 +在多行列表项里将换行符转为
    。 + +值 描述~ +0 将换行符转为
    。 +1 忽略换行符。 + +默认值: 1 + +------------------------------------------------------------------------------ +*g:vimwiki_use_calendar* + +针对日历里选中日期,新建或打开已存在的日记 wiki 文件。 +参考 |vimwiki-calendar|。 + +值 描述~ +0 不要使用日历。 +1 使用日历。 + +默认值: 1 + + +------------------------------------------------------------------------------ +*g:vimwiki_browsers* *VimwikiWeblinkHandler* + +你可以使用 Web 浏览器打开一个外部链接。浏览器列表参考 |g:vimwiki_browsers|。 + +针对 Win32:chrome, opera, firefox 和 explorer。 +针对其他系统:opera, firefox 和 konqueror。 + +列表中第一个可用的浏览器会被用来打开链接。假如你有 opera 和 firefox,并希望 +用后者打开链接,只需要: > + let g:vimwiki_browsers=['C:\Program Files\Firefox\firefox.exe'] + +或者重定义 VimwikiWeblinkHandler 函数: > + function! VimwikiWeblinkHandler(weblink) + let browser = 'C:\Program Files\Firefox\firefox.exe' + execute '!start "'.browser.'" ' . a:weblink + endfunction + + +------------------------------------------------------------------------------ +*g:vimwiki_table_auto_fmt* + +启用或禁用表格的自动格式化。 + +值 描述~ +0 不要自动格式化表格。 +1 自动格式化表格。 + +默认值: 1 + + +------------------------------------------------------------------------------ +*g:vimwiki_w32_dir_enc* + +从当前编码(|encoding|)转换目录名称为 'g:vimwiki_w32_dir_enc' 编码。 + +比如当前编码是 'enc=utf-8' 并且你设置 > + let g:vimwiki_w32_dir_enc = 'cp1251' +< +则下面带换行符()的链接: > + [[привет/мир]] +> +将从 utf-8 的 'привет' 转换为 cp1251 编码,并使用这个编码的名称创建目录。 + +默认: '' + + + +------------------------------------------------------------------------------ +*g:vimwiki_CJK_length* + +使用特殊的方法来计算双宽字符的长度(用来对齐表格单元)。 + +值 描述~ +0 不使用。 +1 使用。 + +默认: 0 + + +------------------------------------------------------------------------------ +*g:vimwiki_dir_link* + +这个选项是关于目录链接的操作 -- [[directory/]], [[papers/]] 等等。 + +值 描述~ +'' 使用标准的 netrw 插件打开 'directory/' 目录。 +'index' 打开 'directory/index.wiki',如果没有就创建。 +'main' 打开 'directory/main.wiki',如果没有就创建。 +等等。 + +默认: '' (空字符) + + +------------------------------------------------------------------------------ +*g:vimwiki_html_header_numbering* + +如果希望 html 中的标题带上自动编号,设置这个选项。 + +例如: > + 1 Header1 + 1.1 Header2 + 1.2 Header2 + 1.2.1 Header3 + 1.2.2 Header3 + 1.3 Header2 + 2 Header1 + 3 Header1 +等等。 + +值 描述~ +0 关闭标题的编号。 +1 开启标题的编号。编号从一级标题开始。 +2 开启标题的编号。彪悍从二级标题开始。 +等等。 + +例如当 g:vimwiki_html_header_numbering = 2: > + Header1 + 1 Header2 + 2 Header2 + 2.1 Header3 + 2.1.1 Header4 + 2.1.2 Header4 + 2.2 Header3 + 3 Header2 + 4 Header2 +等等。 + +默认: 0 + + +------------------------------------------------------------------------------ +*g:vimwiki_html_header_numbering_sym* + +|g:vimwiki_html_header_numbering| 的结束符号。 + +值 描述~ +'.' 点号将被添加到标题编号的后面。 +')' 右括号将被添加到标题编号的后面。 +等等。 + +设置有 + let g:vimwiki_html_header_numbering = '.' +的标题将看起来如下: > + 1. Header1 + 1.1. Header2 + 1.2. Header2 + 1.2.1. Header3 + 1.2.2. Header3 + 1.3. Header2 + 2. Header1 + 3. Header1 + + +默认: '' (空字符) + + +============================================================================== +12. 帮助 *vimwiki-help* + +非常感谢你们帮助 vimwiki 变得更好! +任何帮助,无论是修正错别字还是代码片段补丁 -- 欢迎一切。 + +有问题都可以提交到 http://code.google.com/p/vimwiki/issues . + + +============================================================================== +13. 开发者 *vimwiki-developers* + + - Maxim Kim + 创始人。 + - Mikhail Trishchenkov + 于 2009 年 12 月加入。 + +Vimwiki 的网址: http://code.google.com/p/vimwiki/ +Vim 插件的网址: http://www.vim.org/scripts/script.php?script_id=2226 + +... 后记 + +感谢所有在 www.vim.org 上给 vimwiki 投票的人。我本可以用业余时间和美女跳舞, +不过你的投票也是一种很好的替代形式。 ;) + +此致, +Maxim Kim. + + +============================================================================== +14. Changelog *vimwiki-changelog* + +1.0~ + * NEW: Issue 41: Table cell and column text objects. See + |vimwiki-text-objects|. + * NEW: Issue 42: Commands to move table columns left and right. See + |:VimwikiTableMoveColumnLeft| and |:VimwikiTableMoveColumnRight|. + * NEW: Issue 44: should move cursor to the previous table cell. + * NEW: Issue 45: It should be possible to indent tables. Indented tables + are centered in html. + * NEW: Issue 46: Do not htmlize some wiki pages (blacklist). New + placeholder is added: %nohtml. See |vimwiki-nohtml|. + * FIX: Issue 47: Lists aren't HTMLized properly. + * FIX: Issue 48: With autochdir it is impossible to have path_html such as + 'd:\vimwiki\html\' + * FIX: Issue 49: Table is not HTMLized properly at the end of wiki page. + * FIX: Issue 50: Inline formatting is not performed in table cells. + * FIX: Issue 51: Cannot insert '-' (minus) into table cells of the first + column. + * FIX: Issue 52: Table cell width is incorrect when double wide characters + are used (ie. Chinese). Check |g:vimwiki_CJK_length|. + * NEW: Issue 53: Wiki markup can not nested. (Use links and inline markup + in Headers). + * NEW: Issue 54: Highlight for placeholders. + * NEW: Issue 56: Directory indexes. See |g:vimwiki_dir_link| option and + |:VimwikiGenerateLinks| command. + * NEW: Issue 58: Html new lines with
    . Could be inserted with + in insert mode. + * FIX: Issue 59: List item's text can't be started from *. + * NEW: Issue 60: Links inside completed gtd-items. + * NEW: Issue 61: Headers numbering. See |g:vimwiki_html_header_numbering| + and |g:vimwiki_html_header_numbering_sym| options. + * FIX: Issue 63: Table cannot have leading empty cells in html. + * FIX: Issue 65: Table separator is not htmlized right if on top of the + table. + * FIX: Issue 66: Table empty cells are very small in html. + * FIX: Issue 67: Wrong html conversion of multilined list item with bold + text on the start of next line. + * FIX: Issue 68: auto-indent problem with langmap. + * FIX: Issue 73: Link navigation by Tab. "Escaped" wiki-word should be + skipped for navigation with . + * FIX: Issue 75: `code` syntax doesn't display correctly in toc. + * FIX: Issue 77: Diary index only showing link to today's diary entry + file for extensions other than '.wiki'. + * FIX: Issue 79: Further calendar.vim integration -- add sign to calendar + date if it has corresponding diary page. + * FIX: Issue 80: Debian Lenny GUI Vim 7.2 has problems with toggling inner + todo list items. + * FIX: Issue 81: Don't convert WikiWord as a link in html when + `let g:vimwiki_camel_case = 0` + +0.9.9~ + * NEW: Diary. Help in making daily notes. See |vimwiki-diary|. Now you can + really easy add information into vimwiki that should be sorted out + later. + * NEW: Tables are redesigned. Syntax is changed. Now they are + auto-formattable. You can navigate them with and in insert + mode. See |vimwiki-syntax-tables| and |vimwiki-tables| for more details. + * NEW: Keyword STARTED: is added. + * NEW: Words TODO:, DONE:, STARTED:, XXX:, FIXME:, FIXED: are highlighed + inside headers. + * FIX: Export to html external links with 'file://' protocol. Ex: + [file:///home/user1/book.pdf my book]. + * FIX: Menu is corrupted if wiki's path contains spaces. + * FIX: Settings |wrap| and |linebreak| are removed from ftplugin. Add them + into your personal settings file `.vim/after/ftplugin/vimwiki.vim` if + needed. + * NEW: Headers are highlighted in different colors by default. + See |g:vimwiki_hl_headers| to turn it off. + * FIX: Issue 40: Links with russian subdirs don't work. + * NEW: It is now possible to generate HTML files automatically on page + save. See |vimwiki-option-auto_export|. + + +0.9.8~ + * NEW: Rename |g:vimwiki_fold_empty_lines| to + |g:vimwiki_fold_trailing_empty_lines|. + * NEW: One can use '-' along with '*' to start unordered list item. + * NEW: List items could be started from the first column. + As a result some limitations appeared: + - a space after *, - or # for a list item is mandatory. + - |g:vimwiki_fold_trailing_empty_lines| if set to 0 folds one trailing + empty line. + * NEW: Folding is off by default. Use |g:vimwiki_folding| to enable it. + * NEW: Speed up vimwiki's folding a bit. Should lag a bit less in a long + todo lists. + * NEW: Centered headers. Start header with at least one space to make it + html centered. + * NEW: Change in default css: header's colors. + * NEW: Vimwiki is aware of |GetLatestVimScripts| now. + * FIX: Use tag instead of custom in html. + * FIX: There are no text styling in htmlized quoted text. + * FIX: set default value of g:vimwiki_fold_lists to 0 as written in this + help. + * FIX: Issue 33: Folded list items have wrong indentation when 'tabs' are + used. + * FIX: Issue 34: vimwiki#subdir got wrong dir when VimwikiGet('path') is a + symbolic link. Thanks lilydjwg for the patch. + * FIX: Issue 28: todo-list auto-indent enhancement. New item should always + be unchecked. + * Issue 36: Change the name of the Search command to VimwikiSearch as it + conflicts with MultipleSearch. Alias :VWS is also available. + * NEW: You can generate 'Table of contents' of your wiki page. See + |vimwiki-toc| for details. + +0.9.701~ + * FIX: Issue 30: Highlighting doesn't work for checked list item. + +0.9.7~ + * NEW: Default checkbox symbols are changed to [ ], [.], [o], [O], [X]. + You can change them using |g:vimwiki_listsyms| variable. + * NEW: Color group names are renamed from wikiBold, wikiItalic, etc to + VimwikiBold, VimwikiItalic, etc. + * NEW: Open external links in a browser. There are default browsers + defined in |g:vimwiki_browsers| list. You can also redefine + |VimwikiWeblinkHandler| function to open weblinks in other programs. + * NEW: Issue 25: Toggle the states of multiple TODO list items at a time + (in VISUAL and in VISUAL LINE modes) + * NEW: Issue 26: Highlight code snippets in vimwiki's pre. See + |vimwiki-option-nested_syntaxes|. Thanks kriomant. + * NEW: Issue 27: Automatic garbage deletion from html directory. + * NEW: Save all open vimwiki buffers before export to html. + * NEW: Issue 29: Custom :Search command. + * NEW: Header text objects are now expandable in VISUAL mode. Tap 'vah' to + select a header. Tap again 'ah' to expand selection further. Thanks Andy + Wokula. + * FIX: Folding settings are reset to vim defaults in a new tab (think of + \wt) so you cannot hide things in folds. + * FIX: https links in form of [https://hello.world.com] are not exported + into html. Thanks Saurabh Sarpal for the patch. + +0.9.6~ + * NEW: You can have multiline list items. See |vimwiki-syntax-lists|. + * NEW: You can ignore newlines in multiline list items when do export to + html. See |g:vimwiki_list_ignore_newline| option. + * NEW: Different checkbox symbols [.], [:], [o] are added. See + |vimwiki-todo-lists|. + * NEW: Now there is no longer syntax of preformatted text that is started + by a whitespace. + * NEW: Blockquotes. See |vimwiki-syntax-blockquote|. + * NEW: Per wiki folding option (vimwiki-option-folding) is removed. Global + |g:vimwiki_folding| and |g:vimwiki_fold_lists| are added. + * NEW: Due to being quite slow folding of list items is off by default. + Use |g:vimwiki_fold_lists| to turn it on. + * NEW: If you want replace some symbols in a wikifilename use + |g:vimwiki_badsyms| option (Andreas Baldeau). + * FIX: Command |:VimwikiToggleListItem| doesn't work for one of the two + wikies opened at the same time with different syntaxes. + * FIX: Command |:VimwikiToggleListItem| do not switch parent checkboxes if + there are non-checkbox list items available. + * FIX: Issue 24: Link error in html when write [[one.two.three]]. + * FIX: Rename WikiWord to something with a colon (:) does nasty things. + * FIX: Command |:VimwikiToggleListItem| do not switch right if there are + list items without checkboxes in the list. + +0.9.5~ + * NEW: Added |g:vimwiki_global_ext| to control creation of temporary + wikies in dirs that are not listed in |g:vimwiki_list|. + * NEW: Added |g:vimwiki_hl_headers| to highlight headers with different + predefined colors. + * NEW: Checked [X] items are not highlighted with Comment syntax group by + default. Use |g:vimwiki_hl_cb_checked| to turn it on. + * NEW: Added new syntax for links: [[link address][link description]]. + * NEW: Added allias of mapping for *nix systems. + * NEW: Added |g:vimwiki_camel_case|. Set it to 0 if you do not want + CamelCased WikiWords to be linkified. + * FIX: Links with g:vimwiki_stripsym (default '_') [[My_Link|Text]] are + not highlighted when created. + * FIX: indent/vimwiki.vim is obsolete. If you upgrade from previous + versions remove it. It causes wrong list indentation if noexpandtab is + set. + * FIX: If tabs and spaces are used to indent list items html export gives + error. Thanks Klaus Ethgen for report. + * FIX: Some html export fixes. + +0.9.4~ + * NEW: Links with directories: [[dir1/dir2/Link|Text]]. Thanks Jie Wu. + * NEW: Added %root_path% template variable to get relative root dir of + path_html. See |vimwiki-option-html_header|. + * FIX: Indent is incorrect for vim without "float" compile option. Thanks + Julian Kooij. + * FIX: Convert to html doesn't work right with links like [[foo::bar]]. + * FIX: Rename wikiword doesn't work right when rename WikiWord to + [[WikiWord blablabla]]. + * FIX: Renaming of links with description doesn't work. + * FIX: Weblinks with commas are not highlighted. + * MISC: Some changes in default css file. + +0.9.3~ + * NEW: g:vimwiki_menu option is a string which is menu path. So one can + use let g:vimwiki_menu = 'Plugin.Vimwiki' to set the menu to the right + place. + * NEW: g:vimwiki_fold_empty_lines -- don't or do fold in empty lines + between headers. See |g:vimwiki_fold_empty_lines| + * FIX: Encoding error when running vimwiki in Windows XP Japanese. + Thanks KarasAya. + +0.9.2c~ + * FIX: Regression: Export HTML link error with [[Link|Text]]. + +0.9.2b~ + * FIX: Installation on Linux doesn't work. (Dos line endings in Vimball + archive file). + * FIX: Clear out FlexWiki ftplugin's setup. Now you don't have to hack + filetype.vim to get rid of unexpected ':setlocal bomb' from FlexWiki's + ftplugin. + * FIX: When write done: it will show another done: in html file. + +0.9.2a~ + * FIX: Installation on Linux doesn't work. (Dos line endings in + autoload/vimwiki_lst.vim and indent/vimwiki.vim). + +0.9.2~ + * NEW: Option 'folding' added to turn folding on/off. + * NEW: Header text object. See |vimwiki-text-objects|. + * NEW: Add/remove Header levels with '=' and '-'. See |vimwiki_=|. + * NEW: Vimwiki GUI menu to select available wikies. See |g:vimwiki_menu|. + * NEW: You can specify the name of your css file now. See + |vimwiki-option-css_name| + * NEW: You can add styles to image links, see |vimwiki-syntax-links|. + * FIX: History doesn't work after |VimwikiRenameWord|. + * FIX: Some of wikipedia links are not correctly highlighted. Links with + parentheses. + * MISC: Renamed vimwiki_gtd to vimwiki_lst. + +0.9.1~ + * NEW: HTML Table cell text alignment, see |vimwiki-syntax-tables| + * NEW: Wikipage history simplified. Each vimwiki buffer now holds + b:vimwiki_prev_word which is list of [PrevWord, getpos()]. + * NEW: If highlight for groups wikiHeader1..wikiHeader6 exist (defined in + a colorscheme) -- use it. Otherwise use Title highlight for all Headers. + * FIX: Warn only once if 'html_header' or 'html_footer' does not exist. + * FIX: Wrong folding for the text after the last nested list item. + * FIX: Bold and Italic aren't highlighted in tables without spaces + between || and * or _. ||*bold*||_asdf_ || (Thanks Brett Stahlman) + +0.9.0~ + * NEW: You can add classes to 'pre' tag -- |vimwiki-syntax-preformatted|. + This might be useful for coloring some programming code with external js + tools like google syntax highlighter. + * NEW: !WikiPage is not highlighted. It is just a plain word WikiPage in + HTML, without exclamation mark + * NEW: Definition lists, see |vimwiki-syntax-lists|. + * NEW: New implementation of |:VimwikiRenameWord|. CAUTION: It was tested + on 2 computers only, backup your wiki before use it. Email me if it + doesn't work for you. + * FIX: Less than 3 symbols are not highlighted in Bold and Italic. + * FIX: Added vimwiki autocmd group to avoid clashes with user defined + autocmds. + * FIX: Pressing ESC while |:VimwikiUISelect| opens current wiki index + file. Should cancel wiki selection. + +0.8.3~ + * NEW: on a list item creates checkbox. + * FIX: With * in the first column, shouldn't insert more * (default + syntax). + * FIX: With MediaWiki's ** [ ], should insert it on the next line. + * FIX: HTML export should use 'fileencoding' instead of 'encoding'. + * FIX: Code cleanup. + +0.8.2~ + * DEL: Removed google syntax file. + * NEW: Default vimwiki syntax is a subset of google's one. Header's has + been changed from !Header to =Header=. It is easier to maintain only 2 + syntaxes. See |vimwiki-syntax-headers|. + * NEW: Multiline paragraphs -- less longlines. + * NEW: Comments. See |vimwiki-syntax-comments|. + * DEL: Removed setlocal textwidth = 0 from ftplugin. + * FIX: New regexps for bold, italic, bolditalic. + * FIX: The last item in List sometimes fold-in incorrectly. + * FIX: Minor tweaks on default css. + +0.8.1~ + * NEW: Vimwiki's foldmethod changed from syntax to expr. Foldtext is + changed to be nicer with folded list items. + * NEW: Fold/outline list items. + * NEW: It is possible now to edit wiki files in arbitrary directories + which is not in g:vimwiki_list's paths. New WikiWords are created in the + path of the current WikiWord. + * NEW: User can remap Vimwiki's built in mappings. + * NEW: Added |g:vimwiki_use_mouse|. It is off by default. + * FIX: Removed mapping. + +0.8.0~ + * NEW: Multiple wikies support. A lot of options have been changed, see + |vimwiki-options| + * NEW: Auto create directories. + * NEW: Checked list item highlighted as comment. + * FIX: Multiple 'set ft=vimwiki' for each buffer disabled. Vimwiki should + load its buffers a bit faster now. + +0.7.1~ + * NEW: VimwikiToggleListItem added to be able to remap to + anything user prefers more. + * FIX: Toggleable list items do not work with MediaWiki markup. + * FIX: Changing g:vimwiki_home_html to path with ~ while vimwiki is + loaded gives errors for HTML export. + * DEL: Command :VimwikiExploreHome. + +0.7.0~ + * NEW: GTD stuff -- toggleable list items. See |vimwiki-todo-lists|. + * FIX: Headers do not fold inner headers. (Thanks Brett Stahlman) + * FIX: Remove last blank lines from preformatted text at the end of file. + * DEL: Removed g:vimwiki_smartCR option. + +0.6.2~ + * NEW: [[link|description]] is available now. + * FIX: Barebone links (ie: http://bla-bla-bla.org/h.pl?id=98) get extra + escaping of ? and friends so they become invalid in HTML. + * FIX: In linux going to [[wiki with whitespaces]] and then pressing BS + to go back to prev wikipage produce error. (Thanks Brendon Bensel for + the fix) + * FIX: Remove setlocal encoding and fileformat from vimwiki ftplugin. + * FIX: Some tweaks on default style.css + +0.6.1~ + * FIX: [blablabla bla] shouldn't be converted to a link. + * FIX: Remove extra annoing empty strings from PRE tag made from + whitespaces in HTML export. + * FIX: Moved functions related to HTML converting to new autoload module + to increase a bit vimwiki startup time. + +0.6~ + * NEW: Header and footer templates. See|g:vimwiki_html_header| and + |g:vimwiki_html_footer|. + * FIX: |:Vimwiki2HTML| does not recognize ~ as part of a valid path. + +0.5.3~ + * FIX: Fixed |:VimwikiRenameWord|. Error when g:vimwiki_home had + whitespaces in path. + * FIX: |:VimwikiSplitWord| and |:VimwikiVSplitWord| didn't work. + +0.5.2~ + * NEW: Added |:VimwikiGoHome|, |:VimwikiTabGoHome| and + |:VimwikiExploreHome| commands. + * NEW: Added wt mapping to open vimwiki index file in a new tab. + * NEW: Added g:vimwiki_gohome option that controls how|:VimwikiGoHome| + works when current buffer is changed. (Thanks Timur Zaripov) + * FIX: Fixed |:VimwikiRenameWord|. Very bad behaviour when autochdir + isn't set up. + * FIX: Fixed commands :Wiki2HTML and :WikiAll2HTML to be available only + for vimwiki buffers. + * FIX: Renamed :Wiki2HTML and :WikiAll2HTML to |:Vimwiki2HTML| and + |:VimwikiAll2HTML| commands. + * FIX: Help file corrections. + +0.5.1~ + * NEW: This help is created. + * NEW: Now you can fold headers. + * NEW: VimwikiGoHome and VimwikiExploreHome were added. + * FIX: Bug with {{{HelloWikiWord}}} export to HTML is fixed. + * DEL: Sync option removed from: Syntax highlighting for preformatted + text {{{ }}}. + +0.5~ + * NEW: vimwiki default markup to HTML conversion improved. + * NEW: Added basic GoogleWiki and MediaWiki markup languages. + * NEW: Chinese [[complex wiki words]]. + +0.4~ + * NEW: vimwiki=>HTML converter in plain Vim language. + * NEW: Plugin autoload. + +0.3.4~ + * FIX: Backup files (.wiki~) caused a bunch of errors while opening wiki + files. + +0.3.3~ + * FIX: [[wiki word with dots at the end...]] didn't work. + * NEW: Added error handling for delete wiki word function. + * NEW: Added keybindings o and O for list items when g:vimwiki_smartCR=1. + * NEW: Added keybinding wh to visit wiki home directory. + +0.3.2~ + * FIX: Renaming -- error if complex wiki word contains %. + * FIX: Syntax highlighting for preformatted text {{{ }}}. Sync option + added. + * FIX: smartCR bug fix. + +0.3.1~ + * FIX: Renaming -- [[hello world?]] to [[hello? world]] links are not + updated. + * FIX: Buffers menu is a bit awkward after renaming. + * NEW: Use mouse to follow links. Left double-click to follow WikiWord, + Rightclick then Leftclick to go back. + +0.3~ + * NEW: Highlight non-existent WikiWords. + * NEW: Delete current WikiWord (wd). + * NEW: g:vimwiki_smartCR=2 => use Vim comments (see :h comments :h + formatoptions) feature to deal with list items. (thx -- Dmitry + Alexandrov) + * NEW: Highlight TODO:, DONE:, FIXED:, FIXME:. + * NEW: Rename current WikiWord -- be careful on Windows you cannot rename + wikiword to WikiWord. After renaming update all links to that renamed + WikiWord. + * FIX: Bug -- do not duplicate WikiWords in wiki history. + * FIX: After renaming [[wiki word]] twice buffers are not deleted. + * FIX: Renaming from [[wiki word]] to WikiWord result is [[WikiWord]] + * FIX: More than one complex words on one line is bugging each other when + try go to one of them. [[bla bla bla]] [[dodo dodo dodo]] becomes bla + bla bla]] [[dodo dodo dodo. + + +0.2.2~ + * NEW: Added keybinding -- split WikiWord + * NEW: Added keybinding -- vertical split WikiWord + +0.2.1~ + * NEW: Install on Linux now works. + +0.2~ + * NEW: Added part of Google's Wiki syntax. + * NEW: Added auto insert # with ENTER. + * NEW: On/Off auto insert bullet with ENTER. + * NEW: Strip [[complex wiki name]] from symbols that cannot be used in + file names. + * NEW: Links to non-wiki files. Non wiki files are files with extensions + ie [[hello world.txt]] or [[my homesite.html]] + +0.1~ + * First public version. + +============================================================================== +15. License *vimwiki-license* + +The MIT Licence +http://www.opensource.org/licenses/mit-license.php + +Copyright (c) 2008-2010 Maxim Kim + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + + + + vim:tw=78:ts=8:ft=help diff --git a/doc/vimwiki.txt b/doc/vimwiki.txt index b8836b9..8cae209 100644 --- a/doc/vimwiki.txt +++ b/doc/vimwiki.txt @@ -1,14 +1,15 @@ *vimwiki.txt* A Personal Wiki for Vim - __ __ ______ __ __ ______ __ __ ______ ~ - /\ \/\ \/\__ _\ /'\_/`\/\ \ __/\ \/\__ _\ /\ \/\ \ /\__ _\ ~ - \ \ \ \ \/_/\ \/ /\ \ \ \/\ \ \ \/_/\ \/ \ \ \/'/'\/_/\ \/ ~ - \ \ \ \ \ \ \ \ \ \ \__\ \ \ \ \ \ \ \ \ \ \ \ \ , < \ \ \ ~ - \ \ \_/ \ \_\ \__\ \ \_/\ \ \ \_/ \_\ \ \_\ \__\ \ \\`\ \_\ \__ ~ - \ `\___/ /\_____\\ \_\\ \_\ `\___x___/ /\_____\\ \_\ \_\ /\_____\~ - `\/__/ \/_____/ \/_/ \/_/'\/__//__/ \/_____/ \/_/\/_/ \/_____/~ + __ __ ___ __ __ _ _ ___ ___ _ ___ ~ + | | | || | | |_| || | _ | || | | | | || | ~ + | |_| || | | || || || || | | |_| || | ~ + | || | | || || | | _|| | ~ + | || | | || || | | |_ | | ~ + | | | | | ||_|| || _ || | | _ || | ~ + |___| |___| |_| |_||__| |__||___| |___| |_||___| ~ - Version: 0.9.9 + + Version: 1.1 ============================================================================== CONTENTS *vimwiki-contents* @@ -34,13 +35,12 @@ CONTENTS *vimwiki-contents* 5.9. Comments |vimwiki-syntax-comments| 6. Folding/Outline |vimwiki-folding| 7. Placeholders |vimwiki-placeholders| - 7.1 Table of Contents |vimwiki-table-of-contents| 8. Todo lists |vimwiki-todo-lists| 9. Tables |vimwiki-tables| 10. Diary |vimwiki-diary| 11. Options |vimwiki-options| 12. Help |vimwiki-help| - 13. Author |vimwiki-author| + 13. Developers |vimwiki-developers| 14. Changelog |vimwiki-changelog| 15. License |vimwiki-license| @@ -97,7 +97,7 @@ There are global and local mappings in vimwiki. ------------------------------------------------------------------------------ 3.1. Global mappings *vimwiki-global-mappings* -[count]ww or VimwikiGoHome +[count]ww or VimwikiIndex Open index file of the [count]'s wiki. ww opens first wiki from |g:vimwiki_list|. @@ -106,12 +106,12 @@ There are global and local mappings in vimwiki. 3ww opens third wiki from |g:vimwiki_list|. etc. To remap: > - :map w VimwikiGoHome + :map w VimwikiIndex < -See also|:VimwikiGoHome| +See also |:VimwikiIndex| -[count]wt or VimwikiTabGoHome +[count]wt or VimwikiTabIndex Open index file of the [count]'s wiki in a new tab. wt tabopens first wiki from |g:vimwiki_list|. @@ -120,9 +120,9 @@ See also|:VimwikiGoHome| 3wt tabopens third wiki from |g:vimwiki_list|. etc. To remap: > - :map t VimwikiTabGoHome + :map t VimwikiTabIndex < -See also|:VimwikiTabGoHome| +See also |:VimwikiTabIndex| ws or VimwikiUISelect @@ -174,56 +174,56 @@ See also|:VimwikiTabMakeDiaryNote| NORMAL MODE *vimwiki-local-mappings* *vimwiki_* - Follow/Create WikiWord. - Maps to|:VimwikiFollowWord|. + Follow/Create wiki link. + Maps to |:VimwikiFollowLink|. To remap: > - :map wf VimwikiFollowWord + :map wf VimwikiFollowLink < *vimwiki_* - Split and follow/create WikiWord - Maps to|:VimwikiSplitWord|. + Split and follow/create wiki link. + Maps to |:VimwikiSplitLink|. To remap: > - :map we VimwikiSplitWord + :map we VimwikiSplitLink < *vimwiki_* - Vertical split and follow/create WikiWord - Maps to|:VimwikiVSplitWord|. + Vertical split and follow/create wiki link. + Maps to |:VimwikiVSplitLink|. To remap: > - :map wq VimwikiVSplitWord + :map wq VimwikiVSplitLink < *vimwiki_* - Go back to previous WikiWord - Maps to|:VimwikiGoBackWord|. + Go back to previous wiki link + Maps to |:VimwikiGoBackLink|. To remap: > - :map wb VimwikiGoBackWord + :map wb VimwikiGoBackLink < *vimwiki_* - Find next WikiWord - Maps to|:VimwikiNextWord|. + Find next wiki link. + Maps to |:VimwikiNextLink|. To remap: > - :map wn VimwikiNextWord + :map wn VimwikiNextLink < *vimwiki_* - Find previous WikiWord - Maps to|:VimwikiPrevWord|. + Find previous wiki link. + Maps to |:VimwikiPrevLink|. To remap: > - :map wp VimwikiPrevWord + :map wp VimwikiPrevLink < *vimwiki_wd* -wd Delete WikiWord you are in. - Maps to|:VimwikiDeleteWord|. +wd Delete wiki link you are in. + Maps to |:VimwikiDeleteLink|. To remap: > - :map dd VimwikiDeleteWord + :map dd VimwikiDeleteLink < *vimwiki_wr* -wr Rename WikiWord you are in. - Maps to|:VimwikiRenameWord|. +wr Rename wiki link you are in. + Maps to |:VimwikiRenameLink|. To remap: > - :map rr VimwikiRenameWord + :map rr VimwikiRenameLink < *vimwiki_* Toggle list item on/off (checked/unchecked) - Maps to|:VimwikiToggleListItem|. + Maps to |:VimwikiToggleListItem|. To remap: > :map tt VimwikiToggleListItem < See |vimwiki-todo-lists|. @@ -242,17 +242,31 @@ gqq Format table. If you did some changes to a table or without swapping insert/normal modes this command gww reformat it. + *vimwiki_* + Move current table column to the left. + See |:VimwikiTableMoveColumnLeft| + + *vimwiki_* + Move current table column to the right. + See |:VimwikiTableMoveColumnRight| + *vimwiki_* + Open previous day diary link if available. + See |:VimwikiDiaryPrevDay| + + *vimwiki_* + Open next day diary link if available. + See |:VimwikiDiaryNextDay| Works only if |g:vimwiki_use_mouse| is set to 1. -<2-LeftMouse> Follow/Create WikiWord +<2-LeftMouse> Follow/Create wiki link. - Split and follow/create WikiWord + Split and follow/create wiki link. - Vertical split and follow/create WikiWord + Vertical split and follow/create wiki link. - Go back to previous WikiWord + Go back to previous wiki link. Note: <2-LeftMouse> is just left double click. @@ -267,6 +281,8 @@ INSERT MODE *vimwiki-table-mappings* Goto next table cell, create new row if on the last cell. + *vimwiki_i_* + Insert
    and a newline. ------------------------------------------------------------------------------ @@ -278,6 +294,10 @@ ih Inner Header without leading empty lines. You can 'vah' to select a header with its contents or 'dah' to delete it or 'yah' to yank it or 'cah' to change it. +a\ A cell in a table. +i\ Inner cell in a table. +ac A column in a table. +ic Inner column in a table. ============================================================================== 4. Commands *vimwiki-commands* @@ -285,10 +305,10 @@ You can 'vah' to select a header with its contents or 'dah' to delete it or ------------------------------------------------------------------------------ 4.1. Global Commands *vimwiki-global-commands* -*:VimwikiGoHome* +*:VimwikiIndex* Open index file of the current wiki. -*:VimwikiTabGoHome* +*:VimwikiTabIndex* Open index file of the current wiki in a new tab. *:VimwikiUISelect* @@ -303,36 +323,40 @@ You can 'vah' to select a header with its contents or 'dah' to delete it or ------------------------------------------------------------------------------ 4.2. Local commands *vimwiki-local-commands* -*:VimwikiFollowWord* - Follow/create WikiWord. +*:VimwikiFollowLink* + Follow/create wiki link.. -*:VimwikiGoBackWord* - Go back to previous WikiWord you come from. +*:VimwikiGoBackLink* + Go back to previous wiki link. you come from. -*:VimwikiSplitWord* - Split and follow/create WikiWord. +*:VimwikiSplitLink* + Split and follow/create wiki link.. -*:VimwikiVSplitWord* - Vertical split and follow/create WikiWord. +*:VimwikiVSplitLink* + Vertical split and follow/create wiki link.. -*:VimwikiNextWord* - Find next WikiWord. +*:VimwikiNextLink* + Find next wiki link.. -*:VimwikiPrevWord* - Find previous WikiWord. +*:VimwikiPrevLink* + Find previous wiki link.. +*:VimwikiGoto* + Goto link provided by an argument. For example: > + :VimwikiGoto HelloWorld +< opens opens/creates HelloWorld wiki page. -*:VimwikiDeleteWord* - Delete WikiWord you are in. +*:VimwikiDeleteLink* + Delete wiki link. you are in. -*:VimwikiRenameWord* - Rename WikiWord you are in. +*:VimwikiRenameLink* + Rename wiki link. you are in. *:Vimwiki2HTML* @@ -362,6 +386,44 @@ You can 'vah' to select a header with its contents or 'dah' to delete it or :VimwikiTable cols Create a table with a given cols and 2 rows +*:VimwikiTableMoveColumnLeft* , *:VimwikiTableMoveColumnRight* + Move current column to the left or to the right: + Example: > + + | head1 | head2 | head3 | head4 | head5 | + |--------+--------+--------+--------+--------| + | value1 | value2 | value3 | value4 | value5 | + + + Cursor is on 'head1'. + :VimwikiTableMoveColumnRight + + | head2 | head1 | head3 | head4 | head5 | + |--------+--------+--------+--------+--------| + | value2 | value1 | value3 | value4 | value5 | + + Cursor is on 'head3'. + :VimwikiTableMoveColumnLeft + + | head2 | head3 | head1 | head4 | head5 | + |--------+--------+--------+--------+--------| + | value2 | value3 | value1 | value4 | value5 | +< + + Commands are mapped to and respectively. + + +*:VimwikiGenerateLinks* + Insert all available links into current buffer. + +*:VimwikiDiaryNextDay* + Open next day diary link if available. + Mapped to . + +*:VimwikiDiaryPrevDay* + Open previous day diary link if available. + Mapped to . + ============================================================================== 5. Wiki syntax *vimwiki-syntax* @@ -370,13 +432,8 @@ There are a lot of different wikies out there. Most of them have their own syntax and vimwiki is not an exception here. Default vimwiki's syntax is a subset of google's wiki syntax markup. -As for MediaWiki's syntax -- it is not that convenient for non English -(Russian in my case :)) keyboard layouts to emphasize text as it uses a lot -of '''''' to do it. You have to switch layouts every time you want some bold -non English text. This is the answer to "Why not MediaWiki?" - -Nevertheless, there is MediaWiki syntax file included in the distribution (it -doesn't have all the fancy stuff original MediaWiki syntax has though). +There is MediaWiki syntax file included in the distribution (it doesn't have +all the fancy stuff original MediaWiki syntax has though). See |vimwiki-option-syntax|. @@ -500,18 +557,6 @@ You can center your headers in html by placing spaces before the first '=': -Note: before vimwiki 0.8.2, header's markup syntax used exclamation marks: -! Header level 1 -!! Header level 2 -etc... - -If you upgrade from pre 0.8.2 you might find the next commands useful. -To change headers from !Header to =Header= in your wiki files do: > - :args .wiki - :argdo %s/^\(!\+\)\([^!].*$\)/\=substitute(submatch(1),'!','=','g').submatch(2).substitute(submatch(1),'!','=','g') - -Note: BACKUP FIRST! - ------------------------------------------------------------------------------ 5.4. Paragraphs *vimwiki-syntax-paragraphs* @@ -619,6 +664,7 @@ In html the following part > > is higlighted as a table header. +If you indent table then it would be centered in html. See |vimwiki-tables| for more details on how to manage tables. @@ -723,7 +769,7 @@ To turn folding on/off check |g:vimwiki_folding|. 7. Placeholders *vimwiki-placeholders* ------------------------------------------------------------------------------ -7.1. Table of Contents *vimwiki-toc* *vimwiki-table-of-contents* +%toc Table of Contents *vimwiki-toc* *vimwiki-table-of-contents* You can add 'table of contents' to your html page generated from wiki one. Just place > @@ -740,6 +786,28 @@ or > %toc Whatever +------------------------------------------------------------------------------ +%title Title of the page *vimwiki-title* + +When you htmlize your wiki page you have default title which is the filename +of the page. +Place > + +%title My books + +into your wiki page if you want another title. + + +------------------------------------------------------------------------------ +%nohtml *vimwiki-nohtml* + +If you do not want a wiki page to be converted to html, place: + +%nohtml + +into it. + + ============================================================================== 8. Todo lists *vimwiki-todo-lists* @@ -825,6 +893,8 @@ values: > | James | Esfandiary | 27 | Istanbul | esfandiary@tmail.com | < +To indent table indent the first row. Then format it with 'gqq'. + ============================================================================== @@ -870,6 +940,8 @@ be created in default wiki's diary. Get it from http://www.vim.org/scripts/script.php?script_id=52 +See |g:vimwiki_use_calendar| option to turn it off/on. + ============================================================================== @@ -907,6 +979,20 @@ Empty |Dictionary| in the g:vimwiki_list is the wiki with default options: > < +You can also create wikis as a separate |Dictionary|s. > + + let wiki_1 = {} + let wiki_1.path = '~/my_docs/' + let wiki_1.html_header = '~/public_html/header.tpl' + let wiki_1.nested_syntaxes = {'python': 'python', 'c++': 'cpp'} + + let wiki_2 = {} + let wiki_2.path = '~/project_docs/' + let wiki_2.index = 'main' + + let g:vimwiki_list = [wiki_1, wiki_2] + +< PER WIKI OPTIONS *viwmiki-local-options* @@ -1007,7 +1093,7 @@ This header.tpl could look like: >
    where - %title% is replaced by a wiki page name + %title% is replaced by a wiki page name or by a |vimwiki-title| %root_path% is replaced by a count of ../ for pages buried in subdirs: if you have wikilink [[dir1/dir2/dir3/my page in a subdir]] then %root_path% is replaced by '../../../'. @@ -1044,19 +1130,6 @@ or even > \ 'css_name': 'css/main.css'}] < -*vimwiki-option-gohome* ------------------------------------------------------------------------------- -Key Default value Values~ -gohome split split, vsplit, tabe - -Description~ -This option controls the way |:VimwikiGoHome| command works. -For instance you have 'No write since last change' buffer. After ww -(or :VimwikiGoHome) vimwiki index file will be splitted with it. Or vertically -splitted. Or opened in a new tab. -Ex: > - let g:vimwiki_list = [{'path': '~/my_site/', 'gohome': 'vsplit'}] -< *vimwiki-option-maxhi* ------------------------------------------------------------------------------ @@ -1064,11 +1137,11 @@ Key Default value Values~ maxhi 1 0, 1 Description~ -Non-existent WikiWord highlighting could be quite slow and if you don't want +Non-existent wiki links highlighting could be quite slow and if you don't want it set maxhi to 0: > let g:vimwiki_list = [{'path': '~/my_site/', 'maxhi': 0}] -This disables filesystem checks for WikiWords. +This disables filesystem checks for wiki links. *vimwiki-option-nested_syntaxes* @@ -1079,11 +1152,11 @@ nested_syntaxes {} pairs of highlight keyword and vim filetype Description~ You can make preformatted text to be highlighted with a different syntaxes available for vim. -For example the following setup: > +For example the following setup in your vimrc: > let wiki = {} - let wiki.path = '~/my_site/' + let wiki.path = '~/my_wiki/' let wiki.nested_syntaxes = {'python': 'python', 'c++': 'cpp'} - let vimwiki_list = [wiki] + let g:vimwiki_list = [wiki] would give you python and c++ highlighting in: > {{{class="brush: python" @@ -1152,8 +1225,8 @@ Description~ Number of maximum dated links placed on one line. Ex: = Diary = -|| [[2010-01-30]] || [[2010-01-29]] || [[2010-01-28]] || [[2010-01-27]] || -|| [[2010-01-26]] || [[2010-01-25]] || +| [[2010-01-30]] | [[2010-01-29]] | [[2010-01-28]] | [[2010-01-27]] | +| [[2010-01-26]] | [[2010-01-25]] | @@ -1399,7 +1472,7 @@ Default: 1 Convert directory name from current |encoding| into 'g:vimwiki_w32_dir_enc' before it is created. -If have 'enc=utf-8' and you set up > +If you have 'enc=utf-8' and set up > let g:vimwiki_w32_dir_enc = 'cp1251' < then following the next link with : > @@ -1407,40 +1480,262 @@ then following the next link with : > > would convert utf-8 'привет' to cp1251 and create directory with that name. -Default value: '' +Default: '' + + +------------------------------------------------------------------------------ +*g:vimwiki_CJK_length* + +Use special method to calculate correct length of the strings with double wide +characters. (To align table cells properly) + +Value Description~ +0 Do not use it. +1 Use it. + +Default: 0 + +Note: Vim73 has new function |strdisplaywidth|, so for Vim73 users this option +is obsolete. + + +------------------------------------------------------------------------------ +*g:vimwiki_dir_link* + +This option is about what to do with links to directories -- [[directory/]], +[[papers/]], etc. + +Value Description~ +'' Open 'directory/' using standard netrw plugin. +'index' Open 'directory/index.wiki', create if needed. +'main' Open 'directory/main.wiki', create if needed. +etc. + +Default: '' (empty string) + + +------------------------------------------------------------------------------ +*g:vimwiki_html_header_numbering* + +Set this option if you want headers to be auto numbered in html. + +ex: > + 1 Header1 + 1.1 Header2 + 1.2 Header2 + 1.2.1 Header3 + 1.2.2 Header3 + 1.3 Header2 + 2 Header1 + 3 Header1 +etc. + +Value Description~ +0 Header numbering is off. +1 Header numbering is on. Headers are numbered starting from + header level 1. +2 Header numbering is on. Headers are numbered starting from + header level 2. +etc. +Example when g:vimwiki_html_header_numbering = 2: > + Header1 + 1 Header2 + 2 Header2 + 2.1 Header3 + 2.1.1 Header4 + 2.1.2 Header4 + 2.2 Header3 + 3 Header2 + 4 Header2 +etc. + +Default: 0 + + +------------------------------------------------------------------------------ +*g:vimwiki_html_header_numbering_sym* + +Ending symbol for |g:vimwiki_html_header_numbering|. + +Value Description~ +'.' Dot would be added to the end of header's number. +')' Closing bracket would be added to the end of header's number. +etc. + +With + let g:vimwiki_html_header_numbering = '.' +headers would look like: > + 1. Header1 + 1.1. Header2 + 1.2. Header2 + 1.2.1. Header3 + 1.2.2. Header3 + 1.3. Header2 + 2. Header1 + 3. Header1 + + +Default: '' (empty) + + +------------------------------------------------------------------------------ +*g:vimwiki_file_exts* + +Comma separated list of file extensions. + +Consider you have the following link: [[my_script.php][my script]]. +If there is 'php' extension in g:vimwiki_file_exts this link would be htmlized +to my script. +Otherwise it would be my script (note .html) + + +Default: 'pdf,txt,doc,rtf,xls,php,zip,rar,7z,html,gz' + + +------------------------------------------------------------------------------ +*g:vimwiki_valid_html_tags* + +Comma separated list of html tags that can be used in vimwiki. + +Default: 'b,i,s,u,sub,sup,kbd,br,hr' + + +------------------------------------------------------------------------------ +*g:vimwiki_conceallevel* + +In vim73 |conceallevel| is local to window, thus if you open viwmiki buffer in +a new tab or window, it would be set to default value. + +Vimwiki sets |conceallevel| to g:vimwiki_conceallevel everytime vimwiki buffer +is entered. + +Default: 3 + + ============================================================================== 12. Help *vimwiki-help* -As you could see I am not native English speaker (not a writer as well). -Please send me correct phrases instead of that incorrect stuff I have used -here. +Your help in making vimwiki better is really appreciated! +Any help. Would it be spell correction or code snippet to patch -- everything +is welcomed. + +Issues could be filled in at http://code.google.com/p/vimwiki/issues . -Any help is really appreciated! ============================================================================== -13. Author *vimwiki-author* +13. Developers *vimwiki-developers* -I live in Moscow and you may believe me -- there are no polar bears (no brown -too) here in the streets. + - Maxim Kim + Original author. + - Mikhail Trishchenkov + Joined in at Dec 2009. -I do not do programming for a living. So don't blame me for an ugly -ineffective code. Improvements are welcome. +Vimwiki's website: http://code.google.com/p/vimwiki/ +Vim plugins website: http://www.vim.org/scripts/script.php?script_id=2226 + +... afterword Many thanks to all of you for voting vimwiki up on www.vim.org. I do vimwiki in my spare time I could use to dance argentine tango with beautiful women. Your votes are kind of a good replacement. ;) Sincerely yours, -Maxim Kim . +Maxim Kim. -Vimwiki's website: http://code.google.com/p/vimwiki/ -Vim plugins website: http://www.vim.org/scripts/script.php?script_id=2226 ============================================================================== 14. Changelog *vimwiki-changelog* +1.1~ + * NEW: Issue 57: Make it possible to have pre block inside list item. + * NEW: Issue 82: Add quick goto command. See |:VimwikiGoto|. + * NEW: Issue 83: Quick switch in diary. See |:VimwikiDiaryNextDay| and + |:VimwikiDiaryPrevDay| commands. + * FIX: Issue 84: Vimwiki rename removed the WikiWord display name. + * FIX: Issue 85: Errors if you have '~' subdirectory in a wiki directory. + * FIX: Issue 86: Existed links '[[WikiLink1|Alias1]] | [[WikiLink2]]' are + highlighted as a single link. + * FIX: Issue 88: Underline text. See |g:vimwiki_valid_html_tags|. + * FIX: Issue 92: Wikies in a subdir could be renamed to an empty file. + * FIX: Issue 93: Use alias name in html title. See |vimwiki-title|. + * FIX: Issue 94: Relative links to PHP files are broken. See + |g:vimwiki_file_exts| for details. + * FIX: Issue 96: Closing bracket at the end of weblink shouldn't be a part + of that link. + * FIX: Issue 97: Error opening weblink in a browser if it has # inside. + * FIX: Issue 99: Vim is not responing while opening arbitrary wiki file. + * FIX: Issue 100: Additional content on diary index page could be + corrupted. + * NEW: Issue 101: Customized HTML tags. See |g:vimwiki_valid_html_tags| + * NEW: Issue 102: Conceal feature usage. See |g:vimwiki_conceallevel|. + * FIX: Issue 103: Always highlight links to non-wiki files as existed. + * FIX: Issue 104: vimwiki#nested_syntax needs 'keepend' to avoid contained + language syntax eat needed '}}}'. + * FIX: Issue 105: on a todo list item with [ ] doesn't create new + todo list item. + * FIX: Issue 106: With MediaWiki syntax on a child todo list + item produce errors. + * FIX: Issue 107: With MediaWiki syntax on a list item creates + todo list item without space between * and [ ]. + * FIX: Issue 110: Syntax highlighting doesn't work for indented codeblock. + * FIX: Issue 115: Nested Perl syntax highlighting differs from regular + one. + * MISC: Many vimwiki commands were renamed from Vimwiki.*Word to + Vimwiki.*Link. VimwikiGoHome is renamed to VimwikiIndex, + VimwikiTabGoHome to VimwikiTabIndex. + * MISC: vimwiki-option-gohome is removed. + +1.0~ + * NEW: Issue 41: Table cell and column text objects. See + |vimwiki-text-objects|. + * NEW: Issue 42: Commands to move table columns left and right. See + |:VimwikiTableMoveColumnLeft| and |:VimwikiTableMoveColumnRight|. + * NEW: Issue 44: should move cursor to the previous table cell. + * NEW: Issue 45: It should be possible to indent tables. Indented tables + are centered in html. + * NEW: Issue 46: Do not htmlize some wiki pages (blacklist). New + placeholder is added: %nohtml. See |vimwiki-nohtml|. + * FIX: Issue 47: Lists aren't HTMLized properly. + * FIX: Issue 48: With autochdir it is impossible to have path_html such as + 'd:\vimwiki\html\' + * FIX: Issue 49: Table is not HTMLized properly at the end of wiki page. + * FIX: Issue 50: Inline formatting is not performed in table cells. + * FIX: Issue 51: Cannot insert '-' (minus) into table cells of the first + column. + * FIX: Issue 52: Table cell width is incorrect when double wide characters + are used (ie. Chinese). Check |g:vimwiki_CJK_length|. + * NEW: Issue 53: Wiki markup can not nested. (Use links and inline markup + in Headers). + * NEW: Issue 54: Highlight for placeholders. + * NEW: Issue 56: Directory indexes. See |g:vimwiki_dir_link| option and + |:VimwikiGenerateLinks| command. + * NEW: Issue 58: Html new lines with
    . Could be inserted with + in insert mode. + * FIX: Issue 59: List item's text can't be started from *. + * NEW: Issue 60: Links inside completed gtd-items. + * NEW: Issue 61: Headers numbering. See |g:vimwiki_html_header_numbering| + and |g:vimwiki_html_header_numbering_sym| options. + * FIX: Issue 63: Table cannot have leading empty cells in html. + * FIX: Issue 65: Table separator is not htmlized right if on top of the + table. + * FIX: Issue 66: Table empty cells are very small in html. + * FIX: Issue 67: Wrong html conversion of multilined list item with bold + text on the start of next line. + * FIX: Issue 68: auto-indent problem with langmap. + * FIX: Issue 73: Link navigation by Tab. "Escaped" wiki-word should be + skipped for navigation with . + * FIX: Issue 75: `code` syntax doesn't display correctly in toc. + * FIX: Issue 77: Diary index only showing link to today's diary entry + file for extensions other than '.wiki'. + * FIX: Issue 79: Further calendar.vim integration -- add sign to calendar + date if it has corresponding diary page. + * FIX: Issue 80: Debian Lenny GUI Vim 7.2 has problems with toggling inner + todo list items. + * FIX: Issue 81: Don't convert WikiWord as a link in html when + `let g:vimwiki_camel_case = 0` + 0.9.9~ * NEW: Diary. Help in making daily notes. See |vimwiki-diary|. Now you can really easy add information into vimwiki that should be sorted out @@ -1819,7 +2114,7 @@ Vim plugins website: http://www.vim.org/scripts/script.php?script_id=2226 The MIT Licence http://www.opensource.org/licenses/mit-license.php -Copyright (c) 2010 Maxim Kim +Copyright (c) 2008-2010 Maxim Kim Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/ftplugin/vimwiki.vim b/ftplugin/vimwiki.vim index edda29f..be97b29 100644 --- a/ftplugin/vimwiki.vim +++ b/ftplugin/vimwiki.vim @@ -1,3 +1,4 @@ +" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79 " Vimwiki filetype plugin file " Author: Maxim Kim " Home: http://code.google.com/p/vimwiki/ @@ -20,6 +21,11 @@ let b:undo_ftplugin = "setlocal ". setlocal autowriteall setlocal commentstring= + +if g:vimwiki_conceallevel && exists("+conceallevel") + let &conceallevel = g:vimwiki_conceallevel +endif + " MISC }}} " GOTO FILE: gf {{{ @@ -37,19 +43,22 @@ else endif setlocal formatoptions=tnro -inoremap vimwiki_lst#insertCR() -nnoremap o :call vimwiki_lst#insertOo('o')a -nnoremap O :call vimwiki_lst#insertOo('O')a +if !empty(&langmap) + " Valid only if langmap is a comma separated pairs of chars + let l_o = matchstr(&langmap, '\C,\zs.\zeo,') + if l_o + exe 'nnoremap '.l_o.' :call vimwiki_lst#kbd_oO("o")a' + endif + + let l_O = matchstr(&langmap, '\C,\zs.\zeO,') + if l_O + exe 'nnoremap '.l_O.' :call vimwiki_lst#kbd_oO("O")a' + endif +endif " COMMENTS }}} " FOLDING for headers and list items using expr fold method. {{{ -if g:vimwiki_folding == 1 - setlocal fdm=expr - setlocal foldexpr=VimwikiFoldLevel(v:lnum) - setlocal foldtext=VimwikiFoldText() -endif - function! VimwikiFoldLevel(lnum) "{{{ let line = getline(a:lnum) @@ -194,27 +203,37 @@ command! -buffer Vimwiki2HTML command! -buffer VimwikiAll2HTML \ call vimwiki_html#WikiAll2HTML(expand(VimwikiGet('path_html'))) -command! -buffer VimwikiNextWord call vimwiki#WikiNextWord() -command! -buffer VimwikiPrevWord call vimwiki#WikiPrevWord() -command! -buffer VimwikiDeleteWord call vimwiki#WikiDeleteWord() -command! -buffer VimwikiRenameWord call vimwiki#WikiRenameWord() -command! -buffer VimwikiFollowWord call vimwiki#WikiFollowWord('nosplit') -command! -buffer VimwikiGoBackWord call vimwiki#WikiGoBackWord() -command! -buffer VimwikiSplitWord call vimwiki#WikiFollowWord('split') -command! -buffer VimwikiVSplitWord call vimwiki#WikiFollowWord('vsplit') +command! -buffer VimwikiNextLink call vimwiki#find_next_link() +command! -buffer VimwikiPrevLink call vimwiki#find_prev_link() +command! -buffer VimwikiDeleteLink call vimwiki#delete_link() +command! -buffer VimwikiRenameLink call vimwiki#rename_link() +command! -buffer VimwikiFollowLink call vimwiki#follow_link('nosplit') +command! -buffer VimwikiGoBackLink call vimwiki#go_back_link() +command! -buffer VimwikiSplitLink call vimwiki#follow_link('split') +command! -buffer VimwikiVSplitLink call vimwiki#follow_link('vsplit') command! -buffer -range VimwikiToggleListItem call vimwiki_lst#ToggleListItem(, ) +command! -buffer VimwikiGenerateLinks call vimwiki#generate_links() + exe 'command! -buffer -nargs=* VimwikiSearch vimgrep '. \ escape(VimwikiGet('path').'**/*'.VimwikiGet('ext'), ' ') exe 'command! -buffer -nargs=* VWS vimgrep '. \ escape(VimwikiGet('path').'**/*'.VimwikiGet('ext'), ' ') +command! -buffer -nargs=1 VimwikiGoto call vimwiki#goto("") + " table commands command! -buffer -nargs=* VimwikiTable call vimwiki_tbl#create() command! -buffer VimwikiTableAlignQ call vimwiki_tbl#align_or_cmd('gqq') command! -buffer VimwikiTableAlignW call vimwiki_tbl#align_or_cmd('gww') +command! -buffer VimwikiTableMoveColumnLeft call vimwiki_tbl#move_column_left() +command! -buffer VimwikiTableMoveColumnRight call vimwiki_tbl#move_column_right() + +" diary commands +command! -buffer VimwikiDiaryNextDay call vimwiki_diary#goto_next_day() +command! -buffer VimwikiDiaryPrevDay call vimwiki_diary#goto_prev_day() " COMMANDS }}} @@ -222,59 +241,59 @@ command! -buffer VimwikiTableAlignW call vimwiki_tbl#align_or_cmd('gww') if g:vimwiki_use_mouse nmap nmap - noremap <2-LeftMouse> :VimwikiFollowWord - noremap :VimwikiSplitWord - noremap :VimwikiVSplitWord - noremap :VimwikiGoBackWord + noremap <2-LeftMouse> :VimwikiFollowLink + noremap :VimwikiSplitLink + noremap :VimwikiVSplitLink + noremap :VimwikiGoBackLink endif -if !hasmapto('VimwikiFollowWord') - nmap VimwikiFollowWord +if !hasmapto('VimwikiFollowLink') + nmap VimwikiFollowLink endif noremap