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)
Related
at the top of VS code breadcrumbs, theres a list of sibling files.
i want to open it with a shortcut.
By the way, to switch between files, I use CTRL+TAB
By pressing Ctrl + Shift + <, it both focus the last segment of the breadcrumb and selects it. You can then use the up and down arrow keys to select the file you need.
If ever your cursor is in a method for example, the keyboard shortcut I just describe won't exactly fit, as the last segment of the breadcrumb may not correspond to the file but to its outline content. In this case you may need to favor Ctrl + Shift + . instead which only gives the focus to the breadcrumb and then use the left arrow key to reach the segment you need and then select it.
I've been looking all over, but can't find the following shortcut:
Does MSVC 2022 have a shortcut, either builtin or via an extensions, to delete the word under the cursor?
I know that Ctrl+Del deletes from the cursor to the end of the word. Ctrl+Backspace deletes from the cursor to the beginning of the word. Ctrl+w selects the current word. But, I can't find deleting the word under the cursor in just one shortcut. I usually do Ctrl+w, followed by backspace.
Another shortcut I wish it had, but which I'm pretty sure it doesn't, is jumping to the vertical and/or horizontal middle of the text window. This is to complement Ctrl+PageUp/PageDown, which jump to the top and bottom of the text window.
If I want to delete few lines of text in most of text editors, not touching some words on the bottom line and the whole upper line, I put cursor on the bottom row leaving all unnecessary words to the left of the cursor. Then I select few lines vertically by holding Shift + ↑. I stop on upper row and get some selection: part below + right part of the upper row:
In this example I want to get rid of if word and an empty space between the function header and the code, not touching the function header (even hough let will stick to the opening bracket {).
Normally (not in Xcode) I would still hold Shift and will press cmd + ➝ to deselect the right (selected) part or the top row.
Result will be like this:
I can simply press Delete and job is done.
However, in Xcode such shortcut usage makes bottom row fully selected (till the right) and not changes upper row selection:
Same thing happens if you select from top to bottom and you need to remove extra selection from the bottom line.
I tried to rebind shortcuts in Preferences but didn't find a solution.
This example is very particular and maybe not the best, however I face such selection problems only in Xcode and have to use mouse which is not handy.
This is a rather old question, but what you want is fairly simple to achieve. If your cursor is between the if and the let, you would only need to press option-shift-left arrow twice. The first time, it would select the if and the leading tabs, and the second would select the empty line.
sometimes i just want to move either left or right a couple of characters (or go to the end of the line) but don't really want to leave insert mode just to move a couple chars.
I don't know about viemu and visual studio, but in vim, you can use <Ctrl-o> to enter a single command while in insert mode, so <ctrl-o>2l will move you 2 characters to the left, and <ctrl-o>$ will move you to the end of the line.
There is no way of moving the cursor which is easier than just using the arrow keys, thats what they are there for. Insert mode is for inserting text, not navigating the file. If you would like to be so pedantic about not using the arrow key then there is a solution for you:
press
use 'HJKL' keys until at destination
press 'i'
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