I am using Sublime Text 3 and the Latexing package to apply Knitr to compile .Rnw files that contain both Latex and R code. Overall, it works well in that I can compile the .Rnw files into PDFs nicely. But, I am not able to get an important piece of functionality to work as compared to what I have in .R files.

Specifically, I am not able to send small pieces of code to R without compiling whole .Rnw file. I can compile the entire .Rnw file just fine, and that will of course evaluate all of the code chunks that I have knit into the document and create the PDF. I would like to be able to send small pieces of code to be evaluated in the R console without needing to compile the entire .Rnw file. (This is essentially what you can do in R Studio, and is useful for figuring out whether the code that I am including in the .Rnw file does what I want it to do without needing to compile the entire .Rnw file each time or without needing to copy/paste it into some other running R console). When I am just editing a .R document, I can do this via Command + Enter (using the Enhanced R package for Sublime) but this also doesn't work when editing a .Rnw document. Ideally, I'd like to be able to send it via REPL to the R console right within Sublime.

Are there ways to accomplish this in Sublime that I don't know about, or are they just features that have yet to be developed?


2 Answers 2


I had the same question, and I managed to fix it following this recommendation at least for latextools, it may be the same for latexing. /R/Main.sublime-menu file has to be edited:

(which in Ubuntu is in: ~/.config/sublime-text-3/Packages/SublimeREPL/config/R/Main.sublime-menu)

and the additional scope has to be modified in this way:

 "additional_scopes": ["tex.latex.knitr.ing"]
  • Hallelujah, it works! Thanks! It was that extra ".ing" that the file needed. Why it would need it, I have no idea, but it works. I'm on OS, and the path to the file for me was: /Users/User_Name/Library/Application Support/Sublime Text 3/Packages/SublimeREPL/config/R/Main.sublime-menu Oct 17, 2014 at 2:58

That is indeed a functionality that the LaTeXing package offers, thanks to @RandyLai's Sublime Text package Enhanced-R (or its refactoring R-Box) as per this bit of LaTeXing's documentation. The default key binding, which works for me, is command/ctrl + b, depending on whether you have an Apple keyboard or not.

I assume you have the requisite ST packages installed: LaTeXing, Enhanced-R/R-Box, SublimeKnitr (called "knitr" in Package Control). A few reasons why it may not work for you:

  • when you are writing your .Rnw, perhaps you aren't using the "LaTeXing (Knitr)" syntax
  • perhaps you, like me, don't use the standard Sweave syntax, i.e., delimiting R code with <<>>= and @, for your code chunks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.