The power of a terminal-based text editor is beyond imagination

Using Neovim as a daily driver — the power of a terminal-based text editor is beyond imagination

First a question: Why do we need a terminal-based text editor when we have the whole power of VS Code and all its fancy formatting and modules?

The answer is simple.

  • VS Code uses Electron as its core, which means the amount of RAM it takes is huge.
  • Because Neovim is a terminal-based text editor, it enables you to code in any Linux, even without having a display manager or things like cloud or virtual machines or a Docker container, where all you get is just a terminal.
  • As it is terminal-based, all you need is a keyboard to do all the complex operations, which means once the shortcuts become habitual, you never have to lift a finger off your keyboard to use the mouse for any reason.

With this article, I will try to give a workflow in which I use Nvim as my daily driver and all the configurations that one can use to make life easier with Neovim.

First things first. Let’s start with installation.

Installing Neovim

Taking it from the official Neovim installation guide, here I will mention just a few popular distros.

Ubuntu

Since 18.04 via the official repository, as in Debian, Neovim is in Ubuntu.

sudo apt install neovim

Python (:python) support seems to be automatically installed.

sudo apt install python-neovim
sudo apt install python3-neovim

macOS / OS X

Pre-built archives

The releases page provides pre-built binaries for macOS 10.11+.

curl -LO https://github.com/neovim/neovim/releases/download/nightly/nvim-macos.tar.gz
tar xzf nvim-macos.tar.gz
./nvim-osx64/bin/nvim

Homebrew on macOS or Linux

brew install neovim

Or install the development version of Nvim:

brew install --HEAD luajit
brew install --HEAD neovim

Windows

Chocolatey

  • Release (v0.4): choco install neovim (use -y for automatically skipping confirmation messages)
  • Development (pre-release): choco install neovim --pre

Scoop

  • Release: scoop install neovim
  • Development (pre-release):
scoop bucket add versions
scoop install neovim-nightly

Basics

After we are done setting up Vim, let’s just get some basics clear, like how to get started with Vim and do some basic things.

  • h moves the cursor one character to the left.
  • j moves the cursor down one line.
  • k moves the cursor up one line.
  • l moves the cursor one character to the right.
  • 0 moves the cursor to the beginning of the line.
  • $ moves the cursor to the end of the line.
  • w moves forward one word.
  • b moves backward one word.
  • G moves to the end of the file.
  • gg moves to the beginning of the file.
  • `. moves to the last edit.

Again, here’s a longer list of the commands you’ll definitely want to know starting out:

  • d starts the delete operation.
  • dw will delete a word.
  • d0 will delete to the beginning of a line.
  • d$ will delete to the end of a line.
  • dgg will delete to the beginning of the file.
  • dG will delete to the end of the file.
  • u will undo the last operation.
  • Ctrl-r will redo the last undo.

Here are the commands you most need to start out:

  • v highlights one character at a time.
  • V highlights one line at a time.
  • Ctrl-v highlights by columns.
  • p pastes text after the current line.
  • P pastes text on the current line.
  • y yanks text into the copy buffer.

So don’t mug them up — once you start using them, this will be your muscle memory.

Customizing Vim

This is how my Neovim looks right now.

screenshot of author’s Neovim screen

It has a search bar, or file explorer, just like VS Code.

screenshot of Neovim screen showing file directory

Neovim also allows you to split your text editor.

screenshot of Neovim screen divided into three sections

Now I will share my Neovim config. Copy it to your Neovim config folder, generally at.config/nvim.https://betterprogramming.pub/media/7ead9df15927e3c3307fc29c21e54f97

As you can see, the Plug lines indicate all the plugins I am using. Among them, the best is the NERD tree and google vim-codefmt,

The NERD tree allows you to have that dope side file explorer and codefmt autoformats code.

Apart from that, there are some custom shortcut mappings to key combinations. For example, ctrl+b opens a NERD Tree window.

How To Do the Switch

Believe me, the day I did the switch from VS Code to Nvim, it was tough. Even closing the Nvim window becomes a challenge. But once you start using it for a while, it becomes tough to code or write at any place apart from the Vim environment. I don’t even know how many times I have typed :w here while typing on Medium :).

My take would be this: Don’t be too hard on yourself, but make it a habit that any small code change will be done using Vim. If a whole project is to be developed, only then switch to something like Sublime or VS Code.

Thanks for reading, do ping me in the comments if you need any help.

Good luck!


REVIEWS

If You find it interesting!! we would really like to hear from you.

Ping us at Instagram/@the.blur.code

IF YOU WANT ARTICLES ON ANY TOPICS DM US ON INSTA.

Thanks for reading!! 

Happy Coding

8 thoughts on “The power of a terminal-based text editor is beyond imagination

  1. Hello! I know this is kinda off topic but I was wondering which blog platform are you using for this website? I’m getting tired of WordPress because I’ve had problems with hackers and I’m looking at options for another platform. I would be fantastic if you could point me in the direction of a good platform.

  2. Wow, superb blog layout! How lengthy have you been running a blog for? you made running a blog look easy. The total glance of your web site is fantastic, let alone the content material!

  3. My spouse and I stumbled over here coming from a different web address and thought I may as well check things out. I like what I see so now i am following you. Look forward to exploring your web page again.

Leave a Reply

Your email address will not be published. Required fields are marked *

Begin typing your search term above and press enter to search. Press ESC to cancel.

Back To Top
Hey, wait!

Before you dive into the exciting Article, wanna join our newsletter list, We promise we will not spam