How to highlight multiple words on VIM and modify them all? Like CTRL+D does on VS-Code? - visual-studio-code

On VSCode, if you highlight a text, you can do "CTRL+d" and it will highlight the next matching text and add a cursor there.
You can then start typing/deleting and it will affect all the cursors.
How can I do this in VIM?
Note: I know the search and replace function, this is too slow to type, is there something as easy or almost as easy as it is on VSCode?
:%s/foo/bar
Visual explanation on VSCode:
Highlight the word you're looking to replace:
CTRL+d two times, which highlights them all:
Now modify them all at the same time:

I want this will help you.
You can do the below steps to change all selected words.
< SHIFT > + # // select the all words on your cursor.
:%s//NEW_WORD/g
If you want to change all 'const' to 'AAA',
move to one of the 'const' words and press < SHIFT >+'#'.
And type the command ":%s//AAA/g".

Move the cursor on top of a word in your code.
Type gb to add another cursor. This puts Vim into Visual
mode and ready to operate on the word you have selected.
Type gb to continue adding cursors until you’re done.
Now you can perform an action in Visual mode (delete,
change, etc).
Go back to Normal mode with <ESC>

Related

VS-Code Shift+Command+L equivalent for JetBrains IDEs

In VS Code, pressing Shift+Command+L creates a cursor for every occurrences strings and you can modify them all at once. Is there a similar shortcut for the JetBrains IDEs such as Intellij IDEA?
Yes there is. You can read more about ways to create multiple cursors and selection ranes on their dedicated help page: https://www.jetbrains.com/help/idea/multicursor.html (I'll use links for the Intellij IDEA help pages, but you the instructions should be similar for all the IDEs in the JetBrains family. To get the help pages for a specific one, visit their general help page, then select an IDE, and then use the search function to search "multicursor").
In particular, see this section named "Select multiple occurrences of a word or a text range" Here's an excerpt when the Shortcuts mode is set to "Windows" (visit that link and switch the shortcut mode to whichever platform you are on)
If you want to select words, set your caret at an occurrence of the desired word. Otherwise, select the desired range with the mouse or with keyboard shortcuts.
If you want to select words, set your caret at an occurrence of the desired word. Otherwise, select the desired range with the mouse or with keyboard shortcuts.
Do one of the following:
Successively press Alt+J to find and select the next occurrence of case-sensitively matching word or text range.
Press Ctrl+Alt+Shift+J to select all case-sensitively matching words or text ranges in the document.
To remove selection from the last selected occurrence, press Alt+Shift+J.
After the second or any consecutive selection was added with Alt+J, you can skip it and select the next occurrence with F3. To return the selection to the lastly skipped occurrence, press Shift+F3.
Other functions include:
You can do it with the mouse while holding Alt+Shift+Click the target location to add another caret. You can Alt+Shift+Click one of the existing carets to remove it.
To add carets above or below the current caret using the keyboard, Press Ctrl twice, and then without releasing it, press the up or down arrow key. Or you can enable the column selection mode (press Alt+Shift+Insert) and then press Shift+Up/Shift+Down.
Edit | Find | Select All Occurrences action does it:

Turn multiline selection into multi cursor selection in VSCode

It happens from time to time that I need to edit 100+ lines in a text file all at once.
I know I can use ⌘ Cmd+↑/↓ to select multiple lines but depending on the size of the file that takes a while.
In Atom and Sublime, I can just do a ⌘ Cmd + a to select everything, hit another shortcut (forgot the actual shortcut) and end up with a cursor for every line.
Have not found this in VSCode.
Ctrl-a to select all. (or whatever muli-line selection you want)
Shift-alt-I will put cursors at end of each selected line.
And then if you want those cursors at the beginning of each line you need to trigger the command "cursorLineStart" which is unbound by default. Give it a keybinding and all those end-of-line cursors will jump to the beginning of each line.
With v1.43 and Column Selection Mode this can be quite easy, see Column selection like Visual Studio and How to put the cursor at the end of all selected lines in Visual Studio Code?
FWIW cursorLineStart is not the opposite of Shift-Alt-I. In looking at the commends, Shift-Alt-I is "Add cursors to line ends", but there is not a "Add cursors to line begins" option.
However, the easy trick for that is:
Select your text block
Shift-Alt-I to put a cursor at the end of each line
Command-LeftArrow will move those cursors to the beginning of the lines
Its an extra step but it works. When I get time I will play around with building a custom command to do all this in one action.

