" Vimball Archiver by Charles E. Campbell, Jr., Ph.D. UseVimball finish doc\vimwiki.txt [[[1 970 *vimwiki.txt* A Personal Wiki for Vim __ __ ______ __ __ ______ __ __ ______ ~ /\ \/\ \/\__ _\ /'\_/`\/\ \ __/\ \/\__ _\ /\ \/\ \ /\__ _\ ~ \ \ \ \ \/_/\ \/ /\ \ \ \/\ \ \ \/_/\ \/ \ \ \/'/'\/_/\ \/ ~ \ \ \ \ \ \ \ \ \ \ \__\ \ \ \ \ \ \ \ \ \ \ \ \ , < \ \ \ ~ \ \ \_/ \ \_\ \__\ \ \_/\ \ \ \_/ \_\ \ \_\ \__\ \ \\`\ \_\ \__ ~ \ `\___/ /\_____\\ \_\\ \_\ `\___x___/ /\_____\\ \_\ \_\ /\_____\~ `\/__/ \/_____/ \/_/ \/_/'\/__//__/ \/_____/ \/_/\/_/ \/_____/~ Version: 0.9.1 ~ ============================================================================== CONTENTS *vimwiki-contents* 1. Quick start .............................|vimwiki| 2. Prerequisites ...........................|vimwiki-prerequisites| 3. Mappings ................................|vimwiki-mappings| 3.1. Global mappings .....................|vimwiki-global-mappings| 3.2. Local mappings ......................|vimwiki-local-mappings| 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. Getting Things Done (GTD)................|vimwiki-gtd| 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. Quick start *vimwiki* Vimwiki being a personal wiki for Vim allows you to organize text information using hyper links. 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 (copy&paste without and between ---) : --- = 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 begin to add your own information ... ============================================================================== 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.1. Local mappings *vimwiki-local-mappings* Normal mode (Keyboard):~ Follow/Create WikiWord. Maps to|:VimwikiFollowWord|. To remap: > :map wf VimwikiFollowWord < Split and follow/create WikiWord Maps to|:VimwikiSplitWord|. To remap: > :map we VimwikiSplitWord < Vertical split and follow/create WikiWord Maps to|:VimwikiVSplitWord|. To remap: > :map wq VimwikiVSplitWord < Go back to previous WikiWord Maps to|:VimwikiGoBackWord|. To remap: > :map wb VimwikiGoBackWord < Find next WikiWord Maps to|:VimwikiNextWord|. To remap: > :map wn VimwikiNextWord < Find previous WikiWord Maps to|:VimwikiPrevWord|. To remap: > :map wp VimwikiPrevWord < wd Delete WikiWord you are in. Maps to|:VimwikiDeleteWord|. To remap: > :map dd VimwikiDeleteWord < wr Rename WikiWord you are in. Maps to|:VimwikiRenameWord|. To remap: > :map rr VimwikiRenameWord < Toggle list item on/off (checked/unchecked) Maps to|:VimwikiGTDToggleItem|. To remap: > :map tt VimwikiToggleListItem < See |vimwiki-gtd|. 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. ============================================================================== 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. Note that in order 2HTML commands to work you should set up & create html directory. By default it is g:vimwiki_home/html/ so just go to g:vimwiki_home and create html directory there. *:VimwikiGTDToggleItem* Toggle list item on/off (checked/unchecked) See |vimwiki-gtd|. ============================================================================== 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] Image link is the link with one of jpg, png or gif endings. Plain image link: > http://someaddr.com/picture.jpg Image thumbnail link: > [http://someaddr.com/bigpicture.jpg http://someaddr.com/thumbnail.jpg] Link to local image: > [[images/pabloymoira.jpg|Pablo y Moira]] Path to image (ie. images/pabloymoira.jpg) is relative to |vimwiki-option-path_html|. ------------------------------------------------------------------------------ 5.3. Headers *vimwiki-syntax-headers* = Header level 1 =~ == Header level 2 ==~ === Header level 3 === ==== Header level 4 ==== ===== Header level 5 ===== ====== Header level 6 ====== 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. BACKUP FIRST! To easily change headers from !Header to =Header= in your wiki files use the next commands (\ww first to open your wiki index file): > :args .wiki :argdo %s/^\(!\+\)\([^!].*$\)/\=substitute(submatch(1),'!','=','g').submatch(2).substitute(submatch(1),'!','=','g') < ------------------------------------------------------------------------------ 5.4. Paragraphs *vimwiki-syntax-paragraphs* Paragraph is group of lines started from column 1 (no indentation). Paragraphs divided by a blank line: This is first paragraph with two lines. This is a second paragraph with two lines. ------------------------------------------------------------------------------ 5.5. Lists *vimwiki-syntax-lists* Indent list items with at least one space. Unordered lists: > * Bulleted list item 1 * Bulleted list item 2 * Bulleted list sub item 1 * Bulleted list sub item 2 * more ... * and more ... * ... * Bulleted list sub item 3 * etc. Ordered lists: > # Numbered list item 1 # Numbered list item 2 # Numbered list sub item 1 # Numbered list sub item 2 # more ... # and more ... # ... # Numbered list sub item 3 # etc. It is possible to mix bulleted and numbered lists: > * Bulleted list item 1 * Bulleted list item 2 # Numbered list sub item 1 # Numbered list sub item 2 Definition lists: > Term 1:: Definition 1 Term 2:: ::Definition 2 ::Definition 3 ------------------------------------------------------------------------------ 5.6. Tables *vimwiki-syntax-tables* Tables are created by entering the content of each cell separated by || delimiters. You can insert other inline wiki syntax in table cells, including typeface formatting and links. For example: ||*Year*s||*Temperature (low)*||*Temperature (high)*|| ||1900 ||-10 ||25 || ||1910 ||-15 ||30 || ||1920 ||-10 ||32 || ||1930 ||_N/A_ ||_N/A_ || ||1940 ||-2 ||40 || For HTML, contents of table cell could be aligned to the right, left and center: || Center || Center || Center || ||Left || Center || Right|| || Right||Left || Center || || Center || Right||Left || No spaces on the left side -- left alignment. No spaces on the right side -- right alignment. Spaces on the left and on the right -- center alignment. ------------------------------------------------------------------------------ 5.7. Preformatted text *vimwiki-syntax-preformatted* If the line started from whitespace and is not a list it is "preformatted" text. For example: > 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: >
 def hello(world):
     for x in range(10):
         print("Hello {0} number {1}".format(world, x))
 
