Get Shortcut Recorder working in Xcode 4 - xcode

Is there any way to have a Shortcut Recorder in Objective-C, where the user can choose the shortcut?
I tried DDHotKey, which worked for me, but with this library users can not choose the shortcut themselves.
Then I tried to implement the Shortcut Recorder, but there I can only work with Xcode 3 because of the ibplugin.
So is there any way to have something like this in Xcode 4 ? :
Mentioned Libraries:
DDHotKey: Here
Shortcut Recorder:Here

IBPlugins do not work in Xcode 4, as you've found out. (File a bug if you want them back) However, this does not prevent you from instantiating the control programmatically...

This is definitely possible--take a look at Jumpcut's source. You might have to change the build settings to use LLVM compiler 3.0 for it to build in Xcode 4, but it's a pretty good example Shortcut Recorder implementation.

There is Shortcut Recorder patch I wrote to use user defined runtime attribute on xcode 4.
You don't need to use ibplugin but just editing NSTextField and its cell.
See issue 58

Related

Is it possible to accept all "Fix-It" suggestions in Xcode 8 [duplicate]

After upgrading to Xcode 7, to support iOS 9, i have hundreds of fix-it errors and warnings. Is there a one push button to make Xcode run them all rather then individual going through them one by one?
There is actually a solution for this in Xcode 7.21's Editor menu.
This is the shortcut:
⌃+⌥+⌘+f
which is
ctrl+alt+cmd+f
1 This is the version I can confirm, might work in earlier versions as well.
XCode's "fix-it" isn't always reliable enough to make the changes that the code needs to run properly. Even if there was such a button, I wouldn't advise using it. The only thing I can think of to make it quicker to go through is to use: Navigate > Jump to Next Issue which would mean you wouldn't have to comb through the code to find all of the errors, Xcode would take you straight to them.
Fix All Issues button in Xcode 10.3
control - option - command - f
⌃ ⌥ ⌘ f

Xcode 8: custom description in suggestion

I'm trying to have custom description for my functions shown in the suggestions box which shows up as I type said function names, the same way it works for swift functions: e.g the UIActivityIndicatorView.startAnimating() description is shown both in the
QuickHelp menu AND in the completion box
in Xcode 7 I would just add a comment line with the /** */ tags prior to the function declaration and the ide would recognize it accordingly e.g.
but for some reason doing so with Xcode 8 only shows the custom description within the QuickHelp tab of the Utilities menu, and not in the suggestion box.
Is there any suggestion about how I may obtain the same behavior with this new version of Xcode? I would appreciate it a lot!
Hear i found some solution. You need to change User Header Search Path No to Yes under Build settings. And then restart your xcode.
This is working fine for me.
It is because of Indexing.... just go to your project name at the top of navigation and Clean (cmd+shift+k) then come again to the file where you wanna work type any word you will see suggestion popUp. that it..
Other way is that just quit your xcode and open it again and wait for a moment let xcode indexing the files then type any word you will see suggestion popUp. that it..

Vim key bindings in Xcode?

Is there any way to have Vim key bindings in Xcode?
If you still interested in Vim keybinding plugin for Xcode I made one. Here it is.
http://programming.jugglershu.net/softwares/xvim.html
This is currently developed for personal (my) use. So you may feel bad with some lack of implementation. Give me a feed back(feature request) then. I'll add some keybinds if I have enough time.
#pkamb's answer is correct, but slightly out of date. In the Xcode 13 GM, Apple tweaked how to enable Vim keybindings.
To improve access to the Vim Mode, Xcode replaced the Enable Vim key bindings preference with an Edit > Vim Mode menu item. (75491567)
The next best thing is JetBrains' excellent Objective-C IDE AppCode. They have a great Vim plugin called IdeaVIM that is actively maintained.
I use MacVim as editor instead xcode. For code completion i use vim plugin named clang_complete - awesome plugin.
Xcode 13 in 2021 has added native Vim key binding support:
Xcode > Preferences > Text Editing > Editing > Enable Vim key bindings
https://developer.apple.com/xcode/
Vim mode
Many common key combinations and editing modes familiar to Vim users are supported directly within the code editor, using the new bottom bar to show mode indicators.
I myself use and really appreciate Shu's XVim, but for completeness and in case you're still interested, just recently viemu has opened its beta for Xcode, you can check it out at
http://www.viemu.com/blog/2013/05/01/viemu-for-xcode-public-beta-available/
I haven't tried it yet, but there's also $20 ViCiOUS. Right now, I use Shu's XVim plugin (cf. his answer), and recommend it.
ViEmu is finally available for Xcode, check it out. It uses the same vim emulation engine that they are using for their Visual Studio plug-in, so all the polishing that has been added to the product since 2005 is there.
I'm not affiliated to them, but I tested ViEmu and if it was available for Xcode 5, I would have paid for a license.
Try Editor -> Vim Mode in Xcode =>13.
It supports most of the common key bindings but there are exceptions, which is understandable given it's a relatively new feature. Most notably for me is the lack of support for a .vimrc file so if you want that (or just want more features) you can still use https://github.com/XVimProject/XVim2. Judging by the current maintainer it might eventually be made redundant by Xcode's default vim support but it still works well for me.