When selecting line in VS Code with the shortcut Ctr+i, cursor jumps to the line below. How to avoid it?

When selecting line in VS Code with the shortcut Ctr+i, the cursor jumps to the line below.
Meaning if i press copy, it actually copies two lines...
Is there a way to force the cursor to stay at the end of the selected line?
editor.action.smartSelect.grow
seems to do what you want with some number of keypresses unfortunately. It is already bound to Shift-Alt-RightArrow but you ca rebind that command to something else less cumbersome.

find_under_expand in VS Code

I'm trying to move to VS Code, and really like many of the feature.
But I'm really missing one of the most powerful editing features of sublime text: find_under_expand
i.e. select word with cursor, the select all other concurrences of this word by hitting ctrl+d.
Is there a way to reproduce this behavior in VS Code.
Ctrl-Shift-L : keyboard shortcuts, search for select all.
Ctrl-D adds the next match to the selection one-by-one.

How to move out of auto-completed brackets in IntelliJ IDEA (without using the arrow keys)?

I recently switched from Eclipse to IntelliJ IDEA, and found myself wondering how to move the cursor out of a pair of auto-completed brackets.
In Eclipse after I finished typing in a pair of brackets, pressing tab brings me out of the brackets. How can I do the same thing without using the arrow keys?
Many thanks for your help!
IDEA doesn't have such feature yet. The closest equivalent is the Complete Current Statement editor action (Ctrl+Shift+Enter).
UPDATE
Initial implementation for this feature is available in 2018.2 EAP version - press Tab to jump out.
It works more like in MS Visual Studio - without visual indication of tab 'exit' position. For now, it should work in Java, SQL, Python and some other files. It will take some time for other languages to catch up - some language-specific code changes are required.
The feature is disabled by default, you can enable it in
Settings -> Editor -> General -> Smart Keys -> Jump outside closing
bracket/quote with Tab
Ctrl + Shift + Enter does not seem to work for me in IDEA 12.1.4, but I found the closest feature to what I was looking for was Shift + Enter. This completes the line, creates a new line below the current line and moves the cursor to it.
You can do this by pressing the closing symbol that you would've pressed otherwise, but was auto completed. For example, if you have just typed the f below, you would press shift and 0 (or closing parenthesis), and it will move your cursor outside of the parenthesis.
String asdf = "hello world";
System.out.println(asdf);
I went to preferences->Keymap and set a shortcut for "Move Caret to Line End" to Shift-Space. It takes me to the end of the current line I am on without adding anything, if that's what you want.
Not currently supported by Intellij. There is an open feature request on this at http://youtrack.jetbrains.com/issue/IDEA-74666. Extra votes would be nice.
Intellij supports the ctrl+shift+m shortcut that jumps to the end of the block:
https://www.jetbrains.com/help/idea/2016.2/navigating-to-braces.html
It's not quite what you're looking for, but you can type the character you are trying to move outside of (a closing paren, for example) and that should pop you outside of the auto-completed character.
Not ideal, but functional as far as I've tested it.
I set these setting:
1) I added Semicolon shortcut to Complete Current Statement:
Instead of using for loop command, I using fori command (because for command needs semicolon character):
2) I added Alt+Semicolon shortcut to Move Caret to Code Block End:
So when I inside the loop, by pressing Alt+Semicolon jumping end of the bracket, by pressing Semicolon I jumping out the bracket subsequently.
by adding these shortcuts, the speed of coding will be faster.
Such key is called "End".
You can assign any unused shortcut to "Move Caret to Line End" action in "Settings/Preferences | Keymap".
P.S. You can use Ctrl+Shift+Enter to complete your statement (in your case it will place caret at the end of line and will add ";" there) -- action called "Complete Current Statement" and shortcut can be checked/changed in a same way as described earlier.
If you decide to move back to Eclipse and use PyDev this feature by default is disabled, First Switch to PyDev Perspective and you can enable it by going under Preferences>PyDev>Editor>Typing>Enable link on Automatic parenthesis or literals closing