Can I do multiple select same words in Vim as that was in Sublime text 2 with command ctrl+D and then edit selected words?
Yep! Check this out: vim-multiple-cursors
No you can't but someone is working on it.
Related
I know there is a lot of information on how to do it, but I can't do it anyway. I use vs with vim expansion.
I have text with variables, I want to select for example variable btn in all text and change it to button. How can I do it?
I tried with select and press key n,but it selects all text until next btn;
also '*' is not working, it's just jumping to next btn;
Thank you!
You can use the *or viw to visually select the word under the cursor.
Found a good solution:
:%s/oldText/newText/g
more here: https://www.thegeekstuff.com/2009/04/vi-vim-editor-search-and-replace-examples/
I'm trying to do this Multiple selection with Sublime on Mac:
I can do it easily with Textmate: https://i.stack.imgur.com/htjDk.gif
But did not found how to do it with Sublime.
With text highlighted (CtrlA for all text): CtrlShiftL will allow you to modify text on all lines simultaneously.
http://www.sublimetext.com/docs/selection
Select the required text and press CommandD multiple times.
This question already has answers here:
Sublime Text 2 multiple line edit
(10 answers)
Closed 6 years ago.
I was using Notepad++ and now I want to use the same cool features in Sublime but I don't know how.
I want to edit multiple lines at the same time like this:
But I don't want to Ctrl+Click at each line for this. I want to click at first line and click at last line for one vertical line.
How I can do this?
First, select multiple lines (by dragging mouse, shift+arrow, etc.). Then, press:
CTRL+SHIFT+L
or on MAC: CMD+SHIFT+L (as per comments)
Alternatively you can select lines and go to SELECTION MENU >> SPLIT INTO LINES.
Now you can edit multiple lines, move cursors etc. for all selected lines.
Use CTRL+D at each line and it will find the matching words and select them then you can use multiple cursors.
You can also use find to find all the occurrences and then it would be multiple cursors too.
Thank you for all answers!
I found it! It calls "Column selection (for Sublime)" and "Column Mode Editing (for Notepad++)"
https://www.sublimetext.com/docs/3/column_selection.html
Below is a screenshot of me entering visual block mode and pressing "w" to select by word:
How can I select every word in the rows I have selected? Meaning I want the full word in the rows highlighted instead of it getting cut off as shown in the screenshot.
edit: What I want to be able to do is delete a column of words of varying length. In the example screenshot I want to delete the words between the tags, But it could be any column of words.
There are a bunch of plugins for multiple selection, look them up on vim.org.
But I must remind you that visually selecting text is more often than not an unnecessary step. Why don't you explain what you actually want to achieve instead of your failed attempts? Maybe there's a better way...
[edit]
:'<,'>norm dit
seems to be the simplest way to achieve your goal without selecting every word:
and :,+7norm dit would be even better because you don't select anything.
The highlight modes can only select blocks (by cursor, by line, or by rectangular block). You can use a plugin such as vim-multiple-cursors to do what you are trying to do.
The only place where Vim allows a non-rectangular, "jagged edge" visual selection is at the end of the lines, i.e. by extending the blockwise selection with $. Therefore, you'd need to (temporarily) get rid of the trailing </th> (or include it in the selection, but operate in such a way that they are kept intact).
You shouldn't need a selection to work with the text. For example, to delete the text inside the tags, you can use a substitution:
:%s#<th>\zs.*\ze</th>##
You can't. You can only select rectangular blocks in block select mode. Maybe a plugin solves this?
I use Vim and Vim plugins for Visual Studio when writing C++. Often, I find myself wanting to search for a string within a function, for example every call to object->public_member.memberfunc().
I know Vim offers a convenient way to search for a single word, by pressing * and #, and it can also search for typed strings using the ubiquitous slash / command. When trying to search for all the instances of a longer string like the one above, it takes a while to re-type after /.
Is there a way to search for the selection? For example, highlight with v, then copy with y, is there a way to paste after /? Is there an easier shortcut?
Check this Vim tip: Search for visually selected text
Or you can simply yank the selected text with y and go to search mode /, then you can paste the last yanked text with Ctrl+R 0
Answer
Yank the text you want to search for
q/p
Enter
Explanation
q/ works similarly to vanilla search / except you're in command mode so p actually does "paste" instead of typing the character p. So the above will copy the text you're searching for and paste it into a search.
For more details type :help q/
Use q / instead of just /. (Same with q :). Now you can VIM-edit through your command and search history! (Try Ctrl-N and Ctrl-P sometime).
I just learned (through the excellent book Practical Vim) that there is a plugin for that.
You can find the plugin on GitHub.
The plugin lets you search for a visual selection with * and #.
You can actually select text visually and press * and # to search for the next occurrence... It will work the same, the only caveat is that:
Whitespace in the selection matches any whitespace, when searching (searching for "hello world" will also find "hello" at the end of a line, with "world" at the start of the next line).
http://vim.wikia.com/wiki/Search_for_visually_selected_text
--> if you want to highlight a text occurrences in gvim
Select the text & copy
then ?paste the selected text (Note: This will not work for insert mode)