I am trying to do this:
/**
#param argumentString This is a multiline
comment
about
argumentString
*/
- (void)doSomething:(NSString *)argumentString;
But I don't think #param supports multiple lines describing the same parameter. I haven't been able to find out a way to do this yet; my end goal is to make all the text appear in the same section in the correct segment. With the above code the comment about argumentString part will be moved to the Description section instead. I've tried using #parblock but it doesn't seem to work.
It is very easy to do in Swift, but for Objective-C, there's a simple hack which can make a parameter description look like it is in multiple lines.
Simply add another param whose first word is a whitespace unicode character (other than space). In the following example, I have copied the unicode U+2007 in the 2nd line.
/**
This is the description
#param argumentString: This is a comment,
#param which looks like a multiline comment
*/
- (void)doSomething:(NSString *)argumentString;
The second #param line in the example above is effectively this:
#param U+2007 <space> <comment-text>
The unicode which you could copy is :
Result
This is how it renders in Xcode:
Try this:
/**
* #param argumentString This is a multiline
* comment
* about
* argumentString
*/
Is there any way for PhpStorm to automatically reformat all comments in my project? I've already changed the settings to use one-line comments but it doesn't seem to do anything when I run the code formatter.
For example, let's say I have the following comment:
/*
* Hello, I am a comment
*/
Is there any way for PhpStorm to auto-convert it to this:
// Hello, I am a comment
I'd also want it to work for multi-line comments i.e.:
/*
* Hello, I am a comment
* I'm on multiple lines
*/
Should become this:
// Hello, I am a comment
// I'm on multiple lines
Is it possible for PhpStorm to do this for my entire project automatically?
Just ended up doing a regex replace:
find: \/\*\n(.*)\* (.*)\n(.*)\*\/
replace: // $2
That worked for my first comment, the one with multiple lines I just changed manually.
I'm using expect-lite to communicate with a router. however the router has some customized banner message set and expect doesn't seem to work very well with it. Specifically, when I login in to the router, the cursor was placed at the following location.
***********************************************
* *
* some unuseful info here.. *
* *
***********************************************($cursor)
normally I can just hit enter in an interactive shell and it can then bring me to the normal router shell, I have expected "*" and then send a new line character, but it doesn't seem to work well.
Can you shed some light on this ?
Thanks.
What I would do is add exp_internal 1 somewhere at the beginning of your script, and that way you can see what expect is receiving, and why it is not matching your pattern.
Feel free to add that information to the question if you need some help with interpreting what you get from it.
with the default options to expect ("glob" patterns, documented here), * is a wildcard and will match anything (including nothing). Make sure you're expecting a literal asterisk:
expect -re {\*$}
Here I'm using a regular expression to find an asterisk anchored at the end of the string.
/* Suppose I have a multi-line comment with hard line-breaks
* that are roughly uniform on the right side of the text,
* and I want to add text to a line in order to make the
* comment a bit more descriptive.
*/
Now, most unfortunately, I need to add text to one of the top lines.
/* Suppose I have a multi-line comment with hard line-breaks (here is some added text for happy fun time)
* that are roughly uniform on the right side of the text,
* and I want to add text to a line in order to make the
* comment a bit more descriptive.
*/
It takes O(n) time (n being the number of lines) to fix each line so that they roughly line up again. The computer should do this, not me.
Are there tools to deal with this in our IDEs? What are they called?
emacs supports the command fill-paragraph which is typically mapped to meta-q.
Output from fill-paragraph on your second paragraph of text:
/* Suppose I have a multi-line comment with hard line-breaks (here is
* some added text for happy fun time) that are roughly uniform on the
* right side of the text, and I want to add text to a line in order
* to make the comment a bit more descriptive.
*/
Eclipse has this built in (at least, I think it's what you want). When you type a comment, you then type Ctrl+Shift+F and it will format either all your code, or just the section of code that you have highlighted.
I just tested it now and it aligned all my comments for me.
This question's answers are a community effort. Edit existing answers to improve this post. It is not currently accepting new answers or interactions.
How do I comment a block of lines in YAML?
YAML supports inline comments, but does not support block comments.
From Wikipedia:
Comments begin with the number sign ( # ), can start anywhere on a line, and continue until the end of the line
A comparison with JSON, also from Wikipedia:
The syntax differences are subtle and seldom arise in practice: JSON allows extended charactersets like UTF-32, YAML requires a space after separators like comma, equals, and colon while JSON does not, and some non-standard implementations of JSON extend the grammar to include Javascript's /* ... */ comments. Handling such edge cases may require light pre-processing of the JSON before parsing as in-line YAML.
# If you want to write
# a block-commented Haiku
# you'll need three pound signs
The specification only describes one way of marking comments:
An explicit comment is marked by a “#” indicator.
That's all. There aren't any block comments.
I am not trying to be smart about it, but if you use Sublime Text for your editor, the steps are:
Select the block
Cmd + / on Mac or Ctrl + / on Linux and Windows
Profit
I'd imagine that other editors have similar functionality too. Which one are you using? I'd be happy to do some digging.
In Vim you can do one of the following:
Comment all lines: :%s/^/#
Comment lines 10 - 15: :10,15s/^/#
Comment line 10 to current line: :10,.s/^/#
Comment line 10 to end: :10,$s/^/#
or using visual block:
Select a multiple-line column after entering visual block via Ctrl+v.
Press r followed by # to comment out the multiple-line block replacing the selection, or Shift+i#Esc to insert comment characters before the selection.
An alternative approach:
If
your YAML structure has well defined fields to be used by your app
AND you may freely add additional fields that won't mess up with your app
then
at any level you may add a new block text field named like "Description" or "Comment" or "Notes" or whatever
Example:
Instead of
# This comment
# is too long
use
Description: >
This comment
is too long
or
Comment: >
This comment is also too long
and newlines survive from parsing!
More advantages:
If the comments become large and complex and have a repeating pattern, you may promote them from plain text blocks to objects
Your app may -in the future- read or update those comments
One way to block commenting in YAML is by using a text editor like Notepad++ to add a # (comment) tag to multiple lines at once.
In Notepad++ you can do that using the "Block Comment" right-click option for selected text.
Emacs has comment-dwim (Do What I Mean) - just select the block and do a:
M-;
It's a toggle - use it to comment AND uncomment blocks.
If you don't have yaml-mode installed you will need to tell Emacs to use the hash character (#).
If you are using Eclipse with the YEdit plugin (an editor for .yaml files), you can comment-out multiple lines by:
selecting lines to be commented, and then
Ctrl + Shift + C
And to uncomment, follow the same steps.
For RubyMine users on Windows:
Open the file in the editor.
Select the block and press:
Ctrl + /,
And you will have the selected block starting with #.
Now if you want to uncomment the commented block, press the same key combination Ctrl + forward slash again.
In the Azure DevOps browser (pipeline YAML editor),
Ctrl + K + C Comment Block
Ctrl + K + U Uncomment Block
There also a 'Toggle Block Comment' option, but this did not work for me.
There are other 'weird' ways too: Right-click to see 'Command Palette' or F1
Then choose a cursor option.
Now it is just a matter of #.
Or even smarter [Ctrl + K] + [Ctrl + C]
In a .gitlab-ci.yml file, the following works:
To comment out a block (multiline): Select the whole block section >
Ctrl K C
To uncomment already commented out block (multiline): Select the
whole block section > Ctrl K U