Open a method body in the split screen immediately (without having to go thru tab's header)? - intellij-idea

Is there a way to set Settings or a shortcut which will open a specific method directly into Split screen of IntelliJ or AndroidStudio?
Right now, I am doing the long way via tab's header and choosing one of two split options.

You can set your favorite shortcut to split screen.
Go to Settings -> Keymap.
Then search for the command split (you can use the search field).
Finally select the command, right click and "Add keyboard shortcut"

Related

How to check/uncheck individual change checkbox in IntelliJ commit diff dialog?

I am an aspiring keyboard user, using IntelliJ to do selective commits to my project.
To do this, I open the Commit dialog with Ctrl+K.
I then press Shift+Tab to switch to the file list, Home to select the root-level node, and Space to uncheck/de-select all files.
I then press the down arrow once or more to select a file, press Ctrl+D to display its diff. I press F7 to go to the first change in the file.
At this point, to the left of the right pane (with the new version of the file) is a checkbox. Not the one at the top which selects all the changes in the file, but the one which selects just the change displayed.
My question is: How do I select/un-select this checkbox without using the mouse cursor? I need to use the mouse as little as possible due to RSI.
Note: When asking questions like this, I sometimes get responses with other pointing device suggestions. Unless you're going to recommend a keyboard technique, I am not interested in your suggestion, and will flag/report your response if that's what it is.
By default there is no keyboard keymap for this action. But you can easily choose new keymap for this.
Go to File->Settings and search for "include" in the search box. What you need is to assign a keymap for "Include Lines Into Commit". Double click on this option and assign any keymap that you want. It is hard to find new keymap that didn't assign to any other action, but only for the demo I choosed Ctrl+T.
You can see what I did in the following image:
Click on Apply and then you can use the keymap that you choose to check/uncheck any individual change checkbox in Intellij commit diff dialog.

Can I open a file in a new split screen tab with a keyboard shortcut in IntelliJ?

In VS Code I can press command + P to search for files and then when I find the one I'm looking for I can press Command + Shift + Enter to open the file in a new tab that adds a split pane to the window.
I can browse in a similar way in IntelliJ pressing Shift twice, but I can't figure out how to open the file in a tab in a split pane, just in a new tab in the same pane on pressing Enter. Is there a way to do it?
On the tab line, where all of your files are tabbed and opened, you can right click and see the option Split Vertically and Split Horizontally. They will split your window as needed. You can bind these options to a macro and automatically have anything split in a second.
Then you can just open any file with your explorer, and then run your key combination to split it!
Edit: you can create key mapping from the Settings -> Keymap menu.
Mr. Robot
I think, it's too late to answer this question.
But anyways, there is already a predefined keymap binding as per your requirement to open a new file in a split window.
keymap is Shift + Enter
After searching any file, you just have to press this combination and it will open that new file in a split window.
*This keymap is for Mac, it may be different for other OS.

How can I enter a literal <TAB> character in IntelliJ/IDEA/PyCharm?

My configuration indents with four spaces, and I want to keep that. Occasionally (e.g. in a Makefile) I want to input a literal TAB character.
How can I force the IntelliJ-IDEs to input a tab or space, when it would not do so when I hit tab or space in that instance?
You seem to be asking two questions here:
1. How do I force IntelliJ IDE to input a tab, when it would not do so when I hit tab?
and
2. How do I force IntelliJ IDE to input a space, when it would not do so when I hit space?
I don't understand how the second case can arise. However, I have provided a solution to it as well.
Case 1. Insert a tab character when an IntelliJ IDE wants to replace it with spaces due to configuration
Solution
Use search and replace.
Details
Place the cursor where you want the tab to be
Press the X key
Select the X you just typed
From the main menu, choose Edit | Find | Replace to bring up the search and replace pane
Make sure there is an X in the search field
Enter \t in the replace field
Be sure the option Regex is checked
Be sure the option In Selection is checked
Click the Replace button
Case 2. Insert a space character when an IntelliJ IDE won't just let you type one (???)
Solution
Use search and replace.
Details
Place the cursor where you want the space to be
Press the X key
Select the X you just typed
From the main menu, choose Edit | Find | Replace to bring up the search and replace pane
Make sure there is an X in the search field
Enter a single space into the replace field
Be sure the option In Selection is checked
Click the Replace button
Install the plugin for Makefile support: https://plugins.jetbrains.com/plugin/9333-makefile-support
When I tried it today, this automatically use hard tabs in the editors for Makefile files.
Open another text editor, type a tab, and then copy and paste into the PyCharm editor. In MacOSX this worked for me using both Sublime Text 2 and TextEdit.
I can't think of any "direct" way. Probably the easiest way that I can think of is to write a Live Template to do it. See the help page on Live Templates for more information. When you write it, you may need to copy and paste a tab character in from another application.
However, when I tried it, IDEA saw it as just empty text and would not save it. So I used a variable with the "capitalize" function to capitalize a tab character.
Here's the template I created that you can paste into your templates. Now I type tab, hit the Tab key and I get a tab character. Of course you can change the abbreviation.
<template name="tab" value="$TAB$" description="Enter a tab Character" toReformat="false" toShortenFQNames="true">
<variable name="TAB" expression="capitalize(" ")" defaultValue=" " alwaysStopAt="false" />
<context>
<option name="OTHER" value="true" />
</context>
</template>
You could extend the idea to have multiple ones that enter multiple tabs. For example tab to enter 1 tab, tab2 for 2 tabs, etc.
Screenshot of it after use:
There may also be a way to hack a macro to do it. You could then assign the macro to a keyboard shortcut. I'll see if I can figure something out and update this if I do.
Use the menu option: Edit -> Convert Indents -> To Tabs.
Whenever I edit a makefile I do the "to tabs" conversion before I save the file.
UPDATE: Really sadly, I think the generated character still gets converted to spaces... Am checking...
There is an Action in JetBrains IDEs to enter a Tab character.
Here are the steps to use the Tab character action: (discovered in PyCharm 2020.3)
Double-tap the Shift key OR Help -> Find Action...
Type the 3 characters tab
Click on the action that is called Tab and shows the icon for the Tab character...
It remembers the last action you did, so if you have several tabs to add, you can get into a quick process by doing ShiftShift then Return each time.
Answer based on #Morfic's comment to the question. I think this is the cleanest and most sensible reply here so I figured it deserves a place as an answer (and needless to say, it worked for me).
If they're different types of files you could configure File -> Settings -> Editor -> Code style -> Tabs and Indents for each one to use either space or tab depending on how you want it.
One way to do this is to copy a TAB character from another text editor, then right click in your PyCharm file and use Copy / Paste Special -> Paste as Plain Text (Ctrl+Alt+Maj+V)
I guess this was not available in older PyCharm versions, because no other answer proposed it. Regular paste (Ctrl+V) doesn't work (replaced by spaces), but this one works. The function will also bypass other automatic formatting.
Inspired of Clare's suggestion,
assign the left tab key after finding 'tab' action.
At Actions tab, search by 'tab' and move your up/down arrow key and place there.
Then type Ctrl+1, you will see a popup. Select as follows and click OK.
Then, you might be asked "Do you want to remove other assignments?" if Tab key was already assigned. Click Leave because your usage won't conflict with the existing setup.

Intellij - Split Screen Creates Duplicate

When I have two Java files, and I want to compare them side-by-side, I split them vertically. However, I end up with 3 Java files, because it duplicates the one I split, instead of just moving it.
Is there a way to change the behavior such that it just splits the two files I have open, rather than creating a 3rd?
Not sure when this feature was added, but you can simply right-click the tab and choose Move Right ; it has the effect of splitting horizontally and then closing the old tab.
This is not possible. The concept of a split is just that, to split an editor. See Splitting and Unsplitting Editor Window in the help guide. You can create a second editor window by dragging a tab off the main editor window. See Detaching Editor Tabs in the help guide. Note, if you already have a split in place, you can drag a file from one split pane to the other.
You can also write a macro to accomplish what you want.
Give the tab you want to split focus
From the menu: Edit > Macros > Start Macro Recording
Record the following sequence:
Right click on the tab and split it
Type ctrl+F4 (or ⌘F4) to close the original window
Stop the macro (either view the popup in the bottom or via the Edit > Macros > Stop Macro Recording)
In the dialog, give the macro a name.
You can now either run the macro from File > Edit > Macros, or you can map a keyboard shortcut to it. See Binding Macros with Keyboard Shortcuts in the help guide for how to do such.
Don't use Split Vertically or Split Horizontally actions!
Instead, you can use Split and Move Right and Split and Move Down actions.
You can press Ctrl + Shift + A, and type "split ..." then choose the action.
Also, you could add shortcuts for them,

How to set single clicking to open file in IntelliJ IDEA?

And what are counterparts to eclipse's declaration view and javadoc view?
In the Project View click on the "gear" icon and enable the Open Files with Single Click option:
Use Ctrl+Q for Quick JavaDoc and Ctrl+Shift+I for the declaration pop-up.
Now it's available in a simpler way. In the Project View click on the Gear icon and then click Open Files with Single Click:
Go to Preferences and turn on Enable preview tab, that will enable Open Files with Single Click for all projects.
Javadoc opens with Ctrl+Q
There's no declaration view per se, however, you probably will be satisfied with Ctrl+Shift+I shortcut for quick lookup.
Don't know of any ways to configure it to open files on single clicks. Somehow, if you get used to the shortcuts, you skip using mouse very much. For instance, Alt+Home will bring the navigation bar up and you can move with arrows and open the file with Enter. Or just use some other shortcuts like Ctrl+N or Ctrl+E depending on the context.