When I fold some code blocks (e.g. for(){...} loop or if(){...}) I often need to unfold it back. But my cursor can be far from the original position. I would like to do it using Cntrl+Z hotkey. But it doesn't catches fold/unfold actions.
Is it possible to track folding actions so they can be canceled by Cntrl+Z
No, there is no such feature in Intellij. Folding/Unfolding are not captured as "real" actions.
Unforunately nothing is mention in their official documentation, nor the Settings/Preferences dialog (Ctrl+Alt+S), go to Editor | General | Code Folding provide such feature.
You might be able to get something similar with the code navigation keys:
Ctrl-Alt-Left = go back to previous cursor position
Ctrl-Alt-Right = go to next cursor position
Alternatively, you can use the Back and Forward buttons on your mouse to navigate through your location history.
Related
I sometimes want to see the diff of what has changed only per line, but I find it uncomfortable to always move your hand to the mouse and click on the gutter marker. Is there a way to assign a shortcut to open that little diff window (as seen in the image)? I couldn't find an IntelliJ action that opens it.
That action is called Change Under Caret.
By default, no shortcut is assigned to it. You can find it with Find Action (Ctrl+Shift+A | ⇧⌘A).
You can also assign a shortcut to it right in this popup with Alt+Enter | ⌥⏎.
Other useful shortcuts:
Next Change: Ctrl+Alt+Shift+Down | ⌃⌥⇧↓
Previous Change: Ctrl+Alt+Shift+Up | ⌃⌥⇧↑
Rollback Lines: Ctrl+Alt+Z | ⌥⌘Z
Help documentation:
Review changes - Track changes to a file in the editor
Source code navigation - Navigate between changes
Undo changes in Git repository - Revert uncommitted changes
Use the keyboard shortcuts for Navigate:Navigate in File:Next Change/Previous Change
To make it even easier, modify the shortcut for that command to your liking in Preferences:Keymap.
I like VIM a lot because it kind of doubles the power of my keyboard in a way. It's either in insert or motion or whatever they call it mode.
Navigating through source code, typing code, while being able to keep my hands in the touch type position is great.
But when a dialog box is opened (eg. the one using ctrl+F12), if I have to select something other than the first one in the list, I am forced to have to move my right hand to the cursor keys.
Is there a way so that I can use J and K or else something with ctrl or alt or something, so that I can select an item while keeping my hands in the touch typing position?
You can redefine shortcuts for the Up, Down, Left, Right actions in File | Settings | Keymap (the regular keymap that has nothing to do with IdeaVim). IdeaVim provides Vim emulation only for code editors like file editors, interactive language consoles, etc.
Edit: I guess you can't use j and k since characters typed in the structure window are reserved for searching. But you can use Ctrl+N and Ctrl+P which is the same as the navigation shortcuts for pop-up windows in Vim.
Edit 2: You can't use Ctrl+N and Ctrl+P as well due to this bug in IntelliJ.
I'm really impressed with the autocomplete feature of the IntelliJ IDE so far.
What I'd like to do, is cycle through the autocomplete suggestions I get when hitting Ctrl + Space without using the arrow keys (↑, ↓).
The reason for this is that I prefer to keep my fingers on the home row (I'm using IntelliJ's Vim emulator additionally).
For example, how would I select sortThis instead of sorted without using the arrow keys or the mouse?
Peter Gromov's answer brought me to a satisfying solution:
In IntelliJ's settings, for Keymap → Editor Actions → Down I set a custom shortcut: Ctrl + J.
This way I can cycle forward through the suggestions.
Setting a shortcut for Down with Selection or Scroll Line Down in the IdeaVim-specific shortcuts did not affect the selection of autocomplete suggestions though.
The answer here: https://stackoverflow.com/a/9713306/2370679 led me to discover that Ctrl+n & Ctrl+p allow navigation of the auto-complete options without having to modify any settings
For macOS the IDE will give a hint that "^↑ and ^↓ will move caret up and down in the editor". These clearly do not work.
There are a few extra steps that are needed after following #matthias-braun's solution.
Here is the full list of step that I use:
Go to Preferences -> Keymap
Expand Editor Actions (not Plug-ins -> IdeaVim)
Select Down
Click the pencil icon or right-click
Select Add Keyboard Shortcut
Press the shortcut (I use ^N)*
Repeat for 3-6 for Up (I use ^P)
Click Ok**
Go to Preferences -> Other Settings -> Vim Emulation
In the drop-down under the Handler column for the row containing Down, select Vim***
Do the same thing for Up
* If you are warned about the key binding already existing then remove it. You can always reset back to the defaults by clicking the little cog icon up the very top to the right of the drop-down menu.
** The Vim Emulation doesn't seem to be populated correctly until you reopen the Preferences.
*** I'm not sure why the Handler should be Vim. This seems backwards to me but it works.
If you're able to scroll up/down in editor with some IdeaVIM-specific shortcuts, they should also work in the completion list.
In this particular case, I'd just type another "t" so that "sortThis" becomes selected (and the only) variant.
I have done the same thing with mapping the arrows but in a more logical way:
I mapped them that when I press 'Alt' 'J' is left, 'L' is right, 'I' is up, and 'k' is down. that way I can have easy access to the arrows while my fingers are on the home row and I don't need to move them nearly as much...
I'm posting it just so people who search it on google can have that idea.
I want to move the cursor from here:
To here:
in a single step. Is there any such keyboard shortcut?
Right now I first have to enter the right arrow, then comma and then space which is a task quite cumbersome on my keyboard.
No there isn't but you could create a live template to get something simpler. So you can create a live template live this:
$PARAMONE$, $PARAMTWO$, $PARAMTHREE$, $PARAMFOUR$ $END$
And you can call this param4, and once you type that in, and press tab, it will load up areas that you can type into and just press tab to get from one param to the other.
Other than that, there's no way I know of to do this.
If I split the editor window (horizontal or vertical) into N tab groups, how do I switch/toggle from one tab group to another via the keyboard? If all of the tabs are in the same group you can switch from each tab easily (CTRL + right/left arrow), but when they're in separate tab groups I can't. I've searched through the key mappings and have not found one that seems to accomplish this. I know I can use the mouse, but I'm trying to find ways to avoid the mouse and stay with the keyboard.
TIA for any help on this.
Ctrl+Tab and Ctrl+Shift+Tab for Window | Goto Next Splitter and Goto Previous Splitter. However, these hotkeys may be taken by the Switcher, so you need to remap them in Settings | Keymap.
It looks like it's now mapped to Alt+Tab and Shift+Alt+Tab so no need to remap (at least for OSX 10.5+ settings).
I had the same case and this plugin solve my problem:
https://plugins.jetbrains.com/plugin/7475-tab-shifter
https://github.com/dkandalov/tab-shifter
As I write this, here is what it support:
Move tab to another editor split
Move focus between splits
Resize the split
You may refer more details on the page/github. It works pretty well in 2019.2
I can switch the splitters with CTRL+E and then ENTER.
If you have more then 2 splits, then you can navigate or quick search in the Recent Files dialog.
Switching the splitters with the Switcher doesn't work.