IntelliJ IDEA non standard caret behaviour - intellij-idea

I have an issue with IntelliJ IDEA when selecting a big amount of text, and I cannot find the parameter to set to change that. Here is an example of the situation:
My caret is on line 3
I scroll with the mouse wheel towards line 300
I press ctrl + shift
I press the left button of the mouse
Such an action would result in the text from line 3 to 300 being selected in all common editors (even in MS-Word I think), but not in IntelliJ.
Do you know how to set this right?
Thanks!

Why ctrl+shift? Shift is enough to select those lines in most editors, ctrl is most commonly used to add additional items (for example, two ranges with shift).
Ctrl + Shift + Left Click is "Navigate to Type Declaration" in IDEA. See here.

Related

How do I select mutliple lines using only the keyboard in a JetBrains IDE?

A very minor annoyance of mine as this is something I need to do regularly, therefore it could speed me up considerably over time. Say I have the following four lines:
File.join(root,
'setup',
'pre-suite',
'install.py'),
If my cursor was resting before 'File' I can use CMD+SHIFT+Right arrow to highlight part of the line or the full thing, I can even move this line down the list by using the down arrow instead of the right arrow. However, I want to select all four lines using the keyboard only, is this possible? If so how?
Here on Windows Shift + Up/Down expands selection to include the line above/below.
Since you are on Mac (based on Cmd in your shortcuts) ... just use Preferences | Keymap and look what shortcut you have got there for Editor Actions | Up/Down with Selection actions.
Another idea - use Edit | Extend Selection few times in a row (how many -- depends on context and caret position). Try it -- it does wonders; especially useful when invoked in the middle of such code block/statement.

IntelliJ IDEA find matching parenthesis / bracket

