How do I set WSL console to print tabs instead of spaces (and copy tabs)? - windows-subsystem-for-linux

Printing anything with a tab in WSL prints a series of spaces instead of a tab. When I want to copy and paste these lines, obviously spaces are copied, so I lose a lot of formatting.
I've tried using CMD.exe, PowerShell, and MobaXTerm, but in every case I can't seem to print a tab.
echo -e "Col1\tCol2\tCol3 and spaces"
I expect that tab characters should be output and copyable, but the tabs are converted to spaces. Gnome-Terminal in Ubuntu handles this just fine, but every option in Windows 10 / WSL seems to fail.

Related

using greek letters as variable names

How would I enter greek letters to be used e.g. as variable names in Python 3 under Spyder? Currently I'm using the following Python code on the console:
s = '\u03B1'
print(s)
α is printed on the console and I can copy it into my source. I was wondering if there is a way to directly enter it into my console, perhaps even some macro that automatically replaces \alpha with α.
In the Spyder IPython console, typing \alpha followed by a tab gives you α. You can then copy paste it into the Python editor. I am searching for a better solution.

How to paste multiline text in pycharm?

Everytime i try to copy and paste something on my Pycharm editor it all paste it in single line. How to automatically paste in multiline?[1]
This is what i copied.....
[{"DateObserved":"2020-06-12 ","HourObserved":23,"LocalTimeZone":"EST","ReportingArea":"Central New York Region","StateCode":"NY","Latitude":42.8049,"Longitude":-76.3589,"ParameterName":"O3","AQI":35,"Category":{"Number":1,"Name":"Good"}},{"DateObserved":"2020-06-12 ","HourObserved":23,"LocalTimeZone":"EST","ReportingArea":"Central New York Region","StateCode":"NY","Latitude":42.8049,"Longitude":-76.3589,"ParameterName":"PM2.5","AQI":0,"Category":{"Number":1,"Name":"Good"}}]
and this all got pasted in a single line on my Pycharm editor. can anybody help with that, its pretty hard to read all this info on a single line?
It seems like you didn't copy anything containing newlines as you can see better after my edit (See the side-by-side-markdown diff so you can see that I didn't remove any line breaks).
If you just copy everything as a single line, PyCharm won't be able to split it into multiple lines (except with auto-format maybe).
As you haven't said how you copied the input, I can't say what exactly is wrong.
However, it seems like you copied something from a program that didn't display the text correctly so that you couldn't copy it correctly.
Another possibility is that the IDE interprets line breaks differently.
For example, windows uses CRLF(carriage return+line feed) as a line seperator while linux uses LF only.
If your file contains only LF line breaks and PyCharm is configured to use CRLF like breaks, it is possible that it ignores them because of that.
You can change that behaviour at the bottom of your file in PyCharm (button with CR/CRLF/LF).

Intellij IDEA 14 - remove indents on empty lines

I have an annoying bug regarding intellij 14.0.3. The issue is that it keeps indents on empty lines and I can't remove that whitespace in any way. Under code style, I have not checked the checkbox "keep indents on empty lines" and judging from the display how that functionality works I'd say it would do it.
However, it still keeps the indents and that creates bad diffs in git since whitespace is added. Is this a bug? Can I in any way remove them? I have tried to uncheck that checkbox under both the language I use and the main one. None of them seems to change it.
Try enabling the Strip trailing spaces on save option in Settings/Editor/General.
You can choose whether this should be performed for All lines or only the lines you modify to avoid creating unnecessary diffs.
The whitespace is stripped when you explicitly hit CTRL+S or automatically after some period (IntelliJ has autosaving).
One thing to note is that if you have cursor on an empty line and there are some spaces before it, hitting CTRL + S won't strip the whitespace, because this would probably be annoying as your cursor would jump to the beginning of the line if the file was autosaved by IntelliJ (I read somewhere on YouTrack that this was a design decision).
Here is a screenshot of the option I describe:
What I did to strip spaces without having to open & save each file is running a regex in the find and replace window:
Ctrl+Shift+R
Text to find ^ +\n Find every line that starts with (^) one or more spaces ( +) and nothing else (/n).
Replace with: \n A new line.
General > Regular expression (obviously important to check this box)
Eventually you may want to limit the scope because this will be quite the lengthy operation
Find and eventually continue if IDEA warns for the high amount of occurrences.
Click All Files to run the actual replace operation. It might take some time before IDEA to respond.

Mono Keepass2 Bugs / Errors in Entering Master Password via Paste or Using Backspace

I repro'd this easily with Ubuntu 12.04 Keepass 2.18. I created a new file and saved to the desktop. Set master password as "test". When I close and reopen the same kdbx file, if I type in "text", works fine. If I hit backspace after the last "t" and then retype "t", then hit "ok" I get the keyfile error, even though no keyfile is set and the password should be identical.
In Keepass2 on Ubuntu 12.04 I can NOT copy/paste into the Master Password field when first opening a database file if the copied text includes a symbol. When I paste a symbol characters like the degree symbol, °, it does not paste. Other characters seem to paste fine. The paste function appears in a rmb menu but when I do it nothing seems to happen? What's wrong?
UPDATE
I should note that on pasting passwords into new Keepass2 entries, I also see errant/spurious characters inserted (for example small rectangles). Seems like this may be related. Not sure it will effect most people since the password still pastes ok (paste omits the spurious characters in text fields), but perhaps it may affect other mono password fields used in Ubuntu. Obviously can also be confusing to the user.
create new entry
copy paste a password into password field
save/close/reopen entry
show password
small rectangles appended on end of password
I had the same problem with buggy password characters when using Mono.
Keepassx works better on Linux, it's cross platform and doesn't need Mono.
apt-get install keepassx

To run Sed to Screen's clipboard in Screen's command-mode

I have a copy in Screen's clipboard which contains the word Masi aften.
I would like to replace it with Bond effectively such that I edit the clipboard directly in Screen's command-mode. I know that I could save the clipboard to /tmp and run the replacement there in Vim, but I want to learn Screen.
I run as I have my data in Screen's clipboard
Ctrl-A : sed s/Masi/Bond/ | [Screen's clipboard] /// I do not know how to refer to Screen's clipboard by a command other that C-A ]
I get
unknown command sed
How can you run a command to Screen's clipboard in Screen's command mode?
I don't think screen has any way of running commands on the paste buffer.
One way to do it is to make a bind to save the paste buffer and open a new window in screen that runs a script to modify the buffer. Then make another bind to reload the modified buffer from disk and paste (this can be bound over the normal paste bind).
Add this to screenrc (changing paths):
bind -c screensed s eval "writebuf /pathtoscript/screensed.clipboard" "screen sh /pathtoscript/screensed.sh"
bind -c screensed p eval "readbuf /pathtoscript/screensed.clipboard" "paste ."
bind , command -c screensed
Make a shell script somewhere:
#!/usr/bin/env sh
echo "Enter sed script: "
read sedcommand
sed -i ${sedcommand} /pathtoscript/screensed.clipboard
echo "(Enter to return)"
read something
"ctrl-a , s" in screen will dump the clipboard and make a new window for the sed command to be entered. "ctrl-a , p" will read the clipboard and paste. The pause at the end of the script is to show any errors sed might give.