Newline in block name - makecode

The minecraft make code example has multiline blocks.
How do I also make my blocks this tall?

They used
//% inlineInputMode=external
This breaks blocks (newlines) where each input is. Doesn't give you control over where the line breaks go.

Related

C++ multiline comment syntax in flex

I have a problem with my flex script. I write it for C++ multiline comment. My flex pattern is:
"/""*"[^"*""/"]*"*""/" {strcpy(mlc[mlc_count++],yytext);}
It can find one multiline comment. But when I put entire code in multiline comment it doesn't work. I tried lot but can't find any solution.
Flex reads input one buffer at a time. Using normal matching, a single token can occupy no more than one buffer of data. If memory serves, the buffer is normally something like 8 kilobytes, so a single token longer than that won't match correctly.
Typically you work around this with an exclusive start condition, something on this general order:
"/*" BEGIN(COMMENT);
<COMMENT>*/ BEGIN(INITIAL);
<COMMENT>. { current_comment += yytext[0]; }

comments in C++ in Sublime Text 2

I'm trying to write some C++ in Sublime Text 2. If I begin a line with a double forward slash (//) the text in that line grays out as if it were commented out, but it causes a build error when I compile, so clearly it isn't. If I begin the line with a pound sign (#) that line is commented out but doesn't change in appearance. I want to be able to tell what lines are comments and what lines are actually part of my program. How is this done?
In c++ comments look like this
// one line comment or
/* comment
over multiple
lines */
If your compiler is not recognizing these, chances are, it's not compiling c++. This seems even more likely seeing how lines beginning with # will be ignored like you'd expected for some other languages (for example python)
Make sure to check what the "build" button in your IDE actually calls/does.
You can try this:
/*
I am a comment!
I am another comment!
*/
I hope this helps.

Stata behaving totally differently depending on whether I put semicolon to comment

If we put "*" in the beginning of the line then Stata is supposed to ignore the line.
But I find again and again that if I don't put semicolon at the end of the comment line, the program gives me spoiled estimation result.
Why is this?
Isn't Stata supposed to completely ignore the whole commented line?
Also, in general, when should I and shouldn't I put semicolon at the end of the line?
There is no need to use ; at the end of a Stata command.
In both Stata and Mata this is entirely optional.
As you say, * is used for commenting, but this must be the first character
of the line (excluding blanks) and it comments out only that line.
If you need multi-line comments or comments in the middle of some command,
then use /* and */ (together).
The end of a command is established by a delimiter. The default delimiter
is a carriage return. You are able to change the delimiter to a ; using #delimit ;
in your .do file or program; that doesn't work interactively. In this way, you can break
long commands into several lines without Stata complaining. The point is that
you signal the end of the command explicitly using the ;. But you need not
use #delimit ;. One way to break a long command into several lines is using /// at the end of each line (except the last one).
All that said, you give no example code. You mention that Stata behaves totally
differently depending on semicolon (in your post title) but give no explanation
as to what this means.
Good readings may be help semicolon, help delimit, help comments.

vim regex : multi-line edit and controlling the cursor position

A text file is formatted like this:
Section 4 Area B Unit 20
stuff i don't need...
stuff i don't need...
45990 - Title of Project that I want to save
line of text I need to keep
line of text I need to keep
2010-11 this line (starting with 2010) is not needed
stuff i don't need
Section 589 Area C Unit 1005
stuff i don't need...
stuff i don't need...
45990 - Title of Project that I want to save
line of text I need to keep
line of text I need to keep
2010-11 this line (starting with 2010) is not needed
stuff i don't need
and these sections repeat by the hundreds. The "stuff i don't need" lines are actually about 30 or so. I need to keep the association of the "Section..." line, "Title..." line and "line of text I need to keep" related to each other. So I was hoping to first destruct the text document down (linewise) to the stuff I need before operating on it further (character-wise). So I wrote this:
g!/\Section\s\d*\sArea\s\h\sUnit\s\d*\n\|^\s\{3}\zs\d*\s-\_.*\ze2010-11/d
After deleting I get the "Section.." line and the "Title..." line, but never the subsequent lines underneath the "Title.." line. Those subsequent lines vary from 4 to 8 lines, but the "2010-11" line is consistent and always what I no longer want.
You can see I tried using zs and ze to select what I do not want deleted. I think the selection is working because if I change the command to "2011-12" then there is no match and the (OR) half of the command does not return a result.
I think the fault might be the cursor position(?), but I'm not sure and my effort to fix that has failed.
Can anyone see my error?
Thanks!
Give this a whirl.
:silent! g/^Section/+ , /^\s\+\d\+ -/- d
:g/^\s\+2010/ , -/\nSection\|\%$/ d
:g finds every line matching start of the pattern, ! will revert the selection and command will get applied to these lines.
Would something like g/^Section.../normal! j2dd3jd} do?
If not you can use a search for the Title line inside normal!
You may need to enclose it in "exec" but may be much simpler to write a function.
Do you really need to use vim? Seems like job for Perl to me.
There are many ways to do t, I'm sure. I think this sequence of commands should work (ignoring comment lines that begin with double quote):
" global delete of line below 'Section' to line before 'Title'
g/^\s*Section/+1;/Title/-1delete
" global delete from date line to line before 'Section'
g/^\s*\d\d\d\d-\d\d/;/^\s*Section/-1delete
" go to top line of buffer
gg
" delete last chunk, from final date to last line
/^\s*\d\d\d\d-\d\d/;$delete

Easily comment (C++) code in vim

I have looked at the following question:
How to comment out a block of Python code in Vim
But that does not seem to work for me. How do I comment code easily without resorting to plugins/scripts?
Use ctrl-V to do a block selection and then hit I followed by //[ESC].
Alternatively, use shift-V to do a line-based select and then type :s:^://[Enter]. The latter part could easily go into a mapping. eg:
:vmap // :s:^://<CR>
Then you just shift-V, select the range, and type // (or whatever you bind it to).
You can add this to your .vimrc file
map <C-c> :s/^/\/\//<Enter>
Then when you need to comment a section just select all lines (Shift-V + movement) and then press CtrlC.
To un-comment you can define in a similar way
map <C-u> :s/^\/\///<Enter>
that removes a // at begin of line from the selected range when pressing CtrlU.
You can use the NERD commenter plugin for vim, which has support for a whole bunch of languages (I'm sure C++ is one of them). With this installed, to comment/uncomment any line, use <Leader>ci. To do the same for a block of text, select text by entering the visual mode and use the same command as above.
There are other features in this such as comment n lines by supplying a count before the command, yank before comment with <Leader>cy, comment to end of line with <Leader>c$, and many others, which you can read about in the link. I've found this plugin to be extremely useful and is one of my 'must have' plugins.
There's always #ifdef CHECK_THIS_LATER ... #endif which has the advantage of not causing problems with nested C-style comments (if you use them) and is easy to find and either uncomment or remove completely later.