Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I can select all file by going to the 1st line Alt+\, start marking the text by Alt+A, go to the last line by Alt+/

But there, I don't know which key to remove the selected text. Hit delete doesn't work for me but Ctrl+K to cut the text will destroy my clipboard.

So, what is the hotkey to delete selected text?

share|improve this question

nano does not support deleting a block of text, only cutting it (to the server's clipboard).

Instead, if you are using Putty, do the following:

  1. Select the text you wish to copy to the clipboard with the mouse first -- this copies it to your local clipboard (i.e. Windows 7 clipboard), which nano can't touch:

    enter image description here

  2. Then, select your block in nano and use Ctrl-K to delete it.

  3. Finally, move your cursor to the position where you want to insert the text you copied in Step 1 (you can close nano, open another file, etc. too as long as you don't select another block of text with the mouse). Right-click to paste the copied text at the cursor position.

share|improve this answer
2  
This doesn't work for long lines. The moment you see that $, the line will be truncated. – NightKnight on Cloudinsidr.com Feb 22 at 20:07

nano of course can delete blocks, see this article

  1. use CTRL+Shift+6 to mark the beginning of your block
  2. move cursor with arrow keys to end of your block, the text will be highlighted.
  3. use CTRL+K to cut/delete block.

To paste the block to another place, move cursor to the position and the use CTRL+U. You can paste the block as often as you want to.

share|improve this answer

Sadly, nano doesn't seem to have any way of bulk-deleting without clobbering the clipboard.

The safest thing to do while staying within the document is probably to paste your clipboard before deleting, then re-cut it again afterwards.

If you have a block of text already selected, then Ctrl+U will paste the text, including it in your selected block. You can then unmark the pasted text and just cut your originally selected block.

These steps don't preserve your clipboard, exactly, but at least effectively perform a swap between your selection and the clipboard, allowing you to re-cut the lines you had in there before.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.