---
title: "Terminal: Exploring Vim after 20 Years of Writing Code"
description: "Notice: This is a little \"terminal treat\" – a short tip rather than a whole article. Enjoy!"
date: 2025-04-27
canonical_url: "https://christofersandin.com/texts/terminal-exploring-vim-after-20-years-of-writing-code"
section: "Texts"
---

#  Terminal: Exploring Vim after 20 Years of Writing Code 

**Notice: This is a little "terminal treat" – a short tip rather than a whole article. Enjoy!**

**As a middle-aged CEO and developer, I’ve found myself increasingly occupied with running the company and maintaining a general project overview lately. I needed something new to explore. Therefore, after more than 20 years of coding in regular text editors and IDEs, I decided to explore *Vim*.**

Why? There was no particular reason; I was just a little curious and needed a challenge. I did like the idea that you spend more time editing than writing, so there should be a specific mode for that.

This text is not a general introduction to Vim — there are many available on the Internet — but I have written down a few notes from that endeavor.

---

The whole thing did not start with Vim. At first, I took a look at [Helix](https://helix-editor.com). Helix is an editor that functions similarly to Vim and Neovim. It’s fast, written in Rust, and requires almost zero configuration. I liked it a lot and spent some time in it. It took a bit of getting used to working in different modes, but I could see the appeal.

Helix is still a very niche product, and after reading and reviewing tutorials, I switched to [Neovim](https://neovim.io) mainly because of the extensive amount of material and plugins available. Neovim is an extension of Vim, so learning this provides a solid foundation for Vim motions as well. I also liked learning [Lua](https://www.lua.org), the programming language used to configure Neovim.

Many people suggest starting `nvim`, pressing the `<ESC>` key, typing `:Tutor`, and then `<ENTER>` if you need help with the basics.

Another great place to start is to go all-in on the [kickstart.nvim](https://github.com/nvim-lua/kickstart.nvim) project. You can also read the project’s [config file](https://github.com/nvim-lua/kickstart.nvim/blob/master/init.lua), which is full of comments and ideas, directly on GitHub and pick and choose the things you like.

Both approaches are good options and might suit you, but I needed to see what was doable, so I started watching some "set up Neovim from scratch" videos on YouTube to get into it.

Have I switched to Neovim exclusively? No, I have not. Have I gained insights into what’s out there? Yes, I have. Currently, I’m in the middle, but I can see myself using an editor with Vim key bindings soon.

---

## Key bindings

The most interesting aspect of Vim and Vim-based editors is learning how to work in different modes.

## Normal mode

You start in normal mode, which is your base, and all interactions begin here. Move around files and select what to edit.

### Navigation

- Left, down, up, right `h` `j` `k` `l`
- Start of line `0` / End of line `$`
- `f @`- move cursor to next occurrence of **@**, i.e., `f _` move to next \_
- `t @` - move cursor to character **before** next **@**.
- Next word `w` / WORD `W`
- Previous word `b` / WORD `B`
- End of next word `e` / WORD `E`
- Previous blank line `{` / Next blank line `}`
- Previous sentence `(` / Next sentence `)`
- Move cursor to first line of document `gg`
- Move cursor to last line of document `G`
- Move cursor to last insert point `gi`
- Move cursor to line `#` - `#G`
- Go `#` lines down - `#j` / Go `#` lines up - `#k`
- Move up a screen `Ctrl u`
- Move down a screen `Ctrl d`
- Substitute line (delete line, enter insert mode) `S`

### Editing text

**Edit**

- `a` - add
- `i` - insert

- `A` - start editing at the end of the line
- `I` - start editing at the beginning of the line
- `D` - delete to end of line
- `C` - change text to end of line
- `.` - repeat the last change

- `ciw` - Change Inner Word

**Folding code**

- `zR` - Open all

- `zM` - Collapse all
- `zo` - Open
- `zO` - Open all from the current location
- `zc` - Close
- `zC` - Close all from the current location
- `za` - Toggle current fold
- `zi` - Toggle code folding

**Quit vim**

- `ZZ`

**Auto-complete**

- `Ctrl P/N`

**Selection**

- Select current word - `*`

### Spelling

- Go to previous and next spelling mistake - `[s` and `]s`
- Spell check current word - `z=`
- Add current word to spell check - `zg`
- Remove current word from spell checker - `zG`

## Files and buffers

An open file lives in a buffer. You can display multiple buffers at the same time, and you can have the same file open in many buffers.

### Buffers

- `:ls` - List buffers
- `:bn` - Next buffer
- `:bp` - Previous buffer
- `:bw` - Close buffer
- `:bd#` - Close buffer #

### Splits

- `:sp` - split horizontally
- `:vs` - split vertically
- `ZQ` - quit without saving (same as `:q!`)

- Go between split windows with `Ctrl w` and the Vim keys (`h`or `l` for left and right, `j` and `k` for up and down)

## Macros

Record interactions and reuse them with macros.

**Recordings**

1. Record: `q a` (keystrokes) `q`
2. Play: `@ a`
3. Play multiple (15) times: `15@a`

---

## Visual mode

Working in visual mode allows you to select text and view a visual representation of what you have selected.

**Select a paragraph**

- `Vap` - *select* **around** the current **paragraph**
- `Vip` - *select* **inside** the current **paragraph**

**Select block**

- `v%` - *select* from the current position to the next matching character

**Select until next instance**

- `v/foo` - *select* from your current position to the next instance of **foo**, and `n` expands to the next instance.

**Select Word**

- `viw` and `viW`

**Copy a word and replace another word**

- To copy a word under the cursor, press `bvey`
- To replace the word under the cursor, press `bvep`

---

## Insert mode

- `Ctrl o` - temporarily enter Normal mode.
- `Ctrl w` - delete the word to the left of the cursor.
- `Ctrl u` - delete from the cursor to the beginning of the line.

---

## Third-party plugins

Before committing to third-party plugins and extensions, it is wise to explore the basic commands in your applications. It is also always a good idea to keep dependencies to a minimum.

That said, there are a few plugins that significantly enhance the user experience in Neovim, and if they have a good reputation and solid support, I’m not opposed to using them.

### The foundation

From what I gathered during my research, it appears that [lazy.nvim](https://github.com/folke/lazy.nvim) is a reliable way to manage plugins.

Here is a list of the ones that function as a foundation for my setup:

- Package manager for downloading plugins (lazy.nvim)
- Download LSPs, formatters, and linters (mason.nvim)
- [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter) - syntax highlighting
- [nvim-treesitter-textobjects](https://github.com/nvim-treesitter/nvim-treesitter-textobjects) - working with text objects

## File pickers

### telescope.nvim

[*Telescope*](https://github.com/nvim-telescope/telescope.nvim) is an extendable fuzzy finder over lists for Neovim. It is "built on the latest awesome features from Neovim core," which I guess must be good. It is centered around modularity, allowing for easy customization.

```
vim.keymap.set("n", "<leader><leader>", builtin.oldfiles, {})
vim.keymap.set("n", "<leader>ff", builtin.find_files, {})
vim.keymap.set("n", "<leader>fg", builtin.live_grep, {})
vim.keymap.set("n", "<leader>fb", builtin.buffers, {})
vim.keymap.set("n", "<leader>fr", builtin.registers, {})

```

## File explorers

### oil.nvim

If you like to step away from the file tree view on the left-hand side of the code and use a more native-feeling solution, you want to try [oil.nvim](https://github.com/stevearc/oil.nvim).

Hitting the - key displays a list of the current directory, and you can use your Vim skills to add, delete, and rename files.

Using `g` will display other options if you have [Which Key](https://github.com/folke/which-key.nvim) installed.

Currently, this is my preferred method for quickly and easily performing file-related tasks within Neovim.

## Code formatting and auto-complete

- Formatting code (conform.nvim)
- Linting code (nvim-lint)
- Syntax highlighting and code completion with LSPs 
    - [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig) - LSP interaction
    - [blink.cmp](https://github.com/Saghen/blink.cmp) - code completion with support for LSPs and external sources

### nvim-surround

Surround text with a character or a tag.

- `add` with `ys{motion}{char}`
- `delete` with `ds{char}`
- `change` with `cs{target}{replacement}`

`ysiw)` – add "(" and ")" around word  
`ys$t` - adds a tag around the text from the cursor position to the end of the line

`ds"` - delete " around text  
`dst` - delete tag around text

`cs'"` - change quotes from `'` to `"`

### [// Comment.nvim](https://github.com/numToStr/Comment.nvim)

Comment your code in style.

- NORMAL mode

    - `gcc` - Toggles the current line using a line-wise comment
    - `gbc` - Toggles the current line using a block-wise comment
- VISUAL mode

    - `gc` - Toggles the region using a line-wise comment
    - `gb` - Toggles the region using a block-wise comment

## LSP

### nvim-lspconfig

Nvim supports the Language Server Protocol (LSP), which means it acts as a client to LSP servers. LSP is a standard that lets different editors understand how programming languages work; it originated at [Microsoft](https://microsoft.github.io/language-server-protocol/). This is the official plugin used to make Neovim use LSPs.

> LSP facilitates features like go-to-definition, find references, hover, completion, rename, format, refactor, etc., using semantic whole-project analysis

### trouble.nvim

This is a way to look at the diagnostics that the LSP server provides, both for individual files and for the whole project.

> A pretty list for showing diagnostics, references, telescope results, quickfix and location lists to help you solve all the trouble your code is causing.

[trouble.nvim on GitHub](https://github.com/folke/trouble.nvim)

## Putting a smile on your face

These are the others I use at the moment:

- Interface/UX

    - [α alpha-nvim](https://github.com/goolord/alpha-nvim) - start up Neovim with style
    - [lualine.nvim](https://github.com/nvim-lualine/lualine.nvim) - easy to configure Neovim status line
    - [colorizer.lua](https://github.com/norcalli/nvim-colorizer.lua) - display your color codes in color
    - [:GuessIndent](https://github.com/NMAC427/guess-indent.nvim) - fast indentation style detection written in Lua
    - [Noice (Nice, Noise, Notice)](https://github.com/folke/noice.nvim) - completely replaces the UI for *messages*, *cmdline*, and the *popup menu*.
- Navigation

    - [Neovim-Tmux Navigation](https://github.com/alexghergh/nvim-tmux-navigation) - navigate between tmux and Neovim
- Git

    - [fugitive.vim](https://github.com/tpope/vim-fugitive) - working with Git inside Neovim (haven’t had time to explore, but the name alone puts it on the list)
    - [gitsigns.nvim](https://github.com/lewis6991/gitsigns.nvim) - deep buffer integration for Git

---

## Links

### References and videos

- "Neovim from scratch" by Mr Jakob

    - [Part 1: lazy.nvim, kanagawa.nvim, oil.nvim, Statusline &amp; Essential Settings](https://www.youtube.com/watch?v=g1gyYttzxcI)
    - [Part 2: Supercharged Code Navigation via Treesitter, Textobjects &amp; which-key](https://www.youtube.com/watch?v=E4qXZv34NQQ)
    - [Part 3: Insanely fast Neovim Navigation with fzf ❤️ lua](https://www.youtube.com/watch?v=R3e7uAE8jjo)
    - [Part 4: Code Intelligence in Neovim - The LSP Setup that grants you IDE Powers](https://www.youtube.com/watch?v=b17g20II6SQ)
    - [Part 5: Perfect Code Formatting with conform.nvim](https://www.youtube.com/watch?v=UVO_cq3xATo&t=137s)
    - [Part 6: blink-cmp: Lightning-Fast Autocompletion Built in Rust](https://www.youtube.com/watch?v=GKIxgCcKAq4)
- [How I Setup Neovim To Make It AMAZING in 2024: The Ultimate Guide](https://www.youtube.com/watch?v=6pAG3BHurdM) by Josean Martinez
- [How To Setup Linting And Formatting In Neovim To Replace null-ls](https://youtube.com/watch?v=ybUE4D80XSk) by Josean Martinez
- [The Only Video You Need to Get Started with Neovim](https://www.youtube.com/watch?v=m8C0Cq9Uv9o) by TJ DeVries
- [telescope.nvim introduction](https://www.youtube.com/watch?v=iqdCshrIKIg) by TJ DeVries
- [Code Formatting made easy](https://www.youtube.com/watch?v=mEqqkHLhlGY) by TJ DeVries
- [0 to LSP : Neovim RC From Scratch](https://www.youtube.com/watch?v=w7i4amO_zaE&t=37s) by ThePrimeagen
- [Vim Color scheme ‘evangelion’](https://github.com/xero/evangelion.nvim)
- [Neovim Ascii Logo by rc!](https://gist.githubusercontent.com/liocer/ce1485f9f4971fec4877fae7de2fbfc4/raw/efd6010e9eb4c1d0a2475de99cc4b56f0abcf828/nv.asc)

### Official links to repo and plugins

- [Neovim](https://neovim.io/)
- [Nerdfonts](https://www.nerdfonts.com/)
- [Telescope](https://github.com/nvim-telescope/telescope.nvim)
- [Oil](https://github.com/stevearc/oil.nvim)
- [Neo-tree](https://github.com/nvim-neo-tree/neo-tree.nvim)

### Themes

- [Zenbones](https://github.com/zenbones-theme/zenbones.nvim)

### Guides

- [Learn Vim (the Smart Way)](https://github.com/iggredible/Learn-Vim) – a free book bridging the gap between `:Tutor` and `:help`
- [Intermediate Vim](https://dn.ht/intermediate-vim) by Dennis Hotson
- [LazyVim](https://www.lazyvim.org/) – a popular preconfigured Neovim distribution, if you’d rather not build the stack yourself
- [Dotfyle](https://dotfyle.com/) – discover Neovim plugins and browse real-world configs

---

## Metadata

  [\#terminal-treats](/writing/terminal-treats)

 Published .  
 Last modified .

 29 48 86 1817
