filestyle is a Vim plugin that highlights unwanted whitespace and characters.
Highlights include:
- Trailing spaces
- Tabs or spaces depending on
'expandtab'
- Lines longer than
'textwidth'
- Control characters
filestyle also lets you fix these issues (experimental).
$ cd ~/.vim/bundle
$ git clone https://github.com/aserebryakov/filestyle.git
NeoBundle 'aserebryakov/filestyle'
Clone or download this repository and copy its contents to your ~/.vim/
directory.
When using Vim (not gVim), make sure your colorscheme explicitly defines
ctermbg
in a Normal
highlight group as it is required for the ignore
patterns feature. For example:
hi Normal ctermbg=15
filestyle automatically checks each opened file.
:FileStyleEnable
- enable plugin globally:FileStyleDisable
- disable plugin globally:FileStyleToggle
- toggle enable/disable plugin globally:FileStyleActivate
- enable plugin for current buffer:FileStyleDeactivate
- disable plugin for current buffer:FileStyleCheck
- check current buffer:FileStyleFix
- fix style errors
- If
'expandtab'
is set, highlight tabs (RED), if not, highlight spaces at the beginning of a line (YELLOW). - Highlight trailing spaces (CYAN)
- Highlight line parts that exceed
'textwidth'
(INVERT) - Highlight control characters (BLUE)
- Remove control characters
- Remove trailing spaces
- If
'expandtab'
is set, replace tabs with spaces, if not, replace spaces at the beginning of a line with tabs
By default, filestyle checks all file types. To ignore a file type, for
example text
, add the following line to your .vimrc
:
let g:filestyle_ignore = ['text']
filestyle allows you to specify patterns that should be ignored. To ignore
a pattern, for example quoted lines starting with >
, add the following line
to your .vimrc
:
let g:filestyle_ignore_patterns = ['^\(> \?\)\+$']
filestyle currently uses these highlight groups:
FileStyleTabsError
FileStyleTrailingSpacesError
FileStyleSpacesError
FileStyleControlCharacter
FileStyleTooLongLine
FileStyleIgnoredPattern
Note that FileStyleIgnoredPattern
is only used in gVim.
You can change a highlight group in your .vimrc
or color scheme like this:
highlight FileStyleTabsError ctermbg=3 guibg=Yellow
-
filestyle cannot detect
'textwidth'
changes. If you change'textwidth'
, execute:FileStyleCheck
to ensure the new width is used for highlighting long lines. -
Error E315 is be thrown by Vim in case of
'splitbelow'
option is set when'help'
command is called
Source code and issues are hosted on GitHub:
https://github.com/aserebryakov/filestyle
- Added
FileStyleToggle
command - Fixed the error if default colorscheme is used
- Fixed error messages when Vim is started in a narrow terminal
- Fixed tag and version number in help file
- Fixed cursor positioning after FileStyleFix call
- Added support for user-defined highlight groups
- Fixed issue with tabs switching in INSERT mode
- Implemented ignored patterns
- Removed highlighting of trailing spaces in current line when in Insert mode
- Improved order of highlights
- Fixed issue with highlighting after colorscheme change
- Implemented style errors fixing (experimental)
- Added commands to enable/disable filestyle globally
- Fixed highlighting of the EOL
- Fixed disabling filestyle for specific buffers
- Fixed compatibility with other plugins when Vundle is used
- Added option to ignore certain file types
- Changed
:FileStyleDeactivate
to turn off highlighting in all windows of the current buffer - Added highlighting of control characters
- Fixed the
undefined variable filestyle_active
error
- Added commands to enable/disable filestyle
- Fixed several bugs
- Changed highlighting to use distinct colors for different violations of buffer settings
- Added highlighting of trailing spaces
- Added highlighting of incorrect indentation