This might be useful for coloring some programming code with external js tools like google syntax highlighter. ------------------------------------------------------------------------------ 5.8. Comments *vimwiki-syntax-comments* Text between is a comment. Ex: > < ============================================================================== 6. Folding/Outline *vimwiki-folding* Vimwiki can fold or outline headers and list items. Enable folding with the following command: > :set foldenable > Example: = My current task = * [ ] Do stuff 1 * [ ] Do substuff 1.1 * [ ] Do substuff 1.2 * [ ] Do substuff 1.2.1 * [ ] Do substuff 1.2.2 * [ ] Do substuff 1.3 * [ ] Do stuff 2 * [ ] Do stuff 3 Hit |zM| : = My current task = [8] --------------------------------------~ Hit |zr| : = My current task =~ * [ ] Do stuff 1 [5] --------------------------------------~ * [ ] Do stuff 2~ * [ ] Do stuff 3~ Hit |zr| one more time: = My current task =~ * [ ] Do stuff 1~ * [ ] Do substuff 1.1~ * [ ] Do substuff 1.2 [2] -------------------------------~ * [ ] Do substuff 1.3~ * [ ] Do stuff 2~ * [ ] Do stuff 3~ NOTE: Whether you use default syntax, folding on list items should work properly only if all of them are indented using current |shiftwidth|. For MediaWiki * or # should be in the first column. ============================================================================== 7. Getting Things Done (GTD) *vimwiki-gtd* That is not really a GTD :). But vimwiki can handle "projects" that are just lists of items you can check/uncheck. Consider the following example: = Toggleable list of items = * [x] Toggle list item on/off. * [x] Simple toggling between [ ] and [x]. * [x] All list's subitems should be toggled on/off appropriately. * [x] Toggle child subitems only if current line is list item * [x] Parent list item should be toggled depending on it's child items. * [x] Make numbered list items toggleable too * [x] Add highlighting to list item boxes * [x] Add [ ] to the next created with o, O and list item. Pressing on the first list item will toggle it and all of it's child items. ============================================================================== 8. Options *vimwiki-options* ------------------------------------------------------------------------------ *g:vimwiki_list* Default: default wiki *vimwiki-multiple-wikies* Values: list of options for each wiki. Each item in g:vimwiki_list is a |Dictionary| that holds all customization available for a wiki represented by that item. It is in form of > {'option1': 'value1', 'option2: 'value2', ...} Consider the following example: > let g:vimwiki_list = [{'path': '~/my_site/', 'path_html': '~/public_html/'}] It gives us one wiki located at ~/my_site/ that could be htmlized to ~/public_html/ The next example: > let g:vimwiki_list = [{'path': '~/my_site/', 'path_html': '~/public_html/'}, \ {'path': '~/my_docs/', 'ext': '.mdox'}] gives us 2 wikies, first wiki as in previous example, second one is located in ~/my_docs/ and its files have .mdox extension. Empty |Dictionary| in the g:vimwiki_list is the wiki with default options: > let g:vimwiki_list = [{}, \ {'path': '~/my_docs/', 'ext': '.mdox'}] < *vimwiki-option-path* Key Default value~ path ~/vimwiki/ Description~ Wiki files location: > let g:vimwiki_list = [{'path': '~/my_site/'}] < *vimwiki-option-path_html* Key Default value~ path_html ~/vimwiki_html/ Description~ HTML files converted from wiki files location: > let g:vimwiki_list = [{'path': '~/my_site/', \ 'path_html': '~/my_site_html/'}] If you omit this option path_html would be path - '/' + '_html/': > let g:vimwiki_list = [{'path': '~/okidoki/'}] ie, path_html = '~/okidoki_html/' *vimwiki-option-index* Key Default value~ index index Description~ Name of wiki index file: > let g:vimwiki_list = [{'path': '~/my_site/', 'index': 'main'}] NOTE: Do not add extension. *vimwiki-option-ext* Key Default value~ ext .wiki Description~ Extension of wiki files: > let g:vimwiki_list = [{'path': '~/my_site/', \ 'index': 'main', 'ext': '.document'}] < *vimwiki-option-syntax* Key Default value Values~ syntax default default, media Description~ Wiki syntax. You can use different markup languages (currently default vimwiki and MediaWiki) but only vimwiki's default markup could be converted to HTML at the moment. To use MediaWiki's wiki markup: > let g:vimwiki_list = [{'path': '~/my_site/', 'syntax': 'media'}] < *vimwiki-option-html_header* Key Default value~ html_header Description~ Set up file name for html header template: > let g:vimwiki_list = [{'path': '~/my_site/', \ 'html_header': '~/public_html/header.tpl'}] This header.tpl could look like: > %title%
where %title% is replaced by a wiki page name. *vimwiki-option-html_footer* Key Default value~ html_footer Description~ Set up file name for html footer template: > let g:vimwiki_list = [{'path': '~/my_site/', \ 'html_footer': '~/public_html/footer.tpl'}] This footer.tpl could look like: >
< *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* Key Default value Values~ maxhi 1 0, 1 Description~ Non-existent WikiWord 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. ------------------------------------------------------------------------------ Default: "A-ZА-Я" *g:vimwiki_upper* Values: Upper letters (ranges) This affects WikiWord detection. By default WikiWord detection uses English and Russian letters. You can set up your own: > let g:vimwiki_upper="A-Z" ------------------------------------------------------------------------------ Default: "a-zа-я" *g:vimwiki_lower* Values: Lower letters ranges See |g:vimwiki_upper|: > let g:vimwiki_lower="a-z" ------------------------------------------------------------------------------ Default: 1 *g:vimwiki_auto_checkbox* Values: 0, 1 Press (|:VimwikiGTDToggleItem|) on a list item without checkbox to create it: > * List item result: > * [ ] List item ------------------------------------------------------------------------------ Default: "_" *g:vimwiki_stripsym* Values: symbol Change strip symbol -- in Windows you cannot use /*?<>:" in file names so vimwiki replaces them with symbol given below: (_ is default): > let g:vimwiki_stripsym = '_' ------------------------------------------------------------------------------ Default: 0 *g:vimwiki_use_mouse* Values: 0, 1 Use local mouse mappings from|vimwiki-local-mappings|: > let g:vimwiki_use_mouse = 1 Do not use it: > let g:vimwiki_use_mouse = 0 ============================================================================== 9. 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. Any help is really appreciated! ============================================================================== 10. Known issues *vimwiki-issues* Issue: Opening your wikifiles makes them changed although there were no changes at all. It happens only if you have .wiki extension which is used by FlexWiki ftplugin in the first place to make its own set up. Which is successfully overriden by vimwiki. But. FlexWiki ftplugin has 'setlocal bomb' that makes your wikifiles sort of changed. Fix: 1. Open $VIMRUNTIME/filetype.vim, find FlexWiki and comment it out: > " au BufNewFile,BufRead *.wiki setf flexwiki < 2. Or use other than .wiki extension with vimwiki. See |vimwiki-option-ext|. ============================================================================== 11. Author *vimwiki-author* I live in Moscow and you may believe me -- there are no polar bears (no brown too) here in the streets. I do not do programming for a living. So don't blame me for an ugly ineffective code. 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 . Vimwiki's website: http://code.google.com/p/vimwiki/ Vim plugins website: http://www.vim.org/scripts/script.php?script_id=2226 ============================================================================== 12. Changelog *vimwiki-changelog* 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-gtd|. * [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 * FIXED: [[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. ============================================================================== 13. License *vimwiki-license* GNU General Public License v2 http://www.gnu.org/licenses/old-licenses/gpl-2.0.html To be frank I didn't read it myself. It is not that easy reading. But I hope it's free enough to suit your needs. vim:tw=78:ts=8:ft=help syntax\vimwiki.vim [[[1 128 " Vimwiki syntax file " Author: Maxim Kim " Home: http://code.google.com/p/vimwiki/ " vim:tw=79: " Quit if syntax file is already loaded if version < 600 syntax clear elseif exists("b:current_syntax") finish endif "" use max highlighting - could be quite slow if there are too many wikifiles if VimwikiGet('maxhi') " Every WikiWord is nonexistent execute 'syntax match wikiNoExistsWord /\%(^\|[^!]\)\zs'.g:vimwiki_word1.'/' execute 'syntax match wikiNoExistsWord /'.g:vimwiki_word2.'/' " till we find them in vimwiki's path call vimwiki#WikiHighlightWords() else " A WikiWord (unqualifiedWikiName) execute 'syntax match wikiWord /\%(^\|[^!]\)\zs\<'.g:vimwiki_word1.'\>/' " A [[bracketed wiki word]] execute 'syntax match wikiWord /'.g:vimwiki_word2.'/' endif let g:vimwiki_rxWeblink = '\%("[^"(]\+\((\([^)]\+\))\)\?":\)\?\%(https\?\|ftp\|gopher\|telnet\|file\|notes\|ms-help\):\%(\%(\%(//\)\|\%(\\\\\)\)\+[A-Za-z0-9:#@%/;$~_?+=.&\\\-]*\)' execute 'syntax match wikiLink `'.g:vimwiki_rxWeblink.'`' " Emoticons: must come after the Textilisms, as later rules take precedence " over earlier ones. This match is an approximation for the ~70 distinct syntax match wikiEmoticons /\%((.)\|:[()|$@]\|:-[DOPS()\]|$@]\|;)\|:'(\)/ let g:vimwiki_rxTodo = '\%(TODO:\|DONE:\|FIXME:\|FIXED:\)' execute 'syntax match wikiTodo /'. g:vimwiki_rxTodo .'/' " Load concrete Wiki syntax execute 'runtime! syntax/vimwiki_'.VimwikiGet('syntax').'.vim' " Tables execute 'syntax match wikiTable /'.g:vimwiki_rxTable.'/' execute 'syntax match wikiBold /'.g:vimwiki_rxBold.'/' execute 'syntax match wikiItalic /'.g:vimwiki_rxItalic.'/' execute 'syntax match wikiBoldItalic /'.g:vimwiki_rxBoldItalic.'/' execute 'syntax match wikiItalicBold /'.g:vimwiki_rxItalicBold.'/' execute 'syntax match wikiDelText /'.g:vimwiki_rxDelText.'/' execute 'syntax match wikiSuperScript /'.g:vimwiki_rxSuperScript.'/' execute 'syntax match wikiSubScript /'.g:vimwiki_rxSubScript.'/' execute 'syntax match wikiCode /'.g:vimwiki_rxCode.'/' " Aggregate all the regular text highlighting into wikiText " syntax cluster wikiText contains=wikiItalic,wikiBold,wikiCode,wikiDelText,wikiSuperScript,wikiSubScript,wikiWord,wikiEmoticons "
horizontal rule execute 'syntax match wikiHR /'.g:vimwiki_rxHR.'/' " List items execute 'syntax match wikiList /'.g:vimwiki_rxListBullet.'/' execute 'syntax match wikiList /'.g:vimwiki_rxListNumber.'/' execute 'syntax match wikiList /'.g:vimwiki_rxListDefine.'/' " Treat all other lines that start with spaces as PRE-formatted text. execute 'syntax match wikiPre /'.g:vimwiki_rxPre1.'/ contains=wikiComment' execute 'syntax region wikiPre start=/'.g:vimwiki_rxPreStart.'/ end=/'.g:vimwiki_rxPreEnd.'/ contains=wikiComment' " List item checkbox syntax match wikiCheckBox /\[.\?\]/ execute 'syntax match wikiCheckBoxDone /'.g:vimwiki_rxListBullet.'\s*\[x\].*$/' execute 'syntax match wikiCheckBoxDone /'.g:vimwiki_rxListNumber.'\s*\[x\].*$/' syntax region wikiComment start='' if !vimwiki#hl_exists("wikiHeader1") execute 'syntax match wikiHeader /'.g:vimwiki_rxHeader.'/' else " Header levels, 1-6 execute 'syntax match wikiHeader1 /'.g:vimwiki_rxH1.'/' execute 'syntax match wikiHeader2 /'.g:vimwiki_rxH2.'/' execute 'syntax match wikiHeader3 /'.g:vimwiki_rxH3.'/' execute 'syntax match wikiHeader4 /'.g:vimwiki_rxH4.'/' execute 'syntax match wikiHeader5 /'.g:vimwiki_rxH5.'/' execute 'syntax match wikiHeader6 /'.g:vimwiki_rxH6.'/' endif if !vimwiki#hl_exists("wikiHeader1") hi def link wikiHeader Title else hi def link wikiHeader1 Title hi def link wikiHeader2 Title hi def link wikiHeader3 Title hi def link wikiHeader4 Title hi def link wikiHeader5 Title hi def link wikiHeader6 Title endif hi def wikiBold term=bold cterm=bold gui=bold hi def wikiItalic term=italic cterm=italic gui=italic hi def wikiBoldItalic term=bold cterm=bold gui=bold,italic hi def link wikiItalicBold wikiBoldItalic hi def link wikiCode PreProc hi def link wikiWord Underlined hi def link wikiNoExistsWord Error hi def link wikiPre PreProc hi def link wikiLink Underlined hi def link wikiList Operator hi def link wikiCheckBox wikiList hi def link wikiCheckBoxDone Comment hi def link wikiTable PreProc hi def link wikiEmoticons Constant hi def link wikiDelText Constant hi def link wikiInsText Constant hi def link wikiSuperScript Constant hi def link wikiSubScript Constant hi def link wikiTodo Todo hi def link wikiComment Comment let b:current_syntax="vimwiki" syntax\vimwiki_default.vim [[[1 80 " Vimwiki syntax file " Default syntax " Author: Maxim Kim " Home: http://code.google.com/p/vimwiki/ " vim:tw=78: " text: *strong* " let g:vimwiki_rxBold = '\*[^*]\+\*' let g:vimwiki_rxBold = '\%(^\|\s\|[[:punct:]]\)\@<='. \'\*'. \'\([^*`[:space:]][^*`]*[^*`[:space:]]\|[^*`]\)'. \'\*'. \'\%([[:punct:]]\|\s\|$\)\@=' " text: _emphasis_ " let g:vimwiki_rxItalic = '_[^_]\+_' let g:vimwiki_rxItalic = '\%(^\|\s\|[[:punct:]]\)\@<='. \'_'. \'\([^_`[:space:]][^_`]*[^_`[:space:]]\|[^_`]\)'. \'_'. \'\%([[:punct:]]\|\s\|$\)\@=' " text: *_bold italic_* or _*italic bold*_ let g:vimwiki_rxBoldItalic = '\%(^\|\s\|[[:punct:]]\)\@<='. \'\*_'. \'\([^*_`[:space:]][^*_`]*[^*_`[:space:]]\|[^*_`]\)'. \'_\*'. \'\%([[:punct:]]\|\s\|$\)\@=' let g:vimwiki_rxItalicBold = '\%(^\|\s\|[[:punct:]]\)\@<='. \'_\*'. \'\([^*_`[:space:]][^*_`]*[^*_`[:space:]]\|[^*_`]\)'. \'\*_'. \'\%([[:punct:]]\|\s\|$\)\@=' " text: `code` let g:vimwiki_rxCode = '`[^`]\+`' " text: ~~deleted text~~ let g:vimwiki_rxDelText = '\~\~[^~`]\+\~\~' " text: ^superscript^ let g:vimwiki_rxSuperScript = '\^[^^`]\+\^' " text: ,,subscript,, let g:vimwiki_rxSubScript = ',,[^,`]\+,,' " Header levels, 1-6 let g:vimwiki_rxH1 = '^\s*=\{1}[^=]\+.*[^=]\+=\{1}\s*$' let g:vimwiki_rxH2 = '^\s*=\{2}[^=]\+.*[^=]\+=\{2}\s*$' let g:vimwiki_rxH3 = '^\s*=\{3}[^=]\+.*[^=]\+=\{3}\s*$' let g:vimwiki_rxH4 = '^\s*=\{4}[^=]\+.*[^=]\+=\{4}\s*$' let g:vimwiki_rxH5 = '^\s*=\{5}[^=]\+.*[^=]\+=\{5}\s*$' let g:vimwiki_rxH6 = '^\s*=\{6}[^=]\+.*[^=]\+=\{6}\s*$' let g:vimwiki_rxHeader = '\%('.g:vimwiki_rxH1.'\)\|'. \ '\%('.g:vimwiki_rxH2.'\)\|'. \ '\%('.g:vimwiki_rxH3.'\)\|'. \ '\%('.g:vimwiki_rxH4.'\)\|'. \ '\%('.g:vimwiki_rxH5.'\)\|'. \ '\%('.g:vimwiki_rxH6.'\)' "
, horizontal rule let g:vimwiki_rxHR = '^----.*$' " Tables. Each line starts and ends with '||'; each cell is separated by '||' let g:vimwiki_rxTable = '||' " List items start with whitespace(s) then '*' or '#' let g:vimwiki_rxListBullet = '^\s\+\*' let g:vimwiki_rxListNumber = '^\s\+#' let g:vimwiki_rxListDefine = '::\(\s\|$\)' " Treat all other lines that start with spaces as PRE-formatted text. let g:vimwiki_rxPre1 = '^\s\+[^[:blank:]*#].*$' " Preformatted text let g:vimwiki_rxPreStart = '{{{' let g:vimwiki_rxPreEnd = '}}}' syntax\vimwiki_media.vim [[[1 61 " Vimwiki syntax file " MediaWiki syntax " Author: Maxim Kim " Home: http://code.google.com/p/vimwiki/ " vim:tw=78: " text: '''strong''' let g:vimwiki_rxBold = "'''[^']\\+'''" " text: ''emphasis'' let g:vimwiki_rxItalic = "''[^']\\+''" " text: '''''strong italic''''' let g:vimwiki_rxBoldItalic = "'''''[^']\\+'''''" let g:vimwiki_rxItalicBold = g:vimwiki_rxBoldItalic " text: `code` let g:vimwiki_rxCode = '`[^`]\+`' " text: ~~deleted text~~ let g:vimwiki_rxDelText = '\~\~[^~]\+\~\~' " text: ^superscript^ let g:vimwiki_rxSuperScript = '\^[^^]\+\^' " text: ,,subscript,, let g:vimwiki_rxSubScript = ',,[^,]\+,,' " Header levels, 1-6 let g:vimwiki_rxH1 = '^\s*=\{1}[^=]\+.*[^=]\+=\{1}\s*$' let g:vimwiki_rxH2 = '^\s*=\{2}[^=]\+.*[^=]\+=\{2}\s*$' let g:vimwiki_rxH3 = '^\s*=\{3}[^=]\+.*[^=]\+=\{3}\s*$' let g:vimwiki_rxH4 = '^\s*=\{4}[^=]\+.*[^=]\+=\{4}\s*$' let g:vimwiki_rxH5 = '^\s*=\{5}[^=]\+.*[^=]\+=\{5}\s*$' let g:vimwiki_rxH6 = '^\s*=\{6}[^=]\+.*[^=]\+=\{6}\s*$' let g:vimwiki_rxHeader = '\%('.g:vimwiki_rxH1.'\)\|'. \ '\%('.g:vimwiki_rxH2.'\)\|'. \ '\%('.g:vimwiki_rxH3.'\)\|'. \ '\%('.g:vimwiki_rxH4.'\)\|'. \ '\%('.g:vimwiki_rxH5.'\)\|'. \ '\%('.g:vimwiki_rxH6.'\)' "
, horizontal rule let g:vimwiki_rxHR = '^----.*$' " Tables. Each line starts and ends with '||'; each cell is separated by '||' let g:vimwiki_rxTable = '||' " Bulleted list items start with whitespace(s), then '*' " highlight only bullets and digits. let g:vimwiki_rxListBullet = '^\s*\*\+\([^*]*$\)\@=' let g:vimwiki_rxListNumber = '^\s*#\+' let g:vimwiki_rxListDefine = '^\%(;\|:\)\s' " Treat all other lines that start with spaces as PRE-formatted text. let g:vimwiki_rxPre1 = '^\s\+[^[:blank:]*#].*$' " Preformatted text let g:vimwiki_rxPreStart = '
'
let g:vimwiki_rxPreEnd = '<\/pre>'
autoload\vimwiki_gtd.vim	[[[1
187
" Vimwiki autoload plugin file
" GTD (Getting Things Done) related stuff here.
" Author: Maxim Kim 
" Home: http://code.google.com/p/vimwiki/

if exists("g:loaded_vimwiki_gtd_auto") || &cp
  finish
endif
let g:loaded_vimwiki_gtd_auto = 1

" Script variables {{{
" used in various checks
let s:rx_list_item = '\('.
      \ g:vimwiki_rxListBullet.'\|'.g:vimwiki_rxListNumber.
      \ '\)'
let s:rx_cb_list_item = s:rx_list_item.'\s*\zs\[.\?\]'
let s:rx_li_box = '\[.\?\]'
let s:rx_li_unchecked = '\[\s\?\]'
" used in substitutions
let s:rx_li_check = '\[x\]'
let s:rx_li_uncheck = '\[ \]'
" }}}

" Script functions {{{
" Set state of the list item on line number "lnum" to [ ] or [x]
function! s:set_state(lnum, on_off)"{{{
  let line = getline(a:lnum)
  if a:on_off
    let state = s:rx_li_check
  else
    let state = s:rx_li_uncheck
  endif
  let line = substitute(line, s:rx_li_box, state, '')
  call setline(a:lnum, line)
endfunction"}}}

" Get state of the list item on line number "lnum"
function! s:get_state(lnum)"{{{
  let state = 1
  let line = getline(a:lnum)
  let opt = matchstr(line, s:rx_cb_list_item)
  if opt =~ s:rx_li_unchecked
    let state = 0
  endif
  return state
endfunction"}}}

" Returns 1 if line is list item, 0 otherwise
function! s:is_cb_list_item(lnum)"{{{
  return getline(a:lnum) =~ s:rx_cb_list_item
endfunction"}}}

" Returns 1 if line is list item, 0 otherwise
function! s:is_list_item(lnum)"{{{
  return getline(a:lnum) =~ s:rx_list_item
endfunction"}}}

" Returns char column of checkbox. Used in parent/child checks. 
function! s:get_li_pos(lnum) "{{{
  return stridx(getline(a:lnum), '[')
endfunction "}}}

" Returns list of line numbers of parent and all its child items.
function! s:get_child_items(lnum)"{{{
  let result = []
  let lnum = a:lnum
  let parent_pos = s:get_li_pos(lnum)

  " add parent
  call add(result, lnum)
  let lnum += 1

  while s:is_cb_list_item(lnum) &&
        \ s:get_li_pos(lnum) > parent_pos &&
        \ lnum <= line('$')

    call add(result, lnum)
    let lnum += 1
  endwhile

  return result
endfunction"}}}

" Returns list of line numbers of all items of the same level.
function! s:get_sibling_items(lnum)"{{{
  let result = []
  let lnum = a:lnum
  let ind = s:get_li_pos(lnum)

  while s:is_cb_list_item(lnum) &&
        \ s:get_li_pos(lnum) >= ind &&
        \ lnum <= line('$')

    if s:get_li_pos(lnum) == ind
      call add(result, lnum)
    endif
    let lnum += 1
  endwhile

  let lnum = a:lnum - 1
  while s:is_cb_list_item(lnum) &&
        \ s:get_li_pos(lnum) >= ind &&
        \ lnum >= 0

    if s:get_li_pos(lnum) == ind
      call add(result, lnum)
    endif
    let lnum -= 1
  endwhile

  return result
endfunction"}}}

" Returns line number of the parent of lnum item
function! s:get_parent_item(lnum)"{{{
  let lnum = a:lnum
  let ind = s:get_li_pos(lnum)

  while s:is_cb_list_item(lnum) &&
        \ s:get_li_pos(lnum) >= ind &&
        \ lnum >= 0
    let lnum -= 1
  endwhile

  if s:is_cb_list_item(lnum)
    return lnum
  else
    return a:lnum
  endif
endfunction"}}}

" Creates checkbox in a list item.
function s:create_cb_list_item(lnum) "{{{
  let line = getline(a:lnum)
  let m = matchstr(line, s:rx_list_item)
  if m != ''
    let line = m.' [ ]'.strpart(line, len(m))
    call setline(a:lnum, line)
  endif
endfunction "}}}

" Script functions }}}

" Toggle list item between [ ] and [x]
function! vimwiki_gtd#GTDToggleItem()"{{{
  let current_lnum = line('.')

  if !s:is_cb_list_item(current_lnum)
    if g:vimwiki_auto_checkbox
      call s:create_cb_list_item(current_lnum)
    endif
    return
  endif

  let current_state = s:get_state(current_lnum)
  if  current_state == 0
    for lnum in s:get_child_items(current_lnum)
      call s:set_state(lnum, 1)
      let new_state = 1
    endfor
  else
    for lnum in s:get_child_items(current_lnum)
      call s:set_state(lnum, 0)
      let new_state = 0
    endfor
  endif

  let c_lnum = current_lnum
  while s:is_cb_list_item(c_lnum)
    let all_items_checked = 1
    for lnum in s:get_sibling_items(c_lnum)
      if s:get_state(lnum) != 1
        let all_items_checked = 0
        break
      endif
    endfor

    let parent_lnum = s:get_parent_item(c_lnum)
    if parent_lnum == c_lnum
      break
    endif
    call s:set_state(parent_lnum, all_items_checked)


    let c_lnum = parent_lnum
  endwhile
endfunction"}}}
autoload\vimwiki_html.vim	[[[1
859
" Vimwiki autoload plugin file
" Export to HTML
" Author: Maxim Kim 
" Home: http://code.google.com/p/vimwiki/

" Load only once {{{
if exists("g:loaded_vimwiki_html_auto") || &cp
  finish
endif
let g:loaded_vimwiki_html_auto = 1
"}}}
" Warn if html header or html footer do not exist only once. {{{
let s:warn_html_header = 0
let s:warn_html_footer = 0
"}}}
" TODO: move the next 2 functions into vimwiki#msg and
" vimwiki#get_file_name_only.
function! s:msg(message) "{{{
  echohl WarningMsg
  echomsg 'vimwiki: '.a:message
  echohl None
endfunction "}}}

function! s:get_file_name_only(filename) "{{{
  let word = substitute(a:filename, '\'.VimwikiGet('ext'), "", "g")
  let word = substitute(word, '.*[/\\]', "", "g")
  return word
endfunction "}}}

function! s:syntax_supported() " {{{
  return VimwikiGet('syntax') == "default"
endfunction " }}}

function! s:create_default_CSS(path) " {{{
  let path = expand(a:path)
  if glob(path.'style.css') == ""
    let lines = []

    call add(lines, 'body {margin: 1em 2em 1em 2em; font-size: 100%; line-height: 130%;}')
    call add(lines, 'h1, h2, h3, h4, h5, h6 {margin-top: 1.5em; margin-bottom: 0.5em;}')
    call add(lines, 'h1 {font-size: 2.0em; color: #3366aa;}')
    call add(lines, 'h2 {font-size: 1.6em; color: #335588;}')
    call add(lines, 'h3 {font-size: 1.2em; color: #224466;}')
    call add(lines, 'h4 {font-size: 1.2em; color: #113344;}')
    call add(lines, 'h5 {font-size: 1.1em; color: #112233;}')
    call add(lines, 'h6 {font-size: 1.1em; color: #111111;}')
    call add(lines, 'p, pre, table, ul, ol, dl {margin-top: 1em; margin-bottom: 1em;}')
    call add(lines, 'ul ul, ul ol, ol ol, ol ul {margin-top: 0.5em; margin-bottom: 0.5em;}')
    call add(lines, 'li {margin: 0.3em auto;}')
    call add(lines, 'ul {margin-left: 2em; padding-left: 0.5em;}')
    call add(lines, 'dt {font-weight: bold;}')
    call add(lines, 'img {border: none;}')
    call add(lines, 'pre {border-left: 1px solid #ccc; margin-left: 2em; padding-left: 0.5em;}')
    call add(lines, 'td {border: 1px solid #ccc; padding: 0.3em;}')
    call add(lines, 'hr {border: none; border-top: 1px solid #ccc; width: 100%;}')
    call add(lines, '.todo {font-weight: bold; background-color: #f0ece8; color: #a03020;}')
    call add(lines, '.strike {text-decoration: line-through; color: #777777;}')
    call add(lines, '.justleft {text-align: left;}')
    call add(lines, '.justright {text-align: right;}')
    call add(lines, '.justcenter {text-align: center;}')

    call writefile(lines, path.'style.css')
    echomsg "Default style.css is created."
  endif
endfunction "}}}

function! s:remove_blank_lines(lines) " {{{
  while a:lines[-1] =~ '^\s*$'
    call remove(a:lines, -1)
  endwhile
endfunction "}}}

function! s:is_web_link(lnk) "{{{
  if a:lnk =~ '^\(http://\|www.\|ftp://\)'
    return 1
  endif
  return 0
endfunction "}}}

function! s:is_img_link(lnk) "{{{
  if a:lnk =~ '\.\(png\|jpg\|gif\|jpeg\)$'
    return 1
  endif
  return 0
endfunction "}}}

function! s:is_non_wiki_link(lnk) "{{{
  if a:lnk =~ '.\+\..\+$'
    return 1
  endif
  return 0
endfunction "}}}

function! s:get_html_header(title, charset) "{{{
  let lines=[]

  if VimwikiGet('html_header') != "" && !s:warn_html_header
    try
      let lines = readfile(expand(VimwikiGet('html_header')))
      call map(lines, 'substitute(v:val, "%title%", "'. a:title .'", "g")')
      return lines
    catch /E484/
      let s:warn_html_header = 1
      call s:msg("Header template ". VimwikiGet('html_header'). " does not exist!")
    endtry
  endif

  " if no VimwikiGet('html_header') set up or error while reading template
  " file -- use default header.
  call add(lines, '')
  call add(lines, '')
  call add(lines, '')
  call add(lines, ''.a:title.'')
  call add(lines, '')
  call add(lines, '')
  call add(lines, '')

  return lines
endfunction "}}}

function! s:get_html_footer() "{{{
  let lines=[]

  if VimwikiGet('html_footer') != "" && !s:warn_html_footer
    try
      let lines = readfile(expand(VimwikiGet('html_footer')))
      return lines
    catch /E484/
      let s:warn_html_footer = 1
      call s:msg("Footer template ". VimwikiGet('html_footer'). " does not exist!")
    endtry
  endif

  " if no VimwikiGet('html_footer') set up or error while reading template
  " file -- use default footer.
  call add(lines, "")
  call add(lines, '')
  call add(lines, '')

  return lines
endfunction "}}}

function! s:close_tag_code(code, ldest) "{{{
  if a:code
    call insert(a:ldest, "
") return 0 endif return a:code endfunction "}}} function! s:close_tag_pre(pre, ldest) "{{{ if a:pre call insert(a:ldest, "") return 0 endif return a:pre endfunction "}}} function! s:close_tag_para(para, ldest) "{{{ if a:para call insert(a:ldest, "

") 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, '') elseif strpart(line, 0, 1) == ' ' call add(lines, '') else call add(lines, '') endif endwhile call add(lines, "") elseif table call add(lines, "
    '.line.''.line.''.line.'
    ") 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]] let line = '' let link_parts = split(a:entag, "|") if len(link_parts) > 1 if s:is_img_link(link_parts[0]) let line = ''.join(link_parts[1:], ' elseif s:is_non_wiki_link(link_parts[0]) let line = ''.join(link_parts[1:], "|").'' else let line = ''.join(link_parts[1:], "|").'' endif else if s:is_img_link(a:entag) let line = '' elseif s:is_non_wiki_link(a:entag) 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' setlocal comments=b:\ *\ [\ ],b:\ *[\ ],b:\ *\ [],b:\ *[],b:\ *\ [x],b:\ *[x] setlocal comments+=b:\ #\ [\ ],b:\ #[\ ],b:\ #\ [],b:\ #[],b:\ #\ [x],b:\ #[x] setlocal comments+=b:\ *,b:\ # else setlocal comments=n:*\ [\ ],n:*[\ ],n:*\ [],n:*[],n:*\ [x],n:*[x] setlocal comments+=n:#\ [\ ],n:#[\ ],n:#\ [],n:#[],n:#\ [x],n:#[x] setlocal comments+=n:*,n:# endif setlocal formatoptions=ctnqro " COMMENTS }}} " FOLDING for headers and list items using expr fold method. {{{ setlocal fdm=expr 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 = s: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 "}}} function! s:count_first_sym(line) "{{{ let idx = 0 while a:line[idx] == a:line[0] && idx < len(a:line) let idx += 1 endwhile return idx 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 VimwikiGTDToggleItem call vimwiki_gtd#GTDToggleItem() " 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