Nvim Format Sql

cover for article Nvim Format Sql

I was looking for a way to format my sql in nvim directly.

I found a nice cli called pgFormatter

On mac you can install it with brew

brew install pgformatter

In my case I use a linux distrib based on ubuntu

sudo apt-get install libcgi-pm-perl cd /tmp export version=5.4 wget https://github.com/darold/pgFormatter/archive/refs/tags/v${version}.tar.gz tar xzf v${version}.tar.gz cd pgFormatter-${version}/ perl Makefile.PL make && sudo make install

After that you can use a range and called the external cli pg_format with !

# called pg_format on the current line :.!pg_format # called pg_format on the visually select lines :'<,'>!pg_format #:{range}!pg_format

In action

Stay up to date

Sign up for the mailing list and get notified via email when new blog posts come out.