IntelliJ IDEA shortcut to switch 2 words - intellij-idea

Is there a shortut (or a way to define one) in IntelliJ to switch 2 words?
Eg.
final static
Shortcut to switch to static final?

Under the "Edit" menu look for the "String Manipulation" flyout and there should be an entry called "Swap Characters/Selections/Lines/Tokens".
Selecting both words and then using this command will present you with a dialog. Typing space into the dialog and hitting return will swap two words.
Ctrl+Shift+A will get you a shortcut to this command if you type "swap" after its dialog comes up.
If the same pattern of words occurs multiple times it would be more effective to perform a replace with Ctrl+R.

I found it under "Code" menu : CTRL + ALT + SHIFT + ← or →

If your only issue is final static (and other) modifiers order, you can enable Missorted Modifiers inspection: Preferences | Editor | Inspections.
After that all missorted modifiers will be automatically highlighted, and you'll be able to fix it simply by either hitting Alt + Enter or doing Cleanup Code (also available to do via hotkey).

Related

Navigate to sql position

IntelliJ pro comes with an embedded SQL editor.
Sometimes, I type a wrong request and the database returns an error and the corresponding SQL position.
Example :
[2017-01-02 16:32:35] [42P01] ERROR: missing FROM-clause entry for table "customer"
Position : 516
Problem : for readability reasons, the request is written on multiple lines, making it harder to find the position 516.
Up to now, the only solution I got is to delete the \n characters in order to have the request on only one line then navigate to the 516th column.
But I guess there is a better way, like a fancy keyboard shortcut?
It's been a while you asked but I'll answer anyway to help others:
Download "Character Position" plug-in from here:
https://plugins.jetbrains.com/plugin/10334-character-position
Install plugin & Restart IntelliJ
Character position will be shown in the bottom-left corner of the editor.
In my case I press F2 and cursor go there.
The current caret position (line number and offset) is displayed in the Status Bar. You can click it to open the Go To Line dialog box.
Change the second number to the needed position of your character and will be navigated directly.

Is there a keyboard shortcut to select a column for editing in Atom editor?

Scenario
When editing a file in Atom Editor how do I select multiple lines where the same edit needs to be performed?
For example:
this.name = name;
this.age = age;
this.sound = sound;
needs to be transformed into:
that.name = name;
that.age = age;
that.sound = sound;
Imagine there are many of these lines, but we do not want to use a find-and-replace because it will change more than we need.
Question - Is there a Keyboard Shortcut for Column Selection?
Is there a sequence of keyboard shortcuts (preferably Mac) which we can use to:
a) select the initial word
b) select the "column" (that word on several lines)
then apply the change to several lines at once (in bulk)
I know how to do this in SublimeText:
http://sublime-text-unofficial-documentation.readthedocs.org/en/latest/editing/editing.html#column-selection but have tried many different key combinations without any luck in Atom and googling has proved fruitless...
There are several ways to achieve this:
Keyboard
You can enable column selection mode using Ctrl+Shift+↑/↓. This will allow you to extend the cursor to multiple rows. Once you have selected all rows, release the keys, and use the Delete key to remove the text you want to replace. Once you're done, press the Esc key to release the cursors.
Note: You will have to disable the Mission Control (key bindings) in OS X to use this key combo.
How to Disable Mission Control (conflicting) Key Bindings (Mac)
To do this open System Preferences > Mission Control
Locate the key bindings for Mission Control and Applications windows:
Disable the key bindings for these two:
More details here.
Mouse
If you install the Sublime Style Column Selection package, you can use Alt+Mouse to select the columns in question.
More details here.
Here is a plugin for Atom, just hold alt and be happy.
sublime-style-column-selection
With the cursor somewhere on the first "this", do Ctrl+D (OS X: command+D) three times. Then type "that".
Another option is to select the rows you want to edit. Then select "Split into Lines" from the "selection" menu. Then hit the home-key and start editing away in multi-cursor mode.
For me on Atom 1.7.4 it worked by adding below lines to my /Users/username/.atom/keymap.cson. Ofcourse I am using alt-shift-down as shortcuts.
'atom-workspace atom-text-editor:not([mini])':
'alt-shift-down': 'editor:add-selection-below'
Update: I could not configure both alt+shift+down and alt+shift+up at the same time. For now I am okay with alt+shift+down
On Windows 10, follow the following steps:
Press ctrl + alt together and use up/down arrow keys to expand the height of your now vertical cursor
Now use shift to select the columns to be deleted
press delete key to remove selected columns
click anywhere on document (without pressing ctrl/alt keys) to bring cursor back to normal 1 column height
I came by this thread, and the feature I was personally looking for was the multi-cursor extension.
I've tried all of the following potential solutions:
sublime-style-column-selection
multi-cursor
multi-cursor-plus
Adding the following text to /Users/$(whoami)/.atom/leymap.cson
'atom-workspace atom-text-editor:not([mini])':
'alt-down': 'editor:add-selection-below'
'alt-up': 'editor:add-selection-above'
The last solution is the one that worked best without interfering with any of my other normal workflows.

