Insert block of color into text file - visual-studio-code

The following line of code appears in a python source file. It appears exactly like this when the file is opened up in VS Code and in vi (as well as this text edit block). When I cat the file, the green square is replaced by several non-ascii characters. My question is how does one create a line of text with a swatch of some arbitrary color?
'correct_place': '🟩',

🟩 ("Large Green Square") is actually an emoji. Every emoji has a unicode number. The unicode number for 🟩 is U+1F7E9.
You can open a file in VSCode, copy the emoji above and paste it in that file (using the regular copy and paste commands on your computer, like command+C command+V).
You can also use the echo command in a Linux terminal to write this emoji into a file by using 🟩's unicode number, for example:
$ echo -e '\U0001F7E9' >> sizzzzlerz.txt
$ cat sizzzzlerz.txt
🟩

Related

Incorrect display of 4 byte emojis in vs code integrated terminal

Why is my VSCode integrated terminal not able to show correct emojis:
Text file:
🦎 Emoji
which produces with cat file.txt the output:
�🦎 Emoji
I use a proper UTF8 font MesloLGS NF (pk10 powerline font).
I use git-bash.exe. Starting git-bash.exe from the task bar (mintty terminal?) works fine with these emojis. Also 3 bytes emojis work.
Any clue very welcome.
Changing codepage to chcp.com 65001 and using the newest VS Code
cat A.txt with content 🦎 Emoji
works.

Shell Script doesn't color multiline <<EOF statement

I'm working with a shell script in VSCode,
I'd like to be able to collapse the function.
In order for me to do that, the 'EOF' word has to have some whitespace before it.
But if I put whitespace before it, the entire coloring of the file is ruined (including all the functions appearing thereafter)
Is there a setting / or another way to do it so it will not behave like this?
Thanks
With EOF word at the beginning of the line
With some whitespace before the EOF

Line breaks using dlmcell in Matlab - shows up in Notepad++ but not Notepad

I am using the function dlmcell in Matlab to output text. I want text on a new line each time I append using dlmcell.
When I open my written document in Notepad++, each snippet of text is on a new line as I want it. However, opening it in Notepad that comes with windows, everything is on the same line. Can somebody tell me why this is, and how to fix it?
I'm assuming you're using the string \n to declare a new line in your output. For Notepad++ this is sufficient, because it interprets a new line just with \n. For the Windows Editor you need to include the carriage return also:
substitute:
\n with \r\n
This way not just a new line is created, it also tells the editor to actually continue on the next line.
To illustrate what I mean, open your output file with Notepad++ and activate View > Show Symbol > All characters and you will see something like:
I wrote this with Notepad++ and it automatically adds CR (carriage return) and LF (line feed) at the end of every line. Matlab doesn't if you don't tell it. So your output file only contains LF without the above mentioned substitution.
I've had a look into dlmcell, which is a FEX-function. In the current version \r\n is implemented actually. Do you have the newest version of that function (Download)? If not, something else must be wrong, please post some code.

How can i hinder Eclipse from inserting CRLFs?

I just reinstalled Eclipse Juno.
The problem i have is when i create a new file and start writing, CRLFs are inserted on Return.
Second case: When i fully mark the text of a file (without CRLFs) ans COPY them into another file (i use CRTL+A and DEL to get rid of the file contents and then PASTE i get the file content with CRLFs!)
The resulting file looks like:
Test blah CRLF
Line two ... CRLF
CRLF
How can i get rid of them?
Solution to this is to configure Eclipse accordingly.
Windows->Preferences->General->Workspace
In the right lower corner there is a setting called "New text fiel line delimiter" which i had to switch from Windows to Unix.
The already CRLF prensent i had to remove using Eclispe->File->Convert line delimiters to ->Unix .

Surround with quotation marks

How is it possible in Eclipse JDT to convert a multiline selection to String. Like the following
From:
xxxx
yyyy
zzz
To:
"xxxx " +
"yyyy " +
"zzz"
I tried the following template
"${line_selection}${cursor}"+
but that way I only get the whole block surrounded not each line separately. How can I achieve a multiline processing like commenting the selected block?
Maybe this is not what you mean but...
If I'm on a line in Eclipse and I enter double quotation marks, then inside that paste a multiline selection (like your xyz example) it will paste out like this:
"xxxx\n" +
"yyyy\n" +
"zzz"
Then you could just find/replace in a selection for "\n" to "", if you didn't intend the newlines.
I think the option to enable this is in Window/Preferences, under Java/Editor/Typing/, check the box next to "Escape text when pasting into a string literal". (Eclipse 3.4 Ganymede)
Find/Replace with the regex option turned on. Find:
^(.*)$
Replace with:
"$1" +
Well, the last line will have a surplus +, you have to delete it manually.
I would go with a Find/Replace eclipse in regexp mode:
Find:
^((?:\s(?)\S?)((?:\s(?![\r\n])))
Replace with
\1"\2"\3 +
Will preserve exactly whatever space or tabs you have before and after each string, and will surround them with the needed double-quotes. (last '+' needs to be removed)
This may not be exactly the answer you're looking for. You can easily achieve what you're asking by using the sed stream editor. This is available on all flavors of Unix, and also on Windows, by downloading a toolkit like cygwin. On the Unix shell command line run the command
sed 's/^/"/;s/$/"+/'
and paste the text you want to convert. On its output you'll obtain the converted text. The argument passed to sed says substitute (s) the beginning of a line (^) with a quote, and substitute (s) the end of each line ($) with a quote and a plus.
If the text you want to convert is large you may want to redirect sed's input and output through files. In such a case run something like
sed 's/^/"/;s/$/"+/' <inputfile >outputfile
On Windows you can also use the winclip command of the Outwit tool suite to directly change what's in the clipboard. Simply run
winclip -p | sed 's/^/"/;s/$/"+/' | winclip -c
The above command will paste the clipboard's contents into sed and the result back into the clipboard.
Finally, if you're often using this command, it makes sense placing it into a shell script file, so that you can easily run it. You can then even assign an Eclipse keyboard shortcut to it.