Basic arrow keys and page up/down usage in intellij on mac - macos

What are the equivalent keys for page up/ page down in intellij on os x? Option arrow up/down is not doing anything AFAICT.

Go to Preferences | Keymap and assign any hotkey you like to Move Up/Down and Scroll:

Fn + Up/Down Arrow key do Page up and Page down respectively in IntelliJ running on OS X.
This is one of the standard ways of doing Page Up/Page Down in Mac apart from Option Up and Down arrow key that you mentioned.

It was annoying for me to find out which keys to get the cursor or caret up or down quickly or may be to the end or beginning of current line till I figured out the following shortcuts that might help:
Fn+Left arrow or Ctrl+A move the cursor to the end of current line.
Fn+Right arrow or Ctrl+E move the cursor to the beginning of current line.
Fn+Up arrow or Fn+Cmd+Left move the cursor to the beginning of the file.
Fn+Down arrow or Fn+Cmd+Right move the cursor to the end of the file.

Related

Is there any way of using normal keyboard text selection with a terminal on MacOS?

For the last ~10 years I've been used to manipulating text with the alt/⇧/⌘ keys. For instance, alt+← to jump back a word instead, alt+⇧+← to select that word, ⌘+→ to jump to the end of line, etc.
I understand that terminals have different conventions and historically came first, but I'm used to these shortcuts, they work great and work everywhere else. Is there any way of getting the same controls for selecting and manipulating text in the terminal?
I have seen the following questions:
How to move the cursor word by word in the OS X Terminal
How do I clear/delete the current line in terminal?
But they only address moving the cursor, and not selection.
Depending on the macOS version - your default shell may be zsh.
Shortcuts options are ctrl + a/e to move to beginning/end of line and esc + W/B to move one word backward/forward
Other popular alternatives are -
a. bash - with the shortcuts listed in the answer by #Hossein Amiri
b. iterm2 - From - https://coderwall.com/p/a8uxma/zsh-iterm2-osx-shortcuts
Put this in your .zshrc
bindkey "[D" backward-word
bindkey "[C" forward-word
bindkey "^[a" beginning-of-line
bindkey "^[e" end-of-line
And set iterm preferences.
Moving the cursor:
Ctrl+A Go to the beginning of the line (Home)
Ctrl+E Go to the End of the line (End)
Hold the Option key option and click on the current line = Jump Backwards
Ctrl+P Previous command (Up arrow)
Ctrl+N Next command (Down arrow)
Hold the Option key option and click on a previous line = Jump upwards
Ctrl+F Forward one character
Ctrl+B Backward one character
Alt+B Back (left) one word or use Option+→
Alt+F Forward (right) one word or use Option+←
Ctrl+xx Toggle between the start of line and current cursor position
More information : https://ss64.com/osx/syntax-bashkeyboard.html
You can't, I've beed looking for long time. This is why people use iTerm they have more flexibility with keyboard only.
https://iterm2.com/features.html
Copy Mode
Use the keyboard to make and modify selections.

When I use left/right arrow keys, it goes to beginning or end of line

I pressed some shortcut on the keyboard accidentally that now when I edit a text file, if I press left arrow key once, it goes to beginnnig of line, and when I press right arrow key it goes to the end of the line.
Do you know how to fix it?
Seems that your alt gr is stuck.
Try to use another keyboard or the on-screen keyboard to see if the problem occurs.

How to make a multiline cursor without using a mouse in Sublime text 3?

