Sublime Text 3: how to show line numbers and bookmarks in distraction free mode? - sublimetext3

It's quite easy to show/hide tabs or minimap in distruction free mode using View menu (Alt+V) or Ctr+Shift+P. Is it possible to do the same for line numbers and bookmark arrows?
Or maybe center whole text in a fullscreen mode? It would have the same effect.

It is not default behavior (keybinding). You can get line numbers, centering etc. only by modifying user config (Preferences -> Settings-More -> Distraction Free-User).
Add for example this:
{
"gutter": true,
"line_numbers": true
}
to get line numbers.
P.S. I was also looking for some shortcut for this. No luck. This is the only way I found for now.

Following the comment on the question by Keith Hall, you can do it by creating a custom keybinding. Open Key Bindings from the Preferences menu and add the following to your user keymap.
[
{
"keys": [ "ctrl+k", "ctrl+l" ],
"command": "toggle_setting",
"args": { "setting": "line_numbers" }
}
]
I chose ctrl-k, ctrl+l as the binding to match with the existing binding that hides the sidebar (ctrl-k, ctrl+b), but obviously it can be whatever you like. Search through the list of existing bindings to avoid a clash.

for line and column number open the setting file: (Preferences -> Settings-More -> Distraction Free-User)
{
"line_numbers": true,
"gutter": true,
"column_number": true,
}

OK, here is a solution ( ~/.config/sublime-text-3/Packages/User/Preferences.sublime-settings ):
{
"always_show_minimap_viewport": true,
"draw_centered": true,
"word_wrap": true,
"wrap_width": 80,
"font_size": 10,
"rulers":
[
80
]
}

Related

JupyterLab 3.0.14 How to disable code style highlights (pycodestyle)

I just installed WPy64-3940 that comes with JupyterLab 3.0.14 .
To my surprise, now my code comes decorated with things called "pycodestyle".
As you can see below, the code is underlined in orange and a popup can appear.
I do not like that at all, it perturbs my reading.
Would you know where this comes from and how I can disable this?
Thanks
Michel
This is not a built-in feature of JupyterLab, but an extension called jupyterlab-lsp. As one of the authors I am surprised to see it included by default on the WPy64 distribution, and sorry you don't like it. Here are three potential solutions:
Ignore this specific diagnostic message (recommended). Right click to bring up context menu and select "Show diagnostics panel"; hover mouse over the row with diagnostic message that you do not like, right click, select "Ignore diagnostics like this".
Disable pycodestyle diagnostic provider completely in setting of the language server. Click on "Settings" menu (top menu bar) → "Advanced Settings Editor" and choose "Language Servers" tab. Copy paste the following settings ("pyls" is the old server, "pylsp" is the new one - only one is needed but I do not know which one you are using); you can also disable other sources of diagnostics for this language server here:
{
"language_servers": {
"pyls": {
"serverSettings": {
"pyls": {
"plugins": {
"pydocstyle": {
"enabled": false
},
"pyflakes": {
"enabled": true
},
"flake8": {
"enabled": false
}
}
},
"pylsp": {
"plugins": {
"pydocstyle": {
"enabled": false
},
"pyflakes": {
"enabled": true
},
"flake8": {
"enabled": false
}
}
}
}
}
}
}
Disable all diagnostics by going to "Diagnostics" tab and adding a catch-all regular-expression rule like this:
{
"ignoreMessagesPatterns": [".*"]
}
Disable the LSP extension altogether. It is probably best to consult whoever creates WPy64-3940 on how to do this.

Sublime Text 3 FileBrowser plugin: how to open in new tab by default

