M README.md => README.md +23 -18
@@ 7,16 7,34 @@ The aim of this plugin is to be light weight with minimal dependencies. Thus, th
![Screenshot](images/screenshot.gif?raw=true "Screenshot")
-Installation
+Installation<a name='installation'></a>
============
1. With Pathogen: Place `vim-markdown-preview/` in `.vim/bundle/`.
2. Default browsers:
* OS X: Safari
* Unix: Google Chrome
- * To change browsers, edit [`vim_markdown_preview_browser`](https://github.com/JamshedVesuna/vim-markdown-preview/blob/master/plugin/vim-markdown-preview.vim#L7)
-3. Defaults to keeping rendered `.html` file
- * To remove rendered preview, change [`REMOVE_TEMP_FILE`](https://github.com/JamshedVesuna/vim-markdown-preview/blob/master/plugin/vim-markdown-preview.vim#L6) to 1
+ * 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.
+ * 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.
+ * 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`
+
+The following example is using the write buffer option on OS X, with displaying images in the markdown preview, adding the following to `.vimrc`:
+
+```vim
+let vim_markdown_preview_temp_file=1
+let vim_markdown_preview_toggle=2
+```
+
+![Screenshot](images/screenshot-with-images.gif?raw=true "Screenshot With Images")
Support and Requirements
========================
@@ 34,26 52,13 @@ Support and Requirements
Usage
=====
-When in a *.markdown or *.md file, vim-markdown-preview does the following when you type `Ctrl-p` (can be remapped, see below):
+When in a *.markdown or *.md file, vim-markdown-preview does the following when you type `Ctrl-p` (can be remapped, see [Installation](#installation)):
* If you are not previewing the current file:
* Open an html rendered version of your file in Google Chrome or Safari in the background.
* Otherwise:
* Refresh your preview of the current markdown file in Google Chrome or Safari.
-## Remapping Hotkeys
-Please recomment current mapping if you chose to use another mapping.
-
-* Map to buffer write:
- * Uncomment the [last line of](https://github.com/JamshedVesuna/vim-markdown-preview/blob/master/plugin/vim-markdown-preview.vim#L110) `plugin/vim-markdown-preview.vim`
-* Map to buffer write and enable image viewing:
- * Uncomment the [fourth to last line](https://github.com/JamshedVesuna/vim-markdown-preview/blob/master/plugin/vim-markdown-preview.vim#L107) of `plugin/vim-markdown-preview.vim`
-* Map `Ctrl-p` to view images:
- * Uncomment the [seventh to last line](https://github.com/JamshedVesuna/vim-markdown-preview/blob/master/plugin/vim-markdown-preview.vim#L104) in `plugin/vim-markdown-preview.vim`.
-
-The following example is using the write buffer option on OS X, with displaying images in the markdown preview:
-
-![Screenshot](images/screenshot-with-images.gif?raw=true "Screenshot With Images")
Behind The Scenes
=================
M plugin/vim-markdown-preview.vim => plugin/vim-markdown-preview.vim +18 -16
@@ 3,8 3,9 @@
" git@github.com:JamshedVesuna/vim-markdown-preview.git
"============================================================
-let b:REMOVE_TEMP_FILE = 0 "To remove the temp file, set to 1
let b:vim_markdown_preview_browser = get(g:, 'vim_markdown_preview_browser', 'Google Chrome')
+let b:vim_markdown_preview_temp_file = get(g:, 'vim_markdown_preview_temp_file', 0)
+let b:vim_markdown_preview_toggle = get(g:, 'vim_markdown_preview_toggle', 0)
function! Vim_Markdown_Preview()
@@ 41,7 42,7 @@ function! Vim_Markdown_Preview()
call system('open -g /tmp/vim-markdown-preview.html')
endif
- if b:REMOVE_TEMP_FILE == 1
+ if b:vim_markdown_preview_temp_file == 1
sleep 200m
call system('rm /tmp/vim-markdown-preview.html')
endif
@@ 84,22 85,23 @@ function! Vim_Markdown_Preview_Local()
call system('open -g ' . curr_file . '.html')
endif
- if b:REMOVE_TEMP_FILE == 1
+ if b:vim_markdown_preview_temp_file == 1
sleep 200m
call system('rm ' . curr_file . '.html')
endif
endfunction
-
-"Maps Ctrl-p to Vim_Markdown_Preview()
-autocmd Filetype markdown,md map <buffer> <C-p> :call Vim_Markdown_Preview()<CR>
-
-"Display images - Maps Ctrl-p to Vim_Markdown_Preview_Local() - saves the html file locally
-"and displays images in path
-"autocmd Filetype markdown,md map <buffer> <C-p> :call Vim_Markdown_Preview_Local()<CR>
-
-"Display images - Automatically call Vim_Markdown_Preview_Local() on buffer write
-"autocmd BufWritePost *.markdown,*.md :call Vim_Markdown_Preview_Local()
-
-"Automatically call Vim_Markdown_Preview() on buffer write
-"autocmd BufWritePost *.markdown,*.md :call Vim_Markdown_Preview()
+if b:vim_markdown_preview_toggle == 0
+ "Maps Ctrl-p to Vim_Markdown_Preview()
+ autocmd Filetype markdown,md map <buffer> <C-p> :call Vim_Markdown_Preview()<CR>
+elseif b:vim_markdown_preview_toggle == 1
+ "Display images - Maps Ctrl-p to Vim_Markdown_Preview_Local() - saves the html file locally
+ "and displays images in path
+ autocmd Filetype markdown,md map <buffer> <C-p> :call Vim_Markdown_Preview_Local()<CR>
+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()
+elseif b:vim_markdown_preview_toggle == 3
+ "Automatically call Vim_Markdown_Preview() on buffer write
+ autocmd BufWritePost *.markdown,*.md :call Vim_Markdown_Preview()
+endif