LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-15-2012, 06:55 PM   #1
NeoLux
LQ Newbie
 
Registered: Dec 2012
Posts: 14

Rep: Reputation: Disabled
command line/tty/terminal delete/cut operations confusion (ctrl+u,ctrl+y etc)


Hi! I have some terminal confusion/desires I'd like to clear up.
For the most part everywhere I search and read the terminal shortcuts ctrl+u ctrl+k ctrl+w etc are described as "deleting" characters and in the output of stty -a ^U is typically assigned to something called "kill" and then of course there's the common knowledge that (on terminal) ctrl+y does something referred to as "yanking"(?) that prints back the characters that were deleted.
Now correct me if I'm wrong, but I often think of this behaviour more as "cutting and pasting", furthermore that's how I've been typically using these shortcuts recently. I often find myself then in the pickle of wanting to keep the last thing I cut or "deleted" in-tact while deleting a line.

So my short-form question would then be, how can I delete to the end of a line in terminal such as the behaviour received from ctrl+u and ctrl+k without disturbing the contents of ctrl+y? OR is there another cut/deletion method that stores it's own seperate content so I could then designate a cut/delete shortcut as my conceptual "delete-only" command? Also please I'm not interested in work arounds like "use the mouse right-click" I wanna do this in terminal-only, as in just my keyboard
 
Old 12-15-2012, 07:51 PM   #2
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Arch
Posts: 3,013

Rep: Reputation: 1225Reputation: 1225Reputation: 1225Reputation: 1225Reputation: 1225Reputation: 1225Reputation: 1225Reputation: 1225Reputation: 1225
If you are using bash, then these commands are provided by the readline library. You can read about it in Chapter 8: Command Line Editing. Unfortunately, there don't seem to be any functions that delete without adding to the kill ring. Fortunately, killing and yanking is slightly different than your typical cut and paste implementation in that you have a kill ring which saves multiple pieces of text that you've killed. After yanking the latest thing, you can go back through the ring with M-y (that's alt+y).
 
1 members found this post helpful.
Old 12-16-2012, 01:07 AM   #3
NeoLux
LQ Newbie
 
Registered: Dec 2012
Posts: 14

Original Poster
Rep: Reputation: Disabled
so there is absolutely no way to delete all the characters that doesnt change the latest thing on the kill ring? I notice that it's totally ok to delete one character with delete or backspace. is there any way to access/set the contents of what would be yanked from an executable script?
(I read the manual refreshing)
 
Old 12-16-2012, 11:13 AM   #4
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Arch
Posts: 3,013

Rep: Reputation: 1225Reputation: 1225Reputation: 1225Reputation: 1225Reputation: 1225Reputation: 1225Reputation: 1225Reputation: 1225Reputation: 1225
Quote:
Originally Posted by NeoLux View Post
so there is absolutely no way to delete all the characters that doesnt change the latest thing on the kill ring? I notice that it's totally ok to delete one character with delete or backspace.
Yeah, but if you pass a numeric argument to delete multiple characters it adds to the kill ring:
Quote:
backward-delete-char (Rubout)
Delete the character behind the cursor. A numeric argument means to kill the characters instead of deleting them.
Quote:
is there any way to access/set the contents of what would be yanked from an executable script?
The readline stuff only works in interactive mode, it's disabled in scripts.
 
Old 12-16-2012, 12:33 PM   #5
NeoLux
LQ Newbie
 
Registered: Dec 2012
Posts: 14

Original Poster
Rep: Reputation: Disabled
I suppose yank-pop will do..
would be useful if there were a variation of ctrl-u and ctrl-k that didn't add to the kill-ring but oh well
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] what is vi's equivalent to emacs' CTRL-x CTRL-r refresh command (bash) needsleep Linux - General 2 07-17-2012 12:31 PM
[SOLVED] Trying to access command-line tty1 with Ctrl-Alt-F1 jeriryan Linux - Newbie 1 06-16-2011 08:36 AM
[SOLVED] vim:ctrl+v command to select some data.But when I push ctrl+v.It doesn't work.. e3399 Linux - Newbie 20 12-07-2010 07:21 AM
ctrl+c & ctrl+v equivalent for Gnome terminal window? halfpower Linux - General 2 11-29-2005 03:57 AM
no ctrl-a or ctrl-z in emacs or on command line? ashlock Fedora 5 12-30-2003 09:00 PM


All times are GMT -5. The time now is 08:36 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration