How to use the delete key in Vim when you are reading input - input

So, when I am taking input in Vim, like this:
line = input("> ")
I am not able to press the delete key in Vim. If I do, it enters some weird characters: ^H^#b. I also can't press any other keys besides letters, numbers, and characters. Any idea if you can stop this?
Thanks!

Related

SendKeys.send is sending a key, but the application is not interpreting this key as a command

I'm using SendKeys to send key strokes to a program.
This is my code:
If whandle <> 0 Then
User32.SetForegroundWindow(whandle)
System.Windows.Forms.SendKeys.Send("+")
End If
(I tried also SendWait() instead of Send())
This is my window hierachy shown by Spy++:
Althoug I can find window handle by title and loop through childs with User32.FindWindowEx, when debugging I just enter window handle as shown by spy++ (converting from hex to decimal) and I find that:
Correct window is found and brought to front.
But nothing happens with this particular program, called MetaTrader (if I use a notepad window keys are written in notepad).
So I guess I have one of these problems:
I'm doing something wrong with windows and subwindows (I don't really think this is happening as I tried all handles shown by Spy++).
SendKey("+") is not exactly like pressing the "+" key when window is active and there is some difference.
After calling to User32.SetForegroundWindow(whandle) if I really press the "+" key the desired effect happens, which is a zoom in, but not when it's my program doing SendKeys. I tried also with other keys that produce commands, like Q or A (all of them simple keys and letters).
From MS Docs
The plus sign (+), caret (^), percent sign (%), tilde (~), and
parentheses () have special meanings to SendKeys. To specify one of
these characters, enclose it within braces ({}). For example, to
specify the plus sign, use "{+}"
System.Windows.Forms.SendKeys.Send("{+}")

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.

How to paste text to end of every line? Sublime 2

I'm curious if there is a way to paste text to the end of every line in Sublime 2? And conversely, to the beginning of every line.
test line one
test line two
test line three
test line four
...
Say you have 100 lines of text in the editor, and you want to paste quotation marks to the beginning and end of each line.
Is there an easy way to do this or a plugin that anyone would know of? This would often save me a lot of time on various projects.
Thanks.
Yeah Regex is cool, but there are other alternative.
Select all the lines you want to prefix or suffix
Goto menu Selection -> Split into Lines (Cmd/Ctrl + Shift + L)
This allows you to edit multiple lines at once. Now you can add *Quotes (") or anything * at start and end of each lines.
Here's the workflow I use all the time, using the keyboard only
Ctrl/Cmd + A Select All
Ctrl/Cmd + Shift + L Split into Lines
' Surround every line with quotes
Note that this doesn't work if there are blank lines in the selection.
Select all the lines on which you want to add prefix or suffix. (But if you want to add prefix or suffix to only specific lines, you can use ctrl+Left mouse button to create multiple cursors.)
Push Ctrl+Shift+L.
Push Home key and add prefix.
Push End key and add suffix.
Note, disable wordwrap, otherwise it will not work properly if your lines are longer than sublime's width.
Let's say you have these lines of code:
test line one
test line two
test line three
test line four
Using Search and Replace Ctrl+H with Regex let's find this: ^ and replace it with ", we'll have this:
"test line one
"test line two
"test line three
"test line four
Now let's search this: $ and replace it with ", now we'll have this:
"test line one"
"test line two"
"test line three"
"test line four"
You can use the Search & Replace feature with this regex ^([\w\d\_\.\s\-]*)$ to find text and the replaced text is "$1".
Use column selection. Column selection is one of the unique features of Sublime2; it is used to give you multiple matched cursors (tutorial here). To get multiple cursors, do one of the following:
Mouse:
Hold down the shift (Windows/Linux) or option key (Mac) while selecting a region with the mouse.
Clicking middle mouse button (or scroll) will select as a column also.
Keyboard:
Select the desired region.
Type control+shift+L (Windows/Linux) or command+shift+L (Mac)
You now have multiple lines selected, so you could type a quotation mark at the beginning and end of each line. It would be better to take advantage of Sublime's capabilities, and just type ". When you do this, Sublime automatically quotes the selected text.
Type esc to exit multiple cursor mode.
Select all lines you want to add a suffix or prefix.(command+ A to select all the lines)
Press command+shift+L. This will put one cursor at the end of every line and all the selected lines would still be selected.
For adding suffix press command+right and for adding prefix command+left. This will deselect all the earlier selected text and there will only be cursors at the end or start of every line.
Add required text

TextMate: How do I move my cursor out of the quotations without using the arrow keys?

I was programming in PHP and typing mysql_connect, and by default the single-quotation is automatically closed, so I would have something like this mysql_connect('localhost[cursor is here]'). I still need to type my username and password, it just seems really out of the way to press the right arrow key to escape the single-quotations for writing the other arguments (username/password). Is there a hot key similar to ctrl+enter that can help move my cursor out of the quotations but not to the next line?
I often use Cmd-Right Arrow to move the the end of the line. I also make heavy use of Opt-Right Arrow and Opt-Left Arrow to move words at a time instead of characters.
My solution to this was to record my own macro; it moves the caret to the right, inserts a comma and then a space. I've mapped the macro to command and < (shift and comma). Activating the macro on your code results in:
mysql_connect('localhost', [cursor is here])

Incremental paste plugin?

I know that often using a for loop to generate repetitive content is the better way than pasting something 20 times and changing each paste to the correct number by hand. But let's say for cases where content is hard-coded and I just want a list from 1-20.
I would like a text editor with a "smart" paste command that takes any number imbedded in a string on the clipboard and increments it each time I paste. If it doesn't exist, I will make a plugin.
I'm trying to think of a good 2-stroke keyboard shortcut to do it, close to the ctrl-V. Maybe ctrl-g or numpad_+ (in an app with no zooming).
Does it exist?
In Zeus this can be easily done as follows:
Column mark the area to be converted to a numbers
Use the Macros, Execute Script menu
Type in numbers to run the numbers Lua macro
Type in the first number of the sequence
The marked area will be replaced by an incrementing sequence of number starting at the first number provided in step 4.
I'm trying to think of a good 2-stroke
keyboard shortcut to do it,
Making this into a key stoke action is as simple as binding the numbers Lua macro to the keyboard.
Here is an example of how it works. If 1 values in the text below are column marked and the macro executed with a starting number of 1000:
Field_1
Field_1
Field_1
Field_1
the following text changes will be made:
Field_1000
Field_1001
Field_1002
Field_1003
Armed bear J has a renumber region command, as well as a case-preserving replace-in-files, which means I often keep it around for those features.
TextPad is another text editor with a Fill Region function, for filling with a character, a string, or incrementing numbers (starting from X, with left- or right-alignment, and space- or zero-filled.)
I used Notepad++ now, but I have to keep TextPad around just for that number-filling function.