Vim notes

I’ve used Vi/Vim almost my entire career – starting in college when I would dial into in a mainframe at the university using a phone line modem on my Windows 3.11, i.386 computer. I can’t remember how I got started, but I think I had read about Bill Joy, and concluded that an editor written by him would be the way to go.

Recently, the Changlelog podcast had several episodes about Vim

Gary Bernhardt points out an interesting reason to use Vim:

For me – I don’t know how common this is, but for me it was motivated by fear of RSI, of injury. Programming long-term is dangerous for your hands. Fortunately not the rest of you, but for your hands and your wrists, totally dangerous. And I wanted to keep programming for many more decades… So I was using Emacs, a lot of chording in Emacs, a lot of Ctrl+Shift, Ctrl+Alt, Ctrl+Alt+Shift… And Vim has basically none of that. That for me is the most important difference between Vim and other editors - its input efficiency in terms of keystrokes. And a really easy way to sort of see a summary of that is - in Vim I almost never hit Ctrl, I never hit Alt. If there are keystrokes that require Alt, I don’t even know them… And I rarely hit Shift. So most of my editing is normal mode, which is the mode that Vim boots up in, and just hitting the letter keys to do things, and punctuation. And that is very different from any kind of remotely “mainstream” editor.

I’ve tried Emacs several times and it never resonated with me – not sure why but suspect the Vi modes just work with me. I’m also generally averse to things overly complex and perhaps Emacs is that.

With Neovim, there are several interesting new developments:

  • built in support for LSP (language server protocol)
  • integration with tree-sitter. Tree sitter is written in Rust, but it appears the interface to Neovim is written in Scheme. Still not sure how this all works together, but looks interesting.
  • Lua support – while Vim is revving vimscript to be better, Neovim is moving forward with Lua. Apparently the LSP implementation in Neovim is in Lua. You can also express your Neovim config in Lua if you want, and plugins can now be written in Lua. Telescope is an example.

An example of a nice VIM setup:

Here is Jeremy’s VIM setup:

He uses Lua for config.

It’s interesting one of his recent commits is changes to make Vim more responsive:

So even in Vim, there are limits to how much stuff you can throw at it before it starts to slow down.

In my Linux adventure I started out with emacs, mostly because that’s what other people I was around were using, but now I couldn’t tell you anything about emacs as I’ve been a vim user for a long time. I honestly don’t know why I switched. My guess would be that busybox vi is a good enough editor to do lots of short quick things with and I was working with busybox-based systems at some time so I just learned it.

1 Like

I started with emacs too, because I was hacking on gcc at uni and it had a good IDE like experience debugging gcc and running through code and learning. But then at some point I started to work for Montavista where I needed to frequent stuff on embedded targets and busybox vi editor applet was all there was. So I started using it there and then slowly it became so familiar that I left emacs behind. Now a days I use many editors, I like kate too and nvim is my togo editor.

1 Like

I have been using nvim for sometime now and I needed xxd functionality which is fine but its bundled with vim or gvim in official packages. I did not want to install full vim. I am on archlinux so AUR came to my rescue

yay xxd-standalone

and bingo !!

1 Like

If you use language server e.g. clangd with nvim then it might showcase errors but also suggest fixes with “fix available” string at the end of diagnostic.

To accept the suggestions use following vim command

:lua vim.lsp.buf.code_action()

Fixed !!

1 Like