" Vimball Archiver by Charles E. Campbell, Jr., Ph.D.
UseVimball
finish
doc\vimwiki.txt [[[1
1082
*vimwiki.txt* A Personal Wiki for Vim
__ __ ______ __ __ ______ __ __ ______ ~
/\ \/\ \/\__ _\ /'\_/`\/\ \ __/\ \/\__ _\ /\ \/\ \ /\__ _\ ~
\ \ \ \ \/_/\ \/ /\ \ \ \/\ \ \ \/_/\ \/ \ \ \/'/'\/_/\ \/ ~
\ \ \ \ \ \ \ \ \ \ \__\ \ \ \ \ \ \ \ \ \ \ \ \ , < \ \ \ ~
\ \ \_/ \ \_\ \__\ \ \_/\ \ \ \_/ \_\ \ \_\ \__\ \ \\`\ \_\ \__ ~
\ `\___/ /\_____\\ \_\\ \_\ `\___x___/ /\_____\\ \_\ \_\ /\_____\~
`\/__/ \/_____/ \/_/ \/_/'\/__//__/ \/_____/ \/_/\/_/ \/_____/~
Version: 0.9.2a ~
==============================================================================
CONTENTS *vimwiki-contents*
1. Intro ...................................|vimwiki|
2. Prerequisites ...........................|vimwiki-prerequisites|
3. Mappings ................................|vimwiki-mappings|
3.1. Global mappings .....................|vimwiki-global-mappings|
3.2. Local mappings ......................|vimwiki-local-mappings|
3.3. Text objects ........................|vimwiki-text-objects|
4. Commands ................................|vimwiki-commands|
4.1. Global commands .....................|vimwiki-global-commands|
4.2. Local commands ......................|vimwiki-local-commands|
5. Wiki syntax .............................|vimwiki-syntax|
5.1. Typefaces ...........................|vimwiki-syntax-typefaces|
5.2. Links ...............................|vimwiki-syntax-links|
5.3. Headers .............................|vimwiki-syntax-headers|
5.4. Paragraphs...........................|vimwiki-syntax-paragraphs|
5.5. Lists ...............................|vimwiki-syntax-lists|
5.6. Tables ..............................|vimwiki-syntax-tables|
5.7. Preformatted text ...................|vimwiki-syntax-preformatted|
5.8. Comments ............................|vimwiki-syntax-comment|
6. Folding/Outline .........................|vimwiki-folding|
7. Todo lists...............................|vimwiki-todo-lists|
8. Options .................................|vimwiki-options|
9. Help ....................................|vimwiki-help|
10. Known issues ...........................|vimwiki-issues|
11. Author .................................|vimwiki-author|
12. Changelog ..............................|vimwiki-changelog|
13. License ................................|vimwiki-license|
==============================================================================
1. Intro *vimwiki*
Vimwiki is a personal wiki for Vim. Using it you can organize text files with
hyperlinks. To do a quick start press ww (this is usually \ww) to go
to your index wiki file. By default it is located in: >
~/vimwiki/index.wiki
You do not have to create it manually -- vimwiki can make it for you.
Feed it with the following example:
= My knowledge base =
* MyUrgentTasks -- things to be done _yesterday_!!!
* ProjectGutenberg -- good books are power.
* MusicILike, MusicIHate.
Notice that ProjectGutenberg, MyUrgentTasks, MusicILike and MusicIHate
highlighted as errors. These WikiWords (WikiWord or WikiPage -- capitalized
word connected with other capitalized words) do not exist yet.
Place cursor on ProjectGutenberg and press Enter. Now you are in
ProjectGutenberg. Edit and save it, then press Backspace to return to previous
WikiPage. You should see the difference in highlighting now.
Now it is your turn...
==============================================================================
2. Prerequisites *vimwiki-prerequisites*
Make sure you have these settings in your vimrc file: >
set nocompatible
filetype plugin on
syntax on
Without them Vimwiki will not work properly.
==============================================================================
3. Mappings *vimwiki-mappings*
There are global and local mappings in vimwiki.
------------------------------------------------------------------------------
3.1. Global mappings *vimwiki-global-mappings*
ww or VimwikiGoHome
Open index file of the [count]'s wiki.
ww opens first wiki from |g:vimwiki_list|.
1ww as above opens first wiki from |g:vimwiki_list|.
2ww opens second wiki from |g:vimwiki_list|.
3ww opens third wiki from |g:vimwiki_list|.
etc.
To remap: >
:map w VimwikiGoHome
<
See also|:VimwikiGoHome|
wt or VimwikiTabGoHome
Open index file of the [count]'s wiki in a new tab.
ww tabopens first wiki from |g:vimwiki_list|.
1ww as above tabopens first wiki from |g:vimwiki_list|.
2ww tabopens second wiki from |g:vimwiki_list|.
3ww tabopens third wiki from |g:vimwiki_list|.
etc.
To remap: >
:map t VimwikiTabGoHome
<
See also|:VimwikiTabGoHome|
ws or VimwikiUISelect
List and select available wikies.
To remap: >
:map wq VimwikiUISelect
<
See also|:VimwikiUISelect|
------------------------------------------------------------------------------
3.2. Local mappings *vimwiki-local-mappings*
Normal mode (Keyboard):~
*vimwiki_*
Follow/Create WikiWord.
Maps to|:VimwikiFollowWord|.
To remap: >
:map wf VimwikiFollowWord
<
*vimwiki_*
Split and follow/create WikiWord
Maps to|:VimwikiSplitWord|.
To remap: >
:map we VimwikiSplitWord
<
*vimwiki_*
Vertical split and follow/create WikiWord
Maps to|:VimwikiVSplitWord|.
To remap: >
:map wq VimwikiVSplitWord
<
*vimwiki_*
Go back to previous WikiWord
Maps to|:VimwikiGoBackWord|.
To remap: >
:map wb VimwikiGoBackWord
<
*vimwiki_*
Find next WikiWord
Maps to|:VimwikiNextWord|.
To remap: >
:map wn VimwikiNextWord
<
*vimwiki_*
Find previous WikiWord
Maps to|:VimwikiPrevWord|.
To remap: >
:map wp VimwikiPrevWord
<
*vimwiki_wd*
wd Delete WikiWord you are in.
Maps to|:VimwikiDeleteWord|.
To remap: >
:map dd VimwikiDeleteWord
<
*vimwiki_wr*
wr Rename WikiWord you are in.
Maps to|:VimwikiRenameWord|.
To remap: >
:map rr VimwikiRenameWord
<
*vimwiki_*
Toggle list item on/off (checked/unchecked)
Maps to|:VimwikiToggleListItem|.
To remap: >
:map tt VimwikiToggleListItem
< See |vimwiki-todo-lists|.
*vimwiki_=*
= Add header level. Create if needed.
There is nothing to indent with '==' command in
vimwiki, so it should be ok to use '=' here.
*vimwiki_-*
- Remove header level.
Normal mode (Mouse): ~
Works only if |g:vimwiki_use_mouse| is set to 1.
<2-LeftMouse> Follow/Create WikiWord
Split and follow/create WikiWord
Vertical split and follow/create WikiWord
Go back to previous WikiWord
Note: <2-LeftMouse> is just left double click.
------------------------------------------------------------------------------
3.3. Text objects *vimwiki-text-objects*
ah A Header with leading empty lines.
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. ;)
==============================================================================
4. Commands *vimwiki-commands*
------------------------------------------------------------------------------
4.1. Global Commands *vimwiki-global-commands*
*:VimwikiGoHome*
Open index file of the current wiki.
*:VimwikiTabGoHome*
Open index file of the current wiki in a new tab.
*:VimwikiUISelect*
Open index file of the selected wiki.
------------------------------------------------------------------------------
4.2. Local commands *vimwiki-local-commands*
*:VimwikiFollowWord*
Follow/create WikiWord.
*:VimwikiGoBackWord*
Go back to previous WikiWord you come from.
*:VimwikiSplitWord*
Split and follow/create WikiWord.
*:VimwikiVSplitWord*
Vertical split and follow/create WikiWord.
*:VimwikiNextWord*
Find next WikiWord.
*:VimwikiPrevWord*
Find previous WikiWord.
*:VimwikiDeleteWord*
Delete WikiWord you are in.
*:VimwikiRenameWord*
Rename WikiWord you are in.
*:Vimwiki2HTML*
Convert current WikiPage to HTML.
*:VimwikiAll2HTML*
Convert all WikiPages to HTML.
*:VimwikiToggleListItem*
Toggle list item on/off (checked/unchecked)
See |vimwiki-todo-lists|.
==============================================================================
5. Wiki syntax *vimwiki-syntax*
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).
See |vimwiki-option-syntax|.
------------------------------------------------------------------------------
5.1. Typefaces *vimwiki-syntax-typefaces*
There are a few typefaces that gives you a bit of control on how your
text should be decorated: >
*bold text*
_italic text_
~~strikeout text~~
`code (no syntax) text`
super^script^
sub,,script,,
------------------------------------------------------------------------------
5.2. Links *vimwiki-syntax-links*
Internal links~
WikiWords: >
CapitalizedWordsConnected
You can limit linking of WikiWords by adding an exclamation mark in front of
it: >
!CapitalizedWordsConnected
Link with spaces in it: >
[[This is a link]]
or: >
[[This is a link source|Description of the link]]
External links~
Plain link: >
http://code.google.com/p/vimwiki
Link with description: >
[http://habamax.ru/blog habamax home page]
Images and image links~
Image link is the link with one of jpg, png or gif endings.
Plain image link: >
http://someaddr.com/picture.jpg
in html: >
Link to a local image: >
[[images/pabloymoira.jpg]]
in html: >
Path to image (ie. images/pabloymoira.jpg) is relative to
|vimwiki-option-path_html|.
Double bracketed link to an image: >
[[http://habamax.ru/blog/wp-content/uploads/2009/01/2740254sm.jpg]]
in html: >
Double bracketed link to an image with description text: >
[[http://habamax.ru/blog/wp-content/uploads/2009/01/2740254sm.jpg|dance]]
in html: >
dance
Double bracketed link to an image with alternate text: >
[[http://habamax.ru/blog/wp-content/uploads/2009/01/2740254sm.jpg|dance|]]
in html: >
Double bracketed link to an image with alternate text and some style: >
[[http://helloworld.com/blabla.jpg|cool stuff|width:150px; height: 120px;]]
in html: >
Double bracketed link to an image without alternate text and some style: >
[[http://helloworld.com/blabla.jpg||width:150px; height: 120px;]]
in html: >
Thumbnail link: >
[http://someaddr.com/bigpicture.jpg http://someaddr.com/thumbnail.jpg]
or >
[[http://someaddr.com/bigpicture.jpg|http://someaddr.com/thumbnail.jpg]]
in html: >
Tyger! Tyger! burning bright
In the forests of the night,
What immortal hand or eye
Could frame thy fearful symmetry?
In what distant deeps or skies
Burnt the fire of thine eyes?
On what wings dare he aspire?
What the hand dare sieze the fire?
...
...
Or use {{{ and }}} to define pre:
{{{ >
Tyger! Tyger! burning bright
In the forests of the night,
What immortal hand or eye
Could frame thy fearful symmetry?
In what distant deeps or skies
Burnt the fire of thine eyes?
On what wings dare he aspire?
What the hand dare sieze the fire?
}}}
You can add optional information to {{{ tag: >
{{{class="brush: python" >
def hello(world):
for x in range(10):
print("Hello {0} number {1}".format(world, x))
}}}
Result of HTML export: >
")
return 0
endif
return a:para
endfunction "}}}
function! s:close_tag_table(table, ldest) "{{{
if a:table
call insert(a:ldest, "")
return 0
endif
return a:table
endfunction "}}}
function! s:close_tag_list(lists, ldest) "{{{
while len(a:lists)
let item = remove(a:lists, -1)
call insert(a:ldest, item[0])
endwhile
endfunction! "}}}
function! s:close_tag_def_list(deflist, ldest) "{{{
if a:deflist
call insert(a:ldest, "")
return 0
endif
return a:deflist
endfunction! "}}}
function! s:process_tag_pre_cl(line, code) "{{{
let lines = []
let code = a:code
let processed = 0
if !code && a:line =~ '{{{[^\(}}}\)]*\s*$'
let class = matchstr(a:line, '{{{\zs.*$')
let class = substitute(class, '\s\+$', '', 'g')
if class != ""
call add(lines, "
")
else
call add(lines, "
")
endif
let code = 1
let processed = 1
elseif code && a:line =~ '^}}}\s*$'
let code = 0
call add(lines, "
")
let processed = 1
elseif code
let processed = 1
call add(lines, a:line)
endif
return [processed, lines, code]
endfunction "}}}
function! s:process_tag_pre(line, pre) "{{{
let lines = []
let pre = a:pre
let processed = 0
if a:line =~ '^\s\+[^[:blank:]*#]'
if !pre
call add(lines, "
")
let pre = 1
endif
let processed = 1
call add(lines, a:line)
elseif pre && a:line =~ '^\s*$'
let processed = 1
call add(lines, a:line)
elseif pre
call add(lines, "
")
let pre = 0
endif
return [processed, lines, pre]
endfunction "}}}
function! s:process_tag_list(line, lists) "{{{
let lines = []
let lstSym = ''
let lstTagOpen = ''
let lstTagClose = ''
let lstRegExp = ''
let processed = 0
if a:line =~ '^\s\+\*'
let lstSym = '*'
let lstTagOpen = '
'
let lstTagClose = '
'
let lstRegExp = '^\s\+\*'
let processed = 1
elseif a:line =~ '^\s\+#'
let lstSym = '#'
let lstTagOpen = ''
let lstTagClose = ''
let lstRegExp = '^\s\+#'
let processed = 1
endif
if lstSym != ''
let indent = stridx(a:line, lstSym)
let cnt = len(a:lists)
if !cnt || (cnt && indent > a:lists[-1][1])
call add(a:lists, [lstTagClose, indent])
call add(lines, lstTagOpen)
elseif (cnt && indent < a:lists[-1][1])
while indent < a:lists[-1][1]
let item = remove(a:lists, -1)
call add(lines, item[0])
endwhile
endif
let st_tag = '
'
let en_tag = '
'
let checkbox = '\s*\[\(.\?\)]'
" apply strikethrough for checked list items
if a:line =~ '^\s\+\%(\*\|#\)\s*\[x]'
let st_tag .= ''
let en_tag = ''.en_tag
endif
let chk = matchlist(a:line, lstRegExp.checkbox)
if len(chk) > 0
if chk[1] == 'x'
let st_tag .= ''
else
let st_tag .= ''
endif
endif
call add(lines, st_tag.
\ substitute(a:line, lstRegExp.'\%('.checkbox.'\)\?', '', '').
\ en_tag)
else
while len(a:lists)
let item = remove(a:lists, -1)
call add(lines, item[0])
endwhile
endif
return [processed, lines]
endfunction "}}}
function! s:process_tag_def_list(line, deflist) "{{{
let lines = []
let deflist = a:deflist
let processed = 0
let matches = matchlist(a:line, '\(^.*\)::\%(\s\|$\)\(.*\)')
if !deflist && len(matches) > 0
call add(lines, "
")
let deflist = 1
endif
if deflist && len(matches) > 0
if matches[1] != ''
call add(lines, "
".matches[1]."
")
endif
if matches[2] != ''
call add(lines, "
".matches[2]."
")
endif
let processed = 1
elseif deflist
let deflist = 0
call add(lines, "
")
endif
return [processed, lines, deflist]
endfunction "}}}
function! s:process_tag_para(line, para) "{{{
let lines = []
let para = a:para
let processed = 0
if a:line =~ '^\S'
if !para
call add(lines, "
")
let para = 1
endif
let processed = 1
call add(lines, a:line)
elseif para && a:line =~ '^\s*$'
call add(lines, "
")
let para = 0
endif
return [processed, lines, para]
endfunction "}}}
function! s:process_tag_h(line) "{{{
let line = a:line
let processed = 0
let h_level = 0
if a:line =~ g:vimwiki_rxH6
let h_level = 6
elseif a:line =~ g:vimwiki_rxH5
let h_level = 5
elseif a:line =~ g:vimwiki_rxH4
let h_level = 4
elseif a:line =~ g:vimwiki_rxH3
let h_level = 3
elseif a:line =~ g:vimwiki_rxH2
let h_level = 2
elseif a:line =~ g:vimwiki_rxH1
let h_level = 1
endif
if h_level > 0
" rtrim
let line = substitute(a:line, '\s\+$', '', 'g')
let line = ''.
\ strpart(line, h_level, len(line) - h_level * 2).
\''
let processed = 1
endif
return [processed, line]
endfunction "}}}
function! s:process_tag_hr(line) "{{{
let line = a:line
let processed = 0
if a:line =~ '^-----*$'
let line = ''
let processed = 1
endif
return [processed, line]
endfunction "}}}
function! s:process_tag_table(line, table) "{{{
let table = a:table
let lines = []
let processed = 0
if a:line =~ '^||.\+||.*'
if !table
call add(lines, "
")
let table = 1
endif
let processed = 1
call add(lines, "
")
let pos1 = 0
let pos2 = 0
let done = 0
while !done
let pos1 = stridx(a:line, '||', pos2)
let pos2 = stridx(a:line, '||', pos1+2)
if pos1==-1 || pos2==-1
let done = 1
let pos2 = len(a:line)
endif
let line = strpart(a:line, pos1+2, pos2-pos1-2)
if line == ''
continue
endif
if strpart(line, 0, 1) == ' ' &&
\ strpart(line, len(line) - 1, 1) == ' '
call add(lines, '
")
let table = 0
endif
return [processed, lines, table]
endfunction "}}}
function! s:process_tags(line) "{{{
let line = a:line
let line = s:make_tag(line, '\[\[.\{-}\]\]',
\ '', '', 2, 's:make_internal_link')
let line = s:make_tag(line, '\[.\{-}\]', '', '', 1, 's:make_external_link')
let line = s:make_tag(line, g:vimwiki_rxWeblink,
\ '', '', 0, 's:make_barebone_link')
let line = s:make_tag(line, '!\?'.g:vimwiki_rxWikiWord,
\ '', '', 0, 's:make_wikiword_link')
let line = s:make_tag(line, g:vimwiki_rxItalic, '', '')
let line = s:make_tag(line, g:vimwiki_rxBold, '', '')
" let line = s:make_tag(line, g:vimwiki_rxItalic, '', '')
let line = s:make_tag(line, g:vimwiki_rxTodo,
\ '', '', 0)
let line = s:make_tag(line, g:vimwiki_rxDelText,
\ '', '', 2)
let line = s:make_tag(line, g:vimwiki_rxSuperScript,
\ '', '', 1)
let line = s:make_tag(line, g:vimwiki_rxSubScript,
\ '', '', 2)
let line = s:make_tag(line, g:vimwiki_rxCode, '', '')
" TODO: change make_tag function: delete cSym parameter -- count of symbols
" to strip from 2 sides of tag. Add 2 new instead -- OpenWikiTag length
" and CloseWikiTag length as for preformatted text there could be {{{,}}}
" and
,
.
let line = s:make_tag(line, g:vimwiki_rxPreStart.'.\+'.g:vimwiki_rxPreEnd,
\ '', '', 3)
return line
endfunction " }}}
function! s:safe_html(line) "{{{
"" change dangerous html symbols: < > &
let line = substitute(a:line, '&', '\&', 'g')
let line = substitute(line, '<', '\<', 'g')
let line = substitute(line, '>', '\>', 'g')
return line
endfunction "}}}
function! s:make_tag_helper(line, regexp_match,
\ tagOpen, tagClose, cSymRemove, func) " {{{
"" Substitute text found by regexp_match with tagOpen.regexp_subst.tagClose
let pos = 0
let lines = split(a:line, a:regexp_match, 1)
let res_line = ""
for line in lines
let res_line = res_line.line
let matched = matchstr(a:line, a:regexp_match, pos)
if matched != ""
let toReplace = strpart(matched,
\ a:cSymRemove, len(matched) - 2 * a:cSymRemove)
if a:func!=""
let toReplace = {a:func}(toReplace)
else
let toReplace = a:tagOpen.toReplace.a:tagClose
endif
let res_line = res_line.toReplace
endif
let pos = matchend(a:line, a:regexp_match, pos)
endfor
return res_line
endfunction " }}}
function! s:make_tag(line, regexp_match, tagOpen, tagClose, ...) " {{{
"" Make tags only if not in ` ... `
"" ... should be function that process regexp_match deeper.
"check if additional function exists
let func = ""
let cSym = 1
if a:0 == 2
let cSym = a:1
let func = a:2
elseif a:0 == 1
let cSym = a:1
endif
let patt_splitter = '\(`[^`]\+`\)\|\({{{.\+}}}\)\|'.
\ '\(\)\|\(\)'
if '`[^`]\+`' == a:regexp_match || '{{{.\+}}}' == a:regexp_match
let res_line = s:make_tag_helper(a:line, a:regexp_match,
\ a:tagOpen, a:tagClose, cSym, func)
else
let pos = 0
" split line with patt_splitter to have parts of line before and after
" href links, preformatted text
" ie:
" hello world `is just a` simple type of prg.
" result:
" ['hello world ', ' simple ', 'type of', ' prg']
let lines = split(a:line, patt_splitter, 1)
let res_line = ""
for line in lines
let res_line = res_line.s:make_tag_helper(line, a:regexp_match,
\ a:tagOpen, a:tagClose, cSym, func)
let res_line = res_line.matchstr(a:line, patt_splitter, pos)
let pos = matchend(a:line, patt_splitter, pos)
endfor
endif
return res_line
endfunction " }}}
function! s:make_external_link(entag) "{{{
"" Make link desc
"" from [link link desc]
let line = ''
if s:is_web_link(a:entag)
let lnkElements = split(a:entag)
let head = lnkElements[0]
let rest = join(lnkElements[1:])
if rest==""
let rest=head
endif
if s:is_img_link(rest)
if rest!=head
let line = ''
else
let line = ''
endif
else
let line = ''.rest.''
endif
elseif s:is_img_link(a:entag)
let line = ''
else
" [alskfj sfsf] shouldn't be a link. So return it as it was --
" enclosed in [...]
let line = '['.a:entag.']'
endif
return line
endfunction "}}}
function! s:make_internal_link(entag) "{{{
" Make This is a link
" from [[This is a link]]
" Make This is a link
" from [[link|This is a link]]
" TODO: rename function -- it makes not only internal links.
let line = ''
let link_parts = split(a:entag, "|", 1)
if len(link_parts) > 1
if len(link_parts) < 3
let style = ""
else
let style = link_parts[2]
endif
if s:is_img_link(link_parts[1])
let line = ''
elseif len(link_parts) < 3
let line = ''.link_parts[1].''
elseif s:is_img_link(link_parts[0])
let line = ''
endif
else
if s:is_img_link(a:entag)
let line = ''
elseif s:is_non_wiki_link(link_parts[0])
let line = ''.a:entag.''
else
let line = ''.a:entag.''
endif
endif
return line
endfunction "}}}
function! s:make_wikiword_link(entag) "{{{
" Make WikiWord from WikiWord
" if first symbol is ! then remove it and make no link.
if a:entag[0] == '!'
return a:entag[1:]
else
let line = ''.a:entag.''
return line
endif
endfunction "}}}
function! s:make_barebone_link(entag) "{{{
"" Make http://habamax.ru
"" from http://habamax.ru
if s:is_img_link(a:entag)
let line = ''
else
let line = ''.a:entag.''
endif
return line
endfunction "}}}
function! s:get_html_from_wiki_line(line, para, pre, code,
\ table, lists, deflist) " {{{
let para = a:para
let pre = a:pre
let code = a:code
let table = a:table
let lists = a:lists
let deflist = a:deflist
let res_lines = []
let line = s:safe_html(a:line)
let processed = 0
"" Code
if !processed
let [processed, lines, code] = s:process_tag_pre_cl(line, code)
if processed && len(lists)
call s:close_tag_list(lists, lines)
endif
if processed && table
let table = s:close_tag_table(table, lines)
endif
if processed && deflist
let deflist = s:close_tag_def_list(deflist, lines)
endif
if processed && pre
let pre = s:close_tag_pre(pre, lines)
endif
if processed && para
let para = s:close_tag_para(para, lines)
endif
call extend(res_lines, lines)
endif
"" Pre
if !processed
let [processed, lines, pre] = s:process_tag_pre(line, pre)
if processed && len(lists)
call s:close_tag_list(lists, lines)
endif
if processed && deflist
let deflist = s:close_tag_def_list(deflist, lines)
endif
if processed && table
let table = s:close_tag_table(table, lines)
endif
if processed && code
let code = s:close_tag_code(code, lines)
endif
if processed && para
let para = s:close_tag_para(para, lines)
endif
call extend(res_lines, lines)
endif
"" list
if !processed
let [processed, lines] = s:process_tag_list(line, lists)
if processed && pre
let pre = s:close_tag_pre(pre, lines)
endif
if processed && code
let code = s:close_tag_code(code, lines)
endif
if processed && table
let table = s:close_tag_table(table, lines)
endif
if processed && deflist
let deflist = s:close_tag_def_list(deflist, lines)
endif
if processed && para
let para = s:close_tag_para(para, lines)
endif
call map(lines, 's:process_tags(v:val)')
call extend(res_lines, lines)
endif
"" definition lists
if !processed
let [processed, lines, deflist] = s:process_tag_def_list(line, deflist)
call map(lines, 's:process_tags(v:val)')
call extend(res_lines, lines)
endif
"" table
if !processed
let [processed, lines, table] = s:process_tag_table(line, table)
call map(lines, 's:process_tags(v:val)')
call extend(res_lines, lines)
endif
if !processed
let [processed, line] = s:process_tag_h(line)
if processed
call s:close_tag_list(lists, res_lines)
let table = s:close_tag_table(table, res_lines)
let code = s:close_tag_code(code, res_lines)
call add(res_lines, line)
endif
endif
if !processed
let [processed, line] = s:process_tag_hr(line)
if processed
call s:close_tag_list(lists, res_lines)
let table = s:close_tag_table(table, res_lines)
let code = s:close_tag_code(code, res_lines)
call add(res_lines, line)
endif
endif
"" P
if !processed
let [processed, lines, para] = s:process_tag_para(line, para)
if processed && len(lists)
call s:close_tag_list(lists, lines)
endif
if processed && pre
let pre = s:close_tag_pre(pre, res_lines)
endif
if processed && code
let code = s:close_tag_code(code, res_lines)
endif
if processed && table
let table = s:close_tag_table(table, res_lines)
endif
call map(lines, 's:process_tags(v:val)')
call extend(res_lines, lines)
endif
"" add the rest
if !processed
call add(res_lines, line)
endif
return [res_lines, para, pre, code, table, lists, deflist]
endfunction " }}}
function! s:remove_comments(lines) "{{{
let res = []
let multiline_comment = 0
let idx = 0
while idx < len(a:lines)
let line = a:lines[idx]
let idx += 1
if multiline_comment
let col = matchend(line, '-->',)
if col != -1
let multiline_comment = 0
let line = strpart(line, col)
else
continue
endif
endif
if !multiline_comment && line =~ ''
let line = substitute(line, '', '', 'g')
if line =~ '^\s*$'
continue
endif
endif
if !multiline_comment
let col = match(line, '
" MISC }}}
" GOTO FILE: gf {{{
execute 'setlocal suffixesadd='.VimwikiGet('ext')
setlocal isfname-=[,]
" gf}}}
" COMMENTS: autocreate list items {{{
" for list items, and list items with checkboxes
if VimwikiGet('syntax') == 'default'
setl comments=b:\ *\ [\ ],b:\ *[\ ],b:\ *\ [],b:\ *[],b:\ *\ [x],b:\ *[x]
setl comments+=b:\ #\ [\ ],b:\ #[\ ],b:\ #\ [],b:\ #[],b:\ #\ [x],b:\ #[x]
setl comments+=b:\ *,b:\ #
else
setl comments=n:*\ [\ ],n:*[\ ],n:*\ [],n:*[],n:*\ [x],n:*[x]
setl comments+=n:#\ [\ ],n:#[\ ],n:#\ [],n:#[],n:#\ [x],n:#[x]
setl comments+=n:*,n:#
endif
setlocal formatoptions=ctnqro
" COMMENTS }}}
" FOLDING for headers and list items using expr fold method. {{{
if VimwikiGet('folding')
setlocal fdm=expr
endif
setlocal foldexpr=VimwikiFoldLevel(v:lnum)
function! VimwikiFoldLevel(lnum) "{{{
let line = getline(a:lnum)
let nline = getline(a:lnum + 1)
" Header folding...
if line =~ g:vimwiki_rxHeader
let n = vimwiki#count_first_sym(line)
return '>' . n
endif
" List item folding...
let nnum = a:lnum + 1
let rx_list_item = '\('.
\ g:vimwiki_rxListBullet.'\|'.g:vimwiki_rxListNumber.
\ '\)'
if line =~ rx_list_item && nline =~ rx_list_item
return s:get_li_level(a:lnum, nnum)
" list is over, remove foldlevel
elseif line =~ rx_list_item && nline !~ rx_list_item
return s:get_li_level_last(a:lnum)
endif
return '='
endfunction "}}}
function! s:get_li_level(lnum, nnum) "{{{
if VimwikiGet('syntax') == 'media'
let level = s:count_first_sym(getline(a:nnum)) -
\ s:count_first_sym(getline(a:lnum))
if level > 0
return "a".level
elseif level < 0
return "s".abs(level)
else
return "="
endif
else
let level = ((indent(a:nnum) - indent(a:lnum)) / &sw)
if level > 0
return "a".level
elseif level < 0
return "s".abs(level)
else
return "="
endif
endif
endfunction "}}}
function! s:get_li_level_last(lnum) "{{{
if VimwikiGet('syntax') == 'media'
return "s".(s:count_first_sym(getline(a:lnum)) - 1)
else
return "s".(indent(a:lnum) / &sw - 1)
endif
endfunction "}}}
setlocal foldtext=VimwikiFoldText()
function! VimwikiFoldText() "{{{
let line = getline(v:foldstart)
return line.' ['.(v:foldend - v:foldstart).'] '
endfunction "}}}
" FOLDING }}}
" COMMANDS {{{
command! -buffer Vimwiki2HTML
\ call vimwiki_html#Wiki2HTML(expand(VimwikiGet('path_html')),
\ expand('%'))
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 VimwikiToggleListItem call vimwiki_lst#ToggleListItem()
" COMMANDS }}}
" KEYBINDINGS {{{
if g:vimwiki_use_mouse
nmap
nmap
noremap <2-LeftMouse> :VimwikiFollowWord
noremap :VimwikiSplitWord
noremap :VimwikiVSplitWord
noremap :VimwikiGoBackWord
endif
if !hasmapto('VimwikiFollowWord')
nmap VimwikiFollowWord
endif
noremap