Xcode Go to next line hotkey (like intellij's shift enter) - xcode

I've been programming on a Windows machine for quite a while using Jet Brains IDEs (IntelliJ, Android Studio, WebStorm). I just bought a Macbook and I'm trying to use Xcode to develop on it. My most used hotkey by far is Shift-Enter to start a new line underneath the line where the cursor is. Without the shortcut, I have to CMD-rightarrow, add a semicolon if needed, and then press enter. Is there a shortcut like this in Xcode? If not and thousands of developers use xcode, am I just lazy and have a bad habit? Is there a easier way to do this?
Thanks a bunch

Such a hotkey is not available in Xcode. Since you are new to OS X, I should tell you that emacs shortcuts are available in Xcode and throughout the OS. So, for example, in your case the quickest way to get what you want would be Ctrl-E (move to end of line) followed by enter. You can switch your caps lock and control key easily in System Preferences to make this easier. Check this link for a full list of these bindings. I have found them supremely useful.

Try this:
Copy '/Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Resources/IDETextKeyBindingSet.plist' to desktop.
Add following contents into the .plist file:
<key>My Custom Actions</key>
<dict>
<key>Insert Line Below</key>
<string>moveToEndOfLine:, insertNewline:</string>
<key>Insert Line Above</key>
<string>moveUp:, moveToEndOfLine:, insertNewline:</string>
</dict>
Copy back the modified file.
sudo cp ~/Desktop/IDETextKeyBindingSet.plist /Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Resources/IDETextKeyBindingSet.plist
Restart the Xcode and perform key binding.

Related

Anyway to use someone else's neovim/vim keybindings config on VS Code

I have just migrated from Atom, there, I was using Vim-plus but now on VS Code I have switched to neovim, but the problem is, there are many conflicting keybindings.
I tried to change them manually (something like, to close editor, 'Ctrl+c+t', which I mapped to close editor's tab, similarly others).
But I feel that's very unproductive and also can cause strain in my fingers. So any suggestions, or keybindings config of anyone which I can use alongside the NeoVim to increase my productivity. Or any other suggestions how to properly configure my VS Code?
NOTE: I know about the existence of an Atom Keybindings Extension which I honestly don't care, as I was mainly using Vim keybindings there and never bother to learn atom specific keybindings.
If you want VS Code to act like VIM, which is super unique in its interface and keybindings, there is an extension called:
VSCode Vim
VSCode Vim's Marketplace ID: vscodevim.vim
Personally I can't stand the VIM keybindings, so I don't know how great the extension is, but I know people who use it. It has 2.4 million downloads and counting. I also know, because of my buddy, that its not perfect, but it's close.
As with any other extension, don't just install it and hope it's what you wanted "out-of-the-box", this theme is customizable, and requires you to configure it. Make sure you read the README.md, and set it up so you know that it is best suited for your expectations.
If you are already using the VSCode VIM Extension, and you find that you are having conflicting issues using the keybindings associated with it. You can troubleshoot them using the keybindings troubleshooting tool by selecting it from the quick input menu.
Press F1
Type the phrase: "Keyboard Shortcut Troubleshooting"
Select the option "DEVELOPER: Toggle Keyboard Shortcut Troubleshooting Tool"
The tool should open in the console below. The menu might look like gibberish at first, however; the output of the newly opened console should make more sense once you use a familiar keybinding. Make sure that the console window is scrolled to the bottom and opened wide enough so your able to read everything logged. The tool will tell you what is attached to the keybinding your using, so you can see any conflicts that are happening, and what the key is set to do by you, by extensions, and by default.
Make changes to your keybindings.json file as necessary.

How can I use iterm as default terminal on macOS?

I want to make iTerm2 as my default terminal on macOS,
I open iTerm2 and hit to make iTerm default Term
But it's not working!
And I go to default terminal preferences
But after open it I see this
(Open iTerm Build version 3.3.7)
Menu: iTerm2 > Make iTerm2 Default Term
It sounds like you need to rebuild your macOS' LaunchServices.
To do this, download OnyX and choose the version based on your current macOS version.
The option that you need is in the red box, and I'd suggest that you UNCHECK anything that you don't need or don't know; otherwise, you might end up with deleting data that you might need:
After that, you can try again with the built-in Make iTerm2 Default Term option in iTerm2 (if this option is greyed out for you, click option + the iTerm menu button to re-enable it again).
There are ways to do this through the command line without downloading third-party apps, but I trust OnyX enough to hand it the job.
However, if you decide to do it from the command line, make sure you type the command that corresponds to your current macOS version. More on that here.
Hope this helps :)
Use this location instead:
/Applications/iTerm.app/Contents/MacOS/iTerm2
but note that it will not solve your issue completely. Termianal will start anyway, but this time, it will run iTerm2 - as you instructed it to do.
One thing you can do is find the file that opens a terminal (in my case it was metro opening in a React Native app). Find the file in your finder, right click on it, choose get info, then expand the Open With tab. There you should find a dropdown menu on what to open those kind of files with. The default is terminal, but choose iTerm2 and click on change all.
For example, in my situation I had to find launchPackager.command file under node_modules/react-native/scripts/. Do the above with that file and it will make iTerm your default terminal after clicking change all.
From where do you want to open the terminal? I was facing the same problem as you when I wanted to open the external terminal from Visual Studio Code.
I solved it by going to Code > Preferences > Settings. Look for terminal in the search bar and setting /Applications/iTerm.app in Terminal > External for your operating system.

How do you add the cmd+backspace functionality on VSCode's Integrated Terminal to the Mac's

I've been dying to get this working on the default terminal on the mac, this feature is really useful when you write something wrong, and can just cmd + backspace to delete all the lines.
I googled online several times but I couldn't find anything related to this.
Well, the functionality is already there: ⌃+U will delete everything left to your cursor to the beginning of the line. You cannot, however, change this keyboard shortcut.
You can change application-specific keybindings by installing additional tools like, for example, Karabiner.
Alternatively, you can install iTerm2 as a Terminal replacement. That will allow you to enable this - and many other text editing keybindings - with one click in the settings.

PyCharm Delete Whole Line with cursor moving up

A very specific question, for use on Mac OS:
In VSCode, it's very easy to simply hold ⌘ Command and hit ⌫ Delete for however many whole lines I want to delete and the cursor will keep deleting upward.
However, running PyCharm, it's not available, and I'm having trouble mapping the exact feature.
Going to Preferences -> Keymap -> Editor Actions allows you to map "Delete Line," but using this will just delete downward. Is there a way to mimic the feature of being able to hold down ⌘ Command and just ⌫ Delete lines upward?
To find the shortcut on your setup open up the "Search Everywhere" box with one of the following:
Double ⇧ Shift
⌘ Command+P
⌘ Command+⇧ Shift+P (opens directly on Actions tab)
Then go to the "Actions" tab and search for the shortcut you are looking for, in this case "Delete Line":
Then it shows the shortcut (in my case ⌃ Control+⇧ Shift+K)
In the Jetbrains documentation it does not show up anything to remove a whole line (or at least, I am missing it out).
I know it is not the same, as what you do in VScode is much faster, but you can always shift+home(gets you the whole line if you are at the end of the line)+delete.
I do not think there is another way from jetbrain's doc.
EDIT:
I think I found it by cassualty: R shift+ del.
EDIT2: Just found out that R shift+ del actually cuts (like ctrl+ x).
I know that the post is a bit old but I think it worths to post the 'actual' solution to this issue.
Basically, when you try to delete line in PyCharm for Mac, the IDE is deleting the caret (according to the documentation). Although, IdeaVim plug-in is making your life even more difficult if you don't know how to use it. I don't have experience either.
Disabling IdeaVim plug-in will solve the problem. The IDE will ask you to restart it in order to apply the new settings. After that you can select whatever you want in your code and just hit the backspace button on your Mac to delete. And, yes, all these issues with the key shortcuts are caused by the IdeaVim.
The IdeaVim extension can be disabled from the PyCharm Preferences.

Xcode 6 Copy Line/Cut Line keybindings

I recently have started development for Swift with XCode 6. I've used Sublime Text 3 for the last couple years, and more recently have fallen in love GitHub's Atom Editor. My biggest frustration so far with XCode is the lack of a copy/cut line tool.
In the text editors I've used copy/cut commands will copy/cut the whole line if no selection is made.
So far the only alternative I have found is the following:
Ctrl + A - Move cursor to the beginning of a line
Shift + ↓ - Select the line
Ctrl + C - Copy Selection
This works, however I'm wondering if anyone has figured out an elegant way to wrap these up into one powerful copy/cut line tool
On a side note, I am also missing the move line up/down shortcuts which are also very useful.
Note: a solution described in this answer no longer works in Xcode 6.
From the terminal cd into / to get to the MacHD and then go into applications,otherwise you won't get all of the applications in the list.
open the
file /Applications/XcodeBeta.app/Contents/Frameworks/IDEKit.framework/Resources/IDETextKeyBindingSet.plist with sudo privileges (be sure to use the correct app-directory for the version of Xcode you are using---for Xcode 6.3 beta mine was Xcode-Beta.app). You can use open . in the terminal when you get to the desired location in finder
Now add the following section:
<key>My Custom Commands</key>
<dict>
<key>Cut Current Line</key>
<string>selectLine:, cut:</string>
<key>Copy Current Line</key>
<string>selectLine:, copy:</string>
</dict>
Restart XCode and in the keybindings section you should be able search for cut current line and copy current line and set custom keybindings to them. The format of creating commands is actually pretty simple and intuitive.
On a side note, I am also missing the move line up/down shortcuts
which are also very useful.
Preferences->Key Bindings
Move line up: option+command+[
Move line down: option+command+]

Resources