From 9088e7d154419296dde1794e58037537b1d18c67 Mon Sep 17 00:00:00 2001 From: JamshedVesuna Date: Sat, 15 Aug 2015 10:35:29 -0700 Subject: [PATCH] Added variable to remap ctrl-p --- README.md | 10 ++++++---- plugin/vim-markdown-preview.vim | 12 ++++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 3153de2..32ff46e 100644 --- a/README.md +++ b/README.md @@ -11,22 +11,24 @@ Installation ============ 1. With Pathogen: Place `vim-markdown-preview/` in `.vim/bundle/`. -2. Default browsers: +2. To remap Control-p to a different hotkey, place the following in your `.vimrc`, replacing `p`: + * `let vim_markdown_preview_hotkey=''` +3. Default browsers: * OS X: Safari * Unix: Google Chrome * To change browsers, place the following in your `.vimrc` and replace `'Google Chrome'`: * `let vim_markdown_preview_browser='Google Chrome'` -3. Defaults to keeping rendered `.html` file. +4. Defaults to keeping rendered `.html` file. * To remove the rendered preview, after loading it in a browser, add the following to your `.vimrc`: * `let vim_markdown_preview_temp_file=1` -4. In combination with the above, defaults to mapping `Ctrl-p` to preview without displaying images. +5. In combination with the above, defaults to mapping `Ctrl-p` to preview without displaying images. * To display images with the `Ctrl-p` mapping, add: * `let vim_markdown_preview_toggle=1` * To display images automatically on buffer write, add: * `let vim_markdown_preview_toggle=2` * To disregard images and still automatically preview on buffer write, add: * `let vim_markdown_preview_toggle=3` -5. If you prefer [GitHub flavoured markdown](https://help.github.com/articles/github-flavored-markdown/) you need to install [Python grip](https://github.com/joeyespo/grip) and add: +6. If you prefer [GitHub flavoured markdown](https://help.github.com/articles/github-flavored-markdown/) you need to install [Python grip](https://github.com/joeyespo/grip) and add: * `let vim_markdown_preview_github=1` * Note that this makes a request to [GitHub's API](https://developer.github.com/v3/markdown/) (causing latencies) and may require [authentication](https://github.com/joeyespo/grip#access). * Requires a network connection diff --git a/plugin/vim-markdown-preview.vim b/plugin/vim-markdown-preview.vim index d13115a..3fca16c 100644 --- a/plugin/vim-markdown-preview.vim +++ b/plugin/vim-markdown-preview.vim @@ -8,6 +8,10 @@ let b:vim_markdown_preview_temp_file = get(g:, 'vim_markdown_preview_temp_file', let b:vim_markdown_preview_toggle = get(g:, 'vim_markdown_preview_toggle', 0) let b:vim_markdown_preview_github = get(g:, 'vim_markdown_preview_github', 0) +if !exists("g:vim_markdown_preview_hotkey") + let g:vim_markdown_preview_hotkey='' +endif + function! Vim_Markdown_Preview() let OSNAME = 'Unidentified' @@ -104,12 +108,12 @@ function! Vim_Markdown_Preview_Local() endfunction if b:vim_markdown_preview_toggle == 0 - "Maps Ctrl-p to Vim_Markdown_Preview() - autocmd Filetype markdown,md map :call Vim_Markdown_Preview() + "Maps vim_markdown_preview_hotkey to Vim_Markdown_Preview() + :exec 'autocmd Filetype markdown,md map ' . g:vim_markdown_preview_hotkey . ' :call Vim_Markdown_Preview()' elseif b:vim_markdown_preview_toggle == 1 - "Display images - Maps Ctrl-p to Vim_Markdown_Preview_Local() - saves the html file locally + "Display images - Maps vim_markdown_preview_hotkey to Vim_Markdown_Preview_Local() - saves the html file locally "and displays images in path - autocmd Filetype markdown,md map :call Vim_Markdown_Preview_Local() + :exec 'autocmd Filetype markdown,md map ' . g:vim_markdown_preview_hotkey . ' :call Vim_Markdown_Preview_Local()' elseif b:vim_markdown_preview_toggle == 2 "Display images - Automatically call Vim_Markdown_Preview_Local() on buffer write autocmd BufWritePost *.markdown,*.md :call Vim_Markdown_Preview_Local() -- 2.45.2