Linux nano copy text

Nano: И всё-таки его придётся выучить [2]

Продолжаем. Предыдущий топик (навигация по тексту): тут.

Сегодняшняя тема — работа с выделением, копирование и удаление кусков текста.

Для понимания принципов команд работы с текстом нужно сначала понять принцип выделения текста. Он осуществляется либо мышью, либо с клавиатуры. С клавиатуры выделение происходит так: сначала отмечается начало выделение: Alt-A или Ctrl-^. Далее следует навигация — и до момента выполнения действия над текстом в буффере, выделение сохраняется (обратите внимание, выделение сохраняется даже при вводе текста, в этом оно сильно отличается от выделения в gui-приложениях windows и ближе к persistent blocks в TurboC, DN и соответствующей опции Far Manager’а).

Обратите внимание, применимы все функции навигации, включая переход по номеру строки или поиск (в следующих выпусках).

Далее выделенный текст можно удалить или скопировать в буффер. Это делает комбинация Ctrl-K (или F9 ).

Выделенный текст можно скопировать в буффер обмена — комбинация Alt-6 (да, мы ЛЮБИМ nano).

Далее мы можем вставить текст из буффера обмена — Ctrl-U или F10 . Обратите внимание — в подсказке снизу написана неправда, это не отмена удаления, это вставка.

Кроме этого, для удобства редактирования, Ctrl-K при отсутствии выделения удаляет строку. Либо целиком, либо от курсора до конца строки. Поведение переключается комбинацией Alt-K (по-умолчанию стоит режим удалять строку целиком, а Alt-K переключает его туда-сюда).

Обратите внимание — удалённая строка в буффере, так что её можно вставить с помощью Ctrl-U .

Ещё одна комбинация для лентяев — Alt-T , стирающая всё от курсора и до конца файла (команда trunkate).

Для вставки текста из другого файла используется кнопка Ins (думаю, все пользователи vim хорошо знают поведение этой кнопки в nano).

Источник

How to Cut, Copy and Paste Text in Nano editor?

While Nano is more beginner-friendly than Vim and Emacs, you still need to know the keyboard shortcuts for even the basic operations such as cut, copy and paste in Nano.

GNU Nano is an editor that has a minimal learning curve and hence is widely used for beginner-level guides.

That doesn’t mean that it is as easy to use for beginners as a graphical text editor. Why? because you still have to rely on the keyboard shortcuts to do the basic things such as save, undo, etc.

How about cut, copy and paste in Nano? Does it require specific keyboard shortcuts too?

Well, yes and no. You can use the mouse to copy-paste. There are also keyboard shortcuts for the same purpose. To cut, you must use shortcuts.

Читайте также:  Install linux on mac with parallels

Let me show all this to you in detail.

Copy text in Nano

To copy a piece of text, the text needs to be selected first.

There are two ways to copy the text in Nano:

Using mouse to select, copy and paste

If you want a quick and dirty selection to copy text, there is no better way than using a mouse to do it.

Below are the steps you can follow:

Once the text is copied to clipboard, to paste text using mouse, make sure that you have moved the cursor to the location where you want to paste text.

Then, do a right click, and select «Paste» from the context menu that popped up.

This is what you should do to select, copy and paste text using mouse.

Using keyboard to select and copy (for pros)

Using a mouse to copy text is all good, but when you have to select text that extends the page, it gets frustrating. For that, you will need to use a few keyboard shortcuts.

Below are the steps to select and copy text using keyboard:

  1. To select text, press the Ctrl + 6 key combination. You will see «Mark Set» appear at the bottom of the screen as an acknowledgement.
  2. Now, use the arrow keys (keys like Home, End, Page Up and Page Down can also be used) to select/highlight text.
  3. To copy selected text, press Alt + 6 key combination.

You now have the text copied to your clipboard!

Cut text in Nano

The cut operation is very similar to the copy operation, the only difference is that the data is deleted from one location to be moved to another location.

Unfortunately, cutting text cannot be done with the use of a mouse, so let’s go over the steps to follow if you want to cut text.

  1. Select text using the Ctrl + 6 key combination.
  2. Use the arrow keys to highlight the text you want to cut.
  3. To cut the selected text, press Ctrl + K (think of it as Kutting text).

That is all there is to kutting text 😀

Paste in Nano

Finally, after copying or cutting the text, it won’t be much of a use if you can not paste text.

Thankfully, pasting text in nano is very easy. Follow the steps given below:

  1. Move your cursor to the location where you want to paste text
  2. Press Ctrl + U

Nano shows the keyboard shortcuts at the bottom of the screen all the time. So, even if you forgot it, you can always look at the bottom of the editor for hints or press Ctrl+G for help. If it says ^K for Cut, use Ctrl+K (^ means Ctrl key). Similarly, if it says M-A for Append, use Alt + M (M means Alt key).

Copy-paste between Nano and the system

If you want to copy text from a web browser or other editor into Nano, use the Ctrl+Shift+V to paste the text into Nano.

Читайте также:  Linux mint usb ntfs

