How to configure IntelliJ (also Android Studio) redo shortcut to CTRL+Y instead of CTRL+SHIFT+Z? - android-studio

The default IntelliJ / Android Studio "Redo" action shortcut is CTRL+Shift+Z and this is a common problem for Windows users.
A bigger problem is CTRL+Y is mapped to the "Delete line" action - and this causes the undo stack to be lost.
To solve this issue, how can the "Redo" shortcut be changed to CTRL+Y in IntelliJ?

Open Settings (press CTRL+ALT+S)
Click Keymap on the left list.
There is a combobox that contains keymaps. Select one of them (default means IntelliJ of course. We can't change any of pre-defined keymap however we can copy, edit and then use the edited one. So) we should copy "default" to change only redo mapping.
Give a new name to your copied keymap.
Right click on:
Main Menu -> Edit -> Redo to click "Add Keyboard Shortcut"
Press CTRL+Y
Click OK
Click "Remove" to "the shortcut is already assigned to other actions. Do you want to remove other assignments?"
If you want to use any "remove line" shortcut also, then go to delete line shortcut and give to it any other shortcut (like 5th step)
Click OK to close settings window.

Change the keymap setting to the Visual Studio, Eclipse, or NetBeans preset.
The settings window can be found under File > Settings. CTRL+ALT+S should work if the shortcut hasn't been changed. In the settings window you should find Keymap under the Appearance & Behavior settings list.
You can configure each editor command to a key combo that you like (as #ismail yavuz mentioned) such as for Redo to CTRL+Y or you can just change the Keymap setting to an editor that you are used to. This might be best if you are in the process of switching to IntelliJ as it is probably the path of least resistance. The default settings for the Visual Studio, Eclipse, and NetBeans keymaps all map Redo to CTRL+Y.
The Principle of least astonishment is strangely violated for Windows users but at least shortcuts is customizable. Because of this command being so contrary to the Windows experience I decided it wasn't worth learning the IntelliJ keyboard when anywhere you're working at you need to, you can quickly change. There are almost no drawbacks to not learning the IntelliJ. Remember that in the keymap menu you can search for a command in the search box or click on the magnifying glass on the right to search by key combo.
Of course neither answer is wrong. Chose your preference.

Related

Can't activate shortcut on intellij products

Description
I'm using some intellij products (WebStorm, PHPStorm) and Android Studio and have the same issue with both of theses.
I have an azerty keyboard, with a french layout.
I can type without issue in these softs, but I can't activate shortcuts.
When I try to activate a shortcut (e.g ctrl+z), the activated shortcut is ctrl+w.
the shortcut is correctly triggered, but with the wrong keyboard layout. It seems that when I type, my french keyboard is used, but when I want to use a shortcut, the english layout seems to be used.
Is this a known bug (if so, I've not found any mentions about it), or did I miss something?
What I've tried
I'm running on Fedora 29, with Gnome 3.
I've tried to see if it wasn't reproductible with others softs (e.g firefox/ vscode), and I can't reproduce this.
I've tried to see if it wasn't based on my keyboard settings, so I ran xev to monitor the output of pressed keys. I can't reproduce this issue.
In intellij settings, I've tried to set Keymap > Prefer key position over key char with national layout both true and false, it doesn't seem to change anything.
Current situation
Here is an exemple of a shortcut definition in Android Studio.
I pressed A to Y keys on my french keyboard (which output A,Z,E,R,T,Y), and then press the same keys with ctrl (which output ctrl+Q instead of ctrl+A and so on)
https://imgur.com/a/U4aFd7F
Expected situation (tl;dr)
I expect that when I press ctrl+a, the shortcut triggered inside intellij products is ctrl+a instead of ctrl+q
It is indeed a known bug: https://youtrack.jetbrains.com/issue/IDEA-165950
In the bug report another workaround is mentioned for Gnome 3:
Re-order the languages in Settings > Language and Region tab, put English(US) first of the input source list.
I solved it by running setxkbmap fr. I don't know why this is required by intellij products, but it works.

Is it easy to toggle the vim plugin if you want to disable it?

I really want to use the vim plugin but before I install it I just want to know how easy it is to toggle it on/off?
Does it mess up any of the key bindings or when I toggle it on/off it will revert things nicely without issue?
It's very easy to toggle the Vim plugin on or off. There will be an option under the Tools menu that will allow you to do so. Your previous keybindings shouldn't be affected if you decide to turn the Vim emulator off.
Old post, but I was still looking for the answer, so here goes. Not enough rep to comment on the accepted answer, so I will expand on it here. It would appear that my IntelliJ did not have shortcut defined by default (maybe this has changed through the years). You must go into your settings and define a keyboard shortcut.
[IntelliJ IDEA 2020.3.3]
Settings -> Keymap -> Plugins -> IdeaVim. There should be a Vim Emulator option (which corresponds to the Tools menu option pictured above). Right-click on that item and select Add Keyboard Shortcut. Make the shortcut whatever you like...as long as it is not already assigned.
The shortcut keys will be reflected in the Tools menu if you later forget what you assigned.

Resharper Shortcut keys messed up

Yesterday, resharper randomly uninstalled after I had VS crash, after re-installing, nothing works correctly. I have reset VS's default key bindings and then enabled resharper's. When I first use a resharper shortcut, a menu pops up as expected asking me to select whether or not to use the resharper versions of shortcuts. I say yes and select apply to all resharper shortcuts. This is where the strangeness begins. Here at work we use code cleanup a lot (ctrl+e, ctrl+f), but ever since the crash and reinstall, I cannot use this shortcut. It recognizes the ctrl+e and opens up recent files and doesn't wait for the ctrl+f part of the shortcut. Thoughts?
Seems like you applied "IDEA/ReSharper 2.x" keymap scheme. Please reset keymaps once again and then apply "Visual Studio" keymap scheme here ReSharper | Options | Environment | Keyboard & Menus.
By the way, a default Code Cleanup shortcut in "Visual Studio" scheme is "Ctrl+E, Ctrl+C", not "ctrl+e, ctrl+f" you mentioned

ReSharper Shift+Alt+L (go to open file) not working in 2015 with .resx?

I'm wondering if this is just my ReSharper setup, but as of updating to Visual Studio 2015 with ReSharper Ultimate 9.1.3, using the Shift+Alt+L shortcut while editing a .resx in the designer does nothing.
Has anybody else experienced this, and is there any config that will get this working or is it a bug?
Thanks
This was caused (for me anyway) because my keyboard mapping had magically changed back to UK mapping from US (I want US).
The other day I had another issue that caused Resharper key mappings to go awry and followed some advice on another post (I can't find it at the moment) that want along the lines of:
Open Tools > Options > Keyboard and hit Reset
Open Resharper > Options > Keyboard & Menus, select "Visual Studio" and hit "Apply Scheme"
This should wrest control from Resharper back to Visual Studio and give Resharper the freedom it needs to wrest control back from VS.. ugh, but it worked
Maybe have a look to Stackoverflow - How to locate a file in Solution Explorer in Visual Studio 2010?.
Tools (in Menu) -> Options -> Keyboard -> goto input Show commands containing and type SolutionExplorer.SyncWithActiveDocument. Goto Press Shortcut Keys and press Shift + Alt + L click on Assign button.
You may get a warning that the shortcut is already in use.

shortcut in Android Studio to locate the current editing src file

Do you know how to check the location of current editing file in the project tree panel (the very left panel of the Android Studio), except manually. (The worst case is that all the folders there are collapsed)
The Navigate->Class shortcut can show me the src file in edit panel (central panel) quickly. Then I want to know the src file's logic location in project tree (left panel), so that I can add some new files in the same package quickly. (e.g. right-click the package and add new Class).
Currently, I have to expand the project tree and find it folder by folder.
Actually, in Xcode there is such a shortcut named "Reveal in Project Navigate"
What a convenient way it is.
I wonder whether this is also supported in Android studio.
Thanks
You can use the Scroll from Source button in the Project Toolbar in the left of Android Studio.
Another solution is Alt+F1+1. You can also read Locate current file in IntelliJ for more answers.
Just enable the following option!
In Android Studio 4 it is now Always Select Opened File under the Settings menu in the project view.
For automatic scrolling, you can do following:
You need to ensure Autoscroll to Source and Autoscroll from source is enabled.
Whenever you change the file the Project tree will be highlighted according.
I have observed some slowness and lag if project size is big(several modules or huge code base) and you use short cut Ctrl + N to navigate to a class.
So the alternative would be to either to click following icon:
OR
Use keyboard shortcut:
Alt + F1 + 1 or Alt + F1 + Enter
You can add shortcut (keymap) to "reveal current editing file in project explorer" command.
Press Ctrl + Alt + S, for Windows user, to open Settings
Select Keymap on the sidebar
Find the command using search box, type this into it: select in project view
Right click the result then select Add Keyboard Shortcut
Type any keyboard combination you want, for example, me prefer shortcut Ctrl + K to reveal current editing file on project explorer
Click OK button. It will prompt you to remove keyboard shortcut you typed from existing command, so just click Remove button.
I'm new to android development. I used to code in Sublime Text 3. One of first thing I do to make android development feels more enjoyable is binding all shortcut I used in Sublime Text 3 to Android Studio. Now, it feels like home :)
For Mac users: Option+fn+F1, then Enter.
Android Studio 3.6.3 (April 2020)
Go to Preferences > Keymap & search for "Select in Project View" and assign your keyboard shortcut.
Under options menu, select Auto scroll from Source
Navigate -> Select In.. -> Project View -> Project
open pref -> Keymap, then search 'select file in project view', not 'select opened file'.

Resources