Nano vs vim: сравнении лучших консольных текстовых редакторов

Горячие клавиши

Чтобы вывести информацию по всем горячим клавишам, используется сочетание Ctrl+G.

Наиболее часто используемые горячие клавиши nano:

Горячие клавиши Описание
Ctrl+A Переместить курсор в начало строки.
Ctrl+E Переместить курсор в конец строки.
Ctrl+Y Переместить курсор на 1 страницу вверх (аналог PageUp)
Ctrl+V Переместить курсор на 1 страницу вниз (аналог PageDown)
Ctrl+_ Перейти к определенной строке (нужно будет ввести номер строки).
Ctrl+C Показать на какой строке и в какой позиции находится курсор.
Ctrl+W Поиск текста в файле. Необходимо ввести строку для поиска.
Ctrl+\ Поиск и замена текста в файле. Сначала вводится строка для поиска, затем строка для замены.
Ctrl+D Удалить символ под курсором.
Ctrl+K Удалить текущую строку.
Ctrl+O Сохранить изменения, не закрывая редактор.
Ctrl+X Выход из редактора. Если файл был изменен, появится запрос на сохранение изменений.

2 Editor Basics

Next: ,
Previous: ,
Up: 

2.1 Entering Text

All key sequences in are entered using the keyboard.
is a «modeless» editor. All keys, with the exception of
Control and Meta key sequences, will enter text into the file being
edited.

Next: ,
Previous: ,
Up: 

2.2 Special Functions

Special functions use the Control (Ctrl) key, displayed in the help and
shortcut lists as ^; the Meta key, displayed as M; or the Escape (Esc)
key.

  • Control key sequences are entered by holding down the Ctrl key and
    pressing the desired key, or by pressing the Esc key twice and pressing
    the desired key.
  • Pressing Esc twice and then typing a three-digit number from 000 to 255
    will enter the character with the corresponding value.
  • Meta key sequences are entered by holding down the Meta key (normally
    the Alt key) and pressing the desired key, or by pressing the Esc key
    once and pressing the desired key. Certain operating systems «swallow»
    the Alt key so that it never reaches the application; if your operating
    system does this, you should use the Esc key to generate Meta key
    sequences.

Next: ,
Previous: ,
Up: 

2.3 The Titlebar

The titlebar is the line displayed at the top of the editor. There are
three sections: left, center and right. The section on the left
displays the version of being used. The center section
displays the current filename, or «New Buffer» if the file has not yet
been named. The section on the right will display «Modified» if the
file has been modified since it was last saved or opened.

Special modes: When is in «File browser» mode, the center
section will display the current directory instead of the filename. See
See , for more info.

Next: ,
Previous: ,
Up: 

2.4 The Statusbar

The statusbar is the third line from the bottom of the screen, or the
bottom line in Expert Mode. See See , for more info. It
shows important and informational messages. Any error messages that
occur from using the editor will appear on the statusbar. Any questions
that are asked of the user will be asked on the statusbar, and any user
input (search strings, filenames, etc.) will be input on the statusbar.

Next: ,
Previous: ,
Up: 

2.5 Shortcut Lists

The Shortcut Lists are the two lines at the bottom of the screen which
show some of the more commonly used functions in the editor.

Previous: ,
Up: 

2.6 Using the Mouse

When mouse support has been configured and enabled, a single mouse click
places the cursor at the indicated position. Clicking a second time in
the same position toggles the mark. Clicking in the shortcut list
executes the selected shortcut.

The mouse will work in the X Window System, and on the console when gpm
is running.

Next: ,
Previous: ,
Up: 

GNU nano

GNU nano

GNU nano имеет репутацию относительно удобного для пользователя. Если вы никогда раньше не пользовались nano, есть большая вероятность, что вы сможете к ней привыкнуть без посторонней помощи.

Чтобы начать, вы можете открыть или создать файл, набрав:

nano /home/user/HelloWorld.txt

Команда покажет вам узнаваемый пользовательский интерфейс. Заголовок вашего текстового файла отображается вверху, а текст, содержащийся в файле, отображается посередине. Действия, которые вы можете выполнить в нижней части. Вы выполняете эти действия, нажимая  Ctrl  плюс указанную клавишу.

Например, выйти и сохранить файл с помощью  Ctrl + X. По общему признанию, я путался при сохранении файла в первый раз, когда я начал использовать nano, так как текстовый редактор только перечисляет эту команду как «Выход». Но когда вы пытаетесь редактировать, Nano спрашивает, хотите ли вы сохранить.

