Xcode 4 - Finder with Regular Expressions - iphone

TL;DR I want to use Xcodes finder with regular expressions to update outdated function calls.
Example 'numFrames:??? endFrame:#"step1*_0??? text=" "' where the question marks are replaced by a 1-3 digit number and * is a letter and just delete all of that.
Long Version First off I know I need to refresh my memory on regular expressions but I feel like I'm banging my head into a wall on this...
I want to use finder to update my calls to a function. I was playing ~400 image sequences in my application and it was impractical to keep updating the individual sequence lengths when they would get updated. Now to solve that I have my application figuring out the length on its own, but I still have outdated length declarations. I could go through one at a time and delete them out but I know Finder can use regular expressions...
What I want to delete out is 'numFrames:??? endFrame:#"step1*_0??? text=" "' where the question marks are replaced by a 1-3 digit number and * is a letter.
If you could point me to a good xcode and regular expression guide (Teach a man to fish...) or just tell me how to do this, either would be great.

In the find control click the magnifying glass and choose "Show Find Options". Change the Style option from "Textual" to "Regular Expression". Type your regular expression into the search box.

Related

Only autocomplete on an exact match in Sublime Text 2

I'm making a custom .tmLanguage file to highlight the syntax I'm using correctly and generally make coding with it easier. I'm almost done, and I got the autocompletion working using a .sublime-completions file.
There's just one minor flaw I'd like to change. I have a pretty long list of functions, and almost all of them contain an abbreviation of the word 'parameter', PAR. When I start typing that word, the following are all in the list of completions:
PAR command
DEFPAR command
JDATA command (because the description contains PAR)
SPAA command (because there's a P in the command and an A and an R in the description)
What I want is only for the commands that begin with PAR to show up, so from the list above, only the first item.
So, like this:
In other words, I want the completions to show up based on the literal string I'm typing, and only from the trigger part of my completions file, before the \t only.
That completions file looks like this:
Highlighted in orange is what I want my completions list to be based on.
I hope this is understandable. Any help is greatly appreciated.
This is not possible. By design Sublime's autocomplete feature uses fuzzy matching, so if there are a number of options that all contain the same pattern, but you don't quite remember which one you want, you can type the pattern and have all of the options available. The more you type, the smaller the list of possible options becomes. This is a good thingĀ®, otherwise you'd have to remember the exact command you're looking for, which kind of defeats the purpose of autocomplete and code hinting.

Highlighting line which are not correctly formated [Eclipse]

So I have some formatting rule to follow, such as :
Space on each side of operator (*, =, +, %, etc)
No space at the end of a line
No more than 80 chars per line
Is there a way to highlight in red line containing formating error?
The eclipse auto-formating tool is no good because either :
It will change to many line (old code not written by me)
or it won't (only my code)
Because I must follow some "colorfull" guideline :
You must change formating error relative to operators in old code but nothing else
Your code must be correctly formated.
Any ideas?
Thanks
You can select which lines of code you want to format. The Eclipse formatting tool doesn't have to run across the entire file. To do this: select the lines you want to format, then press Ctrl-Shift-F.
You could try using the Eclipse Checkstyle Plugin.
You'll need to configure it with just the rules that you need (the default configuration is very strict, so create a new one with just the rules you care about).
This will highlight all lines with formatting issues. I don't think it's possible to ignore old code using the plugin.
Talk to whoever created that coding guideline. It does not make sense in the long run, because editing code in Eclipse will always apply all current formatting rules (which violates that guideline) or none, if you disable the formatter (which leads to you writing bad code).
If there is really no way around that guideline, then you should split your workflow into 2 phases: Reformat all existing code one time to fulfill that operator guideline. You may use any tool you like, even just a regular expression search and replace might be fine.
After that has been done, configure Eclipse to auto-format only changed lines, but always apply all formattings to each changed line. There is no good reason to not re-format the other 75 characters in an existing line of code, if you already touched 5 characters of it.

Eclipse basic shortcuts - assigning assistant, extract variable

There are some pretty basic tasks and I'm in doubt how it can be effectively done in Eclipse IDE:
Content assisted variable declaration/assignment:
Imagine you have to write something like this DateFormat df = new SimpleDateFormat();. How can it be effectively typed? One guess like DateFormat df = new plus some quick Ctrl+Space, not very, very long SimpleDateFormat. But this does not work, it will show completely useless alphabetically sorted types from classpath, usually unassignable to DateFormat.
Extracting variable:
Is there any way to extract variable like Alt+Shift+L does but WITHOUT the need to manipulate the mouse to select expression or whole line? Just like extract content under cursor? Or is there some way to select line (this work only for standalone expression but better than mouse)?
Extracting field:
Any way to extract field in more convenient way than perform 2. followed by another magic - convert variable to field?
I'm doing mentioned combos every 1-5 minute, and it seems to me like editor completely unusable for serious work. (Iff one is not Ray Manzarek)How are you typing in Eclipse? Note that I prefer default settings, no fine-tuning which stops working after first upgrade or terminal change. Thanks.
For your first problem, here's how I do:
DateF<ctrl-space><Enter> df = new SDF<ctrl-space><Enter>
For your second problem, I simply select the text I want with ctrl-shift-left_or_right_arrow.
For your third problem, no idea. I don't remember having transformed a local variable into a field for a long long time. Maybe I just know beforehand which fields I'll need for a given class.
For the first one, I find I just need to type DateF Alt-\ Enter df = new Sim Alt-\ Enter ;, which doesn't seem too bad to me.
For your second question Shift-Option-Right extends the selection to the right one word at a time, and Shift-Option-Left to the left; that, in combination with the keyboard shortcut you mention, should do what you want (those are Mac keys, of course, but I'm sure there are Windows equivalents; I understand some folks actually develop software on Windows.)
For number three: don't think so. You could write your own plugin to do it pretty easily.

Eclipse text-search over all files?

I'm optimizing my code at the moment (android game), and wanted to replace all foreach(for(:)) with normal fors. Is there a way to find them all? Ctrl-F only looks through the current file and Ctrl-H doesn't seem to find any java constructs (not sure if right word: ifs, whiles, accessors etc.). Preferably without a plugin, but any answer accepted. It would also be nice if there would be a possibility to search for any string (* in Search).
TL;DR: Looking for way to find all foreaches in eclipse.
First of all, I must say, this sounds like a really strange optimization. Keep in mind that if you have, say, a LinkedList you would be far worse of going through a
for (int i = 0; i < list.size(); i++) {
element = list.get(i);
...
loop, than using an iterator (which for-each loops does). Smells micro-optimizations long way to me.
That said, here's a solution for you:
Make sure the root source folder is selected
Click Search / File Search
Mark Scope as "Selected resources"
Mark Regular expression
Search for a regular expression such as for\s*\(.*:
The expression matches strings on the form for, followed by some white whitespace, followed by ( followed by some characters, followed by : (which kind of characterizes a Java for-each loop).
Right-Click on the project, choose search and you're able to replace all for-commands with a regular expression like for(.*;.*;.*) with other expressions you want to.

What's so great about Block Selection Mode?

Longtime Eclipse user here; I recently discovered the "Block Selection Mode" (Alt-Shift-A) that was added into Eclipse 3.5. I tried it out, it's pretty neat--I can select a rectangle of text in my source code instead of selecting things a line at a time like I usually do.
Apparently this feature is common in other editors too, under other names like "column edit mode", etc. A lot of people seem to really love it, but I've got by without for a long time.
So my question is: What kinds of things is this feature useful for?
The only one I can think of is inserting a comment characters (like // or #) in front of a chunk of text. Also, I supposed if I had a bunch of variables names that were all lined up and I wanted to change the first characters for all of them at once. But surely there's more to it than that? I mean, when it comes to choosing an editor, this feature is apparently a deal-breaker for some people!
I find it is very useful when working with fixed-position field data files, and you only want to select a few fields for search-replace or copy-paste. It is also good for things like this:
call_foo('A',123);
call_foo('B',143);
call_foo('C',331);
call_foo('A',113);
call_foo('R',789);
The code is all the same except for some characters in some columns. You could select a block around the second parameter and search for the line containing 113. Useful when you have more than just a few lines all together in this format.
A colleague of mine told me of a project where they wrote JDBC code like this:
String query =
"select question, answer, accepted " +
"from so_answers " +
"where poster = 'Jon Skeet' " +
"order by upvotes ";
So that they could block-select the SQL in order to paste it into a database tool and run it by hand. Seems a bit barmy to me, but it evidently worked for them.
If you arn't using a block cut/copy/paste operation at least four or five times a day then I would suggest you're just doing a lot of extra typing.
If you are looking at a file with fixed width fields, sometimes you only want to select one column.