Command line text editors linux

My Favorite Command Line Editors for Linux – What’s Your Editor?

Knowing how to fast and effectively edit files via command line is vital for every Linux system administrator. File edits are performed on a daily basis, whether it’s a configuration file, user file, text document or whatever file you need to edit.

This is why it is good idea to pick a favourite command line text editor and master it. It’s good to know how to work with other text editors, but you should master at least one so you can perform more complex tasks when needed.

In this tutorial, we are going to show you the most common command line text editors in Linux and show you their pros and cons.

Note however that we will not cover a complete guide how to work with each one of them as this can be a complete other article with explanation.

1. Vi/Vim Editor

First in our list is the infamous Vi/Vim (Vim comes from Vi improved). This is a very flexible text editor that can perform many different operations on text.

Vi/Vim Linux Editor

For example you can use regular expressions to replace text snippets in a file using vim. This of course is not the only benefit. Vi(m) provides an easy way to navigate between lines, words paragraphs. It also includes text highlighting.

Vim may not be the most user friendly text editor, but it is often preferred by developers and Linux power users. If you want to install this command line text editor on your system, you can use the command associated with your OS:

Install Vi/Vim Editor in Linux

If you want to see our complete coverage of vi(m), please follow the links below:

2. Nano Editor

Nano is probably one of the most used command line text editors. The reason for this is it’s simplicity and the fact that it’s preinstalled in most of the Linux distributions.

Nano Editor for Linux

Nano doesn’t have vim’s flexibility, but it will definitely do the work if you need to edit a large file. Actually pico and nano are quite similar. Both have their command options displayed at the bottom so you can choose which one to run. Commands are completed with key combinations of Ctrl and a letter displayed at the bottom.

Nano has the following features that you can use out of the box:

  1. Get Help
  2. Write out
  3. Justify
  4. Read File
  5. Where is (search)
  6. Previous page
  7. Next page
  8. Cut Text
  9. Uncut Text
  10. Cur Pos (Current position)
  11. Spell check

Install Nano Editor in Linux

You can check our complete guide for editing files with Nano editor on this link:

3. Emacs Editor

This is probably the most complex text editor in our list. It’s the oldest command line editor available for both Linux and UNIX based systems. Emacs can help you be more productive by providing an integrated environment for different kinds of tasks.

Emacs Editor for Linux

At first the user interface may look somehow confusing. The good thing is that emacs has a very detailed manual that will help you with file navigation, edits, customization, setting up commands. Emacs is the ultimate tool used by advanced *Nix users.

Читайте также:  Windows 10 dowland microsoft

Here are some of the features that make it the preferred choice over the previous editors we mentioned:

  1. Emacs server platform enables multiple hosts to connect to the same Emacs server and share the buffer list.
  2. Powerful and extensible file manager.
  3. Customization beyond a regular editor – as some say it’s an OS within the OS.
  4. Commands customization.
  5. Can change to Vi(m) like mode.

Emacs is a multi-platform editor and can be easily installed with the commands shown below:

Install Emacs Editor in Linux

Note: In Linux Mint 17 I had to run the following command to complete the installation:

Conclusion

There are other command line editors, but they barely even reach the functionality that the above 3 provide. Whether you are a Linux newbie or a Linux guru, you will most definitely need to learn at least one of the above mentioned editors. If we’ve missed any command-line editor in this article, please don’t forget to inform us via comments.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

We are thankful for your never ending support.

Источник

Command line text editors linux

Authored by: John Abercrombie

There are two command-line text editors in Linux®: vim and nano.

You can use one of these two available options should you ever need to write a script, edit a configuration file, create a virtual host, or jot down a quick note for yourself. These are but a few examples of what you can do with these tools.

While these tools might seem daunting at first, any Linux user should become accustomed to using at least one. Ask any Linux Administrator or regular user, and you soon find that everyone has their favorite.

This article covers the basics of each editing tool and how they differ.

Vim comes from Vi Improved because it is the successor of an older editor called vi. Because this editor (through its predecessor) has been around a long time, Linux Administrators or coders usually favor it. Vim is typically used by people who are familiar with Linux because it can have a bit of an uphill learning curve.

You can use vim to edit, write, and save a document from the command line. It does this through the use of two different modes:

