Select, copy and paste text in nano, text editor in terminal

Those who use Vi (or Vim) always boast that if I saw it is much more powerful than dwarf, true but !, to a certain extent. Although nano is not as complete or powerful as vi / vim, it is not that poor man is maimed hehe.

Something that can be done in nano but not many know, is to select text, copy that text and paste it in another part of the file, here I will show you how to do this.

Terminal-icon

How to select text in Nano

To select with Nano we must press Other + A , then we will notice how with the direction arrows (left, right, up and down) we can point out what we want to select.

The Alt I indicate is the Left alt, the one on the right may not work depending on the keyboard combination they have defined.

To cancel the selection, press again Other + A . I show you a screenshot:

nan-selection

How to copy with Nano:

To copy we use the combination Other + 6 through which, if we have NOT selected anything, we will copy the line where we are located.

How to paste something copied into Nano:

To paste we will use Ctrl + U and where the cursor is, something that we previously copied will be pasted.

Select + Copy + Paste in Nano?

Suppose we want to select a text, copy it and then paste it, it would be like this:

  1. We push Other + A and using the arrow keys, we mark the desired text.
  2. We do not press again Other + A , but right there with that selected, we press Other + 6 to copy that marked.
  3. As you can see, pressing the copy keys lost the selection.
  4. We already copy it, now we go to the part of the file where we want to paste the previously copied thing, and with the cursor there we do: Ctrl + U
  5. Ready!

The end!

Well clearer nor the water hehe, I hope it is as useful as it is to me


The content of the article adheres to our principles of editorial ethics. To report an error click here!.

30 comments, leave yours

Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   elav said

    Next task .. column selection with Nano .. 😉

    1.    Giskard said

      Well, if you use the mouse and press CONTROL while making the selection, you can select in column mode. I suspect there must be a way to do it with keyboard only.
      So yes you can.

      1.    elav said

        The idea is to use only the keys.

      2.    anonymous said

        Huu that good !! pressing left control + left alt and selecting with the mouse, the selection is made in column mode… .this is fantastic, thank you very much for the information.

  2.   maykel said

    For vim is it the same?

    1.    KZKG ^ Gaara said

      No, with vim to copy you put:
      number-of-lines-to-copy

      For example assuming you want to copy 4 lines:
      4yy

      Then to paste you put p (lowercase) if you want to paste it below the current line, while if it is above the current one it is P (uppercase)

  3.   Gabriel Andrade said

    You can also copy (or rather cut) a complete line with Ctrl + K, and then paste it with Ctrl + U as well.

  4.   Luis Graciano said

    Thanks a lot…! Of enormous help as always ..!

  5.   nonamed said

    nano r00lz

    😀

  6.   sinnerman said

    nano?
    what is that?
    From the almighty and never wrong (?) Wikipedia:
    Nano (symbol n) is an International System prefix indicating a factor of 10 ^ -9 (nano = nine).

    Confirmed in 1960, it comes from the Greek νάνος, which means "dwarf."

    1.    mario said

      google took you the other way, Nano owes its name to being Pico's free brother, they both have their article.

    2.    Matías Olivera said

      Nano is a text editor for Unix-based systems, like GNU / Linux.

    3.    sinnerman said

      Again:
      Elder brother?
      what is that?
      VI GENTLEMEN OR EMACS… .but nano ???? ssssshhhhhh

  7.   faith said

    Select is not ctrl + 6 ???
    nano is a terminal editor, does this mean that all NANO commands also serve me in the terminal?
    And how is it to search in nano?

    1.    KZKG ^ Gaara said

      Select in Nano is Alt + A as I put in the post, anyway with Ctrl + G you get the help 😉

      1.    Franz said

        I think it is + practical to select with the left click and paste with the middle mouse click =)

        1.    KZKG ^ Gaara said

          When it is a server that does not have a graphical interface, that is, there is no mouse or anything like that, this is the only option

    2.    anonymous said

      I copy and paste with the mouse, it's easier ... I mark what I want to copy by holding down the left mouse button and dragging, then I go to where I want to paste and I press the central button of the mouse wheel.
      And if you do not have a mouse in the virtual consoles, you only have to activate it, it is the gpm service.
      The method explained here does not work for me, the left alt + a does not work for me, if you select with left control + 6.
      To search in nano it is with control + w and you write what you want to search, if you want to keep searching you keep pressing control + w and enter successively.

      1.    anonymous said

        Yes, it works ... I was the fool who did not do things well.

        1 - left alt + a and I drop them to indicate the starting mark from where I want to start copying
        2 - I move with the arrow keys marking what I want to copy
        3 - left alt + 6 I copy what is marked to the clipboard buffe (if you can call it that)
        4 - I move with the arrows to the place where I want to hit
        5 - left control + u paste the copied

  8.   Cristian said

    Years using nano, because I met it before I saw it and it takes less time to open than geany, wondering how the hell you could copy / paste into nano. Now I can die in peace.

  9.   neysonv said

    excellent, i had no idea

  10.   nex said

    KZKG ^ Gaara, nice post. which editor is more powerful and its difference between: easy editor, .. vi editor,… nano editor? , ... I would like to know how to skip the line and copy ... as well as go back in each editor mentioned.

  11.   Fer said

    It is worth clarifying:
    I don't really know for which version of linux (mine, Ubuntu 13.10) or for which version of Nano (mine, 2.2.6) but, in my case, the selection did not work. The command that worked for me was:
    Set check mark: CTRL + 6 (Not ALT + A, as this article indicates)
    The rest did work for me:
    Select: Move the cursor according to what you want to select.
    Copy: ALT + 6
    Paste: CTRL + u
    I hope someone will serve you.

  12.   sausl said

    very good
    I never started looking for how to copy and paste with nano

    now it's going to be easier for me to use nano when you don't have a graphical environment

  13.   mat1986 said

    Nano is love, Nano is life <3

  14.   HO2Gi said

    I do "tweet" with NANO, I love to say it knowing. It saved me time.

  15.   guybrsuh78 said

    Thanks for the article, it is not bad at all to start and clarify doubts when you have a file open and you are blank.

    1.    guybrsuh78 said

      Also, a useful piece of information, if you have, like me, the linux servers connected from windows by the Putty, or the MultiPutty to have several connections, and you want to paste from the windows clipboard:
      1 - In windows copy your text as usual.
      2 - In linux, you run nano and you go to the site you want to paste and you hit the right mouse button and paste everything.
      a greeting

  16.   Sterve said

    Thank you very much for the contribution brother, greetings.

  17.   Noobsaibot73 said

    Those commands do not work in my case, if you press ALT (Left) + A you open the top menu, to set the start mark (to be able to shade the text to be copied) you have to press Shift + ALT + A and then yes, put the starting mark and you can now shade… This system is slow and ineffective, put a mark, shade, final mark and then copy… With how easy it is to be able to shade with Shift + Cursors and then paste with CTRL + V… While not simplify, I prefer to shade, copy and paste with the mouse, it is faster and easier