Как показывает нижняя часть экрана, nano содержит большую часть функциональности, которую вы ожидаете от графического приложения. Вы можете вырезать и вставлять, находить и заменять слова и многое другое.

GNU Nano

Особенности GNU nano включают в себя:

  • Поддержка Autoconf
  • Goto-line # команда без флага
  • Функция поиска с учетом регистра
  • Интерактивный поиск и замена
  • Поддержка сленга и ncurses
  • Autoindent (авто-отступ)
  • Параметрs ширины отображаемой вкладки
  • Регулярное выражение поиска и замены
  • Переключение флагов cmdline с помощью мета-ключей
  • Завершение вкладки при чтении / записи файлов

В целом, nano — отличный вариант для новичков в терминальном редактировании текста. Вы можете попробовать свои силы в открытии файлов из командной строки и навигации, используя, в основном, клавиатуру, не выбрасывая при этом большую часть того, что вы знаете о текстовых редакторах.

В системе на основе DEB, такой как Debian или Ubuntu, вы можете установить GNU nano, используя:

sudo apt install nano

На Fedora, основанной на RPM системе, вы можете установить, используя:

sudo dnf install nano

Поскольку nano — это программа командной строки, вы, вероятно, не найдете ее в программном обеспечении GNOME или альтернативных магазинах приложений Linux. Но вы можете установить его с помощью традиционных менеджеров пакетов, таких как Synaptic.

Также рекомендуем прочитать о 10 наиболее часто задаваемых вопросов о Linux

8 Building and Configure Options

Building from source is fairly straightforward if you are
familiar with compiling programs with autoconf support:

  • tar xvfz nano-x.y.z.tar.gz (where x.y.z is the version of
    )
  • cd nano-x.y.z/
  • ./configure
  • make
  • make install

The possible options to are:

Disable the mini file browser when reading or writing files.

Disable the help function. Doing this makes the binary much smaller,
but makes it difficult for new users to learn more than very basic
things about using the editor.

Disable the justify and unjustify functions.

Disable all mouse functionality. This also disables the -m command line
option, which enables the mouse functionality.

Disable setting the operating directory. This also disables the -o
command line option, which sets the operating directory.

Disable use of the spell checker. This also disables the -s command
line option, which allows specifying an alternate spell checker.

Disable the tab completion code when reading or writing files.

Disable all long line wrapping. This also eliminates the -w command
line option, which enables long line wrapping.

This option disables all the above. It also disables some of the larger
internals of the editor, like the marking code and the cut to end of
line code. It also disables the function toggles.

Enable support for runtime debug output. This can get pretty messy, so
chances are you only want this feature to work on the nano source.

Enable extra features. At the moment, this is just easter egg-type
stuff.

Enable support for syntax coloring of files using the nanorc file. This
enables nanorc support as well.

Enable support for opening multiple files at a time and switching
between them on the fly.

Enable support for reading the nanorc file at startup. You can store
custom settings in the nanorc file rather than having to pass command
line options to get desired behavior. See See , for
more info.

Shortcut for enabling the above four features (extra, color,
multibuffer, and nanorc).

Disables Native Language support. This will disable use of the
available GNU translations.

Disable long line wrapping by default when nano is run as root.

Enable support for reading and writing Unicode files. This will require
either a wide version of curses, or a UTF-8-enabled version of Slang.

Disable support for reading and writing Unicode files.

Compiling with Slang is supported, and will make the binary
notably smaller than if compiled with ncurses or other curses libraries.

Сохранение изменений

Сохранить и продолжить работу

Вы отредактировали файл и хотите сохранить изменения, но не закрывать редактор. В таком случае используется сочетание клавиш:Ctrl+O

В строке статуса появится сообщение: File Name to Write: имя_файла (если имя файла отсутствует, то нужно ввести имя файла). Для сохранения изменений нажмите Enter.

Сохранить и выйти

Чтобы сохранить изменения и выйти из редактора можно воспользоваться сочетанием клавиш:Ctrl+X

В данном случае, если вы изменяли файл, то появится вопрос: «Save modified buffer (ANSWERING No Will DESTROY CHANGES)?«. Нажмите клавишу y. Появится вопрос на ввод имени файла. Введите новое имя файла или просто нажмите Enter. Изменения будут сохранены, редактор закроется.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *

Adblock
detector