main page | blog

blog

my yapping

my coding workflow

I swear this is interesting

what is neovim

as I've mentioned before, I use neovim as my text editor for basically everything. if you haven't heard of it, it's a lightweight, terminal-based, extensible text editor. it's a fork of vim, which itself is based on vi, an ancient text editor (from 1976!) which is based around modes. neovim maintains this modal style of editing, and it's the reason me and a lot of other people choose it over more traditional editors!

modes

neovim has 4 main modes: normal, insert, visual, and command. there's a couple more but they're not used nearly as much as these ones. here's what they do:

  • normal mode
  • this is the mode you're put in when you start neovim. if you try to start typing from this mode you'll probably end up doing a bunch of weird stuff instead of actually writing what you wanted to write. that's because pressing keys in normal mode works more like triggering shortcuts in traditional editors; it's like having crtl or alt permanently pressed.
    additionally, commands in neovim are made up of an operator and a motion. the operator is what decides what's gonna happen, while the motion decides where it's gonna happen. the most basic motions are h,j,k, and l, which act like the arrow keys (left, down, up, and right respectively). a command would then be, for example, dl ('d'elete the character to the right).
    another useful command is i, which puts you in...
  • insert mode
  • this is the mode you use to actually type text in your document! it works as you'd expect: each keystroke types the corresponding character in the document. there's some tricks and cool shortcuts you can use in insert mode, but that about it. it's pretty basic.
  • visual mode
  • you get into this mode by pressing v in normal mode. this mode lets you select text by just moving the cursor around (similar to holding shift and using the arrow keys in a traditional editor). after selecting text you can use any operator and it'll act on the selected text.
    visual mode also has a 2 other variants: linewise visual mode and blockwise visual mode. linewise v-mode simply selects whole lines instead of single characters; blockwise visual mode is a bit more interesting: it selects in rectangular regions, as if using a rectangle select tool in an image editor. this is very useful for documents with a particular structure, like code, since you'll often have multiple lines that start with similair words or characters, and with this mode you can easily modify them all at once!
  • command mode
  • this is where stuff gets real. command mode is entered by typing : in normal mode. this will move the cursor to the bottom of the window, inside a command line. from here you can type one of the many, many, commands that neovim has to offer. one of the most useful of these commands is :s, which is neovim's search-and-replace command. as an example, to replace all instances of "dog" with "cat" in a document, you would use :%s/dog/cat/g. it looks weird and intimidating, but it's pretty simple once you get used to it! let me explain how that example works:
    • % - this is the "range"; the lines that will be searched. % indicates "the whole file".
    • s - the search command.
    • /cat - this is a regular expression that describes the word (or pattern) that will be replaced. this part can get complex, regex is very powerful!
    • /dog - the text which will replace all matches found by the regex.
    • /g - 0 or more letters which represent different options for the search-and-replace. in this case g means "replace all occurrences in the line" (without it it'd replace the first match of the pattern in a line before moving on to the next).
    as you can imagine, this mode is very powerful: for a taste of some advanced things you can do with it, I have used it to find all uncommented methods and fields inside of a whole project and add them to a special "quickfix list" that allows me to jump to the next/previous occurence with a normal mode command. all of that from 1 command!

    it takes a bit to get used to this modal style of editing, but the payoff is worth it for me. having everything available to me from my keyboard, without having to slowly move my hand to my mouse and back, really keeps me in a flow state.

    customizabilily

    my setup!

    another big feature of neovim is just how customizable it is. you can do just about anything: theming, changing keybinds, adding entirely new features; the only limit is how much time you're willing to spend (and your lua skills). neovim is configured using either a .vimrc file written in vimscript (this is the legacy way; to maintain compatibility with vim), or one or multiple lua files.

    my config is written in lua, and I used kickstart.nvim as a starting point. it's a single init.lua file containing some plugins to get you started, but its purpose is just to, well, kickstart your own custom configuration; it's intended to be modified, encouraging you to add and remove plugins to your liking. if take a look at my config you'll notice that it's now very different from kickstart!

    my "toggle terminal" keybind

    some highlights of my config are autocompletion and lsp support via blink.cmp and lspconfig respectively; snippet support with luasnip; a fuzzy picker - a program that lets you search and choose files/words/anything from your filesystem or documents - thanks to telescope.nvim; and various miscellaneous features with mini.nvim. there's also my custom theme (as seen in the screenshot) and other odds and ends.
    one thing I'm particularly proud of is the keybind I made to toggle neovim's builtin terminal emulator. it's really convenient for testing whatever program I'm working on! I also have a bunch of custom snippets for latex to make taking notes easier, but I'll save that for its own post.

    if you're interested in using neovim yourself, I suggest taking a look at this playlist by theprimeagen (and only that playlist; guy's too much of a tech bro for my tastes) for general tips about using vim; also check out kickstart.nvim for a basic starting off point for your config or lazyvim for a more plug-and-play kind of setup. there's also other pre-made neovim setups out there, but I haven't had experience with them personally.

    but why?

    I know what you're thinking: "why go through all this effort of learning and customizing a text editor?"
    and, for me, the answer is simply that it's fun! I'm the kind of nerd that loves picking up new skills that I can really sink my teeth into, and neovim scratches that itch while also being a more ergonomic and faster way to write text (in my opinion). it sort of gameifies writing/coding, which I really enjoy.

    I have to admit, though, that using an editor like neovim is not for everyone. if you don't code or write that often or simply don't care about something like this, spending all this time learning keybinds and configuration is just not worth it. if you're on the fence, I suggest using a pre-made config like lazyvim to get a feel for what a good setup can offer, then starting from scratch on your own setup adding only the plugins that you use and ignoring the rest. that's what I did!

    other stuff

    realizing now that there's not that much else I use outside neovim... I guess I can briefly talk about my linux setups
    both my desktop and laptop run linux, cachyos and omarchy respectively (though I'm looking to switch away from omarchy) which are both arch(btw)-based distros. I use kde plasma on desktop and hyprland on my laptop. I like having a tiling window manager on the laptop since the smaller screen makes floating windows kind of annoying, and the more keyboard-centric approach feels better when all you have for mouse controls is a touchpad. I'll talk more about my linux setups in another post though, this one is long enough already.

    I think that's all I wanted to touch on for now. if you read this far, wow you're also a massive nerd lmao (and thanks for reading! :3)

    back to top