By default, the vim editor opens in command mode. To open the vim editor, use the following syntax at the command line:

To start writing or editing, you must enter insert mode by pressing the letter i on your keyboard (“I” for insert). You should see —INSERT— at the bottom of your terminal page if you did it correctly.

When you are finished typing, and you want to save your work, you need to exit insert mode. Press the escape (esc) key, which places you back in command mode. Then you can save your work.

After you press escape, press shift + ;. The bottom of your terminal screen changes to reflect that you did it correctly. You now see a : where the —INSERT— was.

After you see the : in the lower left-hand corner of your vim editor, type w and then press enter to save your work. Then, you can either type i again to go back into insert mode if you want to continue writing, or you can quit the file. To quit, press shift + ; again, type q and then press enter. This saves your file and closes vim. You should see your usual terminal screen again.

You can also enter both the save and quit functions at the same time. To save and quit vim in one command, type wq after the : and then press enter. The file saves and closes.

If you start working on a file, but you change your mind, you can exit without saving. To do this, enter command mode by pressing esc followed by shift + ;. After you see the : at the lower left, enter q! . This force-quits vim without saving. ! is the force function.

Читайте также:  Снести пароль windows с флешки

Those commands are the ones that you are going use most of the time, but you can use the following cheat sheet if you want to do more complex actions with vim.

Vim editor cheat sheet

Use the following commands in command mode:

  • h — Moves the cursor to the left by one character; you can also press the left arrow.
  • j — Moves the cursor one line down; you can also press the down arrow.
  • k — Moves the cursor one line up; you can also press the up arrow.
  • l — Moves the cursor to the right by one character; you can also press the right arrow.
  • w — Moves the cursor one full word to the right.
  • b — Moves the cursor one full word to the left.
  • 0 — Moves the cursor to the beginning of the current line.
  • $ — Moves the cursor to the end of the current line.

