I use GoSublime inside sublime text for Golang development.
Pressing Ctrl + B gives me the build pane, then I need to type a command e.g., go run main.go and press Enter. When I want to execute a command using numpad Enter it doesn't work. How to make it work with numpad Enter too?
I checked the default keymap in sublime text it provides only the following key bindings for build tool
{ "keys": ["f7"], "command": "build" },
{ "keys": ["ctrl+b"], "command": "build" },
{ "keys": ["ctrl+shift+b"], "command": "build", "args": {"select": true} },
{ "keys": ["ctrl+break"], "command": "exec", "args": {"kill": true} },
Thank You!
The only suggestion I can give is to try using numpad_enter both with NumLock on and off, and see if it makes a difference. I'm running OS X and using the standard wired Apple keyboard with a numpad, and I'm also running Linux in a virtual machine. When I open up the console (Ctrl`) and run the command
sublime.log_input(True)
then refocus the file I'm working on, pressing Return (the Enter equivalent on the main keyboard) yields
key evt: enter
in the console, whereas hitting Enter on the keypad yields
key evt: keypad_enter
This behavior does not change in OS X or Linux (I haven't tried in my Windows VM yet) regardless of how NumLock is set. If you're on Windows or Linux with a Windows keyboard, it may change, but I doubt it.
The reason Sublime does this is because numpad_enter and Enter/Return send different keycodes to the program. Sublime is looking for a certain keycode (the one sent by Enter) to submit the contents of popup menus and whatnot, and ignores the code sent by numpad_enter. Unfortunately, because this is built-in behavior, there is no setting or key binding that can be set to override it.
The only other possibility I can think of is to use a utility for your OS to reprogram you numpad_enter to send the same keycode as Enter. I'm not terribly familiar with it, but for Windows I've heard that AutoHotKey is a pretty useful utility, and as far as I can tell is free. You can remap keys with it rather easily. You'll have to google for other utilities if you're on OS X or Linux.
Good luck!
Related
I want to have a keyboard shortcut key for opening the same file in another tab.
this can be done using File>Split view
How can I create a keyboard shortcut for this
{ "keys": ["ctrl+u", "ctrl+s"],
"command": "clone_file",
"args": {"add_to_selection": true} },
BTW, I found the command's name by typing sublime.log_commands(True) into the console. See OdatNurd's excellent video on this: P101-03 Tools of the Trade: Harnessing the power of the console!
I'm using Sublime Text 4's Terminus package and trying to open more than one terminal session within Sublime's panel view.
In VSCode it looks like this:
The closest I can get is to open each session in a separate tab on grid layout, which works fine, but I get the minimap which is not desired, and also I loose the ability to toggle open & close as opposed to the panel:
After doing a bit of research & watching this video I see in the comments the following question & answer:
Q: is there any way to open several instances of Terminus in the panel?
I could open several instances of it in Tab View, but not in the bottom panel.
A: There is an argument you can use in the terminus commands named "panel"; that gives the created panel a name. If you don't provide it there's a default. Using a different panel name lets you create or toggle extra panels.
So I've been testing Terminus settings with that in mind but no luck so far.
Terminus key bindings:
{
"keys": ["ctrl+alt+p"],
"command": "toggle_terminus_panel",
"args": {
"panel": "git",
"cwd": "${file_path:${folder}}"
}
}
With the above, terminal does open from panel but always with one session, if I add another key binding with a different panel name it still opens & closes the same session as the other key binding.
Tried also "command": "terminus_open" instead of "command": "toggle_terminus_panel", but doesn't work with panel as argument. Adding another panel name like the following does nothing either:
"args": {
"panel": "git",
"panel": "server",
}
Is this actually possible or what am I missing?
As noted in the comments on your question, if your goal is to have multiple panels open simultaneously each with a different visible name (i.e. a tabbed panel interface) that's not possible because currently Sublime supports only a single visible panel at a time.
However, if the goal is to have multiple panels that you call up via key bindings, that is indeed possible. What you tried doesn't work because the argument name is actually panel_name and not panel (sorry for the confusion; I've edited the comment on my video as well to reflect that).
So you can do something like this:
{ "keys": ["alt+`"], "command": "toggle_terminus_panel", "args": {
"panel_name": "first-panel"
}, },
{ "keys": ["shift+alt+`"], "command": "toggle_terminus_panel", "args": {
"panel_name": "other-panel"
}, },
The important consideration is that all key bindings need to include panel_name in them; if you don't provide the argument Terminus defaults to finding and opening the most recently active panel, whatever it happened to be.
Thus you could use a third binding if you always wanted to go to the most recent, if that is also interesting.
Note also that in your question you mentioned putting this in Terminus settings; the appropriate place is in your Key bindings (Preferences > Key Bindings).
When I began ST there was a box at the bottom that provided feedback on my code. I've named that the output panel (please enlighten me if that is not the correct term for it)
http://imgur.com/LLovw9B
I must have changed a setting accidentally, because at some point I noticed it had disappeared.
http://imgur.com/a/yAzY6
Solutions tried:
Scrolling the mouse around the area at the bottom of the ST window to try find a bar to drag up, in the hope that would bring the output panel back into view.
Tools/Build Results/Show Build Results.
Clicking on the icon at the far left of the window's bottom panel, selecting "Build Results". There is a "Hide Panel" option too which I've selected. After I select this option the menu remains the same except that that option is no longer there. I can bring it back by selecting the "Build Results" option.
Dragging ST from the applications folder to the Trash, re-downloading the .dmg file from the Internet, and installing the program again.
PS: I've Googled and can't find anyone who has experienced a similar issue.
In Sublime Text, you have the console panel (in which you can enter python commands) and output panels (which can be many).
The console panel is called console (and the default key to open it is CTRL+`), and one already existing output panel is called output.exec (which displays output from building code for example).
To toggle (open/close) a panel, you can bind it to a key:
Open Sublime Key Binding Preferences
In the User Settings file, add a line such as:
{ "keys": ["alt+backquote"], "command": "show_panel", "args": {"panel": "console", "toggle": true} }
Save the file, and try your new shortcut key.
Your User keybindings file should look something like this:
[
{ "keys": ["alt+backquote"], "command": "show_panel", "args": {"panel": "console", "toggle": true} },
{ "keys": ["alt+shift+backquote"], "command": "show_panel", "args": {"panel": "output.exec", "toggle": true} }
]
Note 1: This is JSON so there must be a comma after each line except the final line.
Note 2: Be careful not to set a shortcut already used by your system (Mac OS X)
Modifier Keys:
ctrl = Control key
alt = Alt/Option key
shift = Shift key
super = Command key (or the windows key on MSWindows). It's the key next to the space key usually.
You can see what panels are available by opening the console panel and typing window.panels()
Remove ST (including the system files), download and install again to restore default settings with an output panel.
(This worked for me because I have just started in ST. I imagine it would be an unsatisfactory solution for someone who has customised ST and doesn't want to return to the default settings.)
I saw this project that basically opens a new terminal window from sublime text-2.
What I'm looking for is a way to open the terminal inside sublime text 2 via console.
Does anyone knows how can I do that?
SublimeREPL does what you want
https://github.com/wuub/SublimeREPL/
Of course, there are some limitations because the window of Sublime Text 2 is not originally designed for continuous running buffer of stdin input.
+ 2 years (sorry) - but my solution in ubuntu was to open both sublime and my (real) terminal in the same window, shrink and stretch the terminal to cover the lower portion of the screen, then right click on the terminal and select "keep on top" - works a treat.
EDIT 04/23/2019: Terminus extends TerminalView & adds:
Windows support
Continuous history
Easily customizable themes (see Terminus Utilities)
Unicode support
256 colors support
Better xterm support
Terminal panel view
imgcat support (also works on Linux / WSL)
Bind key shortcut to open shell on file path (e.g. ctrl+alt+t to open):
{
"keys": ["ctrl+alt+t"], "command": "terminus_open", "args": {
"cwd": "${file_path:${folder}}"
}
}
Original Answer:
I've tried pretty much every terminal package around, what you want is TerminalView:
To bind a key shortcut, simply add it to your user key bindings file:
{ "keys": ["ctrl+alt+t"], "command": "terminal_view_open" },
Use Glue. It is a plugin that provides an interface to your shell from the Sublime Text. So basically it a terminal for Sublime Text.
https://packagecontrol.io/packages/Glue
Like #mikko I also decided that due to the limitations of the shell add-ons for sublime to stick with a real terminal window - I've got too used to the F2-F4 workflow of geany.
So really the issue for me is quickly flip-flopping between the two windows easily. To that end, I knocked this up - to be fired from F12 (or whatever you want) in your desktop manager (XFCE in my case)
Note, I launch sublime a from shortcut with terminator -T st3_bash & st3 so I've got a known bash window title for switching focus to.
https://gist.github.com/robertpearce/8725224
I know this code is really, (really) bad, and it'll fail if you have multiple sublime's open, but i don't ever have that anyhow.
Feel free to fork and improve it.
I have always wanted a way to open terminal inside sublime text. After trying out different options I have come to a solution of installing guake terminal as a work around on linux systems, follow the steps below.
Run the command sudo apt-get install guake
Press F12 (for opening terminal)
Now you can use the terminal without leaving sublime.
For windows :
Install Conemu
Have the Quake settings as shown in the pic below
Press ctrl + ~ (for opening terminal)
Note: This is just a workaround. Guake is basically a terminal package for ubuntu-like linux systems.
I am using VIM in Windows. The problem is that I want to use CtrlV as a visual mode. However, this key has conflict with Windows paste. How can I reset this key back to VIM visual mode instead of pasting. I prefer to set this in my _vimrc configuration file.
From the VIM documentation:
Since CTRLV is used to paste, you can't use it to start a blockwise Visual
selection. You can use CTRLQ instead. You can also use CTRLQ in Insert
mode and Command-line mode to get the old meaning of CTRLV. But CTRLQ
doesn't work for terminals when it's used for control flow.
Check your _vimrc file and see if it sources mswin.vim. That script maps the ^v to the paste. You can either remove that line on your _vimrc file or disable the mapping commands directly on mswin.vim.
Do a :help behave on vim for more info.
Visual mode (and other stuff) working like in Unix requires both JOP's and Windows Programmer's suggestions.
In GVim on Windows, go to the edit menu, click on startup settings, and comment out the windows-specific garbage (using the vimrc comment character, which is a double-quote). The mswin.vim file is where the ctrl-v override is specified, and the behave mswin option makes it so that the arrow keys don't just apply motion like you'd expect (it also changes the mouse selection behavior).
"source $VIMRUNTIME/mswin.vim
"behave mswin
I like to add a black-background colorscheme in there as well, so it looks more like what I'd see in a terminal (and because a light background is great on paper, but awful on a backlit screen):
colorscheme koehler
If this line in your _vimrc troubles you:
behave mswin
then delete that line.
Here's a modern day solution to this problem. It applies to the terminal version of Vim/Neovim, not the GUI version. If you use Microsoft's new-ish Windows Terminal (I highly recommend it.), you can redefine its key bindings to your advantage. The following section of the settings file is initially NOT commented out. If you comment it out, as I've shown, Ctrl+V becomes the rectangular visual select key in Vim we all know and love.
// Copy and paste are bound to Ctrl+Shift+C and Ctrl+Shift+V in your defaults.json.
// These two lines additionally bind them to Ctrl+C and Ctrl+V.
// To learn more about selection, visit https://aka.ms/terminal-selection
//{
// "command": {
// "action": "copy",
// "singleLine": false
// },
// "keys": "ctrl+c"
//},
//{
// "command": "paste",
// "keys": "ctrl+v"
//}
Now here's the weird part. I'd expected this to change the behavior of Ctrl+V outside of Vim in the Terminal, so I checked. It still does a paste, but it's different than the Ctrl+Shift+V paste. Inside Vim, however, all is good: Ctrl+V for rectangular select; and "*P, Ctrl+Shift+V, or Right Mouse Button for pasting from the clipboard.
I prefer the same keystrokes everywhere so I use this in my .vimrc to override mswin.vim:
if has('win32')
" Avoid mswin.vim making Ctrl-v act as paste
noremap <C-V> <C-V>
endif
I'm not sure there is a lot you can do about that. You can use CtrlQ instead though.
For the Windows Terminal (PowerShell), click on the Dropdown arrow right next to the Shell-Tab and select settings. In the "actions" section of settings.json you can comment out the following lines so they're saying:
// { "command": {"action": "copy", "singleLine": false }, "keys": "ctrl+c" },
and
// { "command": "paste", "keys": "ctrl+v" },
This unbounds Ctrl+V and Ctrl+C from Paste and Copy. However due to the defaults.json you're still able to use Shift+Ctrl+C and Shift+Ctrl+V for Copy and Paste with this solution.
Please see Phil R comment. Didnt see his solution in the first place.
The combination of jop's advice (looking for mswin.vim in the default _vimrc file) and "Windows programmer's" advice (getting rid of the "behave mswin" line) worked like a charm for me.
(my rep is too low to vote them up or combine them -- someone clean this up for me, or I'll come back once my rep is higher)
For VMs on Windows where CTRL+V does the pasting:
Simply do CTRL+SHIFT+V ... works immediately and similarly to original CTRL+V visual selection.^ Source: Comment mentioned by stevesliva.
If the Windows-specific mappings as a whole bother you, you can set
let g:skip_loading_mswin = 1
in your vimrc to disable loading it (mswin.vim) entirely.
In Windows Terminal, the CTRL+V shortcut is assigned to paste command by default. If you use Vim in Terminal, you can change the paste key binding in Terminal's Settings / Actions menu. (Or use the WSL/PowerShell/Command Promt etc... directly, instead of launching it from Terminal.)