I've recently moved from Sublime Text 3 to WebStorm 11 and I am missing a key feature when selecting occurrences of the same selection:
The ability to skip a selection (with a hotkey).
Use case
const item = { itemValue: 1, itemName: 'one' };
console.log(item.itemValue);
Selecting the first item and pressing Ctrl + G (Mac) will start selecting the item occurrences inside the object properties, and I want to select only the item right after the const and inside the console.log. Essentially, I want to skip the two item occurrences inside the object.
This is a dummy use case to illustrate the point, I know I can Refactor > Rename it.
Highlight the text you want to edit:
Ctrl+G will find the next occurrence of the highlighted text and select it:
Cmd+G will drop the current selection and select the next one:
Cmd+G one more time will drop the current selection and select the next one:
For anyone that has a different Keymap:
Cmd+G: "Find Next / Move to Next Occurrence"
Ctrl+G: "Add Selection for Next Occurrence"
Right now, the only solution I found is using Find:
Select the text and press Cmd + F (the find bar will open with the selected text as a search)
Press Cmd + G to select the next occurrence
Press Enter to skip it (will select the next occurrence)
Press Enter again
Press Esc to exit the find context
And now the desired items are selected and ready for editing.
At least it's doable, but I'd expect a hotkey to just skip the current occurrence.
Related
Basically every line in my text file is formatted like this:
1) Baker
2) Photographer
3) Doctor
4) Teacher
5) CEO
etc, etc.
Using Notepad++ how do I remove the 1), 2), 3), etc?
1 ) Press Ctrl + H for pop window to Replace.
2 ) Provide the ^\d+\) regular expression in Find what text field, choose option Regular expression in search mode and make empty in Replace with text field.
3 ) Click on Replace all or Replace button.
You can use the regex ^\d+\) (note the trailing whitespace) and replace text matching this pattern with an empty string.
Step-by-step guide:
Press Ctrl+h to open the Replace dialog.
Press Alt+F to focus on the Find text field.
Enter ^\d+\) and press Alt+l to switch to the Replace with text field.
Press backspace to delete any text that might be in this box.
Press Alt+g to switch the search mode to regular expression.
Press Alt+a to perform a replace all operation on the document.
You can use the column selection mode, normally accessed with alt + mouse, or by the edit menu, select the 2 columns, and delete them as any text
Simple question: I am looking for the shortcut in WebStorm to select all the occurrences of a word and then replace them
e.g in my CSS file I want to select all the 'phone' variables at once and change them to 'tab-port'
Use Ctrl+ R for find and replace. This will open up a dialog at the top of the file that will look similar to the following: (depending on your IDE theme)
If you want to select all occurrences directly in the code, you can select all of them with the next shortcut:
Ctrl + Cmd + G on Mac OS X or
Ctrl + Alt + Shift + J on Windows
If you want to replace all occurrences, you can make as chazsolo said.
I have a source document with the following text
Here is a bunch of text
...
Collect underpants
???
Profit!
...
More text
I would like to visually select the middle three lines and insert numbers in front of them:
Here is a bunch of text
...
1. Collect underpants
2. ???
3. Profit!
...
More text
All the solutions I found either put the numbers on their own new lines or prepended the actual line of the file.
How can I prepend a range of numbers to existing lines, starting with 1?
It makes for a good macro.
Add the first number to your line, and put your cursor back at the beginning.
Start a macro with qq (or q<any letter>)
Copy the number with yf<space> (yank find )
Move down a line with j
Paste your yank with P
Move back to the beginning of the line with 0
Increment the number with Ctrl-a
Back to the beginning again with 0 (incrementing positions you at the end of the number)
End the macro by typing q again
Play the macro with #q (or #<the letter you picked>)
Replay the macro as many times as you want with <number>## (## replays the last macro)
Profit!
To summarize the fun way, this GIF image is i1. <Esc>0qqyf jP0^a0q10#q.
To apply enumeration for all lines:
:let i=1 | g/^/s//\=i.'. '/ | let i=i+1
To enumerate only selected lines:
:let i=1 | '<,'>g/^/s//\=i.'. '/ | let i=i+1
Set non recursive mapping with following command and type ,enum in command mode when cursor is inside the lines you are going to enumerate.
:nn ,enum {j<C-v>}kI0. <Esc>vipg<C-a>
TL;DR
You can type :help CTRL-A to see an answer on your question.
{Visual}g CTRL-A Add [count] to the number or alphabetic character in
the highlighted text. If several lines are
highlighted, each one will be incremented by an
additional [count] (so effectively creating a
[count] incrementing sequence).
For Example, if you have this list of numbers:
1.
1.
1.
1.
Move to the second "1." and Visually select three
lines, pressing g CTRL-A results in:
1.
2.
3.
4.
If you have a paragraph (:help paragraph) you can select it (look at :help object-select). Suppose each new line in the paragraph needs to be enumerated.
{ jump to the beginning of current paragraph
j skip blank line, move one line down
<C-v> emulates Ctrl-v, turns on Visual mode
} jump to the end of current paragraph
k skip blank line, move one line up
required region selected, we can make multi row edit:
I go into Insert mode and place cursor in the beginning of each line
0. is added in the beginning of each line
<Esc> to change mode back to Normal
You should get list prepended with zeros. If you already have such, you can omit this part.
vip select inner paragraph (list prepended with "0. ")
g<C-a> does the magic
I have found it easier to enumerate with zeroes instead of omitting first line of the list to enumerate as said in documentation.
Note: personally I have no mappings. It is easier to remember what g <C-a> does and use it directly. Answer above describes usage of pure <C-a> which requires you to manually count whatever, on the other hand g <C-a> can increment numbers with given value (aka step) and have it's "internal counter".
Create a map for #DmitrySandalov solution:
vnoremap <silent> <Leader>n :<C-U>let i=1 \| '<,'>g/^/s//\=i.'. '/ \| let i=i+1 \| nohl<CR>
How can I use regular expression in excel ?
In above image I have column A and B. I have some values in column A. Here I need to move data after = in column B. For e.g. here in 1st row I have SELECT=Hello World. Here I want to remove = sign and move Hello world in column B. How can I do such thing?
Stackoverflow has many posts about adding regular expressions to Excel using VBA. For your particular example, you would need VBA to actually move a substring from one cell to another.
If you simply want to copy the substring, you can do so easily using the MID function:
=IFERROR(MID(A1,FIND("=",A1)+1,999),A1)
I used 999 to ensure that enough characters were grabbed.
IFERROR returns the cell as-is if an equals sign is not found.
To return the portion of string before the equals sign, do this:
=LEFT(A1,FIND("=",A1&"=")-1)
In this case, I appended the equals sign to A1, so FIND won't return an error if not found.
You can use the Text to Column functionality of MS-Excel giving '=' as delimiter.
Refer to this link:
Chop text in column to 60 charactersblocks
You can simply use Text to Column feature of excel for this:
Follow the below steps :
1) Select Column A.
2) Goto Data Tab in Menu Bar.
3) Click Text to Column icon.
4) Choose Delimited option and do Next and then check the Other options in delimiter and enter '=' in the entry box.
5) Just click finish.
Here are URL for Text to Column : http://www.excel-easy.com/examples/text-to-columns.html
I'v created a text box and when it gets focus it sets the caret position to 0 rather than the end. I want to set it to the end.
Thanks
|Text Here -> Text Here|
The caret position is basically the same as the current selection -- when the beginning and end are at different positions, you have some text selected. If the beginning and end of selection are at the same place, that's the caret position.
You can set the selection with EM_SETSEL. To put it at the end, use -1 for both the beginning and end of selection.