Sublime Text: prevent new line comment - comments

I am not completely sure if this not a plugin, but after starting a line comment in .js file, for example, when I hit enter the next line starts with "//" as well. This is kind of annoying. Is there a simple way to remove this?

In "Preferences -> Package Settings -> Doc Blockr -> Settings Default" you can find lines:
// If true, then pressing enter while in a double-slash comment (like this one)
// will automatically add two slashes to the next line as well
"jsdocs_extend_double_slash": true,
If you want to disable this behavior go to "Preferences -> Package Settings -> Doc Blockr -> Settings Default" and add
{
"jsdocs_extend_double_slash": false
}

This is indeed caused by the package DocBlockr.
When using this package, you can hit shift + enter to prevent the // from appearing on your new line.

Related

error msg setting editor preferences, format on save, format on paste for Prettier - unable to write into user settings. How do I correct this, pls?

Installed Prettier. Want to set preferences to format on paste and save but getting error message - unable to write into user settings. Please open the user settings to correct errors/warnings in it and try again.
To format prettier I went into the extension, typed in format and tried to select Format on paste and format on save. That's when the error message appeared. When I check settings, I see this:
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[html]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
What can I do?
Follow the steps it might help you:
Open the user settings file by going to Preferences > Settings in the VS Code editor, or by pressing the keyboard shortcut Ctrl+ (on Windows) or Cmd+ (on Mac).
In the Settings editor, find the section for "editor.formatOnPaste" and "editor.formatOnSave". Make sure that these settings are set to true, like this:
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
Check the rest of the file for any syntax errors or warnings. In your case, it looks like there is an extra comma at the end of the "[jsonc]" and "[html]" sections, which is causing the error. Remove the extra comma, and make sure that the file is properly formatted and indented.
Save the changes to the file, and try setting the formatting options again.
This should work now that the syntax errors have been fixed.

sass-lint in Visual Studio Code mixed tabs with spaces

I just installed sass-lint in my VS Code editor and I keep on getting this error for each and every property(line) I've set in my *.scss files:
[sass-lint] Mixed tabs and spaces
Indentation type in VS Code is set to tabs(4), it is set to indent using Tabs.
How can I disable mixing of tabs and spaces for sass-lint?
To close this one off, I later on found out that it is a best practice to use a EditorConfig file to pre-set all of your workflow settings.
This is a plugin-type settings file, which pre-configures desired settings to fit your workflow.
In my case, I use EditorConfig for VScode. After you add it to your editor of choice, simply create a .editorconfig file in your base(root) directory and fill it with the desired settings.
e.g. , my base setup looks like this:
# Editor configuration, see http://editorconfig.org
root = true
[*]
charset = utf-8
indent_style = tab
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
max_line_length = off
trim_trailing_whitespace = false
The real reason is: SASS Lint isn't recognizing your indentation settings and it's using it default indentation (2 spaces). It's looking for 2 spaces and found tabs instead.
You can confirm it by removing all indentation and reading the hint.
As pointed on Pull#725, the correct syntax is:
indentation:
- 1
-
size: 'tab'
I found that sass-lint in Sublime Text 3 wasn't loading my config file.
I got it working after reading this GitHub issue:
In SublimeLinter preferences (Preferences -> Package Settings -> SublimeLinter -> Settings):
"linters": {
"sass": {
"working_dir": "${/home/myusername}"
}
},
Add the file .sasslintrc to your Home folder:
{
"rules": {
"indentation": [
1,
{
"size": "tab"
}
]
}
}

Sublime Text start without opening previous/old files

Sublime text opens, wants to reload old files because they have changed, I reload a few and then it crashes.
Is there a way to start Sublime Text afresh, letting it forget the last files that it had open?
In Sublime Text 3 set hot_exit to false in "Preferences -> Settings-User"
"hot_exit": false
remember_open_files doesn't exist in Sublime Text 3 settings anymore.
Go to Sublime Text
Choose
Preferences >> Settings-User
Add the code below to the current settings. (Remember to add a comma at the end of the first line if it doesn’t) and save it.
{
"remember_open_files": false,
"hot_exit": false,
}

