Sublime Text: Keyboard shortcut for opening user settings on Windows - sublimetext2

Is the shortcut for opening the user settings in Sublime Text in Windows / Linux Ctrl + ,? I'm assuming this because the command for opening user settings on Mac is Cmd + ,.

The Cmd+, keyboard shortcut is OSX specific - the default keybindings for Linux and Windows do not contain anything to open the user settings file.
However, you can add it yourself in the user keybindings file.
In Build 3114, this is accessible from the Preferences -> Keybindings - User menu:
{ "keys": ["ctrl+,"], "command": "open_file", "args": {"file": "${packages}/User/Preferences.sublime-settings"} }
In Build 3118, this is accessible from the Preferences -> Keybindings menu:
{ "keys": ["ctrl+,"], "command": "edit_settings", "args":
{
"base_file": "${packages}/Default/Preferences.sublime-settings",
"default": "// Settings in here override those in \"Default/Preferences.sublime-settings\",\n// and are overridden in turn by syntax-specific settings.\n{\n\t$0\n}\n"
}
},

Update
As of build 3124, the name of the option is now Preferences: Settings. Because of Sublime's fuzzy matching, you can just type in something like prefs to narrow down the options.
Original Answer
If you are referring to the Preferences.sublime-settings file, then you can do it in a couple steps:
Use Ctrl+Shift+P to open the Command Palette.
Start typing in settings - user. Eventually you'll see the option.
Select it.

Related

sublime key binding for plugin commands

I did see:
Sublime text: how to add a key binding to hex_viewer package command
Sublime Text set key binding for Tools > Babel > Babel Transform
I have installed JSON Reindent in my Sublime (3.2.2 Build 3211). To reindent a JSON I press Ctrl+Shift+P type in JSON Reindent in command pallet and press enter.
I would like to bind a key combo say Ctrl+Shift+J to JSON Reindent command. I already have my own Default (Linux).sublime-keymap in the right place with a lot of overrides. But I'm unable to find command name.
This functionality is brought in by a plugin so command won't be available here. I tried to:
bind indent and reindent, no luck
bind json_reindent, JSON_Reindent and JSON Reindent, no luck
enable command logging via sublime.log_commands(True) in cosole, then did
Ctrl+A (select all)
Ctrl+Shift+P
type in JSON Reindent in command pallet
press Enter
It printed following in console (nothing for JSON reindent).
>>> sublime.log_commands(True)
command: move_to {"extend": true, "to": "eol"}
command: select_all
command: show_overlay {"overlay": "command_palette"}
What do I put for command to bind a plugin's command in my Default (Linux).sublime-keymap?
{ "keys": ["ctrl+shift+j"], "command": "?????" },
The command you're looking for is found in the plugin's sublime_json_reindent.py file and is, in fact, called as sublime_json_reindent. It can also be found in the Default.sublime-commands file.

How can I run powershell.exe with Anaconda in new windows terminal profiles?

