My Experience Using Vim with No Plugins Cover Image

My Experience Using Vim with No Plugins

6 Minute read

Vim is an amazing minimal editor, often people install a lot of plugins, I tested how well it works without a single plugin.


Everyone in the programming world has at least heard of Vim, nearly all have opened it even if only for a brief moment, so I think it's safe to say I don't need to spend a paragraph explaining what it is. That said if you want to, you can read my thoughts on vim.

For reference, here is a peek at the Vim configuration I was using while testing Vim without any plugins, it keeps most of it as default, the only things that really change are the colorscheme and a few other comfort settings I like such as tabwidth, cursorline and causing the screen to keep the cursor near the centre of the screen.

vim9script
syntax enable
colorscheme habamax
highlight Normal ctermbg=none
autocmd CursorMoved * normal! zz
command! -nargs=1 G execute ':!git <args>'

for [var: string, val: number] in items({ 
    is_posix: 1, 
    netrw_banner: 0, 
    netrw_liststyle: 3 
})
    execute 'g:' .. var .. ' = ' .. val
endfor
  
for option: string in [
    'tabstop=2', 
    'noswapfile',
    'noshowmode', 
    'cursorline',
    'smartindent',
    'breakindent',
    'shiftwidth=2',
    'relativenumber',
    'regexpengine=0',
]
  execute 'set ' .. option
endfor

As you can see it's written in the newer Vim9Script which takes some nice features from statically typed languages such as TypeScript and also alters the way variables are defined a little. You can read the full Vim9Script Spec for more information.

Motions

To begin with this forced me to learn Vim motions to a much better level than I ever had before, which is incredibly important because while tools like EasyMotion exist the standard Vim motions once learned correctly are actually just as if not more efficient. A few quick ones that are useful include:

Completion

Did you know Vim has completions built-in? It works by searching through the files in the project folder for occurrences of what you are typing, you can activate it with ⌃n while typing a word and then using ⌃n and ⌃p to navigate through the list of completions, you can select an option with ⌃y. This works better in already established projects as it needs a codebase of words to search through. You can extend it further to use omnifunc which can tap into programming language features if you so wish.

Tip

Remap your rarely used capslock key to for a more ergonomic typing experience. represents Control.

File Navigation

This is one that I thought I'd be installing a plugin for eventually, I really enjoy having fuzzy file finding, however with the default vim setup you can use the command :e path/to/file to open a file you can also tab complete the same way you would in your shell. You can then use :ls to list all the buffers you have opened and perform the same functionality as :e with :b path/to/file which will allow you to fuzzy find open buffers and not even type the full name, e.g. if you have components/posts/Details.tsx open in a buffer you can jusy run :b Det<cr> and it will will either open it or show there are more files with this pattern opeb. This is incredibly useful.

Version Control

Vim Fugitive is a pretty much standard plugin for a lot of Vim users, however with the line below you can achieve a good chunk of the functionality, I've been using Git via Vim with this method for a little while now and must say I am very happy with the way it works.

command! -nargs=1 G execute ':!git <args>'

An example usage below, is me running the :G command 3 times for, add and commit all changed files with message and then pushing to GitHub.

:G add .<CR> # Adds All Changed Files
:G commit -m "feat(file): changes"<CR> # Commits Changes
:G push<CR> # Pushes Changes

Tip

With git aliases you can tighten these commands to look a little bit more like :G ac "feat(file): changes"<CR> and :G p<CR> which is nice when coding for longer sessions.

I Finally Installed A Plugin

After a few weeks of using Vim like this, I found I was much more proficient with the text editor, and I am definitely enjoying that. However, there was one thing that was missing that I felt the need to install a plugin for, which is Language Servers.

I'm now comfortable with just a couple of Language Server related plugins solely due to the fact that seeing linting errors is incredibly useful for catching errors before runtime which saves me running the program and then seeing an error and then having to go back and make edits. It is also incredibly useful to have parameter and function information directly in the editor without having to jump back and forth between the function declaration or the language documentation. Here you can see what my configuration looks like after deciding to add the Language Server plugins.

vim9script
syntax enable
colorscheme habamax
highlight Normal ctermbg=none
autocmd CursorMoved * normal! zz
command! -nargs=1 G execute ':!git <args>'

for [var: string, val: number] in items({
    is_posix: 1,
    netrw_banner: 0,
    netrw_liststyle: 3
})
    execute 'g:' .. var .. ' = ' .. val
endfor

for option: string in [
    'tabstop=2',
    'noswapfile',
    'noshowmode',
    'cursorline',
    'smartindent',
    'breakindent',
    'shiftwidth=2',
    'relativenumber',
    'regexpengine=0',
]
  execute 'set ' .. option
endfor

for [map: string, cmd: string] in items({
    lh: 'LspHover',
    lr: 'LspRename',
    ll: 'LspCodeLens',
    la: 'LspCodeAction',
    ld: 'LspDefinition',
    lt: 'LspTypeDefinition',
    ls: 'LspDocumentSymbol',
    lf: 'LspDocumentFormat',
    'l[': 'LspPreviousDiagnostic',
    'l]': 'LspNextDiagnostic',
})
    execute 'nmap <leader>' .. map .. ' :' .. cmd .. '<cr>'
endfor

call plug#begin()
    Plug 'prabirshrestha/vim-lsp'
    Plug 'mattn/vim-lsp-settings'
    Plug 'prabirshrestha/asyncomplete.vim'
    Plug 'prabirshrestha/asyncomplete-lsp.vim'
call plug#end()

Conclusion

Try Vim without any plugins for a little while, find out what's possible and what you miss from plugins, keep the goal of having as small of a configuration file as possible, this will allow you to get back up and running on any system without much hassle. Also, make sure you enjoy your programming, this was a fun learning experience for me.