I want to use ctrl+d / cmd+d to make multiple selections, but then in the case when I have to increment a number (for example 1.jpg , 2.jpg, 3.jpg) I want to jump easily from selection to selection... (or use some Emmet / Sublime magic to do the incrementing automatically?)
There is a package called Insert Nums, that does exactly that and much more. I'd recommend reading the docs at Github for more information about the package.
Related
I'm in PhpStorm and I need to select some text, press some shortcut and have that text wrapped in a function call (that I would have defined somewhere in the settings beforehand).
For example:
"Hello World" would become input("Hello World").
$_GET["foo"] would become input($_GET["foo"]).
I don't know if this is even possible, but it could help me save so much time if so.
Applying regex to solve this problem is unfortunately not possible. Manually selecting what I need to wrap isn't an issue.
Will the function name be the same every time or different?
In any case: it can be done this way:
Make a Live Template of "surround template" type with the following content:
$FUN$($SELECTION$)$END$
The $SELECTION$ variable here tells that it's a surround template.
Apply correct Context (where this template can be used)
Give it an abbreviation (name used to locate & invoke it) and brief description.
Here is mine:
NOTE: replace $FUN$ by a fixed function name if the function will always be the same. You can have additional templates with different abbreviations (that will have different hardcoded function names).
To use it:
Make a selection and invoke Code | Surround with... action where you select the right template. On Windows keymap it's Ctrl + Alt + T
In action (NOTE: it's without hardcoding the function name hence me typing the myFunc part):
(HINT: you can select the desired entry in a few keypresses if the name is unique -- just start typing the name in the popup -- the standard Speed Search work here)
P.S. Code | Surround with... can have other (possibly irrelevant for you in this case) entries. To list Live Templates only, use the shortcut for Surround with Live Template... action (Ctrl + Alt + J here on my Windows keymap). You can check the shortcut or change it in the Settings/Preferences | Keymap:
This way the popup menu will be a bit shorter:
Less keypresses:
You may be able to use Macros functionality to record the invoking the popup and selecting the right entry. You can then assign a custom shortcut to that Macros: select the text, hit the shortcut and it will playback the recorded sequence.
Sadly I cannot 100% guarantee that Macros will always work nicely (sometimes/on some setups it can "eat" keypresses).
P.S. It would be much easier if the IDE would support assigning keyboard shortcuts to specific Live Templates .. but it's in the backlog and no ideas on when this might be implemented. Anyway: https://youtrack.jetbrains.com/issue/IDEA-67811 -- watch this ticket (star/vote/comment) to get notified on any progress.
P.S. You can also try Postfix completion. It's good for writing the code and not really suitable for your case (editing small parts of it), but who knows. You will have to make a custom postfix for this -- should not be an issue though.
https://www.jetbrains.com/help/phpstorm/2021.3/auto-completing-code.html#postfix_completion
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
Is there an option highlighting all strings matching the actual selection in PhpStorm (like in SublimeText) ?
You can use Ctrl + Shift + F7 for this in PhpStorm.
This will highlight all usages of selected text.
Using built-in functionality: select text and hit Ctrl + F that will bring "Find in page" functionality: it will highlight all matches of selected text in this document. But it's not always convenient as you have to hit extra keys and have "find in page" bar open...
You can install and use BrowseWordAtCaret plugin that will automatically highlight word under caret in whole document (regardless of it's nature -- variable or just plain text) + you can easily navigate between all matches.
P.S.
You have mentioned that "I'm used to regularly change the name of an object property, an array key or a parameter name at multiple places in same document."
Consider using Refactor | Rename for variables/class members/etc -- it works across multiple files.
I was wondering if there is a shortcut to Paste from the clipboard & at the same time cut the selection to be pasted somewhere else.
Elaborating the Question:
I find myself often swapping values among various sections of code. As a primitive example:
var a = "two";
var b = "one";
To swap them, I would:
cut the value of a
Paste it next to the value of b
cut the original value of b
paste that back as the value of a
I was wondering id there is a shortcut to combine step 2 & 3 of this process.
Sublime Text provides a tool for doing exactly(?) what you wish.
Double click "one" (to select it)
Hold ctrl and double click "two" (both are selected now)
press ctrl + t to swap selections
Otherwise you may wish to register a new key binding for your custom operation. You can do this via Preferences -> Key bindings (User).
Use Permute Selection > Reverse:
highlight two value
hold control
highlight one value
Edit > permute selection > reverse
Not exactly, but something is kinda there to help in such situations. There is a Clipboard History built-in Sublime Text (atleast in 3, not sure 2). Just copy the text you are replacing, then press <C-k><C-v>. This will popup a small window with clipboard's history. Select the previous copied text to replace currently selected text.
This option is available under Edit -> Paste from History.
HTH
You can do it too with a clipboard history https://github.com/colinta/SublimeClipboardManager
Copy: oneCopy: twoPaste-previous in twoPaste-next in one
The good thing is that clipboard history can be helpful in more situations
I am using the "Find All" feature in Sublime Text and I want to see a few more lines back from the find results. I can't find a setting for this -- is there any way to do this?
To expand upon DarkWater's comment to your question:
Add new lines with a regex before and after your search string:
.*\n.*\n.*search_string.*\n.*\n.*
This will match 2 new lines before and after your search_string.
Make sure you enable regular expression searching in the find dialog. Also make sure that you escape any regex special characters in your search_string.
Are you using the Find in Files… command from the Find menu (SUPER + SHIFT + F)?
If so, there's an option in the find panel to see more lines than the result line alone -- the next to last button (there should be 5 option buttons in the find panel), which has a "Show Context" tooltip, should do the trick.
To expand on the solutions provided by #dasl and #zaboco
I found that this variation was more suitable.
Example:
(.*\n){0,2}.*search_string.*(\n.*){0,2}
This will match 0-2 new lines before/after your search_string. Adjust numbers as needed to provide more/less context, but always keep the 0 as the first number in the quantifier.
Again, make sure you enable regular expression searching in the find dialog.
(The original regexes required that 2 lines above/below are present in the files, and excluded some necessary files from the search results)