~dricottone/vim-markdown-preview

ref: e6729c07f2a7e4d501cffe2125f47dc0628852d9 vim-markdown-preview/plugin/vim-markdown-preview.vim -rw-r--r-- 1.0 KiB
e6729c07 — Jamshed Vesuna Changed mapping to Ctrl-p instead of write until bux is fixed. 10 years ago
                                                                                
906c7a8f Jamshed Vesuna
2d5e5346 Jamshed Vesuna
6f05ab3c Jamshed Vesuna
2d5e5346 Jamshed Vesuna
906c7a8f Jamshed Vesuna
e6729c07 Jamshed Vesuna
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
"============================================================
"                    Vim Markdown Preview
"   git@github.com:JamshedVesuna/vim-markdown-preview.git
"============================================================

function! Vim_Markdown_Preview()
  let curr_file = expand('%:t')
  call system('markdown ' . curr_file . ' > /tmp/vim-markdown-preview.html')
  let chrome_wid = system("xdotool search --name 'vim-markdown-preview.html - Google Chrome'")
  sleep 300m
  if !chrome_wid
    call system('see -g /tmp/vim-markdown-preview.html')
  else
    let curr_wid = system('xdotool getwindowfocus')
    call system('xdotool windowmap ' . chrome_wid)
    call system('xdotool windowactivate ' . chrome_wid)
    call system("xdotool key 'ctrl+r'")
    call system('xdotool windowactivate ' . curr_wid)
  endif
  sleep 31m
  call system('rm /tmp/vim-markdown-preview.html')
endfunction

autocmd Filetype markdown,md map <buffer> <C-p> :call Vim_Markdown_Preview()<CR>
"autocmd BufWritePost *.markdown,*.md :call Vim_Markdown_Preview()