Xcode 4.2.1 Code Folding - xcode

I've got a really frustrating issue in Xcode 4.2.1 on OS X Lion, where the code folding doesn't seem to work, or at least hardly every with no obvious reason.
The default keyboard shortcuts are supposed to be:
Fold Methods/Functions ⇧⌘⌥⌘← shift+option+command+left
Unfold Methods/Functions ⇧⌘⌥⌘→ shift+option+command+right
.. but I just get the Homer ('Doh'), error sound all the times I try it.
I always make sure I have the correct pane selected (before anyone asks ;o), and have also tried the following, with no luck:
- With & without Assistant editor enabled
- In a total separate editing window
- By selecting 'Code Folding >> Fold Methods & functions' from the Editor menu
- Changing the keyboard shortcut (Even tho no conflict was showing)
The only clue I have, and I'm not sure if it's related, is that whenever I press the 'option' key in the editing view my cursor changes to a + (or crosshair) - It only does this in the editing views of Xcode, however I don't think this is the issue as if I change the shortcut to not use the 'option' key, it still doesn't work.
Anyone got any ideas, as it's driving me barmy & my searches haven't come up with anything??

OK, I finally resolved to totally remove Xcode, clear out prefs and then re-install.
This seems to have fixed the issue (So far at least)

I've found that Xcode 3 won't fold unless syntax highlighting is turned on. I don't like syntax highlighting, so for lack of a better alternative I use 'View->Syntax Coloring->Simple Coloring', which only highlights comments and numbers.

Related

Xcode 11 Won't Open New Editor Pane

So Xcode 11 changed the way editor panes are added and removed. Ok, fine, I got used to it soon enough. But a few days after using the Xcode 11 GM build, the option to add an editor is suddenly disabled.
Could be a bug, could be a 'feature' that I've inadvertently triggered. Neither the menu, toolbar button nor shortcut (^⌘T) will give me another editor (though they all did with the same build yesterday).
Any ideas?
(Note: this screenshot has the Navigator pane hidden for simplicity. Its presence/absence doesn't help with this issue)
Ok, this is embarrassing. I was in a 'focus' mode and could only add editors after I had 'hidden focus'. There are a few ways to do this:
View > Editor > Hide Focus
Tap the 'arrows pointing at each other' icon in the top left of the editor toolbar
^⇧⌘↩︎
ps. I was seriously tempted to delete my question when I realised how dumb I'd been, but I'm leaving it up as I suspect this UI quirk might also trip up others (let me know if it does, it'll help me feel like less of a fool)

How do I build an Xcode shortcut for frequently used code snippet? [duplicate]

When I follow all the instructions (including apple's video) to drag text to create a code snippet in xcode, I get a different system behavior: all I see is the selection ibeam... I can't drag. It just ends up selecting text again. Am i missing some obvious Apple-ism?
Thanks
Yes, I ran into the same problem, and Apple-ism seems to be a good term for this issue :)
It works this way:
Select (or highlight) the code your want to turn into a snippet
EDIT: Click and hold (do not drag!) on any part of the selected text for a short moment (like 2 seconds, sometimes 8 seconds)
EDIT: The mouse cursor will change icon (not on El Capitan).
Now you can drag the code over the snippets library, where a green + icon will appear. EDIT: On El Capitan the green icon does not appear, but the frame of the code snippets window will become thinner.
This happened to me as well. The given solution didn't work but still needed to create snippets.
This is a workaround although not the best option, it works.
From Xcode, select the snippet window, and leave it selected.
Open a text editor app.
From Xcode, select and copy the code you want to use to create your snippet.
Paste it into your text editor and then select all of it.
Now drag&drop normally from the text editor into the snippets window in Xcode.
As said, not the best option but it works.
(Note for Xcode 8.1) Sometimes selecting the text and maintain the mouse button clicked for 3..8 seconds the cursor turns into an arrow and it's possible to D&D. Too bad it only works sometimes...
On High Sierra 10.13.3 and XCode 9 I faced the same problem. The decision that works for me is selecting code on a blank space before the first symbol and then dragging it to the snippets library.
Important: you need to drag only from the blank space (look at the screenshot below). Otherwise you will reselect your code again.
The cursor changes only when you start dragging, so don't be confused and don't wait until it changes.
I've run into this problem with Xcode 7.2 on Mac OS X 10.11.2 (El Capitan). Click and hold on the selection and the cursor never changes from the I-beam to the arrow for dragging.
Although MLBDG's answer is a usable workaround, I found that quitting and restarting Xcode fixed the problem. This might not work for everyone, but it's worth a try if you're having difficulty.
just highlight your text
copy in filter text field that u can see on your bottom of snippet library
paste the text
now select the text and drag from there to snippet library
The answer is really !undisobvious. You need to select a chunk of text. Then click on actual text characters, but without moving the mouse. Only then will the gods of XCode bequeath unto you a draggable snippet of code to do with as you please. Should you dare to miss the text and click in empty but selected space, the demons of XCode will strike down your selection and make you start from scratch. The unfortunate will not even realise this feature actually exists.
Hold option to duplicate it. For instance to make a duplicate case statement without destroying your copy buffer, then replace the case you cleverly have ready to paste during your search.
As a UI designer it is not obvious to me why this has such an unreliable twitchy implementation.

Lost syntax highlighting in Textmate

Using Textmate, I have somehow managed to turn off syntax highlighting for php files. After much trial and error, I have worked out that this happened when I accidentally hit SHIFT-CTRL-OPTION-D (I'm on a Mac, btw). I've looked everywhere and tried many key combinations, but I cannot figure out how to re-enable the nice syntax highlighting. Please help me, Textmate gurus, you're my only hope!
The key sequence SHIFT-CTRL-OPTION-D corresponds to an option in the language menu down at the bottom left of the Textmate window. The language menu tells Textmate what language to consider the file so it can determine the proper syntax highlighting. The key sequence I hit caused Textmate to highlight my text as though it were a diff window. Switched it back to PHP and it works great now.
I don't have enough rep to add a comment, so I'll expand on the accepted answer here.
SHIFT+CONTROL+OPTION+<LETTER> will display a menu showing all grammars beginning with <LETTER>. So if you want PHP back, just hit SHIFT+CONTRL+OPTION+P, and then a list of languages beginning with 'P' will pop up. You can choose one from the list by pressing the corresponding number (on my computer, it's 2).

Does intellisense work in XCode?

I am a noob to XCode, so forgive what could be a dumb question. It seems like XCode kind of does intellisense (or code completion). When I type in:
[self setT
it suggests the setTitle because its the first matching one. Is there a way to make it work a bit more like Visual Studio where you get a dropdown of available methods/properties/etc...?
You can press "Esc" for a list of suggestions.
You can also turn on automatic suggestions in the preferences.
Fn + Esc will bring up a list of them, and you may have to enable it in preferences
It's not always context sensitive (or gets confused about context easily)
But it still works

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