Is there a way to create a hotkey to print a specific string in xcode? - xcode

Is there a way to create a hotkey to print a specific string in xcode?
For example if "H" is my hotkey, every time I click "H" it should paste "Hello" on my editor.
This would help when inserting standard fixed comments when coding.
Thanks in advance.

It's easy to do it with Xcode code snippets. First you need to create a content (your comment or code or both). Select your content by dragging mouse on it. Release your mouse then click again on the selected part of text for a second. While holding, your mouse cursor symbol will change to the pointer symbol - drag this content to code snippets library. Xcode will create new code snipped for you. It will be placed at the bottom of all snippets in snippets library with the name "My Code Snippet". Double click it. Then press "Edit" button. Name it in the field "Title". Write summary you want. Choose platform "All" or "iOS" or "OS X". Select add completion shortcut for example "hello" for "//hello comment". Once you've done with all changes press "Done" button. Every time you will write "hello" Xcode will show a pop up with snippet title you have created. Select it and press "Enter" key and your comment will be placed right there where you wrote "hello".
Animated gif shows how you can do this:

Related

Shortcut to move cursor to input text in Find Navigator-Xcode 6

What is the shortcut to move cursor to input textfield in Find Navigator in Xcode?
For example, there is a image and I want to find where the image is used in Xcode project. I copy the image's name in Project Navigator (Cmd+C), then move to the Find Navigator (Cmd+3). I want to know shortcut to move cursor to input text field instead click mouse to the text field.
Does anyone know what the shortcut is? Thank you.
After you press CMD+3, try SHIFT+TAB once or press TAB three times. Let me know if it works

"Tab" button delete code not move in Xcode

There any solution to solve this problem: sometimes I need change indent in code and in some another IDE you can select code and press "Tab" button. But in Xcode this key delete the code and move by indent. How I can change indent in some selected block of code?
Indentation you can make with combination of Command and [ (to the left) and ] (to the right) buttons respectively.

Replace text only in one part of a page in Visual Studio 2012

I want to replace a word only in one particular paragraph of a .cs page. I select the paragraph, but when I go to find and replace the text get deselected and the word is highlighted everywhere on the page and not only in that paragraph. Is there a way to achieve what I want in VS or should I just copy the text in another page/text editor and do the replacing there?
Thank you.
Select the text, press Ctrl+Shift+H, make sure "Selection" is selected in the "Look in" window. While the Find and Replace window is open you should be able to select whatever you want from your code window and the original selection should not change. Copy what you want to replace and paste to Find what window. Set "Replace With" window with the text to replace and click the "Replace All" button.

How to add "Last Position" button to my tool bar in VB6 IDE

I did this before but can't remember how the heck I did it.
I want to have a button on my vb6 IDE toolbar that takes me back to the previous place I was in the code (in my "history) -- an incredibly useful feature.
I have it in my properties (right-click) menu but don't see it in the other menus from which I could drag it to the Toolbar.
Any ideas?
This should do it:
In the IDE right click an empty spot on your
menu and select Customize...
Select the Command tab in the Customize dialog
Select View from the Categories list.
On the Commands list you should see
an item called Last Position.
Drag this item to a toolbar.
#Jay's answer is right on. There are also handy shortcut keys for this feature and the related Definition feature:
Last Position: Ctl + Shift + F2
Definition: Shift + F2
In one of the toolbars in the sample applications?

Can I add my own code snippets to xcode 4?

It'd be really handy to have collection KVC accessor snippets in xcode, as they're a pain to do by hand. Has anyone who's been using 4 for a while worked out how to add new ones?
(...we're allowed to talk about it now, right?)
Yes, it's quite easy - you just highlight text you want to use as a snippet and drag it into the snippets area (dragging selected text can be difficult, I find it works better if you drag from the left edge of the editor). It brings up a dialog box asking you to name it.
Also, you can have custom parameters in snippets - if you put the text <#paramName#> anywhere in the code you are dragging, when you use the snippet it will come up as a replaceable parameter that you can tab between just like in the official Snippets.
Also make sure to set a completion prefix, which makes it shorter to activate the snippet as you are typing. The nice thing about using Snippets over other solutions like global system text expanders, is that snippets can also be limited to being valid in a certain area of code - so for example a snippet that filled out a string formatting line can be marked as valid only within a block, not outside a method. That way the completion prefix only hits in areas where it's valid to use.
You can edit a snippet by clicking once on it, a box will come up with the snippet text and some other snippet settings you can edit.
A tip to help you drag the code every time, select text then click + hold (do not move mouse) until mouse pointer changes from "I" to pointer. You'll then be able to drag the selected text to the Code Snippet Library.
Drag the highlighted code to the Snippet library. (It can be stubborn and not want to drag. Holding the mouse button down for a moment before dragging seems to help.)
You can use Snippets to manage code snippets in Xcode. Check out this demo http://www.youtube.com/watch?v=il4kE4diy0k
Simply select the code, the press ALT key and drag it into the code snippets library and rename it there, Make sure to press the ALT key, other than this you won'n be able to drag it.

Resources