Intellij IDEA shortcut to "create field"? - intellij-idea

There is an useful functionality in IDEA that lets you create a field, and it appears in the little light-bulb when you highlight the non-created variable.
However, I can't find the short-cut, searched for "create field" in the settings but no luck.
Anyone knows?.

Control + Alt + F on a literal will give you the option to extract the value into a field.

Use Alt-Enter to access the lightbulb menu and then use the arrow keys to select the necessary option. There is no possibility to assign shortcuts to individual quickfixes (there are too many of them).

On MacOS, its option-command+F.
Its much faster than Option-Enter, then you need some brain cycle to select create field in the down down menu

Related

VIM equivalent of IntelliJ's expand/shrink selection?

How would one achieve the same result. I believe the keybinding for macOS Intellij is op+up/down and on windows it is alt+w/d.
Essentially the function highlights the current word, then, with successive presses, expands out to the full string/line/area in-between parenthesis/further out to the next set of parenthesis. Very useful for developing in LISP.
The closest I've gotten is this: https://vi.stackexchange.com/a/19028
Try this plug in: https://github.com/terryma/vim-expand-region
It expands selections based on Vim’s text objects.
Well this may seem comfortable but does not correspondent with the internal logic of vim itself.
See, in vim everything you enter is like a sentence. va{ for example: there is a verb v -> visually select and an object (or movement) { -> paragraph. In this case there is also a modifier a around. You can exchange stuff in this sentence and it will still work vaw, dil, cB and so on. The power of vim is greatly based on that concept.
Of course you can write a function that does vaw first, then S-v and lastly va{ but that will only work with visual selection. It will not work with c or d or anything. So I will recommend to get used to use different keys for different actions.
The visual selection is mostly not needed anyway. Change a paragraph? directly use ca} and so on.
I have found that VI/VA + WOBO (as many times as you need to expand) works similarly. Not as fast but its the same concept and you can even expand/shrink asymmetrically based on your WO's and BO's (Or OW's and OB's depending on how you look at it)

intellij wrapping brackets around if-else

Coming from a language like python, I often forget to wrap parenthesis around if conditions when writing Java.
Is there a parenthesis completer built into IntelliJ? If not, how do I best work around this issue? (short of manually wrapping with parenthesis myself -:))
When you will start typing if code completion will ocurs. Push enter - your carret will land inside bracket.
Use surrounding blocks of code. You can first write boolean condition then press shortcut for Surround With option (on windows/linux by default it is Ctrl + Alt + T) and choose if(expr).
Or if you want to only surround with paranthesis, then use (Surround With) and then choose (Curly Braces).
You can use predefined live template with ifn which will initialize if block with comparison to null. You can also configure your own template.
Also you might want to check if this option is selected in your IDE:
Settings(Preferences) | Editor | General | Smart Keys, Surround selection on typing quote or brace

How to select whole 'camelCaseWord' in Pycharm with camel humps turned on

I have use camel humps option turned on in pycharm so I can move between 'camelled' words using ctr + ->/<- but sometimes I want to select the whole
CameledWord I can't do shift + ctr + -> because it will select the first word in the camelled word.
example :
I have this word : ImCamelCase
I want to select the whole word : ImCamelCase
using ctr + shift + -> does not work because I have camel humps option turned
on (and I need this option to remain turned on)
How can I do it (without turning off camelHumps option) ?
Just found a solution :
using (ctr + w) two times will select the wholeCamelCased word
I think it is the best option if you have another idea tell me :)
There is an option under Preferences->Editor->general to honor (or not) camel humps words when selecting on double click.
I realise this doesn't answer your question as you want to select it with keyboard shortcut but wanted to mention it anyways just in case you (or other readers) sometimes also want to select it using the cursor.

Shortcut to get out of parenthesis in IntelliJ (or possibly other IDE as well)

Let's say | is a cursor pointer. What I want to do is to get out from parenthesis once I finish typing paremeters. In step by step explanation:
// 1: type function name
void function|
// 2: openening paren automatically generate closing paren for convenience
void function(|)
// 3: type paremeters...
void function(42|)
// 4: ...and get out of parenthesis!
void function(42)|
Usually I use right arrow to do that, but using arrows are not so convenient, and I wonder if there's any shortcut for this. What I'm curious at is IntelliJ's, but it would be very nice if you can tell me shortcut of any other Jetbrain IDE or Visual Studio, etc.
I think you are looking for Ctrl + Shift + Enter (on Windows). The Action name is Complete Current Statement
On Mac if you want to know the shortcut invoke Command + Shift + A (Find Action) then type Complete Current Statement it will show you the shortcut for the action as well
The shortcut you're looking for, on most keyboards, is shift+0 -- this won't work on the keypad, only the main numbers at the top of the keyboard. Technically this isn't a shortcut, you're actually typing the close parenthesis, but IntelliJ is smart enough not to double up on them so it's as good as a shortcut in this case.
Another setting that I find convenient to use is this option.
Settings - Smart Keys - Jump outside closing bracket/quote with Tab

Intellij Idea Keyboard Shortcut To Select A Token

Is there any intellij idea shortcut to select a token in a statement?
For example, consider this:
cell.setCellValue((profileInfo.get("startTimeOfCrawl")!=null)?profileInfo.get("startTimeOfCrawl"):"");
Currently, if my cursor is on the first character of the above statement(i.e. at beginning of c of cell, if I have to select profileInfo, then I will have to use my mouse and double click on profileInfo to select that.
Another workaround I found was to use arrow keys to get cursor to profileInfo
Then use ctrl+shift+right-arrow keys to select till the end(i.e. till o) of profileInfo
This is good when my cursor is placed at beginning of profileInfo(or even end in which case we can use left-arrow key).
But if my cursor is placed somewhere in between of profileInfo then I will have to use ctrl+right (or ctrl+left) to get the cursor to either beginning or end of this token. Then I Will have to use ctrl+shift+right-arrow (or left-arrow as the case may be).
(Switching from keyboard to mouse breaks the continuity, hence looking for keyboard shortcuts.)
Is there a better shortcut to do above in 1 step?
PS: Solution to above will be very useful when making string replacements.
Use Edit | Extend Selection (Ctrl-W in the default keymaps, Alt-Up in the Mac OS 10.5+ keymap). You can press it multiple times to extend the selection to larger enclosing syntax constructs.
I can't think of a 1-step process of doing this but try using the alt to traverse via arrow keys, it will traverse it per "word" instead of per character.
You can also use alt+shift+ arrow keys to select per word.