Code Formatting In Xcode

Is there anyway to format the code in Xcode like you can do in Eclipse or Netbenas. I have not found any option in menu, is there any hot key for this or its simply not in Xcode?
In Xcode 4, it's been moved to Editor > Structure > Re-Indent command (and has a default shortcut of CTRL+I ).
Select some text and then: Edit->Format->Re-Indent
You can bind this to a hotkey in the preferences.
Well, first of all welcome to 2021. I know it's a very old question but still people like me visit this and for those people, I'm putting out multiple available solutions in one answer that worked for me after 2 hours of research and testing.
Re-Indent
As everyone else is suggesting, it's one of the default solution if you just want to re-indent the lines of code:
Goto: Editor -> Structure -> Re-Indent or use shortcut control + I
Using Xcode Extensions
There are 2 extensions I found and used which works charmingly for me.
1) SwiftFormat: mentioning the steps to install the xcode extension here from the readme.
Like the command-line tool, you can install the SwiftFormat for Xcode
extension application via Homebrew. Assuming you already have Homebrew
installed, type:
$ brew install --cask swiftformat-for-xcode
open the SwiftFormat for Xcode.app that you just installed. there you can change the rules of formatting.
After that, open the system preference -> extensions -> xcode source editor and mark the checkbox for SwiftFormat.
Restart the Xcode
Voila! You're good to go. you can use three options. format selected code, format entire file OR just lint file.
2) Swimat: (it is already mentioned in one of the answer here by #Guy Daher) steps to install from readme
Install via homebrew-cask
Homebrew latest version
brew install --cask swimat
Similar to above extension installation, open the Swimat.app if it does not open then try to sove it from system preferences -> security & privacy -> open swimat app
after opening, click on install in ./bin folder to make it work globally (not sure about this step but I just did it)
Restart Xcode
now you can goto editor -> swimat -> format
Bingo! You're good to go.
Additional uninvited help
You can simply set the keybinding to use any of this command. i.e. I've set the android studio default command to reformat the code as option + command + L
ps If anyone else found a better extension, please let me know in comment, I'll add it to the list.
Other than re-indentation (Edit > Format > Re-Indent), not really. However, Xcode does have support for scripts (the menu to the right of the Window menu), so you could conceivably write a script that formats your code how you like it.
Edit: here are some links that touch on this subject:
http://hackertoys.com/2008/09/18/adding-a-code-beautifier-script-to-xcode (dead link)
http://8020world.com/jcmendez/2006/11/geeky-stuff/software/adding-a-script-menu-to-xcode-to-reformat-code-using-astyle (dead link)
Here are the shortcuts, to format the code in Xcode
1.Format entire code (entire class/controller)
select the entire code and press ⌘+| on mac to format your code.
2.Format particular block of code
select the code and press
⌘+] for right move and ⌘+[ for left move
Note : as per #JavierGiovannini sugesstion you can do using Editor Menu option
3.Select code --> Go to Editor --> Structure --> Re-Indent
My personal favorite code formatter is Uncrustify.
It has many, many options, so I also suggest you download UniversalIndentGUI, a GUI to help set Uncrustify's behavior to your liking.
XCode 8 Extensions
Another option is to use an extension like Swimat. Does the job for me. However, the caveat is that it does not format on save due to the restrictive Xcode Extension APIs, but they're trying to find a workaround.
Not saying this is best approach, but for completeness, if you cut and then paste the code back in, Xcode will automatically format it for you.
In v.4 you can make some adjustments through xCode preferences...
Fix code indentation in Xcode
^-I (control - capital i)
: format the current line
⌘-A + ^-I
: format the whole code file
Try this solution: ⌘A [⌘K ⌘F]

How can I jump from one placeholder to the next in Xcode autocompletion?

When Xcode autocompletes an method for me, it gives me blue blocks for parameters. I always go into the first, but then I click into all next ones rather than fast going there by keyboard commands. I guess that there are some good ones to know.
The default is Command-/, but you can customize that in the key bindings section of XCode's settings window.
In Xcode 3.2 (Snow Leopard), you can also use the Tab key to navigate between parameters. Personally, I find this more intuitive than Command-/.

Resources