How to delete characters as they are typed into MATLAB command line - matlab

I am using my keyboard to run an application in MATLAB, where each keypress is handled differently depending on the number or letter pressed. To recognize keypresses I'm using the HebiRobotics library discussed here:
Detect Keyboard Input Matlab
While running the program, hundreds of keypresses are required, each of which types a character in the command line, after the >>. Is there any way to delete these characters as they are typed so the command line remains clear? I've tried fprintf('%c',8) to backspace, but this applies to the previous executed command, not the characters on the current line.
To be honest, this isn't terribly important, but having the characters appear is ugly, takes a few extra clicks to delete, and is one of those little things that is driving me crazy.

This answer by 'Oleg Komarov' seems to be relevant -Clearing text typed with input() from command history

Related

vs-code is muffing up my indentation in powershell for some reason

Switched to vs-code from vim for editing powershell scripts. Bit of a learning curve, but it's working. However, there is one indentation problem I cannot figure out. It's not a dealbreaker, but it's annoying.
So for the sake of argument, a long function call, with long strings for parameters, multiple parameters, etc. On one line, it's ridiculously long.
So I split the line with the backtick `, and that's OK.
The problem comes when I start the next block of code, be it another call to the function, or some other power-shell statement, vs-code indents it to the same depth as the last parameter. I don't have () or any of those characters, and I have to shift-tab a zillion times to get the new line of code back over where I want it. How do I get the editor to understand that it's really a new line/back to the old indentation level? If I put a # character in the first column then everything is back to OK.
Typing it in would lose the formatting issue and defeat the purpose, so I'm pasting in a pic. The code itself is trivial, the first Get-Item is in the wrong spot, the 3rd "SomeFunctionInSomeModule..." call is lined up wrong.

Trim Trailing Whitespace from ALL files in workspace

I know about the Trim Trailing Whitespace command in the pallette, and I know I can run this on save.
Is there a way to trim trailing whitespace on ALL files in a workspace (either with some command combo, or a way to run "save" on every file)
I have seen other answers on how to trim trailing whitespaces using Unix tools, but I would rather use the built in tool from VSCode specifically. (I would accept an answer that shows how to do this in another GUI text editor like Sublime Text also).
I would prefer not to have answers that use Terminal or other Regex matching--I would prefer to use the exact algorithm that is used by GUI tools already, since I trust that they will do the thing I expect. I will be running this on potentially thousands of files, so mistakes could easily go through even after audit.
I am basically trying not to open every file and ⌘+S it manually.
I am on macOS if that changes anything (but I doubt it matters)
This can be done using the search-and-replace function (keyboard shortcuts given below are for Linux, likely similar to what exists on a Mac):
Ctrl-Shift-H (open the search-and-replace side panel)
Type +$ in the Search field (that is a space, a plus and a dollar, meaning one or more spaces anchored at the end of the line)
Click the .* regular expression button next to the Search field
Leave the Replace field empty
Press Ctrl-Alt-Enter (or press the Replace All button next to the Replace field)
Click Replace (or Alt-R) in the confirmation pop up which also tells you the number of occurrences and files that will be touched
Be careful, as a wrong search or replace argument can mess up many files all at once!

Go up one command instead of one line in IPython 5

IPython 5 is a big release. One of its features is real multi-line editing with prompt_toolkit. The up arrow key now moves to the previous input line instead of the previous input command (block of lines).
This is awesome, but when my previous command spans many lines, and I need to reach the command before that, I find myself wishing I could go up one command at a time. Is there a way to do that? The shortcut ctrlp has the exact same behaviour as the up arrow key, so it does not provide a solution.
On my own Belgian Mac keyboard, fnshift↑ does the job. But I cannot tell whether this also works for other locales.
The PageUp and PageDown keys do exactly what you want without any chorded hotkeys involved; they work on an entry-oriented basis, rather than the arrow keys' line oriented approach.

Ansi-coloured file editing

Context
Have some transcript files from terminal interaction, obtained using traditional Unix command "script".
Those transcripts contain lots of control character (like backspace when editing shell commands), and lots of color code sequences as result of running various commands. Occasionally, even colorful full-terminal (ncurses-based) applications like "emacs -nw" or "aptitude" were run.
At program runtime, TERM environment variable was set as "xterm".
Need 1: read (more or less solved)
I need to read those files again and sometimes copy-paste some small parts.
The trouble is : while one color change here and there is not so much of a problem, their actual density makes the output barely readable. Worse, edited command lines (with cursor jumps and edited words) are completely unreadable.
"Okay" solution
Browse through files using e.g. "less -r". Paging forward in the same terminal setup reproduces the various color and character style.
But many other features come out more or less broken, e.g. search backwards produces jumbled terminal output, often have to pres "Ctrl-L" to clean thing up.
Need 2: editing
My preferred editor is emacs. Some people have had a similar situation when running the shell inside emacs, e.g. Something wrong with Emacs shell.
Here is not the same situation. Examples of differences: here we don't have to run an actual shell, but we need to move cursor freely like in usual editing.
Editing here means easily open such a transcript file in editor and then:
at all times through editing, see character changes (color, attributes) as conveyed by the terminal codes
(optional) some character that are neighbour on the terminal grid but are separated in file by some control characters would have a visual hint about this
ability to insert some text,
delete sections,
use all editor features like search/replace etc.
copy & paste to & from file (including to external programs, which would receive just plain text)
in my wildest dreams, some kind of "flatten" action, like select a sequence with a heavily edited command line and replace it with a simple series of characters as if it was typed in one run. "Visual hints" mentioned above would disappear.
Type Alt-: to evaluate something in the minibuffer. Evaluate (ansi-color-apply-on-region (point-min) (point-max)) and it will convert ansi color codes to be font colors.

Multiline sentence in emacs

If I have a multiline sentence in Emacs it naturally overflows onto the the following lines. Now, if my cursor is at the beginning of such a sentence and I press the DOWN ARROW key, the cursor is placed at the beginning of the next sentence (which might be at 4-5 lines down), rather than on the next line itself (which other editors do). Same is the behavior of the END and HOME keys.
Is there a way in which I can change this behavior and get the cursor on the next line instead of the next sentence?
I haven't yet tried it myself, but I think what you are asking for is the default behavior for emacs 23. What version are you running?
You might want to check out the page Move By Visible Lines page on the emacswiki.
You might want to try auto-fill-mode or longlines-mode. To get either use M-X then type the command you want. Toggle them off the same way.
If that doesn't work you may want to examine the binding that is being applied to your down arrow. Type C-h k then hit the down arrow key.
It sounds as though the text is wrapping, so by definition (a line being a group of characters separated by a carriage return), it is moving down to the next line.
I agree it is a pain, however a lot of other editors also have this behaviour.
One way is to turn off wrapping:
M-x toggle-truncate-lines
You wont be able to see all of the text in the editor, however it will move down to the next line.