vim-shfmt


Ⅰ. 插件描述

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

Ⅱ. 基本信息

创建日期:  2017-03-26
使用用户:  30
Github星:  52
插件作者:  David Wooldridge

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin 'z0mbix/vim-shfmt'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle 'z0mbix/vim-shfmt'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug 'z0mbix/vim-shfmt'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/z0mbix/vim-shfmt

Ⅳ. 文档说明

# Vim plugin for shfmt

The Vim shfmt plugin runs shfmt to auto format the current buffer

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.

添加新评论