I don't understand the format selection (cmd + K cmd + F) shortcut keys in VS Code - macos

Can someone please explain to me how the "format selection" (cmd + K cmd + F) shortcut keys - and other shortcuts that seemingly have multiple button press combinations - work in VS Code.
I tried pressing cmd + K and cmd + F simultaneously (though, cmd is listed twice so I am really pressing cmd + K + F in this case) and I have tried hitting them in order. If someone could explain what they mean here, then it would be much appreciated. I am sure it's a simple solution that I have been overlooking for all these years.

The written format for shortcut expressions use the operators '+' (plus) and ' ' (space) to define whether the expressions on each side of the operator should be pressed simultaneously, or sequentially.
'+' represents two keys pressed then held simultaneously, in left-to-right order.
This is the same as typing an uppercase letter using the shift key: Shift+a -> A
' ' represents concatenating the right-hand-side key combo after the left-hand-side combo.
This is the same as typing an uppercase word using the Shift key: Shift+h Shift+i -> HI
In the second example above, note that you can either keep holding Shift, or you can release it and press it again for each letter. The same applies with VSCode shortcuts.
In the case of Format Selection (Cmd+k Cmd+f), Cmd should be held while first k then f are pressed. Pressing k and f together is a different shortcut entirely (Cmd+k+f), as is pressing f and k together (Cmd+f+k). Since the left-hand-side key (Cmd) is the same for both expressions, you don't need to release it between typing the k and f.
To get a better grasp of how keyboard shortcuts are expressed, I'd suggest opening the the VSCode Preferences for Keyboard Shortcuts either using the command palette, or using the shortcut: Cmd+k Cmd+s: (type ks while holding Cmd).
Then activate the Record Keys mode (Alt+K). Now type different key sequences, and it will show you the textual representation in the search bar, along with any shortcuts that match what you typed.

Related

Set shortcut for command Debug.DisableAllBreakpoints

I am using VS2015. I would like to have shortcut Ctrl + Shift + D for disabling all breakpoints. It should be easy, but under Environment - Keyboard after pressing Ctrl + Shift + D I have only limited amount of choices to pick from. Is it possible to set this shortcut to command Debug.DisableAllBreakpoints?
That bottom list is not your set of choices...it is what is currently assigned to the key sequence you are trying to use.
If you click "Assign", the key sequence should be assigned to your command and overwrite the sequence in the commands in the bottom list, i.e. remove the shortcut from those commands.

Is there something like ctrl + m + o for Xaml?

I often miss CTL + M + O, that collapses all properties and methods in the code editor, when working with Xaml.
I installed Xaml Regions and it is nice but I still miss CTL + M + O
I have played around with:
CTL + M + M
CTL + M + L
CTL + M + P
CTL + M + U
But none of them does what I want.
Is there an extension or even a built-in command that does what I want?
To clearify, I want all children of a resource file collapsed to one row for easier navigation like this:
I recently discovered you can use Ctrl+M, L even though it doesn't work directly. It just takes a little algorithm.
Press Ctrl+M, L.
If everything is expanded, press it again.
???
Profit.
Pressing Ctrl+M, L expands everything if anything is collapsed, otherwise it collapses everything. So when you first open a file, pressing it once should be sufficient. If you've been collapsing and expanding some regions, pressing it once to expand and once to collapse works fine.
This may be too off-topic, however using the VSVim add-on will emulate Vim, unifying a lot of keyboard shortcuts for editing files:
The command zc will close a fold (if the cursor is in an open fold), and zo will open a fold (if the cursor is in a closed fold). It's easier to just use za which will toggle the current fold (close it if it was open, or open it if it was closed).
The commands zc (close), zo (open), and za (toggle) operate on one level of folding, at the cursor. The commands zC, zO and zA are similar, but operate on all folding levels (for example, the cursor line may be in an open fold, which is inside another open fold; typing zC would close all folds at the cursor).
The command zr reduces folding by opening one more level of folds throughout the whole buffer (the cursor position is not relevant). Use zR to open all folds.
The command zm gives more folding by closing one more level of folds throughout the whole buffer. Use zM to close all folds.
Edit: Command sequence in this case would be zM then zo.

Why does pressing the arrow keys while something is running in bash produce "^[[A^[[C^[[B^[[D"?

