The Beginning
I initially made my transition to Linux about two years ago. I started with Fedora Sway and now run Arch Linux as my daily distro. During this time, I can recall ThePrimeagen and TJ Devries blazing through their code like nothing, smooth as it could be, using NeoVim. Motivated by this, I began playing with LazyVim, but it was quite difficult! I had no idea how to quit or navigate, and was lost as to why there were insert and visual modes.
It wasn't until I took a Database Management with SQL course that I had to figure out a pgAdmin substitute. I couldn't get the GUI to work on Fedora due to port issues, and I needed to fix it quickly as I was already three days into the 7-week session. I discovered that I could write my SQL queries in Neovim and run them in psql. My professor was fine with this, and to my surprise, it actually wasn't bad. After 7 weeks, I had not only learned SQL, but I was also able to use Neovim from a functional perspective.
Fast forward to now, and Neovim/Tmux is always open. I keep it minimal, though a multitude of plugins are available at neovimcraft. I've tried ricing it in the past, but you can waste countless days customizing it and still not be happy. Now, I keep the number of plugins super light so I can transfer my keybinding skills to Vim whenever I need to spin up a Docker image or edit files on a remote Linux distro on the fly. While Neovim is a fork of Vim, there are still major differences between the two.
Neovim is an editor that naturally requires constant learning. The built-in tutorial exists and can be accessed via vimtutor from the terminal, or :help nvim from inside the editor itself. I'm guilty of not utilizing this tool as much as I should, but it truly is a wealth of knowledge. As I continue my dive into DevOps, the importance of reading the official documentation is vital.
Below, I'll present some of the keys and shortcuts I personally use to date. There are many ways to perform similar actions and it just depends on how many keystrokes you're willing to execute.
Navigation Basics
There are multiple tutorials that teach you the basics: h, j, k, l, and, of course, :q to exit. Once you break free from using your mouse and arrow keys, your editing speed naturally skyrockets. For larger vertical jumps, combining a line number with a navigation key does the trick. For example, to jump 15 lines up, simply type 15k.
If you need to jump larger distances, you can scroll through the file using:
Ctrl + u: scroll up half a screenCtrl + d: scroll down half a screen
Cursor Movement
For moving around your file with precision, these commands are essential:
gg: go to the start of the fileG: go to the end of the filew: jump forward to the beginning of next wordb: jump backward to the beginning of the previous word0: go to the beginning of the line$: go to the end of the line(: jump to the first character of the previous sentence): jump to the first character of the next sentencegj: move cursor down one line in multi-line textgk: move cursor up one line in multi-line text
Combining a line number with a command goes a long way. Let's say I want to skip 5 sentences, I would enter 5).
Paragraph Editing
Now that we can navigate our editor more freely, making actual edits within a paragraph is the next topic. Instead of manually navigating, these commands and combos drop you straight into Insert mode:
I: jump to beginning of the lineA: jump to end of the lineo: insert a new line below the current lineO: insert a new line above the current linebi: insert at the beginning of the previous wordea: insert at the end of the next word
Text Mutation in Action
To see how powerful combined commands are, let's look at an example. Imagine your cursor is at the very beginning of this sentence:
New Jersey bagels are the best!
If you want to delete the word Jersey, you have at least two options:
wdaw- w to jump forward to Jersey, then daw to delete the word and its trailing spacewdw– w to jump to Jersey, then delete the word
Switching to Insert mode and typing "York" yields the perfect sentence :)
New York bagels are the best!
Visual Block
Visual Block is a great feature for changing multiple lines at once. I typically use visual block when creating HTML list item elements. In our next example, let's say I want to capitalize the first letter of each line.
thanksgiving
is
in
november
- Move cursor to the first letter in t
Ctrl + vto enter Visual Block mode3jto highlight the remaining three rowsUto capitalize the selected words
Macros and Global Search
We will end with an example that requires the creation of 25 email addresses in an instant and removes the @ symbol. It just demonstrates the power of Neovim. The first user is as follows:
- Place your cursor on the first line. Enter
qato start recording a macro into register a. yyto yank the current linepto paste it belowCtrl + ato automatically increment the number 1 to 2qto stop recording23@ato repeat the process 23 more times
Now let's remove the @ symbol using the following command.
:%s/@//
:%to apply the action globally across every single line in the entire file.ss stands for substitute (search and replace)./@//searches for the @ target, but it replaces it with nothing as there is nothing between the second and third slashes.
The first slash (/) marks the end of the command name and the start of your search pattern, @. The second slash marks the end of your search pattern and the beginning of what you want to replace it with. The third slash simply closes out the command.
The Power of Repetition
Ultimately, mastering Vim/Neovim isn’t about memorizing every shortcut overnight, but rather, discovering bindings that compound over time. Whether you are automating repetitive tasks with macros or dynamically restructuring paragraphs on the fly, the initial learning curve pays off exponentially in daily workflow speed. It's all about repetition. Stay consistent, and before you know it, your interaction with the editor will become completely fluid. Happy editing!