Multi-line editing on Atom - multiline

I have this task that I need to complete fast as possible. I have coupon codes (over 1000), I going to create an array out of it. To do that fast as possible I need to be able select multiples lines and edit them at the same time. I am using Atom as my editor choice. I tried to search online for answers but non found.
ST55672
SE82673
SS85074
SD65675
SH75676
to:
"ST55672",
"SE82673",
"SS85074",
"SD65675",
"SH75676",
PS. Im using Mac

1. Atom Commands
Select all text (Cmd+A on Mac, Ctrl+A elsewhere), then use the shortcut to “split the selection into lines” (Cmd+Shift+L on Mac, Ctrl+Shift+L elsewhere). Both commands are also available from the command palette.
PS: like many other keyboard shortcuts, these also work in Sublime Text
2. RegEx Search & Replace
Search for ^(.*)$ and replace with "$1",.

Notice for windows users:
multiline cursor works using these keys in the following order :
CTRL + ALT +
and ↓, or ↑, or a mouse "Click" any where you need

select all lines
Go to selection menu on the top bar (win & Linux)
select split selection into lines

Related

Multi-select all highlighted lines?

In Sublime, I commonly use my cursor to select multiple lines, then use Command + Shift + L to select each line with multiple cursors.
I'm unable to find any documentation or pre-built option within PHPStorm that can handle this.
Does anyone have a solution? Thanks!.
TLDR: ⌥ + Shift + Drag does what you want. On keymap you can also select the Sublime key binding template for general familiarity.
Overview
A great overview of multiple cursors in Jetbrains products and 4 minutes well spent (some minor variants may be present in the exact bindings, but not hard to work out) is:
https://www.youtube.com/watch?v=JBkGOPR3-nA
Three answers to your question:
1. Out of the box
⌥ + Shift + Drag does what you want.
Also relevant:
Press ⌥ (Option) twice, and then without releasing it, press up or down arrow keys. That will add a caret at the start of each line.
There are many more variations:
https://www.jetbrains.com/help/rider/Multicursor.html
https://blog.jetbrains.com/phpstorm/2014/03/working-with-multiple-selection-in-phpstorm-8-eap/
2. Keymap templates
If you go to preferences -> keymap you will find a dropdown with a list of templates. You can select Sublime Text or Sublime Text (OS). This is not always perfect because other plugins can override the key bindings in sometimes opaque ways, so not every single binding ports; but it should bring you a whole bunch of familiarity.
3. Custom
You can create your own key and mouse bindings for any PHPStorm action by going to preferences -> keymap and right clicking on the action; or searching for an action and then right clicking, etc.

Is there any way to switch multiple cursors with tab?

The situation is: in my html-file I have a lot of "href" attributes to be filled with specific links. And I can get multiple cursors on every needed place.(via Ctrl+D, or Alt+Enter).
Now it would be very helpful if I could switch between this cursors with tab(like emmet plugin does with self-generated html-content, if you know what I'm talking about).
You can have multi cursor, and switch between them in using :
Ctrl + F3
or
Ctrl + Shift + F3
You can get the behavior I believe you want by selecting all the "href" attributes using ctrl+d. If you are selecting all of them, you cna run the find_all_under command (alt + f3 in windows, unsure of other platforms but you can search for the command). Then, bookmark the cursor positions (ctrl+f2 in windows). You can then use f2 to cycle through the bookmarks. You could bind the appropriate command to tab if you want also, though you would have to do some work do you don't break normal tab behavior.
As a side note, I believe emmet simply inserts a snippet, so it defines various locations for the cursor to jump to through the built in snippet behavior.
#Jahnux solution may be more ideal since you wouldn't have to select initially, but I believe you would have to move the cursor back to the "href" attribute for continuing to the next token.
You may also want to investigate simply using the find functionality, though perhaps you have run into some limitations with that.

Search and replace selectively across whole project in Sublime

I need to change occurrences of a term only in certain places in my project.
Is there a way in Sublime Text to navigate the search results (across an entire project) and only replace the occurrences of my choice?
⌘ShiftF opens the "search and replace" for the entire project, but the Replace button only gives me the option to replace all occurrences.
If you press the ... button in the search panel, a menu will open that allows you to refine your search. You can use the Where input field with a search pattern, or some tags like <open-files>.
http://docs.sublimetext.info/en/latest/search_and_replace/search_and_replace_files.html
Other than that, if you really need human input to decide where to replace and where not to replace, you can go to the next result by pressing Enter and pasting the code manually.
Just in case you didn't know: when you make a project search a new text file opens up with all the occurrences. You can click those occurrences to navigate to the file in question.
For posterity, the functionality to search/find and replace inside the open project does exist. ⌘ShiftF and add <open project> to the Where input field.

PHPStorm - Find and Replace Text in Selection?

In most other editors, I can select a portion of the text I want to run find and replace on and then hit the ctrl + h combination. A screen pops up asking me what to find and what to replace. How do I do this in PHPStorm?
If you are using the Default keymapping (you can also use the keymaps for Eclipse, Visual Studio, etc) press Ctrl+r to show the Replace Toolbar. If you already have a selection then the option In Selection will already be checked, otherwise you can check it and then do your selection (if you select first and check the option second it will unselect the text after checking the option).
The feature is called Replace in the Keymap configuration if you wish to change the shortcut.
You can also press Shift+F6 to directly rename variables if that's what you want to do.
Highlight the code selection you wish to work on
( you can use alt + arrow up if your looking for a cool way to do that)
Press Ctlr + r on PC or Command + r on a Mac
In the upper options window, insert the values you wish to replace
Select the "in selection" check box
Press Replace/Replace all button

Multiple ST2 Cursors

I am in need of being able to select multiple cursors for thousands of lines that would then let me add content before each of them at the same time. Is there a way to select all and then select the multiple cursor option to put the cursor before each character of each line? Hope that does not sound confusing :-(
On Windows / OS X
Make sure you have View > Word Wrap off
Select all: Ctrl / Cmd+A
Split into Lines:Ctrl / Cmd+Shift+L
Put the cursor at the beginning of the line: Home / Ctrl+A
Yes, though I don't know how well multiple selections works with thousands of lines.
Start with Select All or select the lines that you need to edit.
From the Selection menu -> Split into lines. This will create multiple selections, one for each line.
Move the cursor to the beginning of each line by using the Home key.
Insert your content.
You can do as was suggested in other answers, it will work perfectly fine, sublime can handle thousands of selections for sure, but it might get bit slow sometimes.
Use regex in search n' replace, that's what it's for.
ctrl+h opens search and replace tab
make sure "Regular expressions" is pressed, "wrap" is pressed and "in selections" is NOT pressed.
type ^ to top field, it will mean "beginning of line" in this context
type your text in bottom field
ctrl+alt+enter or whatever the shortcut is to "replace all"