The only way to make a multiline cursor in Sublime text 3 is Ctrl+Shift+RC+Drag. Is there any way to do this without using a mouse?
Yes, there is. Using Shift↓ or Shift↑, select the lines you want multiple cursors on. Next, hit CtrlShiftL (CommandShiftL on macOS) to split the selection into lines. Finally, hitting ← will put the cursors at the beginning of the lines, while → will put them at the end.
Edit
There is also another, quicker way (thanks to minitech) - CtrlAlt↑/↓ will create multiple cursors without having to do selections first, and you can place the cursors anywhere in the line you wish. However, on Windows these key combos may be mapped to changing the screen orientation. To change this, hit CtrlAltF12 to open the Intel control panel, click Options, and either remap the screen orientation hotkeys, or click Off on the left side to disable all of them.
You can use Middle mouse button for this as well.
Click & Hold Middle mouse button and drag up and down
Standard key bindings not work for me(Ubuntu 16.4 and Win 10), but after redefining works good! To redefine default key bindings use (Preferences->Key Bindings)
{ "keys": ["alt+shift+down"], "command": "select_lines", "args":{"forward": true} } will add cursor below, { "keys": ["alt+shift+up"], "command": "select_lines", "args": {"forward": false} } will add cursor above.
MAC: ctrl ( ^ ) + Shift + up / down arrow
ctrlShiftup arrow
ctrlShiftdown arrow
What works for me on a window 10 Surface Pro is
Ctrl + Alt + up/down
Because Ctrl + Alt + up/down already works for me, there is no need to do another key binding. I have it set up the same way for VS Code as well: Ctrl + Alt + up/down.
Or you can also map it as Yaroslav says (which I voted up), which works as well.
In Ubuntu, the accepted answer works. Also, you can do:
Shift + Alt + Key up/down
It was much simpler for me than any other answers above: Just hold ctrl and click on your mouse placing it where you want to have the second or third cursor.

Move to beginning of text in Xcode