Creating a Matlab run line shortcut (like R)

R has a great shortcut that runs the line your cursor is currently on then moves the cursor onto the next line (cmd + return). In matlab, you have to highlight the line then run the highlighted section (shift + F7).
Is there a way to create an 'R like' run line shortcut? I'm using OSX.
On the Home tab, click New, and then select Command Shortcut.
In the Label field: enter a name for the shortcut.
In the Callback field:
currentEditor = matlab.desktop.editor.getActive;
originalSelection = currentEditor.Selection; assert(originalSelection(1)==originalSelection(3));
currentEditor.Selection = [originalSelection(1) 1 originalSelection(1) Inf]; disp(currentEditor.SelectedText);
eval(currentEditor.SelectedText);
currentEditor.Selection = originalSelection + [1 0 1 0];
Now I can run the line I'm on by pressing Alt+s+1 (perhaps you can change this to an arbitrary hotkey). I hope this helps.
EDIT: In MATLAB R2018a Command Shortcuts have been repackaged as Favorite Commands. So to create a new shortcut in this and later version, you need to go Home tab -> Favorites -> New Favorite.
EDIT: You currently (in MATLAB R2020b) can run this code with Alt+1 (no need for 's' as above). However, it does not appear to be changeable in Preferences -> Keyboard -> Shortcuts
currentEditor = matlab.desktop.editor.getActive;
originalSelection = currentEditor.Selection;
currentEditor.Selection = [originalSelection(1) 1 originalSelection(3) Inf]; disp(currentEditor.SelectedText);
eval(currentEditor.SelectedText);
currentEditor.Selection = [originalSelection(3),0,originalSelection(3),0]+[1,0,0,0];

Sublime Text 2 - Default Document Type

Is there a way to set a default document type when saving a NEW FILE?
I created several new files and I want to have a default value of .txt when saving a NEW FILE.
Create a new plugin Tools > Developer > New Plugin...
Paste this in:
import sublime, sublime_plugin
class EverythingIsPowerShell(sublime_plugin.EventListener):
def on_new(self, view):
view.set_syntax_file('Packages/PowerShell/Support/PowershellSyntax.tmLanguage')
Save and call it NewTabSyntax.py. New tabs will now default to Powershell.
You can change the syntax to whatever you prefer. To find out the "path" of a particular syntax, simply open a file of that syntax, open the console (View > Show Console) and type:
view.settings().get('syntax')
This plugin does it:
https://github.com/spadgos/sublime-DefaultFileType
seems pretty great.
Edit:
Ok, two things, there currently seems to be a small bug so the text file syntax is not being correctly picked up due to the whitespace in the filename. In addition you need to set the "use_current_file_syntax" to false, (otherwise the new file will default to whatever filetype you have open already when you hit Ctrl-N)... So the fix/workaround is this:
Put the following code in: Packages/User/default_file_type.sublime-settings
{ "default_new_file_syntax": "Packages/Text/Plain_text.tmLanguage",
"use_current_file_syntax": false }
NOTE THE UNDERSCORE.
Next, find the "Plain text.tmLanguage" file and copy and rename it (in the same folder) as "Plain_text.tmLanguage". [be sure to copy/duplicate it, do not just rename it, as it may have dependancies]
Restart, just to be sure, and this should do the trick.
Also note this plugin only works for new files created with Ctrl-N.
Working after these steps:
1.Uninstalled
2.Installed using Package Control
3.Test using default install (type Jave) <-- worked
4.Copy and Renamed file Sublime Text 2\Packages\Text\Plain text.tmLanguage > Sublime Text 2\Packages\Text\Plain_text.tmLanguage
5.Changed file Sublime Text 2\Packages\Default File Type\default_file_type.sublime-settings >
`{ "default_new_file_syntax": "Packages/Text/Plain_text.tmLanguage", "use_current_file_syntax": true }`
-- All working.
I did not need to copy any files into the 'Packages/User' folder
#fraxel _ Thanks for all the help and quick response.

Resources