Vim Gawd

AKA "Understanding How Modal Editing Works"

A super-quick primer into Vim, its ecosystem and how I use it for everyday activities.

Hi. I'm Jacky.

I work for Lyft as a Software Developer.

I document my life at jacky.wtf.

I enjoy reading, cooking and Twitter.

Vim - a primer

Vim's a modal editor (first and foremost) designed to help its users write with intention in mind.

 

It uses modes, registers, and buffers to achieve this goal. Most of us use only 2 modes, about 3 registers and dozens (if not hundreds) of buffers at a time.

modes

(not the SQL tool)

Modes are the wrapping layer of how one interacts with text blocks in Vim.

There's quite a few of them. They're split into basic and additional categories.

Basic MODES

  • Normal
  • Visual
  • Select
  • Insert
  • Command Line
  • Ex / Super Command Line
  • Terminal (neovim)

VARIANT MODES

  • Operator Mode
  • Virtual Replace
  • Insert Normal
  • Insert Visual
  • Insert Select

registers

(kinda like a NS?)

Registers are places to hold text that can be used for, well, anything.

There's a lot of them. Nearly sixty. You could end up using all of them in one session. Usually not.

all
the
"

10 types.

~60 total avaialable.

A myraid of ways to fill them up!

MYRIAD of fILLINGS

Though too long to fit into this talk, you can fill up these registers in a HUGE number of ways.

Word

buffers

(forget everything you know)

Buffers represent a file's contents as well as other bits of metadata pertaining to that file.

Some buffers aren't real. Other hidden.

HIDDEN

Hidden buffers are ones that have text that's abandondable. In short, if you make a buffer's mode hidden, Vim doesn't care about persisting its contents.

 

This is how NERDTree, Tagbar and the ilk keep those buffers from being saved to disk.

Inactive

One of the three states of a buffer, this is whenever a buffer isn't hidden but also isn't currently being displayed in a window. However, Vim does care about the contents - modified buffers will cause a warning when you try to exit.

CHANGE + MOTION

Think of motion and change as a lexical thing.

So if you want to... ... then you hit
delete a word dw
swap lines ddkkp
keep the middle but delete other lines d1jGd2kZZ
write something on the next line o

Each letter corresponds to an change or motion.

Together, they can be considered macros.

Anything you do can be recorded as a macro.

But that's outside of the scope of this talk.

Something Warshan Shire would say.

Plugins

Vim was designed to be extensible.

The community has created thousands of plugins for, well, anything.

  • pathogen
  • neobundle
  • vundle
  • vim-plug

CURATE your environment

Using plugins can further the abilities of Vim. A lot of notable plugins authors like tpope, Shuogo and june-gunn work to make Vim more usable of an editor and overall tool for developers and editors alike.

IMPACT

Treat code like you're weaving it

Vim allows mnemonic actions that allow for tight weaving of repetitive behaviors and text manipulation.

It does have a learning curve. But Vim is for anyone who's willing. <C-c> <C-x>

(Not so Live) Demos

Title Link
Prose https://asciinema.org/a/BX9I39TocUVTyse9pNZAW9XFj
Refactor https://asciinema.org/a/CK5hPUpNWfytbPpc3HQkHMNbw
Git Cycle https://asciinema.org/a/zdMNuuqN36nsMVwrYPgSvDhFs

FIN

Vim Gawd

By Jacky Alciné

Loading comments...

More from Jacky Alciné