• Stars
    star
    135
  • Rank 269,297 (Top 6 %)
  • Language
    Vim Script
  • License
    MIT License
  • Created over 7 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Vim plugin for shfmt (https://github.com/mvdan/sh)

Vim plugin for shfmt

The Vim shfmt plugin runs shfmt to auto format the current buffer by a command :Shfmt. If instead you prefer to format a textobject, say a paragraph, by gq, then add to the file after/ftplugin/sh.vim in your Vim configuration folder the lines

if executable('shfmt')
  let &l:formatprg='shfmt -i ' . &l:shiftwidth . ' -ln posix -sr -ci -s'
endif

and press, say gqip. Customize the options -ln posix -sr -ci -s to your liking.

Requirements

You just need the shfmt command

Installation

Obtain a copy of this plugin and place shfmt.vim in your Vim plugin directory or be sensible and use something like Plug:

Plug 'z0mbix/vim-shfmt', { 'for': 'sh' }

Usage

You can use the :Shfmt command to run shfmt and automatically format the current buffer

You can also use the :Shfmt command together with options. For example,

:Shfmt -p
:Shfmt -i 2

Configuration

shfmt uses tabs by default for auto formatting, so if you prefer to use 2 spaces, you can set the following in your .vimrc file:

let g:shfmt_extra_args = '-i 2'

Auto format on save

If you would like to auto format shell scripts on save, you can add the following to your vim config:

let g:shfmt_fmt_on_save = 1

License

The Vim shfmt plugin is open-sourced software licensed under the MIT license.

More Repositories

1

dotfiles

*NIX dot files
Lua
13
star
2

sysadmin-tools

Systems Administration tools that I have used in the past to make my life easier
Shell
11
star
3

rolecule

Small, simple tool to test your ansible roles
Go
9
star
4

essh

SSH to EC2 instances using in memory, ephemeral ssh keys and EC2 instance connect
Go
6
star
5

vagrant-ec2-imposter

A vagrant VM to simulate some parts of an EC2 instance
Python
4
star
6

puppet-master-nginx-passenger

Supporting files for building a puppet master with nginx and passenger
Shell
4
star
7

eks

Simple EKS Cluster built with Terraform
HCL
4
star
8

zabbix-agent-rpm

Files to create a Zabbix agent RPM for Enterprise Linux Systems
3
star
9

deploygif

Application code for the deploygif service
CSS
2
star
10

docker-ctl

Docker wrapper script for common tasks
Shell
2
star
11

d0k8s

DigitalOcean Kubernetes Cluster Terraform
HCL
1
star
12

shci

Simple Shell CI/Build System
Shell
1
star
13

rpm-jq

Build an up to date RPM for jq on CentOS/RHEL 6
Shell
1
star
14

zup

zup is a wrapper for unison to easily sync a directory recursively with a remote host.
Ruby
1
star
15

ansible-minio

Ansible role to install the Minio server and client
Ruby
1
star
16

deploygif-infrastructure

Code for managing the deploygif infrastructure
Ruby
1
star
17

openbsd-binpatch-makefiles

OpenBSD binpatch and binpatchng Makefiles
1
star
18

z0mbix.github.com

z0mbix's Blog
JavaScript
1
star
19

bsd-kernel-configs

1
star
20

demo-service

Simple service to demo dynamically reloading configuration by watching a volume mounted Kubernetes ConfigMap
Go
1
star
21

cyberark

Get accounts from CyberArk
Go
1
star
22

infra-tools

Infrastructure related things
Shell
1
star
23

chef-sigil

Installs Gliderlabs' sigil
Ruby
1
star
24

hipcat

Send/pipe messages to HipChat using just curl
Shell
1
star