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

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!

Related

Shortcut to surround an html tag by table/row/cell with their closing tags?

Looking for a shortcut in Visual Studio to surround a selected tag by
<table><tr><td>my selected element</td></tr></table>
I am using Visual Studio 2013.
Anything in plain vanilla VS? Web Essentials? Resharper? CodeRush?
CodeRush can certainly solve this issue for you.
Ruben is quite correct. We have a "Surround with Tag" refactoring which can be applied successively with 'td', 'tr' and then 'table' (working from inside out.
Alternatively you could create a template:
Structure only
<table><tr><td>«Caret»</td></tr></table>
This would create the table structure you are after and place your caret ready to enter the data of your choice.
Structure with Paste
<table><tr><td>«Paste»</td></tr></table>
This would create the structure you are after and paste the content of your clipboard inside it.
Existing Template
The built-in .t template will create a much more complex table structure under your guidance, and plugins can be written to address a specific need.
NOTE: These techniques make use of cutting the target element to the clipboard. If your target element is sufficiently complex, this would make selecting and cutting seem like too much work.
However... another CodeRush feature (Smart Cut\Copy) will make this much easier. Simply position the caret immediately to the left of your target and cut. CodeRush will detect that nothing is selected and will dynamically select the logical element to it's right before continuing with the cut operation.
At this point your task becomes
Cut
Invoke template
(Optionally) paste.
All of these steps are invokable using just the keyboard.
If all else fails... :)
If this does not meet your need, please feel free to comment below, or contact me directly (roryb#devexpress.com) and we can discuss your needs in more detail.
I created a new Surround template in Resharper.
<table><tr><td>$SELECTION$$END$</td></tr></table>

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.

Reformatting code in text mate to established code conventions - Visual studio's ctrl K+D equivalent on Text Mate

Can anyone tell me if there's a quick way to format your code in Text Mate, similar to pressing ctrl K+D in Visual studio?
Thanks!
Edit by Damien_The_Unbeliever:
For those not familiar with Ctrl K+D, it doesn't just indent code - it reformats it using the generally established formatting conventions in the editor - it may replace spaces with tabs or vice-versa for the indentation, ensure code is consistently indented, move braces to separate lines, etc.
TextMate reindenting and reformatting varies a little depending on the language you're using.
You can generally use the Text menu, that depending wether you have an active selection or not it will show you different commands under it. For example, if you have selected a section of code, there will be a Indent Selection menu item. If you have no active selection, it will be Indent Line.
To have this working properly, be sure to select the current language, if it isn't assigned yet (like on unsaved documents). If you're working with HTML, it will simply indent the lines depending on what's above it. It will keep line breaks intact.
If you need something to break out tags on new lines and properly format the document, you should use the Tidy command that is found in the Bundles menu, under HTML (or simply by using the shortcut CTRL+SHIFT+H. If you have a selection active at the moment that you use it, it will simply reindent that section. If instead you have no selection, it will properly reformat the whole document, including checking for tag validity and other errors.
The Bundles for other language have similar commands, like XML (still Tidy) and Javascript (that has a Reformat Document command).
As an ending note, I simply suggest to look into the Bundles menu; there are many little gems in it. ;)
Did you look in the menu bar? Under Text you have a couple of Reformat… entries that may fit your needs.
Beside these native features, some bundles — like the JavaScript one — have custom Reformat… commands : click on the little cog button at the bottom and explore your current language's bundle's content.

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.

Windows text editor that shows/hides lines based on RegEx or Grep syntax?

One of my application components produces some extremely hairy log files. They require a lot of poking and prodding before they produce useful information. I'm on the hunt for a text editor for windows that will let me enter text in either RegEx or Grep-style syntax, and automatically show/hide the relevant lines.
Does anyone know of a text editor that has this feature?
Thanks!
IVR Avenger
I know it's answered already, but http://glogg.bonnefon.org/ is the perfect answer for this. Couldn't live w/o it.
I would recommend Notepad++ as far as a good all-around Windows text editor is concerned - it is very extensible and includes just about every power feature you need to wade through data logs. If your log files are in a well-defined format, you can even use the built-in language editor to define a custom visual scheme for your logs - easier on the eyes.
-matt
GVim with for example, :g command. There are also plugins that allow entering search criteria, and they show relevant lines, and fold everything else.
Emacs, of course (occur), but I think pretty much every editor will do this.
Another option is SlickEdit using it's "Selective Display..." option
Although it wont show/hide based on a regex, Textpad will allow you to search and produce a hyperlinked result file with the lines that will allow you to click into the actual log. Consider the benefit: You can keep the filtered results up on your left monitor, and you can click into the full files and show them on your right monitor to see the context.
SPFLite is free and does just what you want. At least the IBM SPF and ISFP (used on IBM mainframes as part of the MVS operating system) that it emulates is just what you want.
From what I have tried, SPFLite will probably do the job. It can X (exclude) all lines from view, or eXclude lines with a given character or phrase (optionally starting in a certain column) from view. Or after eXcluding all lines, you can display, by Finding, characters or strings (optionally starting in a certain column). I think it also has a macro capability. The original does, and I think this Lite does as well. How robust I do not know. The original could create interactive screens and programs using the MVS TSO Command Language.
I found SPFLite at http://www.spflite.com/
I found that this interface is not so easy to use, but one gets used to about anything if necessary.

Resources