Skip to content

Commit

Permalink
Version 0.2.2
Browse files Browse the repository at this point in the history
Added keybindings to split/vertsplit when following WikiWords.
<S-CR> - split WikiWord
<C-CR> - vertical split WikiWord
  • Loading branch information
habamax authored and vim-scripts committed Oct 18, 2010
1 parent 4e4fb8a commit c0b56d5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
21 changes: 15 additions & 6 deletions ftplugin/vimwiki.vim
Expand Up @@ -4,8 +4,8 @@
" Home: http://code.google.com/p/vimwiki/
" Author: Maxim Kim
" Filenames: *.wiki
" Last Change: (05.05.2008 19:30)
" Version: 0.2
" Last Change: (07.05.2008 19:25)
" Version: 0.2.2

if exists("b:did_ftplugin")
finish
Expand Down Expand Up @@ -132,20 +132,27 @@ function! s:WikiLinkToNonWikiFile(word)
endfunction

if !exists('*s:WikiFollowWord')
function! s:WikiFollowWord()
function! s:WikiFollowWord(split)
if a:split == "split"
let cmd = ":split "
elseif a:split == "vsplit"
let cmd = ":vsplit "
else
let cmd = ":e "
endif
let word = s:WikiStripWord(s:WikiGetWordAtCursor(s:wiki_word), g:vimwiki_stripsym)
" insert doesn't work properly inside :if. Check :help :if.
if word == ""
execute "normal! \n"
return
endif
if s:WikiLinkToNonWikiFile(word)
execute ":e ".word
execute cmd.word
else
" history is [['WikiWord.wiki', 11], ['AnotherWikiWord', 3] ... etc]
" where numbers are column positions we should return when coming back.
call insert(g:vimwiki_history, [expand('%:p'), col('.')])
execute ":e ".g:vimwiki_home.word.g:vimwiki_ext
execute cmd.g:vimwiki_home.word.g:vimwiki_ext
endif
endfunction

Expand Down Expand Up @@ -208,7 +215,9 @@ vmap <buffer> j gj
imap <buffer> <Down> <C-o>gj
imap <buffer> <Up> <C-o>gk
nmap <buffer> <CR> :call <SID>WikiFollowWord()<CR>
nmap <buffer> <CR> :call <SID>WikiFollowWord('nosplit')<CR>
nmap <buffer> <S-CR> :call <SID>WikiFollowWord('split')<CR>
nmap <buffer> <C-CR> :call <SID>WikiFollowWord('vsplit')<CR>
nmap <buffer> <BS> :call <SID>WikiGoBackWord()<CR>
nmap <buffer> <TAB> :call <SID>WikiNextWord()<CR>
Expand Down
10 changes: 4 additions & 6 deletions syntax/vimwiki.vim
Expand Up @@ -4,8 +4,8 @@
" Home: http://code.google.com/p/vimwiki/
" Author: Maxim Kim
" Filenames: *.wiki
" Last Change: (05.05.2008 19:30)
" Version: 0.2
" Last Change: (07.05.2008 19:25)
" Version: 0.2.2
" Based on FlexWiki

" Quit if syntax file is already loaded
Expand Down Expand Up @@ -50,9 +50,6 @@ syntax match wikiEmoticons /\((.)\|:[()|$@]\|:-[DOPS()\]|$@]\|;)\|:'(\)/
" Aggregate all the regular text highlighting into wikiText
syntax cluster wikiText contains=wikiItalic,wikiBold,wikiCode,wikiDelText,wikiSuperScript,wikiSubScript,wikiLink,wikiWord,wikiEmoticons

" Treat all other lines that start with spaces as PRE-formatted text.
syntax match wikiPre /^[ \t]\+.*$/ contains=@wikiText

" Header levels, 1-6
syntax match wikiH1 /\(^!\{1}.*$\|^\s*=\{1}.*=\{1}\s*$\)/
syntax match wikiH2 /\(^!\{2}.*$\|^\s*=\{2}.*=\{2}\s*$\)/
Expand All @@ -72,7 +69,8 @@ syntax match wikiTable /||/
" highlight only bullets and digits.
syntax match wikiList /^\s\+\(\*\|[1-9]\+0*\.\|#\)/


" Treat all other lines that start with spaces as PRE-formatted text.
syntax match wikiPre /^\s\+[^[:blank:]*#].*$/


" Link FlexWiki syntax items to colors
Expand Down

0 comments on commit c0b56d5

Please sign in to comment.