Similarly, if you want to copy some text from Nano to an external application, use Ctrl+Shift+C to copy the text and then the usual Ctrl+V to paste it.

When you use Ctrl+Shift+C/V keys, the text is copied into the system buffer and hence it can be used outside the Nano editor as well.

If you use the Nano specific keyboard shortcuts such as Ctrl+K etc, the text stays in Nano buffer. It cannot be accessed at the system level and hence you cannot use it outside Nano.

Conclusion

GNU Nano is a simple text editor that is known best for getting the job done without much fuss. This article covered the basics of copying, cutting and pasting text in Nano.

If you are interested in mastering the basics of Nano, try this free course on Nano.

Источник

How to Copy Text from Nano Editor to Shell

To cut or copy text in Nano editor, the Ctrl+K or Ctrl+6 shortcuts are used to cut and copy, respectively. These shortcuts do not copy the text to your GNOME clipboard. Instead, they copy the text only to a special cut buffer inside the Nano editor. You cannot paste the cut or copied text from the cut buffer to anywhere outside the Nano editor, including the shell.

This article shows you how to copy text from the Nano editor to the shell through the following two methods:

Both methods copy the text to the GNOME clipboard instead of copying the text to the Nano cut buffer. Using either of these methods, you can copy the text anywhere outside of the Nano editor.

We have tested the procedure in the Ubuntu 20.04 LTS Terminal. The same procedure can be followed in any other Linux distribution that has the Nano editor installed.

Method 1: Using Key Combinations

To copy text from the Nano editor and paste it to the shell, follow the steps listed below:

First, mark (select) the text in the Nano editor. Place the cursor at the start of the text and press Ctr+6. Then, use the right or left arrow key to mark the required text.

To copy the marked text, use the Ctrl+Shift+C shortcut.

To paste the copied text to the shell, use Ctrl+Shift+V.

Method 2: Using the Right-Click Menu

To copy text from the Nano editor and paste it to the shell, follow the steps listed below:

First, mark the text in the Nano editor by holding the left mouse button and dragging it to the right or left to select the text.

To copy the marked text, right-click the text and select Copy from the menu.

To paste the copied text to the shell, again, right-click the text and select Paste from the menu.

About the author

Karim Buzdar

Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. He blogs at LinuxWays.

Читайте также:  Restart php fpm linux

Источник

How to Cut, Copy and Paste Text in Nano Editor

The cut, copy, and paste file editing operations are key in the mastery of Linux file management. On a graphical text editor like LibreOffice Writer, the implementation of these file editing operations are a no-brainer.

However, the nano text editor offers some file editing flexibility not evident in graphical file editors like LibreOffice Writer. For instance, it is easier to navigate to various file paths and open them via the nano editor than it is to achieve the same objective using a graphical text editor.

This tutorial will show us how easy it is to achieve cut, copy, and paste text operations while using the nano text editor in Linux.

Problem Statement

For this tutorial to be interactive and well understood, we need a reference file for demonstrating the cut, copy, and paste operations we will be addressing through the nano editor.

Consider the following sample file:

Nano Sample File in Linux

Cut and Paste Text in Nano Editor

The implementation of the cut text operation can be interpreted in the following manner. The cut text operation deletes the highlighted line entry from the currently open file.

For instance, in the above open file, we can cut the line entry “I am a file called new_file.txt!” in the following manner.

The first step is to position the cursor on the line entry you wish to cut using the keyboard arrow key.

Position Cursor in Nano Editor

From here, use the keyboard key combination [Ctrl]+6 to mark the text selection starting point.

Mark Text Selection in Nano Editor

Now use the keyboard arrow keys to highlight the text you wish to cut.

Highlight Text in Nano Editor

To cut our text, we will use the keyboard key combination [Ctrl]+k .

Cut Text in Nano Editor

To paste our cut text, navigate to the file entry position where you would like to paste the cut text. It could be the same file or on another file opened by the nano editor.

Once you are at the right pasting position, use the keyboard key combination [Ctrl]+u to paste the cut text content.

Paste Text in Nano Editor

Copy and Paste Text in Nano Editor

Text copying operation only duplicates a highlighted line entry on a text file. To copy the text “I am a file called new_file.txt!” we will follow the following steps.

Position the cursor on the line entry you wish to copy using the keyboard arrow key.

Position Cursor Line in Nano Editor

Use the keyboard key combination [Ctrl]+6 to mark the text selection starting point.

Mark Text Selection in Nano Editor

Use the keyboard arrow keys to highlight the text you wish to copy.

Highlight Text in Nano Editor

To copy our text, we will use the keyboard key combination [Alt]+6 .

Copy Text in Nano Editor

To paste the copied text, navigate to the preferred file position and implement the keyboard key combination [Ctrl]+u .

Copy and Paste Text in Nano Editor

Once you are through with cutting or pasting your text, you can save (Ctrl+o) and exit (Ctrl+x) your file.

In our next article guide, we will address how to search and replace text in nano editor.

Источник

Оцените статью
Adblock
detector