I know I can bind keys to "Move to beginning of line", but this ignores the indentation.
What I'm looking for is to move to the beginning of text on a line, so that:
CGRect example = CGRectMake(view.frame.origin.x,
view.frame.origin.y,|
pressing a key will move the cursor to the beginning of the "view" word in this example (char | is cursor).
It is extremely annoying that currently I have to press 3 commands to get to the beginning of the text when inside a code block (cmd <-, opt ->, opt <-).
There's no standard way to accomplish it in XCode, so I've written an XCode plugin implementing this feature:
https://github.com/insanehunter/XCode4_beginning_of_line
Under the hood it overrides XCode's source editor keyboard action dispatch method and implements beginning/ending of line jumps in enhanced way.
Hope it helped.
As of 7.3 (not sure when it was added), Xcode seems to have turned this on by default. Cmd-left in the Key Bindings preference pane is now bound to "Move to Beginning of Text."
Personally, this drives me bonkers, so I've changed it back to "Move to Beginning of Line." But for people who want this behavior, it's good to know that there's now a built-in way to get it.
If you've copied your Key Bindings Set, you may not be seeing the new behavior yet. If not, just search for "beginning" in the Key Bindings preferences and adjust them to your liking.
Use option + ← to jump across entire words.
(That means, hold the option while pressing the left arrow key)
Actually, there is a faster and simpler way to achieve this as Mac OS supports some Emacs (or Unix) keybindings quite well.
You can use Ctrl-a to jump to the beginning of a line. Which means, hold 'Ctrl' key and press 'a' on keyboard.
For your more information, it is also handy to use
Ctrl-e: jump to the end of a line
Ctrl-n: move to next line
Ctrl-p: move to previous line
What's more, these fast keys can be used in terminal and text fields such as this StackOverflow answer editor on Mac OS, too.
Hope that helps.
I'm using Xcode 7.2 and was able to make my own macro to automate those 3 commands you mentioned above (cmd <-, opt ->, opt <-). You can edit the IDETextKeyBindingSet.plist file which defines all the key-bindings to add your own.
Mine was located at /Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Resources/IDETextKeyBindingSet.plist
Add the following to create your own macro
<key>Custom Keys</key>
<dict>
<key>Move to non-whitespace beginning of line</key>
<string>moveToBeginningOfLine:, moveSubWordForward:, moveSubWordBackward:</string>
</dict>
Relaunch xcode and in your Preferences > Key Bindings tab, search for your custom macro and set it to cmd <-. Now it will run those 3 commands and effectively moves your cursor to the beginning of the text in the line.
I don't have an exact solution, just one slight improvement for Xcode 4. You could set up a keyboard mapping for "Move Expression Left" (Xcode prefs > Key Bindings), which is a little more than Opt ←:
s = [NSString string] |
if | is the cursor position, pressing a "Move Expression Left" keystroke will bring it to the beginning of the expression on the left of it, so in that case before "[NSString". Opt ← will only move before "string".
(Side note: I do see an action command called "Move to Left end of line" and another one called "Move to beginning of line." To my experience, these do exactly the same behavior in Xcode 4.0.2: this looks to me like a bug, unless I'm missing something.)
It seems that the simplest way, as already mentioned is
1) Go to the beginning of the line (Cmd + left arrow key)
2) Jump to right word (Alt + right arrow key)
3) Jump to left word (Alt + left arrow key)
Unfortunately (Alt + left arrow key) and (Alt + right arrow key) ignores comments, brackets, etc and therefore the method above will not always work. If this is not a problem, then there is also one solution for the BetterTouchTool users. One can create a sequence of actions (commands) that will be called one after another and assign it to Home button. To do so, open the preferences, go to Keyboard tab, Add new shortcut and assign Home button to the (Cmd + left arrow key). Then click Assign additional actions twice, first one for the (Alt + right arrow key) and the second one for the (Alt + left arrow) key commands.
Hopefully this helps.
Tested on XCode 10:
Step1: Open the file located in the next path by a text editor
/Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Versions/A/Resources/IDETextKeyBindingSet.plist
Add the next elements to the end of the file:
<key>Sublime Commands</key>
<dict>
<key>Cut Current Line</key>
<string>selectLine:, cut:</string>
<key>Copy Current Line</key>
<string>selectLine:, copy:</string>
<key>Duplicate Current Line</key>
<string>selectLine:, copy:, moveToBeginningOfLine:, paste:, moveToEndOfLine:</string>
<key>Delete Current Line</key>
<string>selectLine:, deleteToEndOfLine:, moveToEndOfLine:</string>
<key>Move To First Char In Line</key>
<string>moveToBeginningOfLine:, moveSubWordForward:, moveSubWordBackward:</string>
</dict>
The previous last key 'Move To First Char In Line' will do your request, but I mentioned also other keys.
Now save the file.
Step2: Close XCode and reopen it.
Step3: Navigate to keybinding in xcode preferences then assign your shortcut.
XCode -> Preferences -> Key Bindings
Then search for 'Move To First Char In Line' and assign your shortcut.
In this Xcode extension, Linex, the feature Line Beginning can move to the first non-whitespace character in a line, and also toggle between that and the real beginning.
Works for Xcode 9, perhaps Xcode 8.

Change how home and end keys work in XCode

When I press the End key I expect it to bring me to the end of the line. Likewise when I press the Home key I expect it to bring me to the beginning of the line. In Xcode though, these navigate to the top and bottom of the page. How can this be changed?
Xcode > Preferences > Key Bindings > Text Key Bindings
Then find these two:
Move to beginning of line
Move to end of line
Assign Home and End to these respectively.
If you're doing this, don't forget to update Move to Beginning/End of Line Extending Selection, too and assign ⇧ ShiftHome and ⇧ ShiftEnd, respectively. This will continue the desired behaviour when you have ⇧ Shift pressed.
You will also have to remove the conflicts that appear.
FYI: ⌘ Cmd+→ and ⌘ Cmd+← are the way things are normally done on a Mac. If you are coming from Windows I would try to adjust to this. If you want to jump between words, you can use Alt+→, Alt+←.
Go to Xcode -> Preferences... -> Key Bindings, tab Text Key Bindings, and change them to whatever you want.
If you're after 'smart home', where pressing the Home key takes you to the start of the text on that line, and a second-press takes you to the start of the line... then you'll be wanting this:
https://github.com/insanehunter/XCode4_beginning_of_line

Resources