Advertisement
Guest User

Untitled

a guest
Jun 25th, 2018
549
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 0.70 KB | None | 0 0
  1. augroup wiki
  2.     autocmd!
  3.     autocmd BufRead $HOME/.notes/* set syntax=markdown | set nonumber | syn match StartLink '\[\[' conceal | syn match StartLink '\]\]' conceal | set conceallevel=3 | set iskeyword+=[ | set iskeyword+=]
  4.     nnoremap <expr> <CR> CheckLink() ? ":execute ':e ' . substitute(substitute(matchstr(g:line, '\\[\\[\\(\\s*\\w\\+\\)*\\]\\]', g:curpos), \"\[\[\", \"\", \"\"), \"\]\]\", \"\", \"\")<CR>" : '\<CR>'
  5.     function CheckLink()
  6.       let g:word = expand("<cword>")
  7.       let g:line = getline('.')
  8.       let g:curpos = getcurpos()[2]
  9.       if match(g:word, '\[\[\(\s*\w\+\)*\]\]') > -1 || match(g:line, '\[\[\(\s*\w\+\)*\]\]', g:curpos) > -1
  10.         return 1
  11.       endif
  12.       return 0
  13.     endfunction
  14. augroup END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement