How to delete selected text in nano editor?

66,261

You can't select with mouse and delete text using nano editor. For faster delete you can use Ctrl + K to delete(cut) the present line of text.

Note : Ctrl + K will cut the line of text. Using Ctrl + U you can paste it.

EDIT: Additional Info from steeldriver

You can select and cut something other than the current line using Ctrl-^ to mark the start of the text, then advancing the cursor e.g. using Ctrl-F (forward one character) and/or Ctrl-Space (forward one word) and/or arrow keys, and then pressing Ctrl-K

Share:
66,261

Related videos on Youtube

vaibhav
Author by

vaibhav

Updated on September 18, 2022

Comments

  • vaibhav
    vaibhav over 1 year

    How do I delete selected text in the nano editor?

    I came across this issue while needing to delete the virtual host file and replace its content completely by other content. But the problem is that I can't select and delete the entire text at once. And if I delete it character by character, it won't be a computer thing.

    • vaibhav
      vaibhav almost 10 years
      No, It's not duplicate. I am particularly asking for deleting the selected content that is not available on link you are saying to be duplicate of.
    • A J
      A J almost 10 years
      your question seems to me like problem in editing a text, now I can understand that you are asking about selecting text using mouse and delete... see my answer...
  • steeldriver
    steeldriver almost 10 years
    You can select and cut something other than the current line using Ctrl-^ to mark the start of the text, then advancing the cursor e.g. using Ctrl-F (forward one character) and/or Ctrl-Space (forward one word) and/or arrow keys, and then pressing Ctrl-K
  • precise
    precise almost 10 years
    like @steeldriver said.. that's how you delete in nano! First set the mark with Ctrl + ^, then select with arrow keys, use the cut Ctrl + K and to delete, don't follow that by a paste Ctrl + U;) To copy the key combo is Alt + ^
  • Wilf
    Wilf almost 10 years
    So is the simple answer 'hold down the Backspace/Delete key?' :) +1 Very useful
  • itsazzad
    itsazzad over 8 years
    like @steeldriver said.. for selection you can use SHIFT+ARROW to move any direction. And for Mac or if Ctrl-^ not work then CTRL+SHIFT+^ should work.
  • nathangiesbrecht
    nathangiesbrecht about 8 years
    Also, you can enable the mouse in Nano if invoked with -m option or set mouse in ~/.nanorc You can set the mark with the mouse with a double-click.