How to paste text to end of every line? Sublime 2 - line

I'm curious if there is a way to paste text to the end of every line in Sublime 2? And conversely, to the beginning of every line.
test line one
test line two
test line three
test line four
...
Say you have 100 lines of text in the editor, and you want to paste quotation marks to the beginning and end of each line.
Is there an easy way to do this or a plugin that anyone would know of? This would often save me a lot of time on various projects.
Thanks.

Yeah Regex is cool, but there are other alternative.
Select all the lines you want to prefix or suffix
Goto menu Selection -> Split into Lines (Cmd/Ctrl + Shift + L)
This allows you to edit multiple lines at once. Now you can add *Quotes (") or anything * at start and end of each lines.

Here's the workflow I use all the time, using the keyboard only
Ctrl/Cmd + A Select All
Ctrl/Cmd + Shift + L Split into Lines
' Surround every line with quotes
Note that this doesn't work if there are blank lines in the selection.

Select all the lines on which you want to add prefix or suffix. (But if you want to add prefix or suffix to only specific lines, you can use ctrl+Left mouse button to create multiple cursors.)
Push Ctrl+Shift+L.
Push Home key and add prefix.
Push End key and add suffix.
Note, disable wordwrap, otherwise it will not work properly if your lines are longer than sublime's width.

Let's say you have these lines of code:
test line one
test line two
test line three
test line four
Using Search and Replace Ctrl+H with Regex let's find this: ^ and replace it with ", we'll have this:
"test line one
"test line two
"test line three
"test line four
Now let's search this: $ and replace it with ", now we'll have this:
"test line one"
"test line two"
"test line three"
"test line four"

You can use the Search & Replace feature with this regex ^([\w\d\_\.\s\-]*)$ to find text and the replaced text is "$1".

Use column selection. Column selection is one of the unique features of Sublime2; it is used to give you multiple matched cursors (tutorial here). To get multiple cursors, do one of the following:
Mouse:
Hold down the shift (Windows/Linux) or option key (Mac) while selecting a region with the mouse.
Clicking middle mouse button (or scroll) will select as a column also.
Keyboard:
Select the desired region.
Type control+shift+L (Windows/Linux) or command+shift+L (Mac)
You now have multiple lines selected, so you could type a quotation mark at the beginning and end of each line. It would be better to take advantage of Sublime's capabilities, and just type ". When you do this, Sublime automatically quotes the selected text.
Type esc to exit multiple cursor mode.

Select all lines you want to add a suffix or prefix.(command+ A to select all the lines)
Press command+shift+L. This will put one cursor at the end of every line and all the selected lines would still be selected.
For adding suffix press command+right and for adding prefix command+left. This will deselect all the earlier selected text and there will only be cursors at the end or start of every line.
Add required text

Related

Intellij how to delete all line containing annotation?

I want to delete all lines that contains annotation. I see there is a shortcut to delete line/selection. But how do i pass regex to the delete line shortcut so that all line that starts with # gets deleted?
I want to use like this
^#
You have to use replace option.
Use Ctrl+R to open replace option, select regex(at the left side of search box there is a * sign). Enter #.*$ in replace box. Keep the replace with box empty.
The Regex means any line starting with # followed by zero or more characters(digit/non digit/letter etc) and ended by end line.

Select current line in intellij

Is there any way to select the whole line at caret in IntelliJ 15? I know you can select the current word (ctl + w), go to beginning/end of line but I can't find a current line selection feature.
Simply hit
ctrl+c
Note that for this to select the whole line, you need to ensure that nothing is already selected; otherwise it'll work as an usual "copy" command.
move caret to line
on Windows, press ctrl+shift+a .
This popup appears, where you find Select Line at Caret
for quick access, you can specify a shortcut in Settings
I would like to also add the following from JetBrains website. Because, that what i was looking for here, but no one mentioned it.
1- To select text from the current caret position to the beginning/end of
the current word:
Ctrl+Shift+Left, Ctrl+Shift+Right.
2- To select text from the caret
position to the beginning/end of the current line:
Double-click Ctrl and press Home/End
3- To select text from the current
caret position to the top/bottom of the screen:
Ctrl+Shift+Page Up, Ctrl+Shift+Page Down.
If none of the above are working, I suggest using end and home keys in combination with shift allowing you to select lines quickly.
Go to the end of the line and hit Ctrl+W. If you'll hit Ctrl+W at the beginning of the line it will select only one word.
Not a keyboard feature, but nice to use:
to select the whole row just click on row number on the left of the code.
In addition to that you can click and drag selection.
Moreover, you can doubleclick on the number of the first line of method which results selection of the whole method.

Visual Studio Code: Select each occurrence of find

I'm looking for a "select each occurrence of" something I'm trying to find. For example a file has a bunch of text that includes "abc", I type ctrl+f and type abc. I can either find the first one or the next one, but I would like to "multi-cursor" each one in the file.
I've already found the feature that lets me highlight text and ctrl+d to get the next that matches the selection, but if there's a hundred of these things - well that gets quite tiresome.
Ctrl+Shift+L Select all occurrences of current selection
editor.action.selectHighlights
Ctrl+F2 Select all occurrences of current word
editor.action.changeAll
Please refer for more information here.
Alt+Enter Select all occurrences of find match
editor.action.selectAllMatches
This has the added benefit of working with Regular Expression searches, since selecting occurrences of a word of a selection cannot leverage the Regex functionality.
I know this thread is here for a while now, but I think this will be helpful:
This thread on Github talks exactly about it:
https://github.com/microsoft/vscode/pull/5715
Summary:
Ctrl+F --> Open find widegt.
Alt+R --> Turn on regex mode.
Input search text --> Regex text or normal text.
Alt+Enter --> Select all matches.
Left arrow --> Ajust cursors.(Ignore this step if you don't want to edit the ---selected text.)
Edit text --> Do what you want.(Ignore this step if you don't want to edit the -selected text.)
Shift+Home --> Select modified text.(Ignore this step if you don't want to edit the selected text.)
Ctrl+C --> Copy selected text.
Ctrl+N --> Open a new tab.
Ctrl+V --> Paste.
well , basically the Ctrl+Shift+L will select all occurrences of word in the document BUT
there is some coool way to selecting them growingly:
if you hit Ctrl+d it will selects the second match , it you hit Ctrl+d again it will match the third one and so on ....
For Mach User:
COMMAND + Shift+ L Select all occurrences of the current selection
COMMAND + F2 Select all occurrences of the current word
For mac users::
Control + Command + G
^ + ⌘ + G
Ctrl+F2 is what worked for me for VSCode on Windows 10.
While Ctrl+Shift+L just opened some Language selector.
If you are searching in a single file, use simple search using Ctrl+F, then even if you close the search box, simply keep pressing F3 to go to next match and so on. F3 just repeats previous search and selects your next match.
On Mac:
Ctrl+F to open the find menu in top right:
Select the third option within the input and add the regex you want to match.
Ctrl+Shift+L to select all items that match.
Hope that helps!

How to select all instances of a variable and edit variable name in Sublime

If I select a variable (not just any string) in my code, all other instances of that variable get a stroke (white outline) around them:
Is there a keyboard shortcut that will let me select all of those instances of the variable and edit them all at once?
Things I've Tried:
⌘D, ⌘K, and ⌘U lets me select them one-by-one, but I have to manually exclude the non-variable string matches:
And using Ctrl⌘G simply selects all the string matches:
Clearly, Sublime is able to differentiate between variable and string matches. Is there no way to select just the variable matches?
Put the cursor in the variable.
Note: the key is to start with an empty selection. Don't highlight; just put your cursor there.
Press ⌘D as needed. Not on a Mac? Use CtrlD.
Didn't work? Try again, making sure to start with nothing selected.
More commands:
Find All: Ctrl⌘G selects all occurences at once. Not on a Mac? AltF3
Undo Selection: ⌘U steps backwards. Not on a Mac? CtrlU
Quick Skip Next: ⌘K⌘D skips the next occurence. Not on a Mac? CtrlKCtrlD
Sublime Docs
I know the question is about Macs, but I got here searching the answer for Ubuntu, so I guess my answer could be useful to someone.
Easy way to do it: AltF3.
Despite much effort, I have not found a built-in or plugin-assisted way to do what you're trying to do. I completely agree that it should be possible, as the program can distinguish foo from buffoon when you first highlight it, but no one seems to know a way of doing it.
However, here are some useful key combos for selecting words in Sublime Text 2:
Ctrl⌘G - selects all occurrences of the current word (AltF3 on Windows/Linux)
⌘D - selects the next instance of the current word (CtrlD)
⌘K,⌘D - skips the current instance and goes on to select the next one (CtrlK,CtrlD)
⌘U - "soft undo", moves back to the previous selection (CtrlU)
⌘E, ⌘H - uses the current selection as the "Find" field in Find and Replace (CtrlE,CtrlH)
This worked for me. Put your cursor at the beginning of the word you want to replace, then
CtrlK, CtrlD, CtrlD ...
That should select as many instances of the word as you like, then you can just type the replacement.
The Magic is, you have to start with an empty selection, so put your cursor in front of the word/character you want to multi-select and press Ctrl+D .
To me, this is the biggest mistake in Sublime. Alt+F3 is hard to reach/remember, and Ctrl+Shift+G makes no sense considering Ctrl+D is "add next instance to selection".
Add this to your User Key Bindings (Preferences > Key Bindings):
{ "keys": ["ctrl+shift+d"], "command": "find_all_under" },
Now you can highlight something, press Ctrl+Shift+D, and it will add every other instance in the file to the selection.
As user1767754 said, the key here is to not make any selection initially.
Just place the cursor inside the variable name, don't double click to select it. For single character variables, place the cursor at the front or end of the variable to not make any selection initially.
Now keep hitting Cmd+D for next variable selection or Ctrl+Cmd+G for selecting all variables at once. It will magically select only the variables.
It's mentioned by #watsonic that in Sublime Text 3 on macOS, starting with an empty selection, simply ⌃⌘G (AltF3 on Windows) does the trick, instead of ⌘D + ⌃⌘G in Sublime Text 2.
At this moment, 2020-10-17, if you select a text element and hit CTRL+SHIFT+ALT+M it will highlight every instance within the code chunk.
Just in case anyone else stumbled on this question while looking for a way to replace a string across multiple files, it is Command+Shift+F

how to break up lines of codes AND comments in VB.NET 2010?

everytime i try the space then underscore + enter it doesnt work and it lights up red
edit - like for example this is a comment:
'you must add such and such to this variable and then you must declare it'
say i have that for a comment and i want to break the comment after variable. when i do this
'you must add such and such to this variable _
and then you must declare it'
it gives me an error
The underscore at the end of the line trick doesn't work for comments. The underscores are treated as part of the comment.
To create a bunch of single line comments at once, select the lines you want to comment out and press CTRL+K then CTRL+C
A line continuation consists of at least one white-space character that immediately precedes a single underscore character as the last character (other than white space) in a text line.
Ref.
Doesn't apply to comments though; if you want multiple comment lines simply start a new comment for each subsequent line.