Destructive backspace in vi - editor

How do I make the default backspace/^H destructive in vi (not vim)? The cursor jumps to the left as it should, but changes aren't applied until I switch modes. i.e. it deletes the text, but this isn't visible until hitting ESC.
This has been giving me a headache for a while, is there any way to fix this?

This probably is an issue with the terminal. In any case, keeping the spirit of vi, you should not be using backspace or delete. Prefer X or x to achieve the same functionality.

Related

Disable touch scrolling in xterm.js

How can I disable scrolling by touch on xterm.js?
I have a touchmove event on term.element that simulates cursor keys by swiping the appropriate direction. This works great in applications such as Midnight Commander that use the "alternate screen buffer", but in the default screen buffer that has scrollback (i.e. lynx or bash, for example), it scrolls the terminal (as it normally would) in addition to sending the ansi codes for the arrow keys.
I need to override this behaviour so scrolling does not happen when you swipe, without preventing scrolling by other means such as the mouse-wheel or the scrollbar, or interfering with other mouse events (and possibly touch events).
Tried preventDefault() on the event, even tried attaching it to various elements within the terminal, parentNode, and its parentNode. Same behaviour. Also tried position: absolute with bottom: 0px, but the way xterm.js simulates a terminal makes for abberant results.
Any ideas?
Ok. The solution is: add event.stopPropagation() at the top of the handler for the touchmove event. Attach it to the terminal element (i.e. term.element). Forget the overlay, pointer-events: none, etc. Works perfect. No additional garbage. I left in event.preventDefault() for another reason, but I think just the stopPropagation stands alone for this particular question.
I would like to add, if you just want to disable touch scrolling on the terminal all you need is:
term.addEventListener('touchmove',function(e){e.stopPropagation()});
Assuming your terminal object's name is 'term'.

Delphi XE3 Ctrl+Z undo caret movements too

I'm new to Delphi and I've found some strange behaviors of Rad Studio XE3 code editor.
E.g., when i press the undo shortcut (Ctrl+Z), the editor does not undo just the last code editing, but also latest caret movements. I mean: when I open a unit and I browse through its code, it happens that I go clicking around, without editing the code. Well, if I press Ctrl+Z, the caret will move back to all points where I've been clicking before. I was expecting nothing to happen when I press Ctrl+Z, if no edit was performed!
There is a way to deactivate this feature?
I've CnWizards_1.0.0.638 installed.
Thanks.
You cannot disable that behavior completely, but you can reduce its effect. Turn on the group undo editor option. Then all consecutive cursor movements will be grouped into a single action. Other types of consecutive actions will be grouped together, too, but I don't recall that being an issue for me.
Moving the caret when performing undo of edit actions is very much by design. This is for sure not strange behaviour and all editors behave this way.
If the caret was not moved, and the window now scrolled, you would have absolutely no feedback that an undo event had occurred. For instance, the edit that you undo could perhaps be in code that is not currently visible. For sure in plain Delphi there is no way to change the behaviour and I'd be astounded if any plugin offered such functionality because it would render the undo functionality completely unusable.
Perhaps what you want to do is to undo some changes, and then return to where you were in the edit window before performing the undo operations. Well, the way to achieve that is to drop a bookmark, perform the undo, and then jump to the bookmark.

Editor to select text that is inside a rectangle

Often I find myself with some text where I want to exclude a certain part of the text, say the first three characters of 40 lines. The fastest way I could think of to do this would be to draw a rectangle and copy the text. I am mostly using Windows, but I am sure grep or something similar could do this with a tiny bit of code. My best way of doing this is to open Command Prompt. Then run "Edit" (yes the good old one). Then paste the text in there (this actually takes a significant amount of time). Then I am able to select the rectangle I am after.
Is there any other editors that support this feature? I am familiar with Notepad++.
You can select a rectangular area to cut/copy in Visual Studio be pressing the Alt key prior to making your selection with the mouse or (Shift +) cursor keys. See How to: Select and Change Text.
The Zeus editor can do keyboard driven column cut/copy and paste.
Also the default Zeus mouse marking is in column mode.
If you use Vim, Ctrl + V will let you select a rectangular block of text.
The documentation says Ctrl + Q will let you do a rectangular select in mswin compatibility.
Emacs supports kill-rectangle (bound to C-x r k by default) and yank-rectagle (C-x r y) to achieve this. Also of possible interest is delete-extract-rectangle (no default binding, and intended for programming use).
You use it by navigating to one corner of the interesting area, hitting C-<space> to set the mark, navigating to the opposite corner, and invoking the desired function.
UltraEdit has a column mode (menu Column/Column Mode, keyboard
shortcut Alt + C). This makes it possible to make block selections, delete, insert column-wise, etc. using only the keyboard (the mouse works too).
For your example: make a zero width selection at column position 1 for the 40 lines and press Delete three times. Or simply make the 3 x 40 block select and press Delete.
You can do this with NEdit (which is available for Windows). Hold down Ctrl and drag the mouse (left-click) to select rectangles.
In Linux, you could also just use cut:
cut -b4- file
It will remove the first three characters from every line and print the result to standard output.
jEdit supports vertical selections (keyboard shortcut is Alt + \). It can also do multiple, non-continuous selections (keyboard shortcut is Ctrl + \). And when you type it affects all selections, so you can edit multiple lines at the same time, or the same line in more than place simultaneously. Or both.
Vertical pasting is also supported. This is a feature I use all the time. It makes editing columns a breeze.
If you have too many lines to select easily, then jEdit's Find And Replace is as good as it gets.
jEdit is a Java application, and so uses more system resources than most editors. But on the other hand it works on most systems, and it has loads of plug-ins to make editing text more efficient.
This can be done using JGSoft's Editpad which has a freeware lite version that is not crippled.
In IntelliJ, go to Edit and then click on Column Selection Mode. Or use the ALT+SHIFT+INSERT shortcut.

