@@ -23,3 +23,90 @@ to your .vimrc, source it, and execute `:PluginInstall`.
2323## Screenshot
2424
2525
26+
27+ ## Usage
28+
29+ Files with the .Rmd extension are automatically detected as RMarkdown files.
30+ vim-rmarkdown loads vim-pandoc and pandoc's markdown syntax, and adds some
31+ extra functionality specific to rmarkdown.
32+
33+ ### Syntax
34+
35+ vim-rmarkdown extends pandoc's markdown syntax so
36+
37+ ```
38+ {r qplot, fig.width=4, message=FALSE}
39+ library(ggplot2)
40+ summary(cars)
41+ qplot(speed, dist, data=cars) +
42+ geom_smooth()
43+ ```
44+
45+ is recognized as an R code chunk, and
46+
47+ inline unformatted text like `r 1 + 2`
48+
49+ as inline R.
50+
51+ R syntax is used within such fenced codeblocks and inline spans.
52+
53+ ### Command
54+
55+ To render the file using rmarkdown, the user can execute the `|:RMarkdown|`
56+ command. Its syntax is
57+
58+ `:RMarkdown[!] [OUTPUT_TYPE] [- RENDER_ARGS[ -]] [OUTPUT_TYPE_ARGS] `
59+
60+ OUTPUT_TYPE is one of "pdf", "word", "html", "md", "beamer", "ioslides",
61+ "revealjs", "all", or a combination thereof (e.g., "pdf+html"). Command
62+ completion is provided for defining this variable.
63+
64+ RENDER_ARGS are arguments passed to rmarkdown::render(...), and
65+ OUTPUT_TYPE_ARGS are passed to output objects such as rmarkdown::pdf_document(...)
66+ and rmarkdown::word_document(...). (Refer to RMarkdown's documentation).
67+ Note RENDER_ARGS MUST be surrounded by '- ' and ' -'.
68+
69+ The bang (!) version opens the created file on successful execution. If the
70+ execution fails, a message will be shown and a buffer will open with Rscript's
71+ output (can be dismissed by pressing q in normal mode).
72+
73+ :RMarkdown builds a R expression that executes rmarkdown. For example, if the
74+ current file is "input.Rmd",
75+
76+ :RMarkdown pdf
77+
78+ executes
79+
80+ Rscript -e 'library(rmarkdown);render("input.Rmd", "pdf_document")'
81+
82+ If OUTPUT_TYPE is ommited, RMarkdown produces an html document.
83+
84+ Some more examples:
85+
86+ :RMarkdown pdf latex_engine="xelatex", toc=TRUE
87+ ->
88+ Rscript -e 'library(rmarkdown);render("input.Rmd", pdf_document(latex_engine="xelatex", toc=TRUE)
89+
90+ :RMarkdown html - quiet=FALSE - toc=FALSE
91+ ->
92+ Rscript -e 'library(rmarkdown);render("input.Rmd", html_document(toc=TRUE), quiet=FALSE)
93+
94+ :RMarkdown word - quiet=FALSE
95+ ->
96+ Rscript -e 'library(rmarkdown);render("input.Rmd", "word_document", quiet=FALSE)
97+
98+ Note `|:RMarkdown|` doesn't parse the arguments itself, so the user must type them
99+ exactly as they should be used in R (for example, commas should separate
100+ arguments). For example,
101+
102+ :RMarkdown latex_engine="lualatex" bibliography="input.bib"
103+
104+ will cause rmarkdown to fail.
105+
106+ ## NrrwRgn
107+
108+ If the NrrwRgn plugin is available, vim-rmarkdown will register an extra
109+ command, | :RNrrw | , which "narrows" the current R chunk in a separate buffer.
110+ This command is also mapped to "<LocalLeader> ccn" in normal mode.
111+
112+ `" vim: set ft=help :`
0 commit comments