Skip to content

🧹 Clean Trailing WhiteSpace vim plugin

License

Notifications You must be signed in to change notification settings

MikeHorn-git/ctws.vim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Description

KISS plugin. Removes unwanted tabs and trailing whitespace. Nothing more, nothing less.

Features

  • Removes trailing whitespace globally
  • Removes trailing tabs globally
  • Removes whitespace on empty lines
  • Removes tabs on empty lines

Installation

Use your favorite plugin manager.

Vim

Vim-plug

call plug#begin()
Plug 'MikeHorn-git/ctws.vim'
call plug#end()

Neovim

Lazy

require("lazy").setup({
    "MikeHorn-git/ctws.vim"
})

Autocmd

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.

Vim

autocmd BufWritePre *.c *.py *.sh *.vim call CleanTrailingWhitespaceAndTabs()

Neovim

vim.cmd([[
  autocmd BufWritePre *.c,*.py,*.sh,*.vim call CleanTrailingWhitespaceAndTabs()
]])

Shortcut

Vim

nnoremap <Leader>ctws :Ctws<CR>

Neovim

vim.keymap.set("n", "<leader>ctws", vim.cmd.Ctws) -- Ctws [Clean Trailing WhiteSpace]

Why not use :s[ubstitute] ?

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.

Credits

About

🧹 Clean Trailing WhiteSpace vim plugin

Topics

Resources

License

Stars

Watchers

Forks