DokuVimKi is a Vim plugin which allows you to edit DokuWiki pages of DokuWikis XML-RPC interface. It also does syntax highlighting for DokuWiki syntax.
Just download it and unpack it in ~/.vim/
. You also have to make sure that
vim is compiled with python support (should be the case for most
distributions) and that you have the xmlrpclib
and dokuwikixmlrpc
python
modules installed. You'll also have to install a recent development version of
DokuWiki itself in order to use this plugin! For
details on how to setup XMLRPC for DokuWiki please refer to
config:xmlrpc.
If you want to enable syntax highlighting without issuing :set syntax=dokuwiki
when editing pages of a local wiki just put this in your
~/.vimrc
to make VIM auto-detect DokuWiki files:
" looks for DokuWiki headlines in the first 20 lines
" of the current buffer
fun IsDokuWiki()
if match(getline(1,20),'^ \=\(=\{2,6}\).\+\1 *$') >= 0
set textwidth=0
set wrap
set linebreak
set filetype=dokuwiki
endif
endfun
" check for dokuwiki syntax
autocmd BufWinEnter *.txt call IsDokuWiki()
syntax on
To configure the plugin just add the following to your ~/.vimrc
and change
the values to your needs.
" user name with which you want to login at the remote wiki
let g:DokuVimKi_USER = 'username'
" password
let g:DokuVimKi_PASS = 'password'
" url of the remote wiki (without trailing '/')
let g:DokuVimKi_URL = 'https://yourwikidomain.org'
" width of the index window (optional, defaults to 30)
let g:DokuVimKi_INDEX_WINWIDTH = 40
" set a default summary for :w (optional, defaults to [xmlrpc dokuvimki edit])
let g:DokuVimKi_DEFAULT_SUM = 'fancy default summary'
Once your set and done you can launch DokuVimKi:
:DokuVimKi
For a detailed list of available commands please consult the dokuvimki help:
:help dokuvimki-commands
To speed up the editing you could add some aliases to your $SHELLrc
:
alias vidoku='viDokuVimKi() { vim +DokuVimKi +"DWedit $1" }; viDokuVimKi'
alias gvidoku='gviDokuVimKi() { gvim +DokuVimKi +"DWedit $1" }; gviDokuVimKi'
Usage example:
vidoku playground:DokuVimKi
This will create a DokuVimKi document within the playground namespace.
A good idea is to outsource your DokuVimKi configuration. To do so, store your
settings in a seperate file like ~/.vim/dokuvimkirc
. You can increase
security be setting the file permission properly
chmod 600 ~/.vim/dokuvimkirc
To include this file in your ~/.vimrc
use following code:
" Include DokuVimKi Configuration
if filereadable($HOME."/.vim/dokuvimkirc")
source $HOME/.vim/dokuvimkirc
endif
One way of keeping your .vimrc
lean and mean is to avoid loading dokuvimki
specific configuration file unless you want to edit the wiki, while retaining
all your other .vimrc
magic. To do this simply create a separate
configuration directory called ~/.dokuwiki
which should contain
mywiki.vim
:
source ~/.dokuwiki/macros_dokuvimki.vim
let g:DokuVimKi_USER = 'mywikiuser'
let g:DokuVimKi_PASS = 'mywikipassword'
let g:DokuVimKi_URL = 'http://mywiki.org'
source ~/.dokuwiki/dokuvimki.vim
The last bit displays the list of wiki pages by default. Then you are free to
define a custom macros_dokuvimki.vim
that applies to all your dokuwiki vim
bindings:
" ensures you retain your normal .vimrc magic
source ~/.vimrc
" remap save commands for convenience
nmap <S-z><S-z> :DWsave<CR>
" looks for DokuWiki headlines in the first 20 lines
" of the current buffer
fun IsDokuWiki()
if match(getline(1,20),'^ \=\(=\{2,6}\).\+\1 *$') >= 0
set textwidth=0
set wrap
set linebreak
set filetype=dokuwiki
endif
endfun
" check for dokuwiki syntax
autocmd BufWinEnter *.txt call IsDokuWiki()
"Authentication has been moved to "~/.dokuwiki/mywiki.vim" specific files
" optional Cursorline, I feel makes editing a bit easier on the eye
"highlight CursorLine guibg=lightgreen cterm=bold ctermbg=17
Set a distinct alias in your bash shell (usually your ~/.bashrc
file) to
edit mywiki using dokuvimki:
alias vidmywiki='vi -u ~/.dokuwiki/mywiki.vim
Now all you need to do on your bash shell prompt is issue:
vidmywiki
and you'll be automatically authenticated into mywiki while retaining all
dokuvimki specific settings within macros_dokuvim.vim
for sharing amongst
all your dokuwikis. All you have to do is copy the contents of mywiki.vim
to
mywiki2.vim
, edit the credentials and create a matching new alias for
mywiki2.vim
invocation.
- fixed whitespace check
- disable DokuVimKi command after initialization
- only allow valid pagenames
- fixed docs for DWsave
- use error message on dwquit when unsaved changes
- catch saving of empty new pages
- tracking unsaved pages for all scenarios
- let the user know if some buffers contain unsaved changes on quit
- fixed changes tracking
- cosmetical changes