I want to make keybinding that simply clears everything I entered after prompt and till the end. The same behavior as what Ctr+c does, but without appending ^C character to the end of current line and newline. Is it doable somehow?
You probably want Ctrlu and/or Ctrlk
Ctrl-u kills characters from your cursor to the start of entry (the prompt)
Ctrl-k kills characters from your cursor to the end of the line.
The deleted characters can be pasted (yanked) with Ctrly
Try this:
function clear_to_end
commandline (commandline --cut-at-cursor)
end
bind \cc clear_to_end
This sets the command line to the current command line, truncated at the cursor.
Related
Is there a way to quickly delete an entire query that I've been typing?
To clarify, this would be a query I'm still typing, not something that's currently running.
For example in bash, you can hit CTRL+C and it kills your current line, like:
$ typing some comman<CTRL-C>
After pressing CTRL+C it stops the previous stuff I have typed without executing.
It's just a thing I'm used to doing for quickly switching trains of thought ("oh what if I do this instead of this?"), but CTRL+C in the postgres terminal just terminates the process.
Aa alternative to Ctrl+C is Ctrl+ACtrl+K. While Ctrl+A moves the cursor to the beginning of the current line, Ctrl+K deletes all characters after the cursor.
This can be used in bash or many other UNIX commands, too.
In emacs 24, is there a built-in hotkey to destroy a line when the cursor is located at the end of the line without having to move it at the beginning of the line? C-k works only when the cursor is at the beginning of the line.
Ctrl-Shift-backspace removes the whole line, wherever the cursor is.
It does not appear to work in xterm, but works with Gtk front-end.
http://www.gnu.org/software/emacs/manual/html_node/emacs/Killing-by-Lines.html
How can I delete the current line in Emacs?
In addition to C-S-backspace (kill-whole-line) as jamieguinan mentions, you can give kill-line a prefix argument of 0 (i.e., type C-0 C-k) to kill the portion of the line preceding point.
For example, place point at the beginning of a line with the text "foo bar". Then M-d C- C-e M-C-w C-w C-y produces " barfoo". This behaviour causes problems when I try to switch the order of text and when I combine a real kill with save-as-kill. No doubt prepending is often useful, but all the documentation I have found says that append-next-kill appends. How do I control emacs's choice between appending and prepending?
See the Emacs manual, node Appending Kills. It gives explicit examples, in particular an example that shows clearly what C-M-w is for and what it does. Here is part of that text:
If a kill command is separated from the last kill command by other
commands (not just numeric arguments), it starts a new entry on the kill
ring. But you can force it to append by first typing the command
`C-M-w' (`append-next-kill') right before it. The `C-M-w' tells the
following command, if it is a kill command, to append the text it kills
to the last killed text, instead of starting a new entry. With
`C-M-w', you can kill several separated pieces of text and accumulate
them to be yanked back in one place.
For C-M-w to append the next kill, that kill must immediately follow C-M-w. If you do something else in between then there is no appending. The command name might better have been append-next-kill-if-it-follows-immediately. ;-)
In Octave, when typing command in the command line, sometimes I need to erase the whole line and restart a new command. In Matlab, erasing the text would be done with the ESC key. In Octave this does not work. The only way I found to discard the input text is using Ctrl-C. This works, but it is ugly, as it leaves remains on the screen.
Is there a key combination to clear the line in Octave?
to clear the command window type:
clc
There are several clearing shortcuts defined:
Meta-D: clear the next word1
Ctrl-K: clear to the end of the line
Ctrl-U: clear the whole line
Ctrl-L: clear the line and the screen
See more examples in the octave command-line-editing section of the manual.
For historical reasons Ctrl-U is usually controlled by your terminal rather than octave, although octave also supports it. You can test this with stty kill undef (restore with stty kill '^U').
1 Meta is often bound to the Win key or the Alt key. If not hit the Esc key first and then the character that needs to be "metaified".
Ctrl-A: go to beginning of line.
Ctrl-K: kill all characters starting at the cursor.
I would like to execute a hotkey that would erase the current line in the powershell session. Is such a thing possible?
Esc works for me
Besides using Esc to clear the whole line, you can also use:
Ctrl+Home to erase from the current position back to the beginning, or
Ctrl+End to erase from the current position to the end.