I would like to make comments like this in Sublime Text 2:
/********************
* This is a comment *
********************/
Is there an easy way to make those automatically?
Also, where can I find good documentation about such stuff. I love Sublime, but I feel it's poorly documented!
You could create a snippet for doing this.
Go to Tools -> New Snippet and a new file is opened. Paste this in it:
<snippet>
<content>
<![CDATA[
/********************
* $0 *
********************/
]]>
</content>
<tabTrigger>bigcom</tabTrigger>
</snippet>
Save this in your Packages\User-Folder (which should be set automatically when saving).
Now you can just type bigcom (as defined in the <tabTrigger> - element) and hit tab. The comment will appear and the cursor is set at the position, where $0 is set in the snippet.
Additionaly, you could add a scope - element inside the <snippet>-block, so this snippet will only work in a specific syntax scope, for example:
<scope>source.python</scope>
Unfurtonately, I don't know how you could add the *-character on both sides of the line you are writing in automatically, when you jump into a new line, so I don't know if this fits your needs. You would have to add those manually. Still I hope this helps in some way.
Edit:
Found something for this in another question on stackoverflow. Have a look at this answer. When doing this, at least the * character on the beginning of the new line is added. I'll have a look if I can get it to add the character at the end of the line too.
When it comes to the documentation, I agree, there's not really a lot out there. Of course there is the official documentation: Sublime Doc and of course the forum: Sublime Forum (which is a good resource to some point, not like the poorly filled Doc). On the other hand I always recommend reading the post on net.tutsplus, which is a nice starting point.
I pretty much stumbled over the most interesting parts that come with the standard installation while browsing trough the Global Settings and Key Bindings-Files, which you can open over the Preferences - Menu
Warning, self plug.
The DocBlockr plugin can automatically 'decorate' a comment for you. Right now it only works on inline comments, but it gets the job done. The shortcut key is Ctrl+Enter
// foo bar baz
Becomes
/////////////////
// foo bar baz //
/////////////////
And it works on consecutive comments too:
// foo
// bar baz quux
Becomes
//////////////////
// foo //
// bar baz quux //
//////////////////
You could also try using the DocBlockr plugin
Use this handy sublime plugin https://packagecontrol.io/packages/Comment-Snippets
Related
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.
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!
Is there any way with TextMate to hide comments when editing code? Sometimes I want to see my code with the full comments and other times just want to see the code itself with all comments hidden. I was hoping there would be a way to toggle the display of comments, but haven't been able to find anything about this.
It is something you will need to edit on a language by language basis, but it is very doable. Inside of Bundles -> Bundle Editor -> Edit Languages you will find the language definition that TextMate uses to highlight that particular syntax. Inside of the syntax definition you will find foldingStartMarker and foldingStopMarker.
You can add comment syntax to those to allow the folding off comments themselves. It might be pretty tricky for single line comments, but multiline comments, that have both a clear and unique start and stop syntax, should work fine.
For PHP, for example, we are going to want to add \/\* to the start syntax, and \*\/ to the end syntax. You will need to reload the bundle for these changes to take effect (or restart TM).
I want to know if it is possible with Scintilla API to make something like the following.
I have the following call:
cook(foo , bar);
where foo and bar are only highlighted and the caret is at the beginning of foo.
now if i type anything, it will override foo, and if I pressed Tab, the caret will jump to the highlighted bar.
FingerText does this with snippets (for Notepad++), but the majority of it uses Scintilla, so I would imagine it should be possible to fairly easily adapt it for another Scintilla based editor.
Is there a way to hide/unhide all comments in xcode source files?
This would be very helpful when working with code that has way too many comments added.
You can use fold/unfold to hide/show comments using ⌃⇧⌘↑ and ⌃⇧⌘↓. This is also accessible through View --> Code Folding --> Fold/Unfold Comment Blocks.
Try: Ctrl + Command + Shift + Left
Or Ctrl + Command + Left
Surrounding any code with
/*
....code here....
*/
makes that comment into a section that you can fold/unfold.
This works even for blocks of code already commented out with // in long blocks.
Hope this helps someone even though this question is 4 years old!
Expanding a bit on Mish's answer because XCode is very subtle with its UI
As #Mish pointed out, surrounding any code with /* ... */ makes that code fold/unfold-able just like your { ... } sections.
I haven't had any luck with any of the keyboard shortcuts listed on this answer page yet, but if you hover over the left hand side of the /*...*/ section you'll see the UI change in response to that like so:
that when clicked will collapse the comments. I for one intend on trying to do all comments with the /.../ format from now on.
PS: Note that /*...*/ comments can be inline with code on either side and still be collapsable.
EDIT: I'm finding that collapsing comments inside of some {...} brackets is not working because XCode is collapsing the entire {} section instead...
A very easy and practical way to hide all // comments is to change the comments' color to black (or other background editor color you are using, normally dark color) in Xcode preferences.
When you want to see them again, just change color to primitive one, such as green
I'm made a summary , it works for me. It's late but a good flow helps writing good code. for swift 3-4 only
In case where you want to write pseudo code first before actual code, you can write everything into a comment block
/*
first, use http request
in the callback, do
a.
b.
c.
*/
then because you might re-write but the logics are mostly the same, so you might not want to remove the comments, that's fine, but make sure they don't block your view, so you define a short-cut that conveniently fold/unfold all the comment block into one line. (That's the best you can do.); Then when you fold them, it looks like this: /*...
to Define shortcut, go to Xcode => Preference => Key Bindings => fold comment block
In my case I use alt⇧ctrl{ , alt⇧ctrl}
then define it anyway you want, but be careful of conflicts.
It really pays to have pseudo code comments folded
Select the code and comments IN BETWEEN the /* and */ .
Do NOT select the /* and */ . then select Code Folding from Editor menu. It works for me. Swift 5, Xcode 12.4