go |vim

(N)VI(M): Basic Settings

mariocarrion

Mario Carrion

Posted on December 24, 2020

(N)VI(M): Basic Settings

Over the years I've been collecting vi-like plugins, as well as learning a few obscure built-in commands for helping me improve my typing speed, this includes those specific to programming languages as well as some of those related to the core of writing text.

This is the first of a series of posts covering the settings and plugins I use for my daily workflow. I will cover two must-have built-in settings and then in future posts I will be writing about concrete plugins.

For reference you can take a look at my configuration file.

1) number relativenumber

This setting is amazing, it allows you display a number on the gutter that is relative to the actual line you're on, best explained with a screenshot (you may need to click the image below to see it properly):

vim: relativenumber

The details on the left gutter are:

  • 18 is the current line number,
  • numbers above 18 indicate the relative number above this line, and
  • numbers below 18 indicate the relative number below this line.

With that in mind we can jump down or up easily using k or j, for example:

  • 3 lines down 3j or,
  • 10 lines up 10k.

I really like this one!

2) autochdir

There are few cases where I prefer using the built-in version of something I'm trying to do instead of any of the popular plugins (in this particular case I prefer using netrw instead of like nerdtree).

Here is where this setting comes in, it changes your netrw directory relative to the location of the current file. This action is, most of the times, what we are trying to do when opening the directory browser. In cases where you don't want that you can actually search for an specific file using ctlp (which I will be discussing in a future post).

Besides setting this configuration I also use:

nnoremap - :Explore<CR>
let g:netrw_banner = 0
let g:netrw_liststyle = 3
let g:netrw_bufsettings = 'noma nomod nu nobl nowrap ro'
autocmd FileType netrw setl bufhidden=delete
Enter fullscreen mode Exit fullscreen mode

Which indicates:

  • Pressing - in normal mode will open netrw,
  • The banner details will be gone,
  • The list style will be set to 3, and
  • It will close all opened buffers related to netrw after quitting.

In practical terms this is how it looks like:

nvim: netrw


Yeah I know, two settings only but really those improved my typing life tenfold!

The more you know

💖 💪 🙅 🚩
mariocarrion
Mario Carrion

Posted on December 24, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related