I am using the Sublime Text 3 FileBrowser for file navigation on keyboard.
While usually I open files in new tabs, with FileBrowser, it opens
On the official documentation (https://packagecontrol.io/packages/FileBrowser), it says:
Open all marked items in new tabs ⌘+enter / ctrl+enter
So when I open a file on 'Enter', it will open in the same split pane as the
I want to change this behavior
So I go to Preferences -> Package Settings -> FileBrowser ->
Settings - Default
Key Bindings - Default (Common)
to look for options I can override in user settings. However, nothing seems right.
Somehow found an answer while posting the question, so I throw it out first and look for any better ways from the community.
By setting an open directory command in the Key Bindings, it reverts to opening in a new tab as by default.(I set it as a user setting for easier management: Preferences -> Package Settings -> FileBrowser -> Key Bindings - User)
(from the official package page: https://packagecontrol.io/packages/FileBrowser)
[
{
"keys": ["f1"],
"command": "dired",
"args": {
"immediate": true,
"single_pane": true,
"other_group": "left",
}
}
]
Of course, you can bind the "dired" command to any other suitable key, and tweak other behaviors such as putting it left or right.
One thing to note is that this must not be used with
{
"keys": ["enter"],
"command": "dired_select", "args": {"and_close": true},
"context": [
{ "key": "selector", "operator": "equal", "operand": "text.dired" },
{ "key": "setting.dired_rename_mode", "operand": false }
]
}
Maybe there are ways to tweak around, so I can both open in new tab on "Enter", and let the browser close automatically after selection. For now, I'm settled for closing it with F1.

How do I reassign popup's shortcut in chrome extension?

This manifest.json works fine.
"commands": {
"_execute_browser_action": {
"suggested_key": {
"windows": "Alt+S",
"mac": "Alt+S",
"chromeos": "Alt+S",
"linux": "Alt+S"
}
}
},
How do I allow users to reassign shortcuts? I would like to reassign them right from popup. I have created input, which suppose to be filled with a single letter. This letter suppose to replace 'S' in the manifest. How do I save it into manifest or overwrite shortcut?
You can't integrate shortcut changing in your interface, but you can have a button that links to chrome://extensions/configureCommands

Emmet plugin's expansion doesn't work for Sublime Text 3

I successfully installed Emmet via Package Control.
When I type ul and press Tab, I get <ul></ul>.
When I type ul.class and press Tab, I get ul.body_class but I want it to generate <ul class="class"></ul>.
What am I doing wrong?
I have read posts saying to try Ctl+E instead of Tab as the trigger key, but that doesn't do anything.
Try using Ctrl+Space instead. If that doesn't work, you can try changing the keybinding by putting the following in your User key bindings file which can be found by doing Preferences -> Key Bindings — User:
[
{"keys": ["tab"], "args": {"action": "expand_abbreviation"}, "command": "run_emmet_action", "context": [{"key": "emmet_action_enabled.expand_abbreviation"}]}
]
and then just change "tab" to whatever keybinding you want. Check to see if that works.
After reading your question, I installed Emmet in the Windows version of Sublime Text 3 today and had the same problem. Within my search for the solution, I found the following:
http://docs.emmet.io/actions/expand-abbreviation/#comment-1272517661
In Windows I opened the Default Emmet Preferences. By going to:
Preferences > Package Settings > Emmet > Setting - Default
and
Preferences > Package Settings > Emmet > Key Bindings - Default
As I was closing the settings files, I was prompted to save the setting files. I clicked OK to save and then restarted Sublime Text 3.
After Sublime Text 3 reloaded:
I created a new html file and was able to type ul.class, tabbed and it expanded to <ul class></ul>
It was funny, I never ran into that problem with Sublime on my Mac. If you had to do the same process on Mac, you go to Preferences > Package Settings > Emmet ...
I was facing same issue. Just pasted the below code in "Preferences -> Key Bindings — User:".
{
"keys": ["tab"],
"command": "expand_abbreviation_by_tab",
// put comma-separated syntax selectors for which
// you want to expandEmmet abbreviations into "operand" key
// instead of SCOPE_SELECTOR.
// Examples: source.js, text.html - source
"context": [
{
"operand": "SCOPE_SELECTOR",
"operator": "equal",
"match_all": true,
"key": "selector"
},
// run only if there's no selected text
{
"match_all": true,
"key": "selection_empty"
},
// don't work if there are active tabstops
{
"operator": "equal",
"operand": false,
"match_all": true,
"key": "has_next_field"
},
// don't work if completion popup is visible and you
// want to insert completion with Tab. If you want to
// expand Emmet with Tab even if popup is visible --
// remove this section
{
"operand": false,
"operator": "equal",
"match_all": true,
"key": "auto_complete_visible"
},
{
"match_all": true,
"key": "is_abbreviation"
}
]
}
Github: See for more description
I check the emmet default key is ctrl+e, so I add this to my Key Bindings - User:
{"keys": ["tab"], "args": {"action": "expand_abbreviation"}, "command": "run_emmet_action", "context": [{"key": "emmet_action_enabled.expand_abbreviation"}]}
I will have shared this as a comment directly where I feel like but 50 reps was required. Any ways. Here is what I did that made mine work for me.
From #saadq's answer, do this:
[
//other user key bindings should be here, followed by
{"keys": ["tab"], "args": {"action": "expand_abbreviation"}, "command": "run_emmet_action", "context": [{"key": "emmet_action_enabled.expand_abbreviation"}]}
]
The point is to have other bindings appear before it so that whatever binding overwriting it will be overwritten again.

How to set key-bindings in Sublime that change values of settings?

I'm looking to bind the "alt+f11" binding to toggle "draw_centered", which centers the text as in Distraction-free mode. I'm not sure how to get it to work though.
Heres my keybinds so far:
//if draw_centered == true, set to false
{ "keys": ["alt+f11"], "command": "set_setting", "args":
{
"setting": "draw_centered",
"value": "true",
},
"context":
[
{ "key": "setting.draw_centered", "operator": "equal", "operand": false}
]
},
//if draw_centered == false, set to true
{ "keys": ["alt+f11"], "command": "set_setting", "args":
{
"setting": "draw_centered",
"value": "false",
},
"context":
[
{ "key": "setting.draw_centered", "operator": "equal", "operand": true}
]
}
I couldn't find a command that automatically toggled "draw_centered", so I had to resort to building some sort of advanced command. I'm having a bit of trouble understanding the documentation on keybindings, but I tried to follow the "Contexts" example. Could anyone point to what I'm doing wrong?
Thanks sergioFC for the tip about toggle_setting! I got it to work with this code:
{ "keys": ["alt+f11"], "command": "toggle_setting", "args":
{
"setting": "draw_centered",
}
}
EDIT: I discovered a bug with this. After using the key-combination "alt-f11" now, the distraction-free mode isn't behaving like it should. It now follows the draw_centered state that I am in when I switch from normal to distraction-free mode.
For example: if I have a file opened and click 'alt-f11' so I am left-aligned (i.e. draw_centered = false) , the window will remain left-aligned when I enter distraction-free mode. Any ideas as to why this is and how to fix it?
A little late, but it took me a while to find out how to do something similar and this was the most closest question to what I was trying to achieve.
toggle_setting only works in the current view(file you are working on), it also won't work in other options like show_encoding, because these aren't too related to the view specifically rather than being more part of the panel spectrum.
After digging a couple of hours I found an old plugin called Cycle Settings, this one was for Sublime 2, but after a little tweaking it worked as expected.
(I remember that there was an option to create packages directly in sublime, but don't remember where..)
Go to Preferences/Browse Packages... and create a new file there
"Cycle Settings/cycle_setting.py" and the following code there:
"""
Cycle Setting plugin for Sublime Text 3.
Copyright 2011 Jesse McCarthy <http://jessemccarthy.net/>
Adds a command that can be called from a key binding to toggle or
cycle through values for a setting.
The Software may be used under the MIT (aka X11) license or Simplified
BSD (aka FreeBSD) license. See LICENSE
"""
import sublime, sublime_plugin
class CycleSettingCommand(sublime_plugin.TextCommand):
def run(self, edit, setting, options):
"""Cycle $setting to next of $options"""
index = len(options)
if not index :
return
settings = sublime.load_settings('Preferences.sublime-settings')
value = settings.get(setting)
if value in options :
index = options.index(value)
index += 1
if index >= len(options) :
index = 0
value = options[index]
settings.set(setting, value)
sublime.save_settings('Preferences.sublime-settings')
self.view.set_status(
'cycle_setting',
"Setting '{setting}' cycled to value '{value}'".format(**locals())
)
Now, lets use our new command for bindings
Go to Preferences/Key Bindings
[
{
"keys": ["f5"],
"command": "cycle_setting",
"args": {
"setting": "draw_centered",
"options": [true, false]
}
},
{
"keys": ["shift+f5"],
"command": "cycle_setting",
"args": {
"setting": "default_line_ending",
"options": ["system", "windows", "unix"]
}
}
]
What our command is doing is cycling through the options array and saving the current one in the cycle to User/Preferences.sublime-settings.
I hope this helps someone else, I actually spend a while trying to find how to achieve this with many commands for external plugins and at this rate I was soon going to run out of key combinations, regards!

Resources