Reputation: 1782
I am using the Vim-R-plugin to edit files containing markdown and R-code blocks such that the files can be complied using knitr. The filetype is: RMD. I have enabled spell checking. How can I disable the spell checking within the code blocks?
Upvotes: 3
Views: 2441
Reputation: 1
I got this to work on OS X by editing the ~/.vim/syntax/R.vim and doing a search and replace of all instances of @Spell to @NoSpell. Then restarting vim. All the red underscores were gone from the code chunks but were still in the rest of the the rmarkdown.
Interestingly this has not effected the spell checking in pure R documents that have a .R extension, so I having thought I understood what I was doing perhaps I have to admit I don't fully. But at least it has turned off spell checking of the code chunks in rmarkdown (Rmd) documents while leaving it still working elsewhere in the document.
Upvotes: 0
Reputation: 3794
Instead of trying to get the @NoSpell working by region, my approach is to toggle between languages.
I work in three languages which are set up to toggle with a function key where I include "nospell". This makes turning spellchecking on and off as easy as pressingt F7. When coding and writing nospell is turned on, when finalizing the edits I toggle to the appropriate language.
In fact, I find spellchecks in my code to be a plus. I make mistakes in the comment sections too, sometimes even in variable names/plot lables etc. This way you have a quick last check of all language items that are going to be visible .
Upvotes: 0
Reputation: 172598
Spell checking is attached to certain syntax groups. Find the :syn region
that covers the R code blocks, and append / edit in contains=@NoSpell
.
Upvotes: 5