~dricottone/vim-markdown-preview

ref: 5ab8e9afabfdc49fe92f85a106188af45060fdc3 vim-markdown-preview/README.md -rw-r--r-- 3.9 KiB
5ab8e9af — Oleksandr Shybystyi Added support for github flavoured markdown 9 years ago
                                                                                
906c7a8f Jamshed Vesuna
ae4d0347 JamshedVesuna
906c7a8f Jamshed Vesuna
ef2edea8 Jamshed Vesuna
1135b27a JamshedVesuna
906c7a8f Jamshed Vesuna
2d5e5346 Jamshed Vesuna
cf2cc781 JamshedVesuna
1135b27a JamshedVesuna
5ab8e9af Oleksandr Shybystyi
1135b27a JamshedVesuna
cf2cc781 JamshedVesuna
2d5e5346 Jamshed Vesuna
5ab8e9af Oleksandr Shybystyi
2d5e5346 Jamshed Vesuna
5ab8e9af Oleksandr Shybystyi
906c7a8f Jamshed Vesuna
1135b27a JamshedVesuna
2d5e5346 Jamshed Vesuna
cf2cc781 JamshedVesuna
2d5e5346 Jamshed Vesuna
cf2cc781 JamshedVesuna
906c7a8f Jamshed Vesuna
6f05ab3c Jamshed Vesuna
2d5e5346 Jamshed Vesuna
ae4d0347 JamshedVesuna
5ab8e9af Oleksandr Shybystyi
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
Vim Markdown Preview
====================

A Vim plugin for previewing markdown files in a browser. This plugin was designed to maintain focus on Vim but use Google Chrome or Safari to preview rendered markdown. Thus, everything is done in the background so you never have to leave Vim.

The aim of this plugin is to be light weight with minimal dependencies. Thus, there is no polling engine or webserver involved.

![Screenshot](images/screenshot.gif?raw=true "Screenshot")

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, 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`
5. If you prefer github flavoured markdown you need to install grip (tested only on ubuntu) and set next option:
    * `let vim_markdown_preview_github=1`

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
========================

## OS X:

* [Markdown](http://daringfireball.net/projects/markdown/)
* [Safari](https://www.apple.com/safari/)

## Unix:

* [Markdown](http://daringfireball.net/projects/markdown/) or [grip](https://github.com/joeyespo/grip) if you want to parse github flavoured markdown
* [xdotool](https://github.com/jordansissel/xdotool)
* [Google Chrome](https://www.google.com/chrome/browser/) or [other browser](https://github.com/JamshedVesuna/vim-markdown-preview/wiki/Use-other-browser-to-preview-markdown#ubuntu-or-debian)

Usage
=====
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.


Behind The Scenes
=================
* Regular mapping:
    1. First, vim-markdown-preview renders your markdown as html and creates a temporary file `vim-markdown-preview.html` in `/tmp/`.
    2. Next, vim-markdown-preview either opens the html file or refreshes the Google Chrome or Safari tab.
    3. If you would like vim-markdown-preview to remove the temporary file so nothing left behind, set `REMOVE_TEMP_FILE` to 1.
* Image viewing:
    1. First, vim-markdown-preview renders your markdown as html with the filename `<your-file>.md.html` in the same directory.
    2. Next, vim-markdown-preview either opens the html file or refreshes the Google Chrome or Safari tab.
    3. There is currently no option to remove this file after previewing.

Know issues
===========
* If you've chosen to use github flavoured markdown (with grip), there might some issues:
    * necessity to use [access token](https://github.com/joeyespo/grip#access) (a solution is to set `alias grip="grip --user <your-username> --pass <your-pass>` in your ***.bashrc/.zshrc***).
    * if github is unresponsive you wont be able to render your file.