- nano (Русский)
- Contents
- Установка
- Настройка
- Подсветка синтаксиса
- PKGBUILD
- Forth
- Фоновый режим
- Перенос текста
- Использование
- Специальные функции
- Советы и рекомендации
- Замена vi на nano
- Решение проблем
- Оконный менеджер перехватывает горячие клавиши
- nano — текстовый редактор
- Содержание
- Общая информация
- Опции использования
- Текст помощи nano
- Подсветка синтаксиса
- Ubuntu Documentation
- Introduction
- Installing Nano
- Using Nano
- Starting Nano
- Screen Layout
- Using The Mouse
- Using the Keyboard
- Opening, Saving, and Closing Files
- Opening Files
- Save and Save As
- Closing Files
- Editing Text
- Quitting Nano
- Resources
nano (Русский)
GNU nano (или просто «nano») — текстовый редактор с простым и интуитивно понятным интерфейсом, включающим в себя основные команды для редактирования текста. Nano поддерживает подсветку синтаксиса, конвертацию файлов DOS/Mac, проверку орфографии и кодировку UTF-8. Программа Nano (с пустым буфером) занимает в оперативной памяти менее 4 Мб.
Contents
Установка
Настройка
Вид, поведение и функции nano управляются посредством аргументов командной строки или настроек в файле
Пример конфигурационного файла находится в /etc/nanorc . Чтобы настроить nano, сначала скопируйте данный файл в
Продолжите настройку nano путём установки и/или отключения команд в файле
Подсветка синтаксиса
Nano поставляется с предопределенными правилами подсветки синтаксиса, заданными в /usr/share/nano/*.nanorc . Чтобы включить их, добавьте следующую строку в
/.config/nano/nanorc или /etc/nanorc :
Для получения улучшенной подсветки синтаксиса, расширяющей стандартные возможности, установите nano-syntax-highlighting или nano-syntax-highlighting-git AUR и добавьте следующий параметр в дополнение к вышеуказанному:
PKGBUILD
Сохраните https://paste.xinu.at/4ss/ в /etc/nano/pkgbuild.nanorc и включите его:
Forth
См. https://paste.xinu.at/wc17YG/ для получения конфигурации подсветки синтаксиса языка программирования Forth.
Фоновый режим
В отличие от большинства интерактивных программ, фоновый режим не включен по умолчанию. Чтобы изменить это, раскомментируйте строку ‘set suspend’ в /etc/nanorc . Это позволит использовать сочетание клавиш Ctrl+z для отправки nano в фоновый режим.
Перенос текста
До версии 4.0, в отличие от многих текстовых редакторов, nano автоматически вставлял перенос строки. Чтобы изменить это поведение, добавьте следующую строку в
Использование
Сочетания клавиш можно просмотреть из nano. См. справочные файлы nano онлайн с помощью Ctrl+g из nano или nano Command Manual (англ.) для получения полных описаний и дополнительной поддержки.
Специальные функции
Сочетания клавиш с наиболее используемыми функциями приведены на двух строках внизу экрана nano.
Их можно переключать следующим образом:
- Ctrl для включения сочетаний клавиш, основанных на ^
- Meta (обычно Alt ) или Esc для включения сочетаний клавиш, основанных на M-
Советы и рекомендации
Замена vi на nano
Чтобы заменить vi на nano в качестве стандартного текстового редактора при использовании таких команд, как visudo, задайте переменные окружения VISUAL и EDITOR , например:
Решение проблем
Оконный менеджер перехватывает горячие клавиши
Некоторые оконные менеджеры используют сочетания клавиш, конфликтующие с nano, например, Alt+Enter . Удалите и переназначьте их, к примеру, на Super (с помощью dconf для mutter , muffin и marco ) и перезапустите оконный менеджер.
Источник
nano — текстовый редактор
Содержание
Общая информация
nano 1) — консольный текстовый редактор для Unix и Unix-подобных операционных систем, основанный на библиотеке curses и распространяемый под лицензией GNU GPL . В настоящее время включен в дистрибутивы Ubuntu по умолчанию и в установке не нуждается.
Чтобы запустить nano, следует открыть терминал и выполнить:
Опции использования
По стандартной команде, позволяющей получить справку по использованию программы, где можно просмотреть возможные опции открытия файлов и иные сведения, следует выполнить:
Получаем «выхлоп», приведённый ниже. Следует повторить, команда
— стандартна для всех консольных программ.
Текст помощи nano
Редактор nano разработан для эмуляции функциональности и простоты использования оригинального редактора UW Pico. Редактор разбит на 4 основные части: верхняя строка содержит версию программы, текущее имя файла, который редактируется, и были ли внесены изменения в текущий файл. Вторая часть — это главное окно редактирования, в котором отображен редактируемый файл. Строка состояния — 3 строка снизу — показывает разные важные сообщения. Две строки внизу показывают наиболее часто используемые комбинации клавиш.
Система обозначений комбинаций клавиш следующая: Комбинации с Control обозначены символом (^) 2) и вводятся при помощи нажатой кнопки Ctrl или двойном нажатии Escape Esc ; комбинации с Esc обозначены символом Meta m и могут быть введены при помощи кнопок Esc , Alt или Meta, в зависимости от используемой клавиатуры. Также, нажатие Esc дважды и дальнейший ввод трёхзначного числа от 000 до 255 введёт соответствующий символ.
Следующие комбинации доступны в главном окне редактирования. Альтернативные комбинации показаны в скобках:
Ctrl + G или F1 — Показать эту справку
Ctrl + X или F2 — Закрыть текущий буфер / Выйти из nano
Ctrl + O или F3 — Записать текущий файл на диск
Ctrl + J или F4 — Выровнять текущий абзац
Ctrl + R или F5 — Вставить другой файл в текущий
Ctrl + W или F6 — Искать текст или регулярное выражение
Ctrl + Y или F7 — Перейти на предыдущий экран
Ctrl + V или F8 — Перейти на следующий экран
Ctrl + K или F9 — Вырезать текущую строку и сохранить её в буфере обмена
Ctrl + U или F10 — Вставить содержимое буфера обмена в текущую строку
Ctrl + C или F11 — Показать положение курсора
Ctrl + T или F12 — Проверить орфографию, если доступно
m + \ или m + | — На первую строку файла
m + / или m + ? — На последнюю строку файла
Ctrl + _ или m + G — Перейти на указанный номер строки и ряд
Ctrl + \ или m + R — Заменить текст или регулярное выражение
Ctrl + ^ или m + Alt — Отметить текст в текущей позиции курсора
m + W — Повторить последний поиск
m + ^ или m + 6 — Копировать текущую строку и сохранить ее в буфере обмена
m + > — Увеличить отступ строки
m + < - Уменьшить отступ строки
Ctrl + F — Вперёд на один символ
Ctrl + B — Назад на один символ
Ctrl + Space — Вперёд на одно слово
m + Space — Назад на одно слово
Ctrl + P — На предыдущую строку
Ctrl + N — На следующую строку
Ctrl + Alt — На начало текущей строки
Ctrl + E — В конец текущей строки
m + ( или m + 9 — На начало текущего абзаца; потом следующего абзаца
m + ) или m + 0 — В конец текущего абзаца; потом следующего абзаца
m + ] — На соответствующую скобку
m + − или m + _ — Прокрутить одну строку вверх, не перемещая курсор
m + + или m + = — Прокрутить одну строку вниз, не перемещая курсор
m + или m + , — Переключить на предыдущий буфер
m + > или m + . — Переключить на следующий буфер
m + V — Вставить следующую комбинацию клавиш как есть
Ctrl + I — Вставить табуляцию в позиции курсора
Ctrl + M — Вставить строку в позиции курсора
Ctrl + D — Удалить символ под курсором
Ctrl + H — Удалить символ слева от курсора
m + T — Вырезать с текущей позиции до конца файла
m + J — Выровнять весь файл
m + D — Подсчитать количество слов, строк и символов
Ctrl + L — Обновить текущий экран
Ctrl + Z — Приостановить редактор (если включено)
m + X — Режим справки разрешить/запретить
m + C — Постоянное отображение положения разрешить/запретить
m + O — Использование дополнительной строки для редактирования разрешить/запретить
m + Shift — Плавная прокрутка разрешить/запретить
m + P — Отображение пробелов разрешить/запретить
m + Y — Подсветка синтаксиса разрешить/запретить
m + H — Умная кнопка home разрешить/запретить
m + I — Автоотступы разрешить/запретить
m + K — Вырезать до конца разрешить/запретить
m + L — Автоматическая разбивка строк разрешить/запретить
m + Q — Преобразование ввода табуляций в пробелы разрешить/запретить
m + B — Делать резервные копии разрешить/запретить
m + F — Несколько файловых буферов разрешить/запретить
m + M — Поддержка мыши разрешить/запретить
m + N — Без преобразования из формата DOS/Mac разрешить/запретить
m + Z — Приостановка разрешить/запретить
m + $ — Мягкий перенос строк разрешить/запретить
Подсветка синтаксиса
На удаленных серверах для правки конфигов можно использовать nano – быстрый, понятный, простой текстовый редактор, с подсведкой синтаксиса. Согласитесь, это очень удобно
1. Найдем, где в нашей системе находятся примеры файлов .nanorc. На Ubuntu они обычно в каталоге /usr/share/nano/. Скопируем к себе в каталог, файл конфигурации:
2. Добавим строчки в файл
/.nanorc (на Ubuntu примеры конфигурации идут в поставке) для подсветки необходимых нам файлов, если они отсутствуют в стандартном файле конфигурации:
3. Если этого мало, то берем Syntax Highlight Pack и настраиваем подсветку при редактировании всего и вся.
Источник
Ubuntu Documentation
Introduction
GNU nano is a simple terminal-based text editor. Though not as powerful as Emacs or Vim, it is easy to learn and use. Nano is ideal for making small changes to existing configuration files or for writing short plain text files. It was originally created as a free replacement for the non-free Pico editor. Pico is the terminal-based editor used in the Pine email suite from the University of Washington.
Nano can be used in a terminal window or at the system console.
Basic use of nano is covered here. If you want to learn more advanced techniques such as the use of multiple buffers or syntax highlighting of code, see the the nano project’s documentation.
Installing Nano
Nano is part of the standard Ubuntu installation, and should be on your system already. If for some reason it’s not, use your favorite package manager to install nano.
Using Nano
Nano is a terminal-based command-line program. Although not complicated or difficult to use, it is different than a GUI-based text editor such as gedit. The two main features that differ are the short-cut key combinations and the use of a mouse.
Note
This discussion refers specifically to the use of nano in a terminal window. Using nano at the system console is almost identical, with the main difference being the use of the mouse.
Starting Nano
To start nano with an empty file, open a terminal window and at the command-line type «nano» (without the quotes). For example:
nano
To open an existing file for editing, type «nano filename» where filename is the name of the existing file. For example, to open the file that contains the list of most recently issued commands, make sure you are in your home directory, and at the command line type «nano .bash_history» as in the following example:
nano .bash_history
In the above example, if the file .bash_history does not exist in your current directory, nano will start a new blank file and use .bash_history as the name for it.
Caution
Line wrap is on by default. When line wrap is on, nano inserts end-of-line characters into your file when it wraps lines to fit the width of the terminal window. Only lines that you type or paste into the window are wrapped. Existing long lines are not wrapped until you add new text to the line or use the Ctrl-J key combination to justify the current paragraph.
If you are using nano to edit configuration files, you probably do not want line wrapping to be on. To start nano with line wrapping off, use the -w switch, as in the following example:
nano -w .bashrc
Screen Layout
Figure 1: Default nano screen layout
The default nano screen layout is as shown in Figure 1. The bottom two lines show the key combinations for common operations. The ^ symbol represents the Control key on your keyboard. For example, use the Ctrl-G key combination to display a basic introduction to nano and its default screen layout.
The screen fonts and background colours are determined by your terminal settings. And when you resize the terminal window, nano adjusts itself accordingly.
Long lines that are not wrapped to fit the window are indicated by the $ symbol at the extreme right edge of the terminal window. The $ symbol is not part of your file; it just tells you that the line of text is too long to be displayed in the terminal.
Using The Mouse
By default, mouse services are provided by the terminal window. The mouse works almost the same as in a GUI editor. You can highlight text, right-click to copy and paste, and use the middle mouse button for pasting text from the buffer. However, when you use the middle mouse button to paste text, the text is pasted at the current cursor location, not at the mouse pointer location. Other limitations exist. For example, you cannot use the mouse to cut or delete text, nor can you use the mouse to scroll through the file.
Nano has its own built-in mouse services, but they are limited. They provide only the ability to move the cursor to the point where you click, and to mark the beginning and end of a section of text. Use the Alt-M key combination to toggle between using the terminal’s mouse services and nano’s built-in mouse services.
Note
If you are using nano at the system console, you must have gpm installed and running before using the mouse. The gpm package is in the Universe repository.
Using the Keyboard
Typing at the keyboard will insert text at the current cursor location. The Page Up and Page Down keys, the Arrow keys, and the Insert key and Delete key all work as in most other text editors. If you are at a keyboard that does not have these keys, you can use alternative Ctrl-key combinations. They are listed in nano’s online help, accessible with the Ctrl-G key combination.
Copy, paste, and cut operations are available, but they do not use the same Ctrl-key sequences as in most GUI editors. See the Editing Text section for more information.
Opening, Saving, and Closing Files
You can open a file for editing when you start nano, as discussed in the Starting Nano section. This section shows you how to open a file when nano is already started.
Opening Files
Open a file with the Read File command, Ctrl-R. The Read File command inserts a file from disk at the current cursor location.
When prompted, type the name of the file you want to open, or use the Ctrl-T key combination to use nano’s built-in file browser to navigate to the file you want to open.
If a file is already open, nano will insert the new file into it at the current cursor location; it will not close the existing file, nor will it open a new screen for the new file.
Save and Save As
Save and Save As are both accomplished with the Write Out command, Ctrl-O.
When prompted, press enter to accept the existing file name. To save as another file name, type in the new name and press Enter, or use the Ctrl-T key combination to use nano’s built-in file browser.
Closing Files
Close a file with the Ctrl-X key combination. If the file you are working on has been modified since the last time you saved it, you will be prompted to save the file first. Type y to save the file, or n to exit nano without saving the file.
Closing a file also closes nano.
Editing Text
As is normal in most text editors, text that you type into nano is inserted at the current cursor position. The Delete and Backspace keys also work the same as in other editors.
Use the Alt-6 key combination to copy text to the «cut buffer». Similarly, use the Ctrl-K key combination to delete text (it is cut to the «cut buffer»). If no text is marked, these two commands copy or cut the entire line of text.
Use the Ctrl-U key combination to paste the text in the «cut buffer» into the file.
To cut or copy specific text, you must first mark the start and end points of the text you want to select. You can do this with the either keyboard or the mouse, but to use the mouse for marking you must first turn on nano’s built-in mouse services.
To use the keyboard to select text, move the cursor to the start of the text you want to select, press the Alt-A key combination to mark the start, then move the cursor to the end of the section you want to select.
To use the mouse to mark the start of a selection, first make sure that nano’s built-in mouse services are turned on. Use the Alt-M key combination to toggle between nano’s mouse and the terminal’s mouse. Click on the location where you want to mark the start of the selection, move to the end of the section you want to select, and click the mouse again. You might need to use the keyboard to scroll the screen up or down because nano does not support scrolling with the mouse.
Once you have marked the beginning and end of text, the Alt-6 and Ctrl-K key combinations can be used to copy or cut it, respectively.
Note
Text copied or cut into nano’s internal «cut buffer» can only be pasted back into the current nano session. The text is not available for pasting into other windows or programs.
If you are using nano in a terminal window you can use the mouse to copy and paste text to and from other windows on your desktop. You cannot use the mouse to cut or delete text.
Quitting Nano
To quit nano, use the Ctrl-X key combination. If the file you are working on has been modified since the last time you saved it, you will be prompted to save the file first. Type y to save the file, or n to exit nano without saving the file.
Resources
Basic Introduction to Emacs: EmacsHowto
Introduction to Vim: VimHowto
Using a terminal and the command line: HowToUseTheTerminal and CommandlineHowto
Nano (последним исправлял пользователь drkokandy 2017-08-17 22:14:14)
The material on this wiki is available under a free license, see Copyright / License for details
You can contribute to this wiki, see Wiki Guide for details
Источник