I press Shift + CMD + F in my Atom Editor (on OS X) to search for the term "aria" within all files of my project.
Now I also get search results for "Variant" which is not what I want, so I want to exclude the word variant from my search.
How would I do that?
Try using the "whole word" option (ctr + alt + w, or click on the button on the far right in the project search options)
I'm searching for useful Android Studio keyboard shortcut for commenting code, as in Sublime Text or Eclipse.
When I press either cmd+/ or cmd+maj+/ nothing happens...
Mac With Numeric pad
Line Comment hold both: Cmd + /
Block Comment hold all three: Cmd + Alt + /
Mac
Line Comment hold both: Cmd + + =
Block Comment hold all three: Cmd + Alt + + =
Windows/linux :
Line Comment hold both: Ctrl + /
Block Comment hold all three: Ctrl + Shift + /
Same way to remove the comment block.
To Provide Method Documentation comment type /** and press Enter just above the method name (
It will create a block comment with parameter list and return type like this
/**
* #param userId
* #return
*/
public int getSubPlayerCountForUser(String userId){}
In spanish keyboard without changing anything I can make a comment with the keys:
cmd + -
OR
cmd + alt + -
This works because in english keyboard / is located at the same place than - on a spanish keyboard
Be sure you use the slash (/) on right side of keyboard.
For Line Comment:
Ctrl + /
For Block Comment:
Ctrl + Shift + /
You can see all keymap in Android Studio: Help ➤ Default Keymap Reference
On Mac and Turkish Keyboard it is (both for commenting out and uncommenting)
line comment:
cmd +.
block comment:
cmd+alt +.
An Example for a Mac OS X 10.5+ with a German layout keyboard without NumPads:
Open Preferences
Search for "Keymap"
Expand "Main menu"
Expand "Code"
Delete all shortcuts (just a suggestion)
Add a shortcut for a single line comment (e.g. Ctrl++)
Add a shortcut for a block comment (e.g. Ctrl+alt +)
This way you can be sure that those keys are not mapped (except if you assigned them before to another function)
Reviewing and Changing Keyboard Shortcuts in Android Studio
Keyboard shortcuts can be configured (and reviewed) via the Settings dialog, accessible via File -> Settings.
Once this dialog appears, to review (and/or add) a shortcut, do the following:
Select Keymap in the list on the left. Note that there is a "Keymaps" option, and depending on the original selection, shortcuts assigned to a given feature differ based on the Keymap.
Type "comment" or text corresponding to the feature for which the keyboard shortcut is to be reviewed/assigned. Each match has a line entry in the list below, and keyboard shortcuts are shown right-justified along with the feature. For example, both CTRL+ALT+SLASH and CTRL+K, CTRL+C are the two assignments for creating a line comment.
To modify a shortcut:
Select the resultant line corresponding to the feature for which the keyboard shortcut is to be reviewed/assigned
Right-click, and select the desired Add or Remove option.
Comment method like pro developers:
Windows/linux:
Line Comment : Ctrl + /
Block Comment : Ctrl + Shift
Method Commenting:
Type `/**` and press `Enter Key`
it will add the comment snippet like we see in standard documentation, give it a try this once.
/**
*
* #param addOpacity
*/
public void setOpacityOnUserImage(boolean addOpacity) {
// Your business logic.
}
In Android studio CTRL + SHIFT + / for windows.
for German Layout (Deutsches Layout) the default is:
for line Comment:
strg + Numpad(/)
for block Comment:
strg+shift+Numpad(/)
I use this sequence (not a 'linear' shortcut but useful anyway):
alt+c then alt+b (holding alt) for block comment
alt+c then alt+l (holding alt) for line comment
(they use the android studio menu)
On PC it's by default set to Ctrl + /. This will toggle commenting a selection or current line.
I am working with a german keyboard and the slash (/) is on the 7 key, meaning access would be Ctrl + Shift + 7. However, this does not work as this is predefined as something with bookmark 7.
I went to settings (search for keymap) and deleted all existing shortcuts. I than added Ctrl + 7, confirmed deletion of bookmark shortcut and now can work well.
For Line Comment: Ctrl + /
For Block Comment: Ctrl + Shift + /
For multiline comment in android studio
select the statement that you want to commented then
use ctrl+shift+/
and for removing mutiline comment
select the statement that you want to uncommented then
use **ctrl+shift+/**
SINGLE LINE COMMENT
For single line comment
use ctrl+/
Ctrl + Shift + / works well for me on Windows.
In LINUX
1.Single line commenting. Ctrl + /
2.For block comment Ctrl + Shift + /
on mac, using uk english keyboard layout to reach quickcomment in android studio the key combination is:
cmd + alt(option) + /
Mac (French-Canadian Keyboard):
Line Comment hold both: Cmd + É
Block Comment hold all three: Cmd + Alt + É
"É" is on the same position as "?/" in english one.
Are you sure you are using / and not \ ?
On Mac I have found by default:
Cmd + /
Comments using // notation
Cmd + Opt + /
Comments using /* */ notation
If you are used with Eclipse, there is something in Settings>Keymap Keymaps: and you can pick Eclipse to keep the same shortcuts.
For Line Comment hold both:
Ctrl + /
For Block Comment hold all three:
Ctrl + Shift + /
Same way to remove the comment block.
In android studio you can do
single comment with (go to line then Ctrl+/)
and
block comment with ( select text then Ctrl+Shift+/)
Also if you want to change color of commented text
go to File->Settings->IDE settings->Editor->Color & fonts->Java->(Line comment or block comment) and change properties.
I prefer it to be green which is used in notepad++ editor.
In the Icelandic MAC keyboard: CMD + -
You can add three slashes.
/// Add comments
this can clear the "comment out code 2 lines" issues.
Mac:
To comment/uncomment one line, use: Ctrl + /.
To comment/uncomment a block, use: Ctrl + Shift + /.
I noticed that command Ctrl + Shift + / works on Windows only in case if there is no indentation on the left. I.e. if you need to comment out an entire function or class, you must additionally press Enter at the top and bottom of the class/function.
It helped me.
Using Sublime Text 2 - Is it possible to insert a line break/text return after a specific String in a text file e.g. by using the Find ‣ Replace tool?
(Bonus question: Is it possible to remove all line breaks after a specific String)
Here's how you'd do it on a Mac:
Command+F > type string > Control+Command+G > ESC > Right Arrow > line break
and Windows/Linux (untested):
Control+F > type string > Alt+F3 > ESC > Right Arrow > line break
The important part being Control+Command+G to select all matches.
Once you've selected the text you're looking for, you can use the provided multiple cursors to do whatever text manipulation you want.
Protip: you can manually instantiate multiple cursors by using Command+click (or Control+click) to achieve similar results.
Using the Find - Replace tool, this can be accomplished in two different ways:
Click in the Replace field and press Ctrl + Enter to insert a newline (the field should resize but it doesn't, so it is hard to see the newline inserted).
Inside the Find - Replace tool, activate the S&R regex mode (first icon on the left .*, keyboard shortcut is Alt + Ctrl/Cmd + R to activate/deactivate it).
Type \n in the Replace field wherever you want to insert a newline.
Both solutions also work if you want to find newlines, just do it in the Find field.
Edit->Lines->Join Line (Ctrl+J)
You should probably use multiple cursors. See the unofficial documentation, or this nice tutorial. Here's some brief instructions to set you on your way:
Put the cursor on the string of interest.
Type Command+D (Mac) or Control+D (Windows/Linux) to select the current instance of the string.
Type Command+D (Mac) or Control+D (Windows/Linux) to select successive instances of the string.
Alternately, type Control+Command+G (Mac) or Control+Command+G to select all instances of your string.
Now you have multiple cursors, so insert or remove your newline as you please.
(type esc to exit multiple cursor mode.)
Have fun!
How I can search within a specific block of code or selection in IntelliJ IDEA?
I got used to using this feature in Eclipse. In Eclipse you can just double click on the beginning of a curly bracket, and it'll highlight the entire block of code. After which you could do Command+f
(Ctrl+f on Windows) to search ONLY in the highlighted block, or you could just highlight whatever you need and search just that block of code.
Go to Settings | Keymap, search for the Find... action in the Other group. This action should have the following description:
Find a string in active editor, shows
modal dialog
Assign a keyboard shortcut to this action (you need to make a copy of default keymap to modify it), for example Ctrl+Alt+Shift+F.
When in editor, select any block of text, then press this shortcut, a dialog will open with the Scope automatically set to Selected text:
To quickly select the method body while standing on the opening curly brace use Ctrl+W.
As of 2020, I'm able to perform find in selection on PhpStorm
Select the block of text and hit Cmd + F on MacOS / Ctrl + F on other platforms
On the find toolbar (that appears on top) there's an In Selection button; use that to limit search scope to the selected text only
Here's the link to my original answer on JetBrains support forums
I'm using
PhpStorm 2020.1.2
Build #PS-201.7846.90, built on June 3, 2020
First select some text and press ctrl+R to open the dialog, then check the "in selection" option :
In current version, 2020.2, default for Find In Selection is Ctrl+Alt+E.
On IntelliJ in Mac:
In a file select the specific block in which we want to find something
Press CMD + F
Press CTRL + OPTION + G
Notice that the cursor has automatically landed in the find toolbar's text field
Type in what is intended to be found
Press enter to move the cursor to the first occurrence.
When I'm programming I often use copy and paste, which requires me to grab the mouse, highlight the text, and press CTRL + C (I'm using Windows BTW). Is there any hotkey or solution out there for a keyboard short cut that I could press and have it start copying each character I type? It would be such a godsend to get rid of that whole highlighting mess!
You can probably develop a quick application that does that in VB (via global hotkey listener). But for me, I am a keyboard shortcut nerd, and I use CTRL + Shift + ← /→ to navigate the caret through "words" (sometimes that means every non-alphanumeric token, but it varies on the IDE you're using) that I want to copy--It's much faster than Shift + ← /→. I also use this combination frequently: End, Shift + Home, CTRL + C, which is a quick way to select and copy the whole line.
I can see where you're coming from with the "toggling copy", but I think using the full extent of the keyboard, while primitive, is the best and most practical.
Shift + ← and Shift + → will select text forward and backup.
Most editors have a lot more (Ctrl - Shift + ← for selecting to next word boundary for instance) but depends on the application.
Depending on how long your code is, you can always do Shift + End, then CTRL + C to copy the line, providing that you're at the end of the line. Shift + Home would select the preceding line if you're at the beginning of the line, etc.