top of page

Set Up & Fix a Buffer for Linux kernel Coding Style in Vim

Updated: Jul 29, 2018


This post lists the Vim commands to set up and fix a buffer so that it adheres to Linux kernel coding style guidelines.


Commands


Set up options

:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab cindent


Fix the Existing Buffer (now that the options are in effect)

:%retab


Remove white space on save

:autocmd BufWritePre * %s/\s\+$//e


Set a 80 char column visual guide

:set cc=80



Execute All Commands At Once


:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab cindent cc=80 | %retab | autocmd BufWritePre * %s/\s\+$//e


Note

You can put this line directly into your personal Vim initialization file: ~/.vimrc


References

  • Options at [link]

  • Retab at [link]

  • Remove white space at [link]

  • Over 80 char at [link]

  • Image is an amalgamation of images from [link] (Vim) and [link] (Tux)

  • Multiple commands at once [link]



bottom of page