Why is TextMate treating two spaces as a single character?

When I enter two spaces into TextMate 1.5.7, under certain circumstances it seems to treat the two spaces as a single character..
For example when typing ("[space][space]")
(" |")
\_ the cursor
If I then press backspace, both spaces get deleted, and if I press the left arrow it jumps both spaces (which is surprisingly annoying)
It's nothing to do with my soft-tabs setting (which is set to 4 space soft-tab).. Has anyone else noticed this?, or is it something strange with my configuration (unlikely as it happened with a clean install, on a new OS install)?
I've since updated to v1.5.8, and the issue remains.
The double spacing is caused by soft tabs. At the bottom of Textmate where the column indicator, line indicator, file type, and tab size indicators are, click on the soft tabs drop down and click soft tabs to turn it off.
Consider that textmate is an editor for programmers. in most programming languges the number of spaces doesn't matter, so it doesn't seem to me that strange.
Anyway, I use 1.5.8 and I don't have this problem. I also looked in the configuration window and I can't see anything about it.

Seeking a way to have a "Hover button" to expand a section

i have a flow panel that i'm adding extra items to it at runtime based on whether they have chosen to show all the items. that's all works fine; the expansion is controlled by a toolbar button.
the trouble is we'd like the user to be able to move his mouse over the "+" sign to expand the section.
initially i looked at TSpeedButton (OnMouseEnter) but even when it's "Flat", the focus rectangle still shows and so the glyph isn't centered. the main problem with this solution is it's appearance.
then i looked at making a descendant of TImage. that's a bit "unconventional" but it'd work. in OnMouseEnter or OnClick, it'd toggle an internal boolean "Expanded" flag and then load the appropriate picture from a resource. i have a dislike for unconventional solutions like that.
i need to add it to a few different screens so it's probably prudent for me to have/build a component for this. i have JVCL but i don't see anything suitable offhand.
thank you for your comments/help!
I always liked the approach used by the ModelMaker Code Explorer.
For example, when you're adding a new method, some rarely-used stuff is displayed collapsed ('Options and Directives' in the image below).
(source: 17slon.com)
When you hover over the text, you notice that it's actually a flat button. (Except that it's not - I believe Gerrit does some custom painting magic here).
(source: 17slon.com)
When you click this button, a panel appears. Button is still there, but with a new image. You can click it to close the panel.
(source: 17slon.com)
The state of this toggle button is preserved between sessions. IOW, even if you restart the Delphi, next tima you invoke 'Add Method', the 'Options and Directives' panel will appear exactly as you left it the last time.
i have a dislike for unconventional solutions like that.
Over the past few years, I have grown a bit suspicious of unconventional UI solutions — which is what you seem to be creating here. Why not just use a button that the user actually has to click? That seems to be much more common in the software I use, be it MS Office or programming utilities. Also, I'd make the button somewhat larger: in the screenshot, it really seems like a tiny little thing you have to target with your mouse cursor. Oh well, and if I'm bugging you with advise you haven't asked for anyway, why not give it ">>" as a caption instead of "+"? And if you'd give it a textual caption with a mnemonic as well, it'd actually be keyboard accessible. All this should make your UI better and more intuitive. I guess.
I do apologize for not answering your question, but I hope you'll spend 2 minutes thinking whether your users would actually prefer this solution :-)
Good luck!
Actually, I think that using a TImage in this situation is pretty conventional. I have seen many people suggest using the TImage, when either the TButton, or any of its associates did not have the right amount of control for whatever the developer was trying to do.
Have you tried a TBitBtn? I think when you get rid of the text it centers whatever image you have associated with it. I just checked in Delphi 6, all I have installed on this machine, and it had the MouseMove event.

Resources