Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added global variable for custom browser refresh key mapping #75

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,17 @@ Example: Mapping Control M.
```vim
let vim_markdown_preview_hotkey='<C-m>'
```
<a name='browser refresh key'></a>
### The `vim_markdown_preview_browser_refresh_key` option

By default, this plugin maps `ctrl+r` (Control+r) to be forwarded to the specified (or default) browser. This keybinding does not use vim syntax for keys, the keys are emulated with xdotools.

Defalt: `ctrl+r`

Example: Changing to F5
```
let g:vim_markdown_preview_browser_refresh_key='F5'
```

<a name='browser'></a>
### The `vim_markdown_preview_browser` option
Expand Down
8 changes: 6 additions & 2 deletions plugin/vim-markdown-preview.vim
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ if !exists("g:vim_markdown_preview_hotkey")
let g:vim_markdown_preview_hotkey='<C-p>'
endif

if !exists("g:vim_markdown_preview_browser_refresh_key")
let g:vim_markdown_preview_browser_refresh_key="ctrl+r"
endif

function! Vim_Markdown_Preview()
let b:curr_file = expand('%:p')

Expand Down Expand Up @@ -86,7 +90,7 @@ function! Vim_Markdown_Preview()
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 key" . g:vim_markdown_preview_browser_refresh_key)
call system('xdotool windowactivate ' . curr_wid)
endif
endif
Expand Down Expand Up @@ -140,7 +144,7 @@ function! Vim_Markdown_Preview_Local()
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 key" . g:vim_markdown_preview_browser_refresh_key)
call system('xdotool windowactivate ' . curr_wid)
endif
endif
Expand Down