Is there any keyboard shortcut to navigate from one parenthesis ( to the matching one ) in IntelliJ?
Or even to "jump to the next opening/closing parenthesis (/) from wherever my cursor is"?
And, if there's no way to do it 'natively', are there any plugins that could add this functionality quickly and easily?
EDIT: the best solution I've found is added as a comment in liango's answer below, namely to put the cursor on the first or last brace and then press CTRL-W twice. Not ideal, but it does the job!
You can use Ctrl + [ and Ctrl + ] to navigate to a code block's start and end.
You can also use Ctrl + Shift + M to navigate between the start and end of a code block.
On Mac, you can use Option + Cmd +[ and Option + Cmd + ], and Ctrl + M
Source: https://www.jetbrains.com/help/idea/2016.2/navigating-to-braces.html
use CTRL-W to expand the selection within a bracket, use repeatedly if needed to select further out, then use the arrows.
CTRLSHIFTM is the Windows/Linux default shortcut for action "Move caret to matched brace". (For other environments see here and use the Shortcuts dropdown in the top right of the page.)
Or if desired, the shortcut keys can be changed as follows:
Go to Settings -> Keymap -> Editor Actions, or just type the name in the search box.
Here's the latest and greatest as of version 2020.1
To move caret between matching code block braces, press Ctrl+Shift+M.
To navigate between code blocks, press Ctrl+Shift+[ or Ctrl+Shift+].
From the documentation
Navigate with the caret
To navigate backwards, press Ctrl+Alt+← Left. To navigate forward, press
Ctrl+Alt+→→ Right.
To navigate to the last edited location, press Ctrl+Shift+Backspace.
To find the current caret location in the editor, press Ctrl+M. This
action might be helpful if you do not want to scroll through a large
file.
However, you can press the Up and Down arrow keys to achieve the same
result.
To highlight a word at the caret you are trying to locate, select Edit
| Find | Next Occurrence of the Word at Caret from the main menu.
To see on what element the caret is currently positioned, press Alt+Q.
To move caret between matching code block braces, press Ctrl+Shift+M.
To navigate between code blocks, press Ctrl+Shift+[ or Ctrl+Shift+].
To move the caret forward to the next paragraph or backward to the previous one, press Ctrl+Shift+A and search for the Move Caret Forward a Paragraph or Move Caret Backward a Paragraph action.
You can also select a text and then move the caret forward or backward to a paragraph. Press Ctrl+Shift+[ and search for the Move Caret Forward a Paragraph with Selection or Move Caret Backward a Paragraph with Selection action.
You can use Ctrl-[ and Ctrl-].

Move text cursor to previous string when I am at the left corner of current string

Is it possible in IntelliJ IDEA to move cursor to previous string when it is at the left corner of current string and I am pushing on left arrow keyboard key.
Let me explain:
1) Text cursor at the left corner of line 4
2) I am pushing on left arrow keyboard key
3) All I want to get - move text cursor to end of previous (3) line
But IDEA not moving text cursor from previous line, it just stays there.
Help me please.
This is because by default IntelliJ allows placing the caret after the end of line. When you press your ← key, it does not move as it would have to go to the infinite right side of your file, which is not very convenient (at least that's how I understand it :p).
Go to Settings > Editor and uncheck Allow placement of caret after end of line, this will solve your problem.

How do you deselect the text in a rename dialog without moving the cursor, with the keyboard, in IntelliJ IDEA

I'm using IntelliJ IDEA 10.5.2
Example:
Say I want to rename this class to SomeAwesomeClass.
If we do the Rename refactoring we get a dialog like this:
It has the cursor in the right place however the text is selected. So if we started writing "Awesome" the original name would disappear. So what I want to do is keep the cursor position but deselect the text.
I have not been able to find any way to do this. All things I've tried ether moves the cursor or removes the text or does nothing.
Left or Right keys goes to the left or right.
Up or down does nothing.
Esc closes the dialog.
PageUp or PageDown does nothing.
Home or End goes to left or right.
The fact that the cursor is in the right place to start with makes me believe this is a existing feature...
In 11-eap (110.365) when you rename a class (Shift+F6):
at first full class name is selected and you have a dropdown with suggested names, press Esc
full class name is still selected (dropdown gone), press Esc again
you have class name unselected, and can write at cursor
Note a third Esc will exit rename.
In earlier versions (10.5.2) you can do a trick:
Before rename select one character (shift+arrow forward) where you want to end up (in SomeClass select C) then Shift+F6 and arrow back. I know it is a lot of keys to presses but in a long class name this helps.

How to Select Columns in Editors (Atom,Notepad++, Kate, VIM, Sublime, Textpad,etc) and IDEs (NetBeans, IntelliJ IDEA, Eclipse, Visual Studio, etc) [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Closed 1 year ago.
Locked. This question and its answers are locked because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions.
How to select columns in Editors and IDEs to columnar delete, insert or replace some characters ?
Editors:
Atom
Notepad++
Kate
VIM
Sublime
Emacs
Textpad
Emerald Editor
UltraEdit
MCEdit
jEdit
Nedit
IDEs:
NetBeans
Eclipse
Visual Studio
IntelliJ IDEA
Flash Builder
Aptana Studio
Notepad++, Visual Studio, and some others: Alt + drag.
vim: Ctrl + v or (bizarrely enough) Quad-click-drag. In windows: Ctrl + Q (since Ctrl + V is the standard for paste)
In Kate toggle Ctrl + shift + B .
In Netbeans 7.1 can select columns (Rectangular Selection) with Ctrl + shift + R . There is also a button in the code editor available.
This is how rectangular selections look like:
Eclipse used to need a column mode plugin to be able to select a rectangular selection.
Since Eclipse 3.5, you just need to type Alt+Shift+A: see its News and Noteworthy section. (On OS X it's Option-Command-A.)
Or activate the 'Editor Presentation' action set ( Window > Customize Perspective menu) to get a tool bar button for toggling the block selection mode.
AmbroseChapel adds in the comments:
This is a toggle.
Columnar selection is a mode you enter and leave: in other words, Eclipse switches into a mode where all mouse selections have to be columnar and you stay in that mode until you switch back (by using the same command again).
It's not like other editors where columnar selections are enabled only while certain keys are down.
In vim column visual mode is Ctrl + v. If that is what you meant?
SublimeText 2, 3, and 4
Using the Mouse
Different mouse buttons are used on each platform:
OS X
Left Mouse Button + Option
OR: Middle Mouse Button
Add to selection: Command
Subtract from selection: Command+Shift
Windows
Right Mouse Button + Shift
OR: Middle Mouse Button
Add to selection: Ctrl
Subtract from selection: Alt
Linux
Right Mouse Button + Shift
Add to selection: Ctrl
Subtract from selection: Alt
Using the Keyboard
OS X
ctrl + shift + ↑
ctrl + shift + ↓
Windows
ctrl + alt + ↑
ctrl + alt + ↓
Linux
ctrl + alt + ↑
ctrl + alt + ↓
Source: SublimeText2 Documentation
You didn't explicitly state emacs, but since you've highlighted lots of editors...
In emacs, you can use rectangles for this, where a column is a rectangle of width 1.
To create a rectangle, mark the top-left and bottom-right of the rectangle (where the bottom-right mark is one to the right of the further right point included in the rectangle. You can then manipulate via:
C-x r k
Kill the text of the region-rectangle, saving its contents as the "last killed rectangle" (kill-rectangle).
C-x r d
Delete the text of the region-rectangle (delete-rectangle).
C-x r y
Yank the last killed rectangle with its upper left corner at point (yank-rectangle).
C-x r o
Insert blank space to fill the space of the region-rectangle (open-rectangle). This pushes the previous contents of the region-rectangle rightward.
M-x clear-rectangle
Clear the region-rectangle by replacing its contents with spaces.
M-x delete-whitespace-rectangle
Delete whitespace in each of the lines on the specified rectangle, starting from the left edge column of the rectangle.
C-x r t string RET
Replace rectangle contents with string on each line. (string-rectangle).
M-x string-insert-rectangle RET string RET
Insert string on each line of the rectangle.
In IntelliJ IDEA, you can switch the selection mode with Alt + Shift + Insert combination. You can also column select by keeping the middle mouse button (i.e. the scroll wheel button) pressed and dragging.
on Kate
Ctrl + Shift + B also allows you to add more columns by simply clicking anywhere and paste it.
I used this when saving text files I copied from Google Translate as a side-by-side view.
This feature is not available in older versions of Netbeans (up to 7.1) and the plugin is not supported anymore.
A plugin is now available for NetBeans 6.9.
In TextMate with the mouse: start a selection and keep alt pressed while you move the cursor.
Without the mouse: first select normally using ⇧ and arrows then hit alt and move the cursor.
in Notepad++ , you can select a particular column holding ctrl + alt + shift and then left click mouse button and drag to select.
In TextPad:
With the mouse, Left-Click + Alt + Drag. Note that if you first use Alt, and then Click-and-drag, it does not work (at least for me). Ctrl+Alt instead of Alt also Works.
For pure keyboard, no mouse, enable Block Select Mode with Ctrl+Q, B.
Or use the sequence Alt, C, B, to do it via the Configure menu.
Warning 1: if Word Wrap is enabled, then Block Select Mode will not be available (which is somewhat logical). First disable Word Wrap. This was causing me some trouble, and this gave me the answer.
Warning 2: if you mean to insert text in every selected row by typing, you have to use Edit, Fill Block. Other editors let you type in directly.
In Ultra Edit and Crimson (or Emerald) Editor you can enable/disable the column mode with Alt + C
In textpad.
Go to left top of the page.
hold "shift key
Now use right arrow key to select column.
Now click "down arrow" key.
And the entire column will be selected.
jEdit:
With the keyboard: press Alt-\ (Opt-\ in Mac OS X) to toggle between rectangular and normal selection mode; then use Shift plus arrow keys to extend selection. You can switch back to regular selection mode with another Alt-\ (Opt-\ in Mac OS X), if desired.
With the mouse: Either use Alt-\ (Opt-\ in Mac OS X) as above to toggle rectangular selection mode, then drag as usual; or Ctrl-drag (Cmd-drag in Mac OS X). You can switch back to regular selection mode with another Alt-\ (Opt-\ in Mac OS X), if desired.
Actually, you can even make a non-rectangular selection the normal way and then hit Alt-\ (Opt-\ in Mac OS X) to convert it into a rectangular one.
In MCEdit toggle Shift+F3 (ie F13) or F9->Edit ->Mark columns.
P.S. In this case, MCEdit is an editor written for the Midnight Commander.
In Sublime3 (Windows):
Some users may get an inverted screen using the Ctrl+Alt+▲ in windows. To Solve this go to
Preferences->Key Bindings-User
And add these two lines at the end of the file just before closing brackets:
{ "keys": ["ctrl+alt+pageup"], "command": "select_lines", "args": {"forward": false} },
{ "keys": ["ctrl+alt+pagedown"], "command": "select_lines", "args": {"forward": true} }
Or use your own keys.
If you're using Nedit under Cygwin-X (or any platform for that matter), hold down the Ctrl key while selecting text with the left mouse.
Additionally, you can then drag the selected "box" around in an insert mode using the depressed left-mouse button or in overwrite mode by using Ctrl+left-mouse button.
With Nedit you can do several operations with selected column:
CTRL+LEFT-MOUSE -> Mark Rectangular Text-Area
MIDDLE-MOUSE pressed in area -> moving text area with pushing aside other text
CTRL+MIDDLE-MOUSE pressed in marked area -> moving text area with overriding aside text and deleting text from original position
CTRL+SHIFT+MIDDLE-MOUSE pressed in marked area -> copying text area with overriding aside text and keeping text from original position
In Flash Builder (v 4.5 and up), and Aptana Studio (at least v 2.0.5) there is a toolbar button to toggle block select. It is between the 'mark occurrences' and 'show whitespace characters' buttons. There is also a Alt + Shift + A shortcut. Not surprisingly, this is basically the same as for Eclipse, but I'm including here for completeness.
For any editor, you can use the below shortcuts. These shortcuts work for every text area also.
Shift + UpArrow/DownArrow - this will select text line by line
Ctrl + Shift + LeftArrow/RightArrow - this will select text word by word
Ctrl + BackSpace - this will delete text word by word