— Changes the case of the current character.

  • dd — Deletes the current line.
  • D — Deletes everything on the line to the right of the cursor’s current position.
  • x — Deletes the current character.
  • u — Undo the last command.
  • . — Repeats the last command.
  • :w — Saves current file, but does not exit.
  • :wq — Saves current file, and quits.
  • The following commands place you into insert mode:

    • i — Inserts to the left of the current cursor position.
    • a — Appends to the right of the current cursor position.
    • dw — Deletes the current word.
    • cw — Changes the current word.

    Nano is a newer text editor in Linux systems. It’s simpler and easier to use than vim.

    To open a file with nano, use the following syntax at the command line:

    After the nano editor opens, you can begin typing. When you’re ready to save your work, press ctrl + o, which is called a write out. It saves your current work while allowing you to continue your work. If you’re done, you can save and quit by pressing ctrl + x. When you save a file in nano, your current work is color-coded based on what you’re writing.

    Another major difference with nano is that you can access a list of commands within the editor, but you can use the following cheat sheet as well.

    Nano editor cheat sheet

    Note: The commands in the following list use ^ to indicate that you should press the ctrl key along with the other key. For example ^G means that you should press ctrl + G.

    • ^G — Get Help.
    • ^X — Exit. Nano then asks if you want to save with a Y or N option.
    • ^O — Write Out; also known as save.
    • ^R — Read File. Enter the name of a file you want to paste into the current document at your cursor’s position.
    • ^W — Where Is; Search function.
    • ^\ — Replace.
    • ^K — Cut text.
    • ^U — Uncut text.
    • ^J — Justify.
    • ^T — To spell.
    • ^C — Current Position; Cancel save.
    • ^_ — Go to line.

    You can use the man pages to find out more in-depth information about each text editor. The commands are ‘man vim’ or ‘man nano’, respectively.

    Share this information:

    ©2020 Rackspace US, Inc.

    Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License

    Источник

    Top 6 awesome text editors for Linux and Unix command-line users/developers

    Top 6 awesome text editors for Linux, macOS and Unix CLI users

    The curated list for text editors is in alphabetical order.

    1. emacs – GNU Emacs is the extensible self-documenting text editor

    GNU Emacs is an acronym for Macros Macros. One of the most common text editors on Linux and Unix-like systems. Developers and programmers primarily use it. Emacs’ key selling points are its powerful Emacs Lisp, a built-in programming language that lets the user extend the editor’s capabilities. Emacs fans are often involved in an Internet turf war with vim/vi fans.

    GNU Emacs running on my Ubuntu desktop

    2. kakoune – Modal editor inspired by vim, especially keystrokes

    Kakoune is a modal text editor. Vim is a significant inspiration for Kakoune existence, and it tries to improve the text editing workflow and fit better to the Unix philosophy. From the project home page:

    Kakoune is a code editor that implements Vi’s “keystrokes as a text editing language” model. As it’s also a modal editor, it is somewhat similar to the Vim editor. Kakoune can operate in two modes, normal and insertion. In insertion mode, keys are directly inserted into the current buffer. In normal mode, keys are used to manipulate the current selection and to enter insertion mode. Kakoune has a strong focus on interactivity, most commands provide immediate and incremental results, while still being competitive (as in keystroke count) with Vim.

    Kakoune in action

    3. micro – A simple and easy to use text editor

    Micro is a terminal-based text editor that aims to be easy to use and intuitive while also taking advantage of modern terminals’ full capabilities. From the project page:

    micro aims to be somewhat of a successor to the nano editor by being easy to install and use in a pinch, but micro also aims to be enjoyable to use full time, whether you work in the terminal because you prefer it (like me), or because you need to (over ssh).

    Features are as follows:

    • Standard keybindings (Ctrl-s to save, Ctrl-z to undo, Ctrl-q to quit, etc.)
    • Syntax highlighting for over 140 programming languages supported
    • Full support for the mouse. It means you can click and drag to select the text, double click select by word, and triple-click to select by line
    • Multiple cursors
    • Configurable keybindings and settings (tab width, tabs vs. spaces, diff gutter, etc.)
    • Built-in terminal emulator
    • Splits and tabs
    • Automatic linting and commenting via Lua plugins
    • Plugin manager to download additional Lua plugins other users have made
    • Terminal emulator
    • And much more

    micro text editor

    4. nano – Nano’s ANOther text editor, inspired by Pico for new users/developers

    GNU nano is a tiny text editor with a reputation for newbie-friendly. Nano was initially gain popularity due to Ubuntu and now default on many Linux distros. It mimics the look and feel of Pico text editor, although is free software, and implements several features that Pico lacks. For instance:

    • Opening multiple files
    • Scrolling per line
    • Undo/redo
    • Syntax coloring
    • Line numbering
    • Soft-wrapping overlong lines and much more.

    GNU nano editing the /etc/resolv.conf on my Linux system

    5. neovim – Vim fork focused on extensibility, usability, and backward comparability

    Neovim is a fork of vim with additional features. The authors of Neovim wanted text editor features to improve Vim’s extensibility and maintainability. It is fully compatible with Vim’s editing model and the Vimscript language. With 30% less source-code than Vim, the vision of Neovim is to enable new applications without compromising Vim’s traditional roles. Since Neovim is a drop-in replacement for vim, the learning curve is easier for existing vim users. Feature includes:

    • No ads and tracking
    • In-depth guides for developers and sysadmins at Opensourceflare✨
    • Join my Patreon to support independent content creators and start reading latest guides:
      • How to set up Redis sentinel cluster on Ubuntu or Debian Linux
      • How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
      • How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
      • A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
      • How to protect Linux against rogue USB devices using USBGuard

    Join Patreon

    • Strong defaults
    • Modern terminal features such as cursor styling, focus events, bracketed paste
    • Built-in terminal emulator
    • The plugin API
    • LUA based scripting apart from Vimscript

    6. vim – The most loved and memed text editor

    Vim is an acronym for Vi IMproved. It is a clone, with an additional set of features to the original Bill Joy’s vi text editor for Unix. Vim’s author, Bram Moolenaar, based Vim on the source code for a port of the Stevie editor to the Amiga. At the time of its first release, the name “Vim” was an acronym for “Vi IMitation”, but this changed to “‘Vi IMproved” late in 1993.

    Vim text editor running on Ubuntu

    Meme about editor war: Let us start a flame fest over a text editor

    How do I set up a screen-oriented text editor on Linux or Unix?

    You need to set up a variable called $VISUAL (or in some cases $EDITOR) as follows:

    Источник

    Читайте также:  Форматы файлов образов дисков windows
    Оцените статью