Let's say you run the command
find . -iname bob
While it is running, pressing various letters on your keyboard inserts it before the standard output of the next line produced by "find". However, pressing the up arrow produces "^[[A". Is this some keyboard shortcut for the arrow keys?
I am currently imagining it is something like CTRL + ? + A since CTRL + C produces "^C".
Is this some keyboard shortcut for the arrow keys?
Correct. The terminal generates these character sequences when extended keys are pressed, and it is up to the software (e.g. readline) to interpret these sequences appropriately.
I am currently imagining it is something like CTRL + ? + A since CTRL + C produces "^C".
Also correct. It is Ctrl[, just as shown.

Is there a shortcut to search the word under cursor in Xcode?

The functionality I'm talking about is in VI/VIM. ie. When the cursor is over the text of a word like say jiggle in command mode, press * to search for the next instance of jiggle. I use this all the time in VIM. Does such a shortcut exist for Xcode? or can we only double-click to highlight, CMD + C, CMD + F, CMD + V, and hit Enter?
Ok, Phrogz has a good solution, but I found a simpler way to do this...
To search consecutive instances of a word in Xcode:
Double-click the word you would like to find the next instance(s) of, then as Phrogz mentioned press ⌘ + E (Use Selection for Find) and then ⌘ + G (Find Next) to search for the next occurrence(s)
Cmd + Ctrl + T will invoke the menu item "Edit All in Scope". That will highlight all uses of the current identifier and allow you to edit all simultaneously.
Not exactly the same thing, but I find it very useful for the sort of case you're talking about. Even if I don't need to edit an identifier, it's a nice way to quickly see all the places its used.
If you select the word (⌥←,⌥⇧→) you can press ⌘ + E (Use Selection for Find) and then ⌘ + G (Find Next) to search for the next occurrence.
You can combine the command+e, command+g to a shortcut
Find a file IDETextKeyBindingSet.plist in directory "/Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/"
Open this file by Xcode
Add a Dictionary named Customized under the Root
Add a String named Move to Next Instance under the Customized
and set the value to selectWord:, useSelectionForFind:, findNext:
IDETextKeyBindingSet.plist
Restart Xcode and set the Key Bindings
Find Move to Next Instance and set the key to option+↓ (or other key you prefered)
Key Bindings
To search a word in the currently opened file using Xcode 5 and above:
Double click the word and then
shift optioncommand E
Now you can move to the next/previous instance using:
command G
or
shiftcommandG

Mac OS X Terminal: Map option+delete to "backward delete word"

Tried to map it from Preferences -> Settings -> Keyboard, but the "key" combo box has only "forward delete" but no "delete". My keyboard on the other hand has only "delete" and no "forward delete"!
Is there some other way to do it except from the preferences?
Enable option key as meta key
Go to Terminal > Preferences > Profiles > Keyboard
Check Use option key as meta key.
Image
On macOS High Sierra 10.13.6, captured on October 23, 2018.
Notes
Many applications (including bash and tcsh) treat Meta-Delete as "backward delete word."
OS X's terminal runs bash, which includes readline support. Follow Glomek's advice and tell terminal to use option as meta key (or else use Esc) and then you've got a bunch of handy options: Ctrl+w deletes prev word (as does Meta+delete as mentioned), but you can also use Meta+f and Meta+b to walk forward and backwards thru words, Ctrl+a and Ctrl+e to beginning and end of line, Ctrl+k delete (kill) from cursor to end of line, and a bunch more.
See http://www.bigsmoke.us/readline/shortcuts for a nice little reference table.
Delete a word going back:
Ctr-w.
Command Editing Shortcuts
Ctrl + a – go to the start of the command line
Ctrl + e – go to the end of the command line
Ctrl + k – delete from cursor to the end of the command line
Ctrl + u – delete from cursor to the start of the command line
Ctrl + w – delete from cursor to start of word (i.e. delete backwards one word)
Ctrl + y – paste word or text that was cut using one of the deletion shortcuts (such as the one above) after the cursor
Ctrl + xx – move between start of command line and current cursor position (and back again)
Alt + b – move backward one word (or go to start of word the cursor is currently on)
Alt + f – move forward one word (or go to end of word the cursor is currently on)
Alt + d – delete to end of word starting at cursor (whole word if cursor is at the beginning of word)
Alt + c – capitalize to end of word starting at cursor (whole word if cursor is at the beginning of word)
Alt + u – make uppercase from cursor to end of word
Alt + l – make lowercase from cursor to end of word
Alt + t – swap current word with previous
Ctrl + f – move forward one character
Ctrl + b – move backward one character
Ctrl + d – delete character under the cursor
Ctrl + h – delete character before the cursor
Ctrl + t – swap character under cursor with the previous one
Command Recall Shortcuts
Ctrl + r – search the history backwards
Ctrl + g – escape from history searching mode
Ctrl + p – previous command in history (i.e. walk back through the command history)
Ctrl + n – next command in history (i.e. walk forward through the command history)
Alt + . – use the last word of the previous command
Command Control Shortcuts
Ctrl + l – clear the screen
Ctrl + s – stops the output to the screen (for long running verbose command)
Ctrl + q – allow output to the screen (if previously stopped using command above)
Ctrl + c – terminate the command
Ctrl + z – suspend/stop the command
Bash Bang (!) Commands
Bash also has some handy features that use the ! (bang) to allow you to do some funky stuff with bash commands.
!! – run last command
!blah – run the most recent command that starts with ‘blah’ (e.g. !ls)
!blah:p – print out the command that !blah would run (also adds it as the latest
command in the command history)
!$ – the last word of the previous command (same as Alt + .)
!$:p – print out the word that !$ would substitute
!* – the previous command except for the last word (e.g. if you type _find somefile.txt /, then !* would give you _find somefile.txt)
!*:p – print out what !* would substitute
⌃W (control+W) is not the same thing than meta + delete (ESC+delete if you don't have checked use option as meta key)
meta+delete will treat / _ as word delimiter where ^W will consider space as delimiter.
e.g.
using ESC+Bakcspace on (cursor at the end)
rm /dira/dirb/file1
gives
rm /dira/dirb/
while ^W on the same will give
rm
So it is better to use \033\177 rather than ^W when defining the modifying the terminal profile.
That way you are really mapping ⌥⌫ to what esc⌫ is doing and you keep having ^W to erase word based on space delimiter.
I would love to be able to post an image on how do this but as a newbies I can't.
refer to bouke comment to see how to modify terminal profile.
By default meta backspace does a backwards word yank in most shells. If you press escape and then press backspace, that pretty much works everywhere.
In your Terminal's profile, you can bind ⌥⌫ (option+delete) to ⌃W (control+W), so it works similar to other apps.
If you are using Iterm2 (which is like the regular terminal of OSX just better :)
you can use this like to change this behavior:
You need to set your left ⌥ key to act as an escape character. This can be done going to iTerm2 > Preferences > Profiles > Keys.
With Natural Text Editing preset enabled in Profile -> Keys.
You can simply remove the word
Backward with alt + delete
Forward with fn + alt + delete

Resources