Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- augroup wiki
- autocmd!
- autocmd BufRead $HOME/.notes/* set syntax=markdown | set nonumber | syn match StartLink '\[\[' conceal | syn match StartLink '\]\]' conceal | set conceallevel=3 | set iskeyword+=[ | set iskeyword+=]
- nnoremap <expr> <CR> CheckLink() ? ":execute ':e ' . substitute(substitute(matchstr(g:line, '\\[\\[\\(\\s*\\w\\+\\)*\\]\\]', g:curpos), \"\[\[\", \"\", \"\"), \"\]\]\", \"\", \"\")<CR>" : '\<CR>'
- function CheckLink()
- let g:word = expand("<cword>")
- let g:line = getline('.')
- let g:curpos = getcurpos()[2]
- if match(g:word, '\[\[\(\s*\w\+\)*\]\]') > -1 || match(g:line, '\[\[\(\s*\w\+\)*\]\]', g:curpos) > -1
- return 1
- endif
- return 0
- endfunction
- augroup END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement