Терминальный редактор в linux

Выбор текстового редактора в консоли Linux

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

Проблем с этим, как правило, никаких нет — запускаешь предпочитаемый текстовый редактор, открываешь файл, редактируешь и сохраняешь. Однако редактирование некоторых файлов конфигурации, в частности /etc/sudoers, осуществляется только посредством специальных утилит (в данном случае — visudo или crontab — при редактировании расписания планировщика), которые запускают текстовый редактор для консоли Linux по умолчанию. Таковым является vi, перекочевавший в современные дистрибутивы Linux с годов и его нельзя назвать удобным.

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

клавиатура

Многообразие выбора

Самый удобный и простой, из известных мне, текстовый редактор Linux консоль — nano (раньше он назывался pico и входил в состав почтового клиента pine). Nano изображен на рис. 1.

Nano

Внизу (под текстом) есть подсказка по комбинациям клавиш для управления редактором. Символ ^ означает . То есть для выхода из ytuj нужно нажать комбинацию клавиш +, а для сохранения текста — +.

В некоторых системах (например, в FreeBSD) вместо nano используется ee (в Linux его нет). Он похож на nano, но существуют и различия — подсказки выводятся до текста (вверху экрана), а не после него, но идея та же. Также довольно удобен joe. Скажем так, текстовый редактор Linux консоль nano будет удобнее, он поддерживает подсветку синтаксиса, внизу есть панель с подсказками, но это дело привычки.

joe

В пакет mc (файловый менеджер) входит хороший и довольно удобный mcedit, который запускается при нажатии клавиши в mc (рис. 3). Но вы можете запустить консольные текстовые редакторы в Linux отдельно:

mcedit

Классический синий фон, подсказки функциональных клавиш внизу Не менее удобен, чем nano. Консольные текстовые редакторы в Linux joe, nano и ee запускаются аналогично:

Мы только что рассмотрели три текстовых редактора для Linux (один был для FreeBSD). Выбор конкретного зависит от ваших личных предпочтений. Но в любом случае, каждый из представленных вариантов будет удобнее, чем стандартный vi.

Источник

9 Best Text Editors for the Linux Command Line

Looking to edit files in the command line? These are the best editors for Linux terminal when you go all command line.

A text editor is a must-have application for any operating system. We have no dearth of good text editors on Linux. There is Gedit for quick text note down, there is VS Code for writing codes and more. But those are all GUI-based editors. What if you need to edit files in the terminal? Linux sysadmins need to do that on a daily basis. The average desktop Linux user may also need to edit files in the command line from time to time. Your distribution has a terminal-based text editor installed by default. But don’t restrict yourself to just that. Here, I have compiled a list of the best command line text editors for Linux. Feel free to experiment. Please note that this is not a ranking list.

Читайте также:  Linux путь до файла терминал

1. Neovim

neovim text editor

Neovim is a fork of Vim that aims to add more extensibility while simplifying it. If you’re comfortable with Vim, you will be good to go using Neovim. The project is being actively maintained and the progress is promising so far. Of course, unless you’re acquainted with how Vim works, you may not notice the striking difference between the two. But, overall, Neovim tries to take Vim up a notch.

How to install it?

For other Linux distributions or platforms, you may refer to its official installation instructions to get started. To give you a head start, I must mention that when using the terminal, you will have to type the following to launch it (instead of neovim):

2. ne – The Nice Editor

ne the nice editor

When compared to the classic and popular text editors, ne (the nice editor) is a good alternative that tries to offer advanced functionalities and make it easier to use them. In other words, it’s a simpler alternative to Vim/Emacs offering you powerful features. It is being actively maintained. I tried it installing on Ubuntu 22.04 and it worked just fine. You can explore more about it on their GitHub page. Of course, unless you test it extensively, you should take it with a pinch of salt.

How to install it?

You should find it available in the official repositories of your Linux distribution. For Ubuntu-based distros, you can install it using the command:

You can also check out their official download page for more information on other Linux distributions.

3. Vim

vim text editor

If you’ve been on Linux for quite some time, you must have heard about Vim. Vim is an extensively configurable, cross-platform, and highly efficient text editor. It may not be suitable for newbies but it’s something every aspiring Linux System administrator should get comfortable with. You will probably find it pre-installed in your Linux distribution. It is extremely popular for its wide range of advanced features. Vim can be quite agonizing for first-time users. I remember the first time I tried to edit a text file with Vim, I was completely puzzled. I couldn’t type a single letter on it and the funny part is, I couldn’t even figure out how to close this thing. If you are going to use Vim, you must be determined to climb up a very steep learning curve. But after you have gone through all that, combed through its official documentation, and practice the commands/operations, you’ll find it worth all the time spent. Not to forget, you can use it for basic text editing or leverage its support for hundreds of programming languages, extensions, and file formats.

How to install it?

If you don’t have it installed already, you can just try typing in the command (on Debian-based systems) to install it:

Читайте также:  Linux scripting in windows

You can also find it listed in your software center of the Linux distribution you use. In either case, just head on to its official download page to get more details.

4. GNU Emacs

gnu emacs text editor

GNU Emacs is undoubtedly one of the oldest and versatile text editors out there. In case you didn’t know, it was created by GNU Project founder Richard Stallman. Emacs is cross-platform and has both command line and a graphical user interface. It is also very rich with various features and, most importantly, extensible. Just as Vim, Emacs too comes with a steep learning curve. But once you master it, you can completely leverage its power. Emacs can handle just about any type of text file. The interface is customizable to suit your workflow. It supports macro recording and shortcuts as well. The unique power of Emacs is that it can be transformed into something completely different from a text editor. There is a large collection of modules that can transform the application for use in completely different scenarios, like — calendar, news reader, word processor, etc. You can even play games in Emacs!

How to install it?

You should find it in your software center, or if you prefer using the terminal on Ubuntu-based distros, you can type in:

You can find more information on it on their official download page. Once you’re done installing, you need to type in a specific command to launch emacs in your terminal, which is:

Basically, this command instructs not to include any window to launch the program but the terminal itself.

5. MCEDIT

mcedit text editor

Midnight Commander is a fairly popular command line file manager and mcedit is an internal file editor of GNU Midnight Commander. It’s possible that many of us forget about this text editor, which is embedded inside the midnight commander utility. What this editor does, is open the files specified on the command line. The editor is based on the terminal version of cooledit – a standalone editor for X Window System.

How to install it?

6. Nano

nano text editor

When it comes to simplicity, Nano is the one. Unlike Vim or Emacs, it is suitable for beginners to get used to quickly. If you want to simply create & edit a text file, look no further. The shortcuts available on Nano are displayed at the bottom of the user interface. It is minimal and perfectly suitable for editing system & configuration files. For those who don’t need advanced features from a command-line text editor, Nano is the perfect pick. If interested, you can learn how to use Nano text editor in our beginner’s guide.

How to install it?

For the most part, Nano editor should come in pre-installed on Ubuntu-based distributions. If it isn’t there, you can simply visit the official download page to get the binaries for the distribution you want.

7. Tilde

tilde text editor

Tilde is a terminal-based text editor tailored for users who are normally used to GUI applications. Unlike other options mentioned in this list — this may not be a power tool. But, for basic text editing operations, this is very easy to use. You do have some advanced functionality – but that’s not something to compare with Vim/Emacs. If you wanted to try something easy-to-use and different, this is the one I’d recommend you to try.

Читайте также:  Менеджер сети для линукс

How to install it?

For information on other Linux distributions, you may refer to their GitHub page or the download page to explore more about it.

8. Micro

micro text editor

Micro is an easy-to-use and highly customizable text editor. It also implements the universal copy/paste/save shortcuts (CTRL + C/V/S), which is rare in Linux terminal editors. Another cool offering from this text editor is its plugin system and internal command mode. Though it’s not feature-rich like Vim or other mature text editors, it can easily replace tools like Nano for occasional file editing in the terminal.

How to install it?

Micro is available in the repositories of all major distributions. In Ubuntu, you can install it with:

For other Linux systems, you can check out their GitHub page. We have an article on Micro text editor with a free cheat sheet for beginners if you are interested.

9. Helix

helix editor

Helix editor is a rust-based terminal text editor, which is both fast and efficient in resources. It uses Tree-Sitter for syntax highlighting, which helps boost the speed. The built-in language server support provides context-aware completion, diagnostics, and code actions. Helix editor offers several powerful tools, that can make it work like other editors like Vim and Emacs. On their website, they call themselves, a post-modern text editor, if Neovim is the modern Vim, then Helix is post-modern. For those who are interested, you can check out a dedicated Helix article

How to install it?

For Arch and its derivatives, there is a package available in the Community repository. Also, an AUR package is also available, which builds the master branch. For other Linux distributions, you have to use Cargo, the Rust Package Manager. You should be able to install Cargo using your distribution package manager Also, you need to make sure that Git is installed. On Ubuntu-based distributions, install both like this:

sudo apt install git cargo
git clone https://github.com/helix-editor/helix cd helix cargo install --path helix-term

Helix also needs its runtime files so make sure to copy/symlink the runtime/ directory into the config directory. This location can be overridden via the HELIX_RUNTIME environment variable.

ln -s $PWD/runtime ~/.config/helix/runtime
export PATH=$PATH:/home/team/.cargo/bin

Wrapping Up

If you are an experienced Linux user, you must have heard of most of the options mentioned in this list, if not all. For most users, going with Nano, Vim or Emacs should be good enough. The seasoned terminal dwellers could experiment with the likes of Micro, Helix or some other terminal text editors. That’s just my recommendation. And I would like to know yours. Which text editor do you prefer in the command line? Did you find a new, interesting one on this list? Share it in the comments.

DuckDuckGo hidden features

Hidden Features! 25 Fun Things You Can Do With DuckDuckGo Search Engine

What is TTY in Linux

What is TTY in Linux?

s-tui is used for CPU utilization monitoring

Beautifully Monitor CPU Utilization in Linux Terminal With Stress Terminal UI

Access Grub in VM

How to Access the GRUB Menu in Virtual Machine

FOSS Weekly 23.28

FOSS Weekly #23.28: China’s Linux OS, Linux Exit Codes, Btrfs Origins and More

cp command in Linux

Using cp Command in Linux

Become a Better Linux User

With the FOSS Weekly Newsletter, you learn useful Linux tips, discover applications, explore new distros and stay updated with the latest from Linux world

Источник

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