Xcode Rename Variables Across Multiple Files - xcode

Normally in Xcode, when you hover over a variable name, Xcode will underline it and place a triangle to the right of the variable name that you can click on and select "edit all in scope." This allows you to rename all instances of a variable at once. However, this doesn't seem to work if you are working across multiple files, for example, when writing a program that has a header file with the class specifications, the cpp with the implementation, and maybe a main that tests the class. This method of changing all variable names doesn't work in this situation, that I know of. It allows you to change all variable names of one page, but it doesn't change the same variable elsewhere. Is there a way around this? I tried the refactoring menu, but I guess refactoring isn't supported in non-Apple languages, like C++. I hoping that there is a better option for multi-page variable renaming, other than using search and replace. Any help would be greatly appreciated.

Related

Sublime Goto anything using dot notation

When using Sublime 3, I'd like to search for a file using the "Dot notation", i.e. file names using . as the separator.
E.g. if I press CtrlP (Goto Anything) and type frontend/banks/index it will find, for example, frontend/banks/index.php
But I want to type frontend.banks.index, which are used in Laravel's views.
How do I achieve this? Is this a sublime setting or a package?
This doesn't directly answer the question, and it makes an assumption for Sublime users: that you want/need this functionality to easily find view files in Laravel code, probably blade templates, based on the the de facto dot notation for view paths, eg.
return view('frontend.banks.index');
PhpStorm users will know about (and rub your nose in) the functionality it offers when hovering over the view path. It will give you a pop-up with a list of files whose path matches the pattern.
The workaround I use for Sublime though is to use slash notation instead of dot notation, eg.
return view('frontend/banks/index');
It's not well known that this works and I haven't seen it documented but it functions identically.
The downside to this is it breaks PhpStorm's above mentioned functionality. I recently got into a debate with a coworker over it. Since PhpStorm is more prevalent in the Laravel world, he won out. For my personal/solo projects, I use this syntax, and newcomers to the project using PhpStorm can suck it.
So, to wrap up my longwinded rant, here's my workflow to find a Laravel view in Sublime Text:
Prerequisite: write all view paths using slashes instead of dots in my codebase.
Highlight the view path
Copy to clipboard
cmd+p (or super+p, ctrl+p, based on your OS) to open the fuzzy file finder, whatever it's called
Paste
Open the desired file (if multiples match, otherwise just hit enter)
It's decent enough and doesn't require a mouse, like half of PhpStorm's best functionality. 😜
PhpStorm functionality mentioned above:
(Edit: apparently this PhpStorm tooltip is just for auto-complete, which is nice, but to actually open the file, F12 should work with the cursor on the path string. Also, according to my coworker, F12 also works with slash notation, so that's very nice for PhpStorm users obviously. All said an done, I think slashes should be used for views in Laravel projects.)

How do I add features to a syntax definition in Sublime Text without editing it?

For example, I would like to highlight #param, #type, and #return (i.e. epytext declarations) in my Python docstrings. I have figured out how to do this by simply editing Python/Python.tmLanguage; however, I would really like to put this in its own file, for a couple of reasons:
I don't always want to apply this highlighting. It's only for projects that use epydoc as their documentation tool; in other projects, I would want to highlight reStructuredText instead.
When Sublime Text updates, I'd like to have my own syntax as an overlay onto the included features. there are several features of Python that Sublime's author may choose to include in future versions and I don't want to have to manually figure out what I changed each time an update modifies the base Python syntax definition.
I keep my own editor configuration in version control, but I want that to be my own original stuff; I don't want to be burdened with having to carry copies (possibly proprietary? I don't know, it doesn't seem to have an independent license) of syntax definitions that come with Sublime.
Is there a way to put highlighting rules into a separate file, perhaps to only be applied to a particular scope?
Sounds to me like you want to create your own syntax file, inherit from the Python syntax file (source.python), and make your changes and customizations there. Sublime Text 2 uses the .tmLanguage format for syntax files, which is a bit complex, but fortunately most of the work has already been done for you, just by inheriting from source.python.
What you want to do is set up a regex pattern to match the substrings that you want to highlight, and give that pattern a name; something like punctuation.definition.comment.epydoc, to follow the convention set in Java/JavaDoc.tmLanguage. Then, check your color scheme file (ending in .tmTheme) and make sure there are settings for the scope that you've chosen -- or for one of its parents, since ST2 should use proper scoping rules for this sort of thing.
To use the syntax file you've created, stick it in Packages/User (so that ST2 doesn't overwrite it on upgrades), open a Python file in the editor, and then select your new syntax from the dropdown list in the bottom right corner of the window. If you've set up everything correctly, the epydoc strings should change to be whatever color you've set in your color scheme.
Good luck! And post a link somewhere when you've got a syntax file that works, so others can see and use it, as well!

