Possible to hilight specific text (like user-defined words) in rstudio? - rstudio

With theme option, it's quite convenient to edit on rstudio, especially the highlighted keywords, is it possible to add user-defined keywords? as the number 1 and function.

Related

Customized Comment Rendering - Visual Studio

In Visual Studio (2015) is it possible to change the color/font of lines within comments as viewed in the Text Editor using a custom token or indicator? IE a manner that is similar to that of how Task List items can be assigned and are recognized by user-custom tokenization.
For example:
/* --- Explanatory Comment ---
<> This token is recognized, and the rest of this line appears in orange color.
<1> As a result of the token, this line now appears in a different font.
+ Additional information about the above; the text is light grey.
<?> This line appears in bold (and indicatively curious) blue text.
<!> Extra points, pending the possibility of the aforementioned that the
remainder of the text in line with first character of this paragraph
also conforms to the style as defined by the token preceding it.
*/
MSDN documentation seems to indicate that the creation of "Custom
Categories and Display Items" can be achieved (With the addition of
a VSPackage?) such that they would appear within the display options
box of the fonts and colors under environment in the IDE's options
menu (Options>Environment>Fonts and Colors).
Or by some way of the "IVsFontAndColorDefaultsProvider Interface".
Is there some known and/or preexisting manner in which to accomplish the previously described rendering or a preferable alternative (similar) solution? If the above is the solution, any insight as to its implementation would be greatly appreciated. Thanks in advance.
*Note: My intent is visual enhancement within my own VS Text Editor (potentially others with a package) for the purpose of clarity in such a case that hierarchical organization in comments would be beneficial; rendering to supplement ASCII characters alone.
MSDN Docs:
Implementing Custom Categories and Display Items
IVsFontAndColorDefaultsProvider Interface

Sublime color syntax for Ruby variables vs keywords

Is there a way for Sublime Text 2 to display different colors for Ruby "variables" vs "keywords"? The image below is an example of Ruby code with the default Monokai color scheme. I was hoping I could having the variables (list, x) be a different color than the keywords (each, print).
Currently, they're all tied to <key>foreground</key>. I did try changing the variable color, but that only changed for the |x|.
No, there is not a way to do this with the default Ruby syntax that ships with Sublime. list, each, print, and x are all scoped as source.ruby, meaning they don't have a specific scope that can be targeted by a color scheme. On the other hand, end is scoped keyword.control.ruby, and do is keyword.control.start-block.ruby (in addition to the base source.ruby scope that applies to all elements), so if you have a rule in your color scheme for keyword or keyword.control, they can be colored differently. |x| is punctuation.separator.variable.ruby for the pipes |, and variable.other.block.ruby for x, so those can be adjusted per your preferences.
Essentially, an item can only be colored if it has a distinct scope, and your color scheme contains a rule for that scope (or a more generalized version of it, but not a more specific version of it). Ruby is especially challenging as compared to Python, for example, as while Python methods always have parentheses at the end (string_var.replace(), for example) and regexes can be written to highlight anything between the dot . and the parens as a function call, Ruby does not follow this paradigm, so the syntax highlighting definition (found in the various .tmLanguage files) cannot distinguish between a method call and a simple attribute, and so cannot highlight them differentially. This is why list.each in your program is only source.ruby, and each is not highlighted as a function.

Xcode to highlight operators in different color?

Is there any way to make xcode highlight operators(".","<>", "()", ";", etc) differently, like it is possible in Visual Studio? It really improves the readability of the code.
There's no such option in the preferences but maybe there's some way to edit coloring file directly and make these symbols appear as reserved words? It's ok if the color is blue, like it is for reserved words - as long as it's not the same color as the generic text. I tried googling a plug-in with this functionality, but couldn't find it. It doesn't seem like there are many xcode plug-ins out there.
Try to edit /Applications/Xcode.app/Contents/OtherFrameworks/DeoolsCore.framework/Versions/A/Resources/Built-in languages.pblangspec by adding your operators as keywords.

How do I add features to a syntax definition in Sublime Text without editing it?

For example, I would like to highlight #param, #type, and #return (i.e. epytext declarations) in my Python docstrings. I have figured out how to do this by simply editing Python/Python.tmLanguage; however, I would really like to put this in its own file, for a couple of reasons:
I don't always want to apply this highlighting. It's only for projects that use epydoc as their documentation tool; in other projects, I would want to highlight reStructuredText instead.
When Sublime Text updates, I'd like to have my own syntax as an overlay onto the included features. there are several features of Python that Sublime's author may choose to include in future versions and I don't want to have to manually figure out what I changed each time an update modifies the base Python syntax definition.
I keep my own editor configuration in version control, but I want that to be my own original stuff; I don't want to be burdened with having to carry copies (possibly proprietary? I don't know, it doesn't seem to have an independent license) of syntax definitions that come with Sublime.
Is there a way to put highlighting rules into a separate file, perhaps to only be applied to a particular scope?
Sounds to me like you want to create your own syntax file, inherit from the Python syntax file (source.python), and make your changes and customizations there. Sublime Text 2 uses the .tmLanguage format for syntax files, which is a bit complex, but fortunately most of the work has already been done for you, just by inheriting from source.python.
What you want to do is set up a regex pattern to match the substrings that you want to highlight, and give that pattern a name; something like punctuation.definition.comment.epydoc, to follow the convention set in Java/JavaDoc.tmLanguage. Then, check your color scheme file (ending in .tmTheme) and make sure there are settings for the scope that you've chosen -- or for one of its parents, since ST2 should use proper scoping rules for this sort of thing.
To use the syntax file you've created, stick it in Packages/User (so that ST2 doesn't overwrite it on upgrades), open a Python file in the editor, and then select your new syntax from the dropdown list in the bottom right corner of the window. If you've set up everything correctly, the epydoc strings should change to be whatever color you've set in your color scheme.
Good luck! And post a link somewhere when you've got a syntax file that works, so others can see and use it, as well!

Reformatting code in text mate to established code conventions - Visual studio's ctrl K+D equivalent on Text Mate

Can anyone tell me if there's a quick way to format your code in Text Mate, similar to pressing ctrl K+D in Visual studio?
Thanks!
Edit by Damien_The_Unbeliever:
For those not familiar with Ctrl K+D, it doesn't just indent code - it reformats it using the generally established formatting conventions in the editor - it may replace spaces with tabs or vice-versa for the indentation, ensure code is consistently indented, move braces to separate lines, etc.
TextMate reindenting and reformatting varies a little depending on the language you're using.
You can generally use the Text menu, that depending wether you have an active selection or not it will show you different commands under it. For example, if you have selected a section of code, there will be a Indent Selection menu item. If you have no active selection, it will be Indent Line.
To have this working properly, be sure to select the current language, if it isn't assigned yet (like on unsaved documents). If you're working with HTML, it will simply indent the lines depending on what's above it. It will keep line breaks intact.
If you need something to break out tags on new lines and properly format the document, you should use the Tidy command that is found in the Bundles menu, under HTML (or simply by using the shortcut CTRL+SHIFT+H. If you have a selection active at the moment that you use it, it will simply reindent that section. If instead you have no selection, it will properly reformat the whole document, including checking for tag validity and other errors.
The Bundles for other language have similar commands, like XML (still Tidy) and Javascript (that has a Reformat Document command).
As an ending note, I simply suggest to look into the Bundles menu; there are many little gems in it. ;)
Did you look in the menu bar? Under Text you have a couple of Reformat… entries that may fit your needs.
Beside these native features, some bundles — like the JavaScript one — have custom Reformat… commands : click on the little cog button at the bottom and explore your current language's bundle's content.

Resources