New Windows Terminal (Windows Terminal (Preview) Version: 0.2.1831.0) have settings in JSON file. How can I setup powershell running with Anaconda?
Anaconda running in powershell with:
%windir%\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy ByPass -NoExit -Command "& 'C:\Users\akali\Anaconda3\shell\condabin\conda-hook.ps1' ; conda activate 'C:\Users\akali\Anaconda3' "
Windows Terminal use profiles in JSON like this:
"profiles": [{
"colorScheme": "Solarized Light",
"commandline": "powershell.exe"
}]
How can I use running with Args with double quote in JSON that allow me run something like -Command "& 'C:\'"?
I realize I'm late of some years but I had a similar problem and stranded up here looking for an answer. So, I'm hoping that this is useful for people like me in the future.
After some time tinkering I generated an Anaconda profile:
copy paste an existing profile
generate guid here
open C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Anaconda3 (64-bit)
right click on Anaconda Powershell Prompt (Miniconda3) and go to Properties
copy the entire content of the target field and paste it on the field commandline (make sure the field is commandline and not source)
escape all the \ characters (\ --> \\)
Change the name field
You should have something like this
{
"guid": "{generated guid}",
"hidden": false,
"name": "Anaconda",
"commandline": "powershell.exe -ExecutionPolicy ByPass -NoExit -Command & 'C:\\ProgramData\\Miniconda3\\shell\\condabin\\conda-hook.ps1' ; conda activate 'C:\\ProgramData\\Miniconda3'"
},
As a nice sidenote, you can also create a profile to directly launch an Ipython session or a jupyter notebook.
As you may have noticed, lo launch anaconda in the commandline field we are just launching powershell.exe, and then telling the powershell instance to execute a -Command, which is the subsequent string.
Were you to add a ; ipython to the command, you would launch an ipython session.
Copy-paste the settings for cmd from above.
Go to "C:\Users\Username\AppData\Roaming\Microsoft\Windows\Start
Menu\Programs\Anaconda3 (64-bit)"
Right-click on "Anaconda Prompt (Anaconda3)"
Copy the content from the target field and paste it on the field commandline
Mine is %windir%\System32\cmd.exe "/K" C:\bin\Anaconda3\Scripts\activate.bat C:\bin\Anaconda3
Replace \ with \
Thanks to the above answer by Marco Necci, this is a more clear version with cmd and anaconda
"commandline" : "%windir%\\System32\\cmd.exe /K C:\\bin\\Anaconda3\\Scripts\\activate.bat C:\\bin\\Anaconda3"
Building upon Navaneeth M et al, I contribute a command line which includes the default Anaconda location using USERPROFILE environment variable, specifying non-default Anaconda env (fastai), starting directory and color scheme.
"commandline": "%windir%\\System32\\cmd.exe /K %USERPROFILE%\\Anaconda3\\Scripts\\activate.bat fastai",
"colorscheme": "Solarized Light",
"startingDirectory": "c:\\sw",
Pro Tip: Use keybindings to add a hotkey which opens a new tab in the specified project directory. For example, use ctrl-b to open a new Anaconda tab in just the right place.
"keybindings": [
{
"keys": [ "ctrl+b" ],
"command": {
"action": "newTab",
"profile": "Anaconda",
"startingDirectory": "c:\\sw\\myproject\\myprojectdirectory"
}
}
]
Right click properties of conda powershell shortcut (in desktop or start menu). There you get the path to the command that effectively starts conda using powershell.
Now, just follow the recipe of Marco Necci outlined above, just caring to put double backslashes instead of single ones.
Searching further modifications, in this site i've found that i could generate the new needed guid with powershell itself: [guid]::NewGuid().
And in the repo of new terminal, i've discovered it's possible to customize the icon too. My icon was in a different path, that i came across looking in anaconda shortcut in windows menu (i used anaconda navigator's icon - right click it > more > open; somewhere ending with 'Start Menu\Programs\Anaconda3 (64-bit)': right click once more in the shortcut > properties; change icon - there is the path to the icon).
Again, be wary to use double backslashes instead of single ones.

Open file on macvim from Iterm2

I always use Command + click to open file from iterm2.
However, it always open a new window instead a new tab of the existing windows.
What configuration do I need to do?
I realized that the configuration need to be done in macvim.
1) Click on macvim > Preferences
2) Go to the General tab
3) In Open files from applications:, choose in the current window

Sublime Text Build in an external window

Is there a way to create a build command in Sublime Text that opens a new external window (terminal/cmd.exe)? Everything I try gets captured to the built-in output window.
I tried:
{
"cmd": ["ruby", "$file"],
"target": "cmd.exe",
"file_regex": "rb$",
"selector": "source.rb"
}
But nothing happened
The following works for Windows (I've tested it on XP and 7):
{
"cmd": ["start", "cmd", "/k", "c:/ruby193/ruby.exe", "$file"],
"selector": "source.ruby",
"shell": true,
"working_dir": "$file_dir"
}
Save it as Packages/User/Ruby_cmd.sublime-build (you may need to alter the path to the Ruby executable depending on your system), select Tools -> Build System -> Ruby_cmd, and build with CtrlB.
start does what it says it does, start a new process independent of Sublime Text. cmd is cmd.exe, the Windows command-line interpreter. The /k flag keeps the window open (at a new command prompt) after your program has run, allowing you to examine its output, look at tracebacks, run additional commands, etc.
May be you will find this solution helpful:
https://github.com/rctay/sublime-text-2-buildview
(transfers build output in the separate sublime tab, you can then do with it whatever you want)

Open folder in Git Bash with Sublime Text 2 on Windows

I'm looking for a solution to be able to right-click on any folder in the side bar, of Sublime Text 2 on Windows, and select "Open with Git Bash" so that Git Bash opens with that folder, ready for my git commands.
I've tried the Open With functionality with the Side Bar Enhancements plugin, but no luck.
Oh, and I've tried the "Git" plugin for ST2. It's not what I need.
This worked for me on Windows 7
Create the following files under Packages/User
git_bash.py
import sublime
import sublime_plugin
class GitBashCommand(sublime_plugin.WindowCommand):
def run(self, **args):
dir = args["dirs"][0]
self.window.run_command("exec", {"cmd": ["start", "sh", "--login", "-i"], "shell": True, "working_dir": dir})
self.window.run_command("hide_panel", {"panel": "output.exec"})
def is_visible(self, **args):
return len(args["dirs"]) > 0
Side Bar.sublime-menu
[
{ "caption": "Git bash...", "command": "git_bash", "args": { "dirs": []} }
]
Make sure to add you Git Bash bin folder avaiable in the Windows PATH, on windows 8 its per default ;C:\Program Files (x86)\Git\bin\
http://www.howtogeek.com/118594/how-to-edit-your-system-path-for-easy-command-line-access/
Create a file with no extension name and put this:
#!/bin/sh
"C:\Program Files\Sublime Text 2\sublime_text.exe" $1 &
Then, open your Git folder > bin, paste it there.
Now, you can do
subl sample_directory