SublimeText 3 - dynamically enable/disable invisible white space option - sublimetext3

Is there a dynamic way to enable and disable invisible white space display apart from persistent setting, via:
"draw_white_space": "all",

The only way to control the state of the display for white space is via changing the setting that you reference in your question, draw_white_space:
// Set to "none" to turn off drawing white space, "selection" to draw only the
// white space within the selection, and "all" to draw all white space
"draw_white_space": "selection",
For many such settings that are a Boolean value, you can bind a key to the toggle_setting command, telling it what setting that you want to toggle between. However, for the case of the draw_white_space option, it takes a string argument of either "all", "selection" or "none" and so the standard toggle command won't work.
The following is a simple plugin that implements a toggle_white_space command which performs this operation for you. To use it, select Tools > Developer > New Plugin... from the menu, replace the stub code you see with the plugin code here, and then save it as a .py file in the location that Sublime will default to (your User package):
import sublime
import sublime_plugin
class ToggleWhiteSpaceCommand(sublime_plugin.TextCommand):
def run(self, edit, options=["none", "selection", "all"]):
try:
current = self.view.settings().get("draw_white_space", "selection")
index = options.index(current)
except:
index = 0
index = (index + 1) % len(options)
self.view.settings().set("draw_white_space", options[index])
The defined command takes an optional argument named options which allows you to specify the values that you want to toggle between, with the default being all of the possible options.
You can bind a key directly to the command to toggle the state of the setting between all of the possible values of the setting, or use something like the following if you only want to swap between it always being on and always being off, for example:
{
"keys": ["super+s"],
"command": "toggle_white_space",
"args": {
"options": ["all", "none"]
}
},
Note that although this is changing the setting, it's applying the setting directly to the currently focused view, which is persistent but only to the view in question and only as long as that view is open. This doesn't alter the setting for other files that are already open or for any new files that you might open in the future; the default for such files will still be what you have the setting set to in your user preferences.

Related

Is there any way to set background color of lines in GoLand (JetBrains IDE)?

Is there any way to set the background color for certain lines in GoLand (JetBrains IDE) so I can sign what code I have read?
Is it possible to do this? Does not matter if it's an IDE function or via some plugin.
There are a few ways to mark some lines and add them to the "Reading" list:
Bookmarks. It is built-in functionality in IntelliJ-based IDEs. You can go to the line with Authenticator interface declaration and select Edit | Bookmarks | Toggle Bookmark in the main menu. All bookmarks are available in View | Tool Windows | Bookmarks.
3rd-party plugins. I'm aware of MultiHighlight plugin that supports selection of the piece of code.
Sticky selection can do that trick.
there is the brief intro about it:
you can mark a selection to be permanently highlighted, even when your caret moves away. Inspired by "Style token" of Notepad++.
You can define an arbitrary number of Paint Groups. Selecting the appropriate editor action (keystroke or context menu), the all occurrences of currently selected text will be added to the Paint Group and will be permanently highlighted (until you clear the selection with an other editor action). So you can have different text fragments to be selected with the same Paint Group. The Paint Groups are kept when IntelliJ is closed.
You can set different colours for each Paint Group
You can set a marker to be visible on the right side of the editor
You can add multiple selections to the same group
You can convert a Paint Group to multi caret selection (and thus edit, copy, delete, etc. it)
For convenience you can undo the last addition (until the document is edited)
You can cycle through each element in a given Paint Group or in all Paint Groups
Keymap actions are added dynamically for paint, clear and convert as you add more Paint Group

Remove text highlighted rounded corner in Sublime text