Xcode comments autocompletion (appledoc style)

I find documentating my interfaces particularly painful because I need to type everything myself. So I figured that I must not be the only one like this and started to look for a way to reduce my pain but didn't find much.
My question is, is there a shortcut or a way to have Xcode autocomplete my comments? For example, I'd very much like if I type /** + [tab] that it autocompletes to:
/**
* [cursor here]
*
* (maybe some pre-populate a list of arguments for the method below)
*/
- (void)test:(NSString *)testString another:(NSString *)another;
Thanks!
Use Xcode's snippets feature. You can create a snippet with whatever text you want, and add items in the text to be filled in. To create a snippet, just select some text in an Xcode editor and drag it into the snippet library. You can set the completion shortcut, so something like m-comment could be your standard method comment:
Typing the first bit of m-comment then displays the entire shortcut (and any other completions), and accepting the completion adds a comment with the parameterized parts waiting to be filled in. As usual, you can tab from one to the next:
You indicate that a given part of the text is a field to be filled in by enclosing it in <# and #>, like: <#method name#>.
Of course, one of the strengths of Objective-C is that the method name generally tells you what the parameters are. Repeating that in a comment seems like unnecessary extra work. Xcode 3 had better support for scripts included scripts that would automatically generate HeaderDoc comments with parameters. They weren't widely used, though, probably because those kinds of comments weren't really useful.

How can I change the template CodeRush uses when it extracts a method?

When I extract a method in CodeRush, it has some default formatting. I'd like to change it. Specifically, when I choose the location of the extracted method, CodeRush smashes it in, directly above the method I put the location marker at.
So:
When I choose to drop the extracted method, like this:
It ends up looking like this:
What I want is for it to have some control over how the method looks, at the moment I want to add some blank lines between it and the next method. How can I do that?
Open the DevExpress -> Options dialog;
Go to the Editor | Code Formatting | Blank Lines option page;
Toggle the 'After multi-line members' option.
I requested this here: http://www.devexpress.com/Support/Center/p/S130722.aspx
It got implemented here: http://www.devexpress.com/Support/Center/p/S19229.aspx
There's now a massive formatting subsystem I spent 3 hours fighting that tries to outdo ReSharper's massive formatting subsystem which both need to be able to survive VS Autoformat (CtrlK D) and don't always.
Now you know it's there, I'd appreciate a quick summary from you as to whether you were able to make it do what you wanted!

Fastest way to "jump back" to a file in TextMate?

Often, when I am reading code or debugging, I want the ability to quickly jump around files. I especially want to "go back" to where I was. I know about "Command+T", "Command+Shift+T", and, bookmarks. But, I cannot figure out a way to jump around files quickly.
UPDATE: I do not think I my question was clear enough judging by two answers given. Specifically, I am looking for a way to "jump back" to where I was in a file. I know how to navigate in TextMate (in general). I want to know if TextMate has a "jump back" key binding.
It's subtle.
The command-T thing has the files listed in Most Recently Used order.
So, you can go command-T return to get back to your last file real quick. At first I couldn't find it either.
I don't think there's a go to last edit location as there is in, say, IDEA/RubyMine.
Courtesy of MacroMates.com
2.3 Moving Between Files (With Grace)
When working with projects there are a few ways to move between the open files.
The most straightforward way is by clicking on the file tab you need. This can also be done from the keyboard by pressing ⌘1-9, which will switch to file tab 1-9.
You can also use βŒ₯βŒ˜β† and βŒ₯βŒ˜β†’ to select the file tab to the left or right of the current one.
It is possible to re-arrange the file tabs by using the mouse to drag-sort them (click and hold the mouse button on a tab and then drag it to the new location). This should make it possible to arrange them so that keyboard switching is more natural.
One more key is βŒ₯βŒ˜β†‘ which cycles through text files with the same base name as the current file. This is mainly useful when working with languages which have an interface file (header) and implementation file (source).
When you want to move to a file which is not open you can use the Go to File… action in the Navigation menu (bound to ⌘T). This opens a window like the one shown below.
Go To File
This window lists all text files in the project sorted by last use, which means pressing return will open (or go to) the last file you worked on. So using it this way makes for easy switching to the most recently used file.
You can enter a filter string to narrow down the number of files shown. This filter string is matched against the filenames as an abbreviation and the files are sorted according to how well they match the given abbreviation. For example in the picture above the filter string is otv and TextMate determines that OakTextView.h is the best match for that (by placing it at the top).
The file I want is OakTextView.mm which ranks as #2. But since I have already corrected it in the past, TextMate has learned that this is the match that should go together with the otv filter string, i.e. it is adaptive and learns from your usage patterns.
If you have a project window open, you can leave frequently-accessed files open (in tabs), and then use ⌘+1-9 to jump to open tabs.

Resources