((@))
home
users
pictures
movies
motorcycles
role playing games
other resources
the downward spiral

tcsh tips


tcsh command line shortcuts


On Thursday, May 31, 2001, at 11:10 PM, chad wrote:

> quick question,
>
> if i mistype a command, how can i clear the entire line without
> deleting each character one-by-one?
> i'm using tcsh

Man pages are your friends.

[rei:~] rmohns% man tcsh
[--snip stuff--]
   The command-line editor (+)
       Command-line  input can be edited using key sequences much
       like those used in GNU Emacs  or  vi(1).   The  editor  is
       active  only when the edit shell variable is set, which it
       is by default in interactive shells.  The bindkey  builtin
       can  display  and  change  key  bindings.  Emacs-style key
       bindings are used by default (unless the  shell  was  com-
       piled  otherwise;  see  the  version  shell variable), but
       _bindkey_ can change the key bindings to  vi-style  bindings
       en masse.
[--snip more stuff--]

[rei:~] rmohns% bindkey | less
"^@"           ->  set-mark-command
"^A"           ->  beginning-of-line
"^B"           ->  backward-char
"^C"           ->  tty-sigintr
"^D"           ->  delete-char-or-list-or-eof
"^E"           ->  end-of-line
"^F"           ->  forward-char
"^G"           ->  is undefined
"^H"           ->  backward-delete-char
"^I"           ->  complete-word
"^J"           ->  newline
"^K"           ->  kill-line
"^L"           ->  clear-screen
"^M"           ->  newline
"^N"           ->  down-history
"^O"           ->  tty-flush-output
"^P"           ->  up-history
"^Q"           ->  tty-start-output
"^R"           ->  i-search-back
"^S"           ->  tty-stop-output
"^T"           ->  transpose-chars
"^U"           ->  kill-whole-line
"^V"           ->  quoted-insert
"^W"           ->  kill-region
"^X"           ->  sequence-lead-in
"^Y"           ->  yank
"^Z"           ->  tty-sigtsusp
"^["           ->  sequence-lead-in
"^\"           ->  tty-sigquit
"^]"           ->  tty-dsusp
" "  to "/"    ->  self-insert-command
"0"  to "9"    ->  digit
":"  to "~"    ->  self-insert-command
"^?"           ->  backward-delete-char

[--snip--]

So your options are Control-A, Control-K (go to beginning of line, kill
to end of line), or Control-U (clear line).  Either one performs a kill
(a cut operation), and you can paste with Control-Y (yank from buffer). 
(This "cut/paste" only works inside the current shell, not the system
clipboard!)

Useful stuff.  For instance, you can mark the start of a region with
Control-@ (control-shift-2), arrow to extend it, Control-W to kill
region, move elsewhere and then Control-Y to yank it back.


downwardspiral.net © 2001–2007 robert mohns