I'm switching editors to RubyMine and I wanted to know what the easiest way to select a block of code is. I'm surprised the default shortcuts are kind of spare. Say I have this code:
require 'spec_helper'
describe Promotions::DarkChocolatePromotion do
let(:multiplier) { 2 }
it "extends Chocolate Promotion" do
expect(described_class.singleton_class.included_modules).to include(Promotions::ChocolatePromotion)
end
describe ".bonuses" do
subject { described_class.bonuses(multiplier) }
let(:expected_bonus) { { "dark" => 2 } }
it { is_expected.to eq(expected_bonus) }
end
end
What's the easiest way to select the code from describe ".bonueses"... all the way down to the completing end?
Best way is to use the shortcut for the Extend/Shrink Selection action which is Alt+Up Arrow / Alt+Down Arrow on Mac and Ctrl+W / Shift+Ctrl+W on Windows and Linux. Here's what it looks like.
In a Mac its its option + Up/Down arrow
Related
I've seen a ton of questions about TinyMCE shortcuts, but nothing quite like this.
I have a situation in which I am iterating over an object of shortcuts I want to add to TinyMCE.
The shortcuts add functionality for the greater app around the editor.
For the most part, it works fine.
However, it appears that I cannot add certain combinations. For example, alt+l and alt+left.
Take this code:
_.each(oHotKeyCollection, function (oHotKey, sHotKey) {
this.editor.addShortcut(sHotKey, oHotKey.note, function (e) {
if (!e) {
e = event;
}
// sHotKey is the pattern (ie. alt+l)
alert(sHotKey)
oHotKey.execute(e);
}.bind(this));
}
}.bind(this));
When alt+l is added, and then alt+left is added, hitting alt+l on the keyboard will bring up an alert with alt+left.
Removing the alt+left shortcut allows alt+l to function as expected.
The same behaviour seems to be true of alt+r and alt+right as well as alt+u and alt+up.
How I can get both shortcuts working?
The problem is that only certain keywords can be used in a shortcut, such as the modifier names (ctrl, alt, etc...). Anything else is treated as a single key so left in this case isn't valid and is treated as just being l (see Shortcuts.ts). That's why alt+l is being overridden with your alt+left behavior.
So to fix that, you'll need to use the keycode for left instead of a keyword. In this case that would be alt+37. Here's a fiddle showing that working by printing to the console: https://fiddle.tiny.cloud/EEhaab.
Since you also mentioned you're trying to register other arrow keys, here's the key combinations you'd need to use:
Left: alt+37
Right: alt+39
Up: alt+38
Down: alt+40
What keyboard shortcut lets you go to the start of a string? I need this for emails. When i use CTRL + back arrow it jumps to the dot and # sign, i have a block of strings with emails at the end, i want to select only the email by going to the end of the string but as some people have firstname.lastname#something.com and flastname#something.com the cursors dont line up when i use CTRL + back arrow.
I cant find any specific shortcuts which would help in this situation.
thanks!
You can use the extension Select By
You can use the:
forward - backward
surround
Add this to your settings:
"selectby.regexes": {
"email": {
"surround": "[-.a-zA-Z0-9]+#[-.a-zA-Z0-9]+"
}
}
You can call the select with a command or define a keybinding, see the doc page
There are no built-in commands that will do what you want. You will need an extension. I wrote such an extension: Jump and select.
With this setting (in your settings.json):
"jump-and-select.putCursorBackward": "afterCharacter" // default is beforeCharacter
and the default keybinding for jumping backward and selecting Shift+Alt+B it is easy to select everything from your cursor to some preceding character. Just trigger that keybinding and type the character to select backward to, in your case a Space. As you can see in the demo, it works with multiple or single cursors.
I can't seem to find a way to select the beginning of a bracket and jump to the end of it through some key combination or something in VS Code. For example, in atom, this is done with Ctrl + m.
I know there is a way to jump to the beginning and end of a bracket or curlybraces with Cmd + Shift + \ but that does not work for tags. Any ideas?
It is possible to do, but either using Ctrl + Shift + P -> "Emmet: Go to Matching Pair" or by manually setting a shortcut for it (Ctrl + K Ctrl + S).
Unfortunately there is currently no support for it out of the box.
You can use Cmd + % to jump tags in VSCode if you add the following to your keybindings.json.
{
"key":"cmd+shift+5",
"command": "editor.emmet.action.matchTag"
}
Go to: File > Preferences > Keyboard Shortcuts and click the underlined link to edit keybindings.json.
For those using VIM keys: you are already used to pressing % to jump to matching parens and tags. So, hopefully, Cmd + % will be close enough to your existing muscle memory to make this transition painless.
For those who are using Vim plugin and Mac, Leader+% is working well for me.
You can setup in your Vim json file setting.json by adding:
"vim.normalModeKeyBindingsNonRecursive": [
{
"before": ["<leader>", "%"],
"commands": [
{
"command": "editor.emmet.action.matchTag"
}
]
}
]
PS. I mentioned Mac user because cmd+shift+5 is for capturing the screen in Mac.
You can jump to the matching bracket with Ctrl+Shift+\
For more reference, you can refer: Visual Studio Code Navigation
I think you are asking about Breadcrumb Keyboard Navigation
In this case you can simply press Ctrl+Shift+. to go to elements before or after the current element.
There is no support for this out of the box. Though if you are willing to use extensions, there is: https://marketplace.visualstudio.com/items?itemName=vincaslt.highlight-matching-tag which among other things, gives you ability to use command: Jump to matching tag which you can bind to a key.
I found this working autohotkey (ahk) code from the website https://jacksautohotkeyblog.wordpress.com/2015/10/22/how-to-turn-autohotkey-hotstring-autocorrect-pop-up-menus-into-a-function-part-5-beginning-hotstrings/ .
::agin::
TextMenu("again,a gin,aging")
Return
::duh::
TextMenu("what,huh,you're joking")
Return
TextMenu(TextOptions)
{
StringSplit, MenuItems, TextOptions , `,
Loop %MenuItems0%
{
Item := MenuItems%A_Index%
Menu, MyMenu, add, %Item%, MenuAction
}
Menu, MyMenu, Show
Menu, MyMenu, DeleteAll ;Moved from MenuAction:
}
MenuAction:
SendInput %A_ThisMenuItem%{Raw}%A_EndChar%
Return
This is a hotstring script with menu. For example when I type agin I get a many with three options (again,a gin,aging) to choose. Now I want to write it something like this:
agin=again,a gin,aging
duh=what,huh,you're joking
qwe=qwe,qww,ere
Because I have a lot of hotstrings.
As time has passed, in the most recent version of AHK it became possible to do!
Use option x to allow expressions in the oneliner.
Either as :x:...:: OR as a group option above all lines: #Hotstring x
:x:agin::TextMenu("again,a gin,aging")
As nice as it would be, unlike AutoHotkey Hotkeys, I don't believe you can put anything other than replacement text on the same line of an AutoHotkey Hotstring. In other words,
::agin::TextMenu("again,a gin,aging")
would not work while,
::agin::
TextMenu("again,a gin,aging")
Return
does. It is a few more characters long, but not overwhelming.
I am trying to send { character with AutoHotkey but following script is not working.
<^>!b::Send,{
Return
The { char has special meaning so it needs to be escaped. Your code would need to look like
<^>!b::Send,{{}
Return
see explanation here
While #garyh provided correct answer to the question asked, it didn't actually solve the problem that made me use AutoHotkey in the first place.
In my case that was fixing Delphi 7 and RAD PHP XE2 on Windows 8.1 where using Alt Gr + B in editor would execute "Show breakpoints window" shortcut (defined as Ctrl + Alt + B) instead of writing { character.
Another way of emitting { character that does work even in above case is
<^>!b::Send,{Asc 0123}
Return
You can also send the { and other special meaning keys by using the raw option
command:
<^>!b::Sendraw, {
option:
<^>!b::Sendinput, {raw}{
Hope it helps