When you’re working on a single buffer on a widescreen monitor you end up looking far to the left which over the course of the day can result in some neck pain. Previously my solution was to split NeoVim and work on the right buffer via the :vsplit
command. But recently I found Centerpad.nvim which centres a single buffer for you.
Installing Centerpad.nvim
I use Packer, so I’m going to show that method. You can find install instructions for other methods of managing your NeoVim configuration in the Centerpad repository.
For me I add the following line to my plugins.lua
file in ~/.config/nvim
and save it with :w
.
-- packer.nvim
use { 'smithbm2316/centerpad.nvim' }
Then run :PackerSync
and the plugin will be installed. Next quit NeoVim with :qall
and open it back up again in the directory.
Using Centerpad.nvim
To use Centerpad you should be able to use the :Centerpad
. This command takes two arguments which set the width of the left/right spacing. If you want the side spaces to match only pass one argument like this :Centerpad 100
. If you want to have two different sized spaces then you pass both arguments :Centerpad 100 20
.
The first argument sets the width for the left spacer and the right side width is set by the second argument.
You can also set a keyboard command and adjust the default width of the side spacers. By default they’re set to 36 columns, which doesn’t feel like quite enough space on my 43″ monitor. Using the line below I mapped Centerpad to <leader>z
and set the default column width to 60 when I invoke the command.
vim.api.nvim_set_keymap('n', '<leader>z', "<cmd>lua require'centerpad'.toggle{ leftpad = 60, rightpad = 60 }<cr>", { silent = true, noremap = true })
Productivity is more than tools
A good process will work no matter what tool you choose to use. It will work on paper or in a digital task manager. If you’re looking to build a productivity practice that will help you get more done without being overloaded, this is the course you want. Become a member to get all my courses.
$49 USD (30-day guarantee)