This is a naive (and likely dumb) question, but I can't seem to get the R syntax highlighting to work with my Linux setup.
I've downloaded a r.vim
file that has improved syntax highlighting, and it works on my Windows gvim setup. Does this r.vim
file need to be in the /usr/share/vim/v70/syntax
directory? Right now, I have it in my home directory and trying out source ~/r.vim
in the ~/.vimrc
file. However, this doesn't seem to do anything. Perhaps I'm barking up the wrong tree?
After opening login.sh file in vim editor, press ESC key and type ':syntax on' to enable syntax highlighting. The file will look like the following image if syntax highlighting is on. Press ESC key and type, “syntax off” to disable syntax highlighting.
VIM is an alternative and advanced version of VI editor that enables Syntax highlighting feature in VI. Syntax highlighting means it can show some parts of text in another fonts and colors. VIM doesn't show whole file but have some limitations in highlighting particular keywords or text matching a pattern in a file.
You can change color schemes at anytime in vi by typing colorscheme followed by a space and the name of the color scheme. For more color schemes, you can browse this library on the vim website. You can enable or disable colors by simply typing "syntax on" or "syntax off" in vi.
Press 1 to highlight the current visually selected text, or the current word (if nothing is selected). Highlight group hl1 is used. Press 2 for highlight hl2 , 3 for highlight hl3 , etc. Press 0 to remove all highlights from the current visually selected text, or the current word.
Try adding this line to the file filetype.vim
. filetype.vim
is generally located in the folder ~/.vim
. Create the file if it doesn't exist.
au! BufNewFile,BufRead *.R,*.Rout,*.r,*.Rhistory,*.Rt,*.Rout.save,*.Rout.fail setf r
On startup, vim links all the file extensions listed above to the filetype r, which is likely used by your syntax file. Your syntax file will not define the file extension for you typically.
See this reference for more information. For syntax highlighting, this tutorial might be helpful.
Is the file type getting detected?
:set ft?
That should print out something like filetype=r
in your case. If it's not set, try:
:set ft=r
Still nothing? Try:
:syntax on
I place all downloaded plugins in ~/.vim/plugins/
. You shouldn't have to place any plugins in the system folders.
In your .vimrc
:
filetype plugin on
syntax on
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With