How to delete a whole word on the right in Linux Bash Shell command line [duplicate] - bash

This question already has an answer here:
On the Bash command-line, how do you cut the word immediately after the cursor? [closed]
(1 answer)
Closed 4 years ago.
How can I delete a whole word to the right in Linux Bash Shell command line?
Such as this:
Ctrl + U = Delete left of the cursor
Ctrl + K = Delete right of the cursor
Ctrl + W = Delete word on the left
I want to know a shortcut to delete a whole word on the right, no matter where the cursor is in the word. It is just like in Vim opt it is:
daw
And I want to the same result on the Bash command line.

Use Esc + D or Alt + D to delete the word on the right.

You can try Ctrl + K to delete from the cursor to end of the line (all on the left side of the cursor), and Ctrl + U to delete from the cursor to the start of the line (all to the right side of the cursor).
Also, I find the nice blog post Bash Shortcuts For Maximum Productivity covering a handful of Bash shortcut, and you may want to give it a read.

Related

Shortcut to copy multiple lines in Visual Studio

Maybe this is wishful thinking, but is there a way to quickly copy, or even just select, multiple lines quickly in Visual Studio? Similar to a multiple yank in vim.
I'm aware of the copying a single line, by just pressing Ctrl+C with nothing selected, but can't find any way of doing this for n lines.
If there's nothing that comes with it, is there any way to write a macro to achieve this?
To select multiple lines using the keyboard (starting from the current line, selecting downwards):
Press HOME (to move the cursor to the first character of the current
line)
If the cursor is NOT all the way to the left (i.e. Col 1) press HOME
again
While holding the SHIFT key press the DOWN ARROW (each subsequent
DOWN ARROW will select an additional line)
Alternatively the UP ARROW can be used to select lines from the starting line up.
Additional info: Combinations of SHIFT, CTRL and all the ARROWS can be used for various cursor moving and character selection, examples:
CTRL + Left (move the cursor to the start of the current word)
CTRL + Right (move the cursor to the start of the next word)
SHIFT + LEFT (select the previous character)
CTRL + SHIFT + RIGHT (select all characters to the right of the cursor, in the current word)

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.

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

Visual Studio Minimize regions shortcut? [duplicate]

This question already has answers here:
Command to collapse all sections of code?
(21 answers)
Closed 8 years ago.
Is there a shortcut key in Visual Studio that will minimize all of the regions or + signs so that I don't have to go through and click each one individually?
C-m, C-o // collapse all
C-m, C-l // expand all
C-m, C-m // collapse, expand one
Where C is short for Ctrl. You can find more shortcuts at the msdn site
You can find the commands by going to Keyboard Options under the Tools menu, they are mapped to these commands
Edit.CollapseToDefinitions (C-m, C-o),
Edit.ToggleOutliningExpansion (C-m, C-m) and
Edit.ToggleAllOutlining (C-m, C-l)
If you are using Visual Studio Code the commands are similar but work differently. The commands are roughly these
C-k 2 - Fold Level 2
C-k C-j - Unfold all
C-k [ - Unfold recursively (unfold where the caret is)
You can search for Fold or Unfold commands (using C-S-p) to find all of them.
Ctrl + M,M - expand/collapse at caret
Ctrl + M,O - collapse all in document
Ctrl + M,L - expand all in document
Ctrl + M, Ctrl + M
You can perform this on a selection too.

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