Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I view syntax-highlighted source code for operators e.g. %in%?

Tags:

In RStudio, I know that if I press F2 while the caret is on a function name I will be shown the source code for that function as if it was an open R script, which syntax highlighting and everything.

How do I do the same for operators like %in% and names like if? These things don't work:

  1. Typing %in% into the script or console and pressing F2/Go To Definition.
  2. Typing `%in%` (surrounded by backticks) into the script or console and pressing F2/Go To Definition.

The only way I can view their source code is by running `%in%` in the console, where it shows me an unhighlighted version.

Thanks!

like image 621
DuckPyjamas Avatar asked Feb 18 '19 01:02

DuckPyjamas


People also ask

How do I print codes with syntax highlighting?

Simply open the file on command line with vim <filename> , type :syntax on<ENTER> , then :hardcopy<ENTER> to print it.

How do you copy with syntax highlighting in VS Code?

Usages. Open code file or select code snippet in Text Editor, then press F1 and then select/type Copy Syntax , or right click the Text Editor and then click Copy Syntax in context menu, the code with syntax highlight will copy to clipboard.


1 Answers

You can see them by using View() with backticks around the argument:

View(`%in%`)
View(`if`)
like image 200
morgan121 Avatar answered Sep 17 '22 23:09

morgan121