I don't like the rounded corner on the highlighted text in sublime text 3. How can I disable this feature from the sublime text?
The rounded corners of selected text in Sublime Text is controlled by the selection_corner_style global setting of your active color scheme. In order to change it, there are basically two ways. You can follow any one.
If you have the PackageDev package installed, then you can choose PackageDev: Edit Current Color Scheme from the command palette. This will open a split window layout with the default color scheme on your right group & your User version on the left group. Add selection_corner_style: "square" to the existing global values and save the file. This will get rid of the rounded corners and give it sharp corners instead.
The second (and the laborious way if you don't want to install a package) is to follow these steps :-
Find out your active color scheme name from the color_scheme setting from your User preferences (go to Preferences: Settings from the command palette).
Create a file by that exact same name in the User directory (Preferences -> Browse Packages ... from the main menu).
Paste the following
{
"variables": {
// Define variables here
},
"globals": {
"selection_corner_style": "square",
},
"rules": [
]
}
Save the file.
Note: If you are using a custom color scheme and don't define the selection_corner_style, the default value of this key is round & it will still apply.

Specify a color scheme for specified file type

I want to use Monokai as my default Color Scheme.
For JSON files I want to use the Monokai JSON+ Color Scheme.
Question: How do I specify which color scheme to use for a specified file type?
The color scheme used in Sublime is controlled by the color_scheme setting. If you select Preferences > Settings from the main menu, Sublime will open up a new window split down the middle vertically showing you two files.
The settings in the left hand side are the default settings that globally apply to everything in Sublime. The settings on the right hand side are your user specific settings.
Any setting you place in the right hand side overrides the default setting on the left, and any setting you don't specifically add to your custom preferences remains at the default.
For Sublime build 3143, the default value for the color_scheme is:
// Sets the colors used within the text area
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
A small handful of settings in Sublime are application specific and can only be altered from the defaults in your user settings, an example of which is the theme setting that controls the overall look of the application.
For all other settings, you can further refine the settings that you want on a syntax (file type) basis, for example to alter how wide a tab is based on the type of the file that you're editing.
color_scheme is an example of setting that can be changed in this manner, allowing you to specify a color scheme other than the default for files of a certain type.
In order to do that, you first need to open up a file of the type whose settings you would like to change (in your example, that would be a JSON file). Make sure that the bottom right of the window is telling you that the file is of type JSON before you proceed.
Next, select, Preferences > Settings - Syntax Specific from the menu. Like the above command, this opens a new window that's split vertically, but this time your custom user settings are on the left and the settings specific to JSON are on the right (the file should be named JSON.sublime-settings).
Any settings that you add to this file will be in effect for any JSON file that you have open, with the rest of the settings behaving as they do above; if it appears in your user preferences, it will be set for JSON, and if it doesn't appear in your user preferences it will be set to the defaults.
So by adding the color_scheme setting specifically to that file, you can make your JSON files have a customized color scheme.
With all of that being said, the easiest way to change the global color scheme in Sublime Text 3143 is to use the Preferences > Color Scheme menu item, which allows you to interactively select the color scheme that you want to use.
There is no such menu item for specifically changing this setting on a per file basis. So if you're unfamiliar with settings in general, your best course of action to get a custom color scheme for a certain file type (JSON in this case) would be:
Use Preferences > Color Scheme... to set the color scheme that you want to use for a particular file type (i.e. Monokai JSON + in your case)
Open up a JSON file
Select Preferences > Settings - Syntax Specific to open up the settings for JSON files
Copy the color_scheme setting from the left hand pane to the right, then save the file
Use Preferences > Color Scheme... to set the color scheme back to your global default.
As soon as you finish step #4, you should see the color scheme in your open JSON file change, letting you know that the operation has succeeded.

Enable mouse wheel to change tabs in Sublime Text 3

I'm trying to enable tab switching using the mouse wheel in Sublime Text 3.
I added this configurations to my User settings:
"enable_tab_scrolling": false,
"mouse_wheel_switches_tabs": true,
Also tried different order and values but none is working.
I always restart Sublime after changing my settings.
Anyone got this working?
"mouse_wheel_switches_tabs": true, only works if the following conditions have been met:
the mouse pointer is over the tab bar while using the scroll wheel
your theme supports it in conjunction with your preferences
try with the Default theme
tweak your theme to support it
The Default theme contains the following rule to enable this functionality:
{
"class": "tabset_control",
"settings": ["mouse_wheel_switches_tabs", "!enable_tab_scrolling"],
"mouse_wheel_switch": true
},
Note that it doesn't work with "enable_tab_scrolling": true, so you did the right thing to set it to false.
You could add this rule to whichever theme you are using by creating a file with the same name as the .sublime-theme you are using, and pasting in the rule surrounded by square brackets - it needs to be a valid JSON array.
More information on how themes work can be found in the official docs.
You haven’t registered Sunblime. It’s the Unregistered popup that is staying in the background messing with your scroll. Look for it and close it and the scroll will work again.

Why Sublime Text 3 doesn't jump a line when I write codes?

When I write the codes in Sublime Text 3 code screen, it is continuosly slides to the right as in the picture. What can I do for this?
Please note that 10th line.
The setting word_wrap controls this:
// Disables horizontal scrolling if enabled.
// May be set to true, false, or "auto", where it will be disabled for
// source code, and otherwise enabled.
"word_wrap": "auto",
The default value is auto as shown here. If you add this to your own settings and set it to true, it will wrap for you,
If you want to activate word wrap only for the current view (the current file you're editing), just go view -> word wrap
Just in case you don't know where you have to add the setting, it is in you setting file, you can open it by going to Preferences -> Settings - User, and then just add it between the brakets (it's json)
Matt

Resources