selenium (phpunit) click on drop down link

I want be able click on link from drop down using selenium with phpunit. I don't have any idea how make it happens, can anyone show me example or relevant tutorial, post or anything that can help me figure out.
when I try click on the element without put mouse over the drop down I got this error:
Element is not currently visible and so may not be interact with command ....
Thanks.
EDIT:
when I said "drop down" I don't mean regular select. it more like popup
you can see the example here:
http://investing.com
look how they build the menu I want be able click on 'Technical' -> 'Fibonacci Calculator' for example.
Check this post out:
Selenium: How to select an option from a select menu?
You can find more info about this here
select(selectLocator, optionLocator)
Arguments:
selectLocator - an element locator identifying a drop-down menu
optionLocator - an option locator (a label by default)
Select an option from a drop-down using an option locator.
Option locators provide different ways of specifying options of an HTML Select element (e.g. for selecting a specific option, or for asserting that the selected option satisfies a specification). There are several forms of Select Option Locator.
label=labelPattern: matches options based on their labels, i.e. the visible text. (This is the default.)
label=regexp:^[Oo]ther
value=valuePattern: matches options based on their values.
value=other
id=id: matches options based on their ids.
id=option1
index=index: matches an option based on its index (offset from zero).
index=2
If no option locator prefix is provided, the default behaviour is to match on label.
Credits go to Dave Hunt
What I use:
$search13 = $this->webDriver->findElement(WebDriverBy::id('id_of_dropdown_field'));
$search13->click(); // Clicking on the dropdownfield
$this->webDriver->getKeyboard()->pressKey('ARROW_DOWN'); // Will go down in your dropdown selection )
sleep(1);
$this->webDriver->getKeyboard()->pressKey('ENTER'); // Enter for submitting your selection
EDIT:
http://www.anitpatel.net/2012/02/25/selenium-webdriver-how-to-click-on-a-hidden-link-or-menu/
This one explains it in java but basically what he does is a mouse over/hover and wait.
Then he clicks on the element.
I'm not a java genius but it's an example how to work with it.
You can use the:
string mouseOver(string $locator)
This simulates a user hovering a mouse over the specified element.
http://docs.tadiavo.com/phpunit/www.phpunit.de/pocket_guide/3.1/en/selenium.html
Check if the element is visible using the xpath of the required option value.
$this->isElementPresent($xpath);
$this->click($xpath);
If it is true, then click() method selects the specified option.

webmatrix list of keyboard shortcuts

