How to use Option in Intellij Keymaps? - intellij-idea

I am trying to add Option-i | u for "Find usages" as shown in this dialog (Note that the "i" is lowercase - shift is not depressed):
But after having selected OK and then going back into Actions we see that the setting did not "take":
Note: I do have custom keymap entries to use Option- for accessing Main Menu items. But why is Option not working in this case? Is there a workaround?

On macOS, "Option" is used for typing special characters, thus when editor is focused and you hit Option-I the shortcut you assigned won't work (it will type a character instead).
However, when no editing field is selected, the shortcut should work (e.g. from tool windows).

Related

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.

Unable to type > character in Intellij IDEA

Whenever I am using the Canadian Multilingual Standard Keyboard, I can't type the greater than character which are the keys AltCar + period. A dialog box shows
There are no custom foldings in the current file.
Removing/changing the shortcut for Fold selection/ Remove region in the Keymap did not work. I've also tried to add actionSystem.force.alt.gr=true to bin/idea.properties but I can't apply changes to idea.properties.
Press Ctrl-Alt-Shift-Slash (Cmd-Alt-Shift-Slash if you're using Mac OS X), select "Registry" from the menu that appears and enable the "actionSystem.force.alt.gr" checkbox in the menu that appears.
Go to File | Settings | Keymap. On the top of the screen, in a dropdown box you will see that one of the default keymap is selected. You need to make a copy of it. This is important becasue you can't change the default keymaps. To copy it, click on the Copy button on the right of the dropdown box and name your new layout however you want.
Now, with your new Keymap selected, search for the "Custom Fo...". Right click on any shortcut that is mapped to either Alt+. or Ctrl+Alt+. to delete it. Hit OK and you should be good to go.

Cycle through autocomplete suggestions without arrows

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.

Rename using suggested var name with resharper

I'm Using resharper 6 nighty builds and VB.net. I've a big medium project with multiple files that don't follow the code style conventions of my company.
I've configured resharper with my own convenctions and It suggest to me the right name for each variable (perfect!).
But I can't find any automagic way to make the current name to be replaced with the suggested name.
Are there any way to do it? If not ... did you know ane fearure of coderush Xpress to achieve it?
Thanks.
If you've configured ReSharper with your naming conventions, then it should show a warning (blue squiggly underline) under any identifiers that don't comply. If you put the text cursor on one of those misnamed identifiers, you should see a pyramid icon appear near the left margin. Then you can press Alt+Enter (or click the pyramid icon) to drop down a quick-fix menu. There should be an option in the menu to "Rename to '_myField'". Usually it's the first item in the list, so you can just press Enter again to do the rename.
If you want to do this on everything in a source file, you can use the ReSharper > Inspect > Next Issue in File command (or its keyboard shortcut -- F12 in the IDEA keymap) to move the cursor to the next warning in the file. Then, if it's another name warning, you can use Alt+Enter, Enter again to fix it.
Unfortunately, there isn't a way to automatically fix every instance of a warning at once (though it's been requested; please feel free to vote for RSRP-126551 in their issue tracker).

Xcode question: Quickly jump to a particular selector/class/symbol?

What is the quickest way to jump to a particular symbol/selector/class in Xcode? (I'm looking for keyboard shortcuts preferably).
Right now, I know two ways of doing this:
“Open Quickly” > Click on the Symbols dropdown menu at the top of the editor > Select the selector to jump to it.
Click on “Project Symbols” in the “Groups and Files” section on the left sidebar, and type in a name in the Search text field in the top right of the XCode window.
Is there a quicker way of doing this? (If I could even assign a shortcut to jump to the “Project Symbols”, that would suffice for me. Alternatively, if I can find a keyboard shortcut to jump to the symbol dropdown above an editor that would do it to).
For experienced Xcode programmers, what do you use to jump to a symbol?
In Xcode 3.2, the "Open Quickly" command (Shift-Control-D) lets you type in selectors and class names as well as file names. This would at least get you close to what you wanted.
Your idea about using the "Symbols" drop-down also works. You can use the keystroke Control-2 to bring up the Symbols drop-down menu, and then use the arrow keys, or start typing the name of the method that you want to reach.
Edit: In Xcode 4, the "Symbols" drop-down appears when pressing Control-6. You can change this in the Xcode settings by changing the key binding for "Standart Editor > Show Document Items".
If you're looking at the symbol in a source file and want to jump to its definition, ⌘-click it.
(command + double click) on your symbol/selector/class in any place of your implementation to jump to them
(option + double click) on framework classes/selectors to jump to their reference in help->documentation
One (arguably crude) way to do it seems to be as follows:
This is based on the fact that the Search field at the top right of the Xcode window seems to change behavior depending on what is selected in the Groups & Files sidebar.
Select “Project Symbols” in the “Groups & Files” sidebar
Press ⌥⌘F (That is Command+Option+F) to jump to the Search field
Enter the symbol to jump to, and an outline will quickly show up
(this will remain in effect until you click on something else in the Groups & Files sidebar)