I'm opening .RUL files in Sublime Text which do not have any syntax highlighting, since InstallScript has a similar syntax to C/C++ I want all my .rul files to be treated as if they were .c or .cpp files and automatically have all the same highlighting applied to them. In other words: I want to have the same effect as if I renamed each .rul file to .cpp and then opened the .cpp in Sublime.
What's the easiest way to implement this in Sublime Text 2.0.2 ?
You can open the file in Sublime Text and use menu "View" → "Syntax" → "Open all with current extension as..." → (select appropriate syntax).
Also, you can click on right bottom corner of the window. This will open similar menu, where "Open all with current extension as..." is presented too.
I'm not sure if the other solutions posted above will apply to all future instances of *.rul files, OR only to the currently open file.
I found a solution that works perfectly fine for me, just edit:
...\Application Data\Sublime Text 2\Packages\C++\C.tmLanguage
<key>fileTypes</key>
<array>
<string>c</string>
<string>h</string>
<string>rul</string>
According to:
http://docs.sublimetext.info/en/sublime-text-2/reference/syntaxdefs.html
fileTypes
This is a list of file extensions (without the leading dot). When opening files of these types, Sublime Text will automatically activate this syntax definition for them. Optional.
Press Ctrl+Shift+P and type C++, highlight Set Syntax: C++ and press Enter.
Or go to View menu > Syntax > Click C++.
/Users/HOME/Library/Application Support/Sublime Text 2/Packages/C++/C++.sublime-settings
{
"extensions": ["cpp", "cc", "cxx", "c++", "h", "hpp", "hxx", "h++", "inl", "ipp", "rul"]
}
Or, create a similar file and place it in your User directory, for rul and any other additional extensions not defined in the file mentioned hereinabove:
/Users/HOME/Library/Application Support/Sublime Text 2/Packages/User/C++.sublime-settings
{
"extensions": ["rul"]
}
Related
When I open the curly brackets in CSS and hit enter, it just jumps to the next line like this:
body {
}
It doesn't add a new line with an indentation like it used to, I tried looking through the setting and trying everything but couldn't get a result.
I want it to look like this when I press Enter:
body {
}
What you need is a VSCode plugin called "Prettier".
It can be downloaded in the "Extensions" section of VSCode,
or downloaded from this link: https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode
You can try the following:
Check if you have set your default formatter to prettier
You can check the box to Format On Save or ;
Autosave: There are are currently 4 options available -:
a) off
b) afterDelay
c) onFocusChange
d) onWindowChange
To anyone who is facing this problem in VSCode. This feature is not related to any extension, not Prettier or any other extension. What you have to do to fix this bug is:
Go to the settings
Search for Folding Strategy and choose the Auto option
Then enable Folding
It adds that indentation in both HTML and CSS
I would like to auto-close brackets for .csv files when they are open in vscode. Given the following user settings...
{
"editor.autoSurround": "languageDefined"
...
"editor.autoClosingQuotes": "languageDefined"
}
... is there a user configuration where I can add or remove language modes to apply the autoClosingQuotes setting(s) to without enabling it for all language modes?
What you want are called "language-specific settings". See using language-specific settings in vscode and documentation for same.
In your case:
"editor.autoClosingBrackets": "never",
"[plaintext]": {
"editor.autoClosingQuotes": "languageDefined"
}
You can play with those settings to achieve what you want. First I set all languages to never, and then enable it only for plaintext.
Why did I use [plaintext] above? Because in looking through the choices (Ctrl-Shift-P and search for "configure language-specific settings" there isn't a .csv choice. I assume plain text is as close as you are going to get.
I have some Angular component HTML some.component.html that I'm trying to format. When I hit ctrl-shiftp, and selectFormat Document` I get the message:
There is no document formatter for 'nunjucks'-files installed.
So it seems VSCode thinks that the .html file is a nunjucks file.
Is there a way to make it think that it's a html file?
You can switch back to HTML by clicking on the word "Nunjucks" in VS Code's status bar. This "Language Indicator" is near the bottom-right of VS Code's window. Clicking it will display a "Select Language Mode" drop-down-list where you can select "HTML".
After that, things that normally work for HTML files (like Format Document) will work again; however, things like the special syntax highlighting applied to Nunjuck files will not, but you can switch back and forth as needed.
Here's VS Code's documentation for Changing the language for the selected file.
Explicitly adding a "file.associations" in settings.json seems to solve the need to switch back-and-forth.
"files.associations": {
"*.html": "html",
}
Is there a way to tell sublime text 2 to display a column 78 ruler in python and javascript and no ruler in HTML, by default?
Yes! For both a Python and a Javascript file, open it (or just set the syntax for an empty file to Python or Javascript), then click Preferences -> Settings – More -> Syntax Specific – User. Edit that settings file like you would your regular user settings file. Once you're finished, it will look something like this:
{
"rulers": [
78
]
}
Do the same for HTML, but make the "rulers" array empty, i.e.:
{
"rulers": [ ]
}
Subsequently, Javascript and Python files will have a ruler at line 78, whereas HTML will display no rulers. Any settings that you can define in your user settings file can be made specific to a syntax.
Close the file and re-open it if it doesn't take effect. Had to do this with my .py files. Applies for Sublime 3
In Sublime Text 2, I've seen ways of basing the syntax off of the extension. But what about a filename with no extension? For example, I often have a file called "Vagrantfile" which is in ruby, yet Sublime Text 2 always wants to start off in plain text. Is there a way to have it default to "ruby" for a file if it is called "Vagrantfile"?
With Sublime Text 2.0.1, build 2217, look in the lower right of the window, where it says "Plain Text" for the Vagrantfile that is open.
Click that and in the menu that opens, at the top, there will be an "Open all with current extension as ..." sub-menu. Go into that sub-menu and choose Ruby.
Even though the Vagrantfile has no extension, Sublime will remember this and open Vagrantfiles with the Ruby syntax as expected. This does not spread to all files with no extension.
Add the following line to the Syntax Specific - User file in
Preferences > Setting - More > Syntax Specific - User
for permanent staying of the syntax for every Vagrantfile file.
{
"extensions":
[
"Vagrantfile"
]
}