List of keyboard shortcuts supported by Microsoft webmatrix.
Official list from Microsoft here:
http://www.microsoft.com/web/post/webmatrix-keyboard-shortcut-guide
Also, you can use the Alt key to display top level key tips. The top level key tips are show below:
Then, press Alt plus a top level key (such as H for Home as shown above) to show all of the keys that can be used on that tab. Use the displayed key value to access the related functionality.
For instance, Alt + H then T will allow you to print.
Just for those who happen upon this post, please check out the up to date list here:
http://www.microsoft.com/web/post/webmatrix-keyboard-shortcut-guide
Here are some additional ones that work inside the editor. Mind these are in an internal format that maps hotkeys to command codes. Its fairly readable though.
If you save this file in the WebMatrix config folder (typically c:\program files (x86)\Microsoft WebMatrix\Config), the editor will pick up modifications you make to this file. * Use at your own risk *
None;Right;RIGHT
None;Left;LEFT
None;Up;UP
None;Down;DOWN
None;PageUp;PAGEUP
None;Next;PAGEDN
None;Home;HOME
None;End;END
None;Escape;CANCEL
None;Delete;DELETE
None;Back;BACKSPACE
None;Insert;INSERT
None;Return;RETURN
None;Tab;TAB
Shift;Back;BACKSPACE
Shift;Right;RIGHT_EXT
Shift;Left;LEFT_EXT
Shift;Up;UP_EXT
Shift;Down;DOWN_EXT
Shift;Home;HOME_EXT
Shift;End;END_EXT
Shift;PageUp;PAGEUP_EXT
Shift;Next;PAGEDN_EXT
Shift;Tab;BACKTAB
Shift;Return;RETURN
Alt, Shift;Right;RIGHT_EXT
Alt, Shift;Left;LEFT_EXT
Alt, Shift;Up;UP_EXT
Alt, Shift;Down;DOWN_EXT
Alt, Shift;Home;HOME_EXT
Alt, Shift;End;END_EXT
Control, Shift;Right;CTLMOVERIGHT
Control, Shift;Left;CTLMOVELEFT
Control, Shift;Home;TOPLINE_EXT
Control, Shift;End;BOTTOMLINE_EXT
Control, Shift;L;DELETELINE
Control, Shift;Oem6;GOTOBRACE_EXT
Control, Shift;Space;PARAMINFO
Control, Shift;P;SELUPCASE
Control, Shift;W;SELLOWCASE
Control;Space;COMPLETEWORD
Control;J;SHOWMEMBERLIST
Control;Back;DELETEWORDLEFT
Control;Delete;DELETEWORDRIGHT
Control;A;SELECTALL
Control;Right;WORDNEXT
Control;Left;WORDPREV
Control;Home;TOPLINE
Control;End;BOTTOMLINE
Control;Up;SCROLLUP
Control;Down;SCROLLDN
Control;C;COPY
Control;X;CUT
Control;V;PASTE
Control;Z;UNDO
Control;Y;REDO
Control;OemPlus;ZOOMIN
Control;Add;ZOOMIN
Control;OemMinus;ZOOMOUT
Control;Subtract;ZOOMOUT
Control;D0;ZOOM1X
Control;NumPad0;ZOOM1X
Control;Oem6;GOTOBRACE
Control;L;CUTLINE
Control;T;TRANSPOSECHAR
Control,Control;K,D;FORMATDOCUMENT
Control,Control;K,F;FORMATSELECTION
Control,Control;K,I;QUICKINFO
Control,Control;K,C;COMMENT_BLOCK
Control,Control;K,U;UNCOMMENT_BLOCK
Control,Control;M,M;OUTLN_TOGGLE_ALL
Control,Control;M,U;OUTLN_TOGGLE_CURRENT
Control,Control;M,O;OUTLN_COLLAPSE_TO_DEF
Control,Control;M,P;OUTLN_STOP_HIDING_ALL
Control,Control;M,S;OUTLN_START_AUTOHIDING
CTRL-C
CTRL-V
CTRL-O
CTRL-S
CTRL-A
CTRL-W
CTRL-T moves a letter one step to the left?
CTRL-Z
CTRL-U
CTRL-I search in file (direction down)
CTRL-F find
CTRL-G go to line
CTRL-H replace
CTRL-X
CTRL-N new file
To view the current file in the browser instead of the site root.
CTRL+F12
As the Webmatrix 2 'Run' button opens the root index html file.

How to disable region collapsing or expand ALL regions in Visual Studio VB.NET?

In Visual Studio C# (2008), Ctrl+M+L expand all the regions.
There's also a setting in menu:
Tools -> Options -> Text Editor -> C# -> Advanced
to not collapse during file open. I see no equivalents in VB.NET.
Is there a way to expand all the regions, not just the one which has focus in VB.NET?
Or a macro or add-in that does it? I just hate not being able to see all the code.
In Visual Studio 2012 and 2013 there is an option for deactivating collapsing (called 'outlining mode').
You can find it under:
Text-Editor->Basic->VB Specific
and then uncheck "Enable outlining mode".
But you will then lose the feature for collapse/expand at all.
If you are willing to remove regions you can try this:
Ctrl+F
Quick Replace
Find Options
Use: Regular Expressions
Find What:
^\s*#(end)?region.*$
Replace with:
[leave replace box empty]
Explanation:
^ - Match the start of a line
\s* - Match zero or more whitespace characters
# - Match one # character
(end)? - Optionally match the string end
region - Match the string region
.* - Match zero or more of any other characters
$ - Match the end of the line
This will effectively find all #region or #endregion lines, whether they are indented or not, and whether they have description text after them or not.
In the Edit Menu, the Outlining submenu, you have all the options. Including Toggle All Outlining (Ctrl+M+L by default).
Maybe your key mappings were altered.
If you so desire, you can even select menu:
Edit -> Outlining -> Stop Outlining
In VB.Net, do a Search and Replace and select Use Hidden and Use Regex:
Replace:
^.*\#(end)*(:Wh)*region.*\n
With:
I wrote an extension to do this (and more), and it works for VB and C#. See this answer for more info:
Hiding the regions in Visual Studio
Once I changed:
#Region Form Level Events
#End Region
To (note the addition of quotes):
#Region "Form Level Events"
#End Region
The minus signed appeared and I was able to collapse/expand Regions.
That's pretty odd. The default profile settings for VB.Net and C# should bind the outlining functions to Ctrl+M, Ctrl+L combos.
It's possible that your profile is in a weird state. Try resetting your profile to VB.Net settings and see if that fixes the problem.
Tools → Import / Export Settings → Reset All Settings → VB.Net Profile
I came up with this trick:
Ctrl+F
Quick Replace
Find:
#Region
Search in: current document (or entire project or wherever you need to expand regions)
Search in hidden text
Then press Return and keep it pressed until VS notify the search is endend.
As a result all your '#region's have been expanded in very few seconds.