[Slackbuilds-users] Vim indent settings for SlackBuilds

Dave Woodfall dave at slackbuilds.org
Fri Sep 4 16:09:02 UTC 2020


On 04/09/20 15:16,
Slackbuilds Users <slackbuilds-users at slackbuilds.org> put forth the proposition:
> Hi list,
> Does anyone have (or aware of) a vim formatting rules file for SlackBuilds?  I recently submitted a SlackBuild that had mixed tabs and spaces... I want to avoid that oversight in the future.
> After a quick internet search all I turned up was this, which is for automatically treating the *.info file as a shell script:
> ---
> https://www.linuxquestions.org/questions/slackware-14/tip-have-vim-handle-slackbuild-info-files-properly-4175628148/
> Put the following in .vimrc:
> autocmd BufEnter,BufNew *.info call CheckSlackBuildInfo()
> function CheckSlackBuildInfo()
>     if filereadable(expand('%:p:r'). '.SlackBuild')
>         setlocal filetype=sh
>     endif
> endfunction
> Then, if you open a file whose extension is .info and there's a corresponding SlackBuild in the same directory, vim will treat the .info file as shell script.
> ---
> Based on the SlackBuild template file, it looks like SlackBuild files should be indented 2 spaces, and indentation should always be with spaces (no tabs).
> I think I want the following options set:
> :set expandtab
> :set tabstop=2
> :set shiftwidth=2
> After inheriting all other settings from the filetype 'sh'.
> Erich

I use those settings everywhere mostly, but you can make an autocmd
for slackbuilds something like:

au BufRead,BufNewFile *.SlackBuild setl expandtab | 
  \ setl tabstop=2 |
  \ setl etc...

`setl' is short for `setlocal', and it only works in the buffer with
the slackbuild open, in case you have other buffers open.

--
Dave

Love is a snowmobile racing across the tundra and then suddenly it flips over,
pinning you underneath.  At night, the ice weasels come.
	 --Friedrich Nietzsche
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.slackbuilds.org/pipermail/slackbuilds-users/attachments/20200904/366375b3/attachment.asc>


More information about the SlackBuilds-users mailing list