KISS plugin. Removes unwanted tabs and trailing whitespace. Nothing more, nothing less.
- Removes trailing whitespace globally
- Removes trailing tabs globally
- Removes whitespace on empty lines
- Removes tabs on empty lines
Use your favorite plugin manager.
call plug#begin()
Plug 'MikeHorn-git/ctws.vim'
call plug#end()
require("lazy").setup({
"MikeHorn-git/ctws.vim"
})
Modify the filetypes as needed. It's better to specify the exact filetypes you want to support. Certain filetypes, like Markdown, require trailing whitespace for specific purposes.
autocmd BufWritePre *.c *.py *.sh *.vim call CleanTrailingWhitespaceAndTabs()
vim.cmd([[
autocmd BufWritePre *.c,*.py,*.sh,*.vim call CleanTrailingWhitespaceAndTabs()
]])
nnoremap <Leader>ctws :Ctws<CR>
vim.keymap.set("n", "<leader>ctws", vim.cmd.Ctws) -- Ctws [Clean Trailing WhiteSpace]
Dangerous commands : Avoid using :s[ubstitute] as it moves the cursor and prints error messages. Prefer functions (such as search()) better suited to scripts. For many vim commands, functions exist that do the same thing with fewer side effects. See :help functions() for a list of built-in functions.