diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2024-07-30 00:44:53 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2024-07-30 00:44:53 -0300 |
commit | c0c227d51a3caf5502eac6bd65ab01117f12d29a (patch) | |
tree | aefb342134e1f740cf0f0cacd503250e8a40f189 | |
parent | 32131c83c870e4900c21443b997ee7172753e470 (diff) | |
download | vim-c0c227d51a3caf5502eac6bd65ab01117f12d29a.tar.gz vim-c0c227d51a3caf5502eac6bd65ab01117f12d29a.tar.bz2 |
Feat: adds TrimWhitespace()
-rw-r--r-- | vim.dot.link/plugin/key_mappings.vim | 4 | ||||
-rw-r--r-- | vim.dot.link/plugin/lib.vim | 11 |
2 files changed, 15 insertions, 0 deletions
diff --git a/vim.dot.link/plugin/key_mappings.vim b/vim.dot.link/plugin/key_mappings.vim index 2b0f2e7..0c8bfba 100644 --- a/vim.dot.link/plugin/key_mappings.vim +++ b/vim.dot.link/plugin/key_mappings.vim @@ -245,3 +245,7 @@ nnoremap <leader>d i<C-R>=strftime('%Y-%m-%d')<CR> inoremap <leader>d <C-R>=strftime('%Y-%m-%d')<CR> map <leader>e :put =strftime('## %Y-%m-%d')<CR> " }}} + +" Remove trailing whitespaces {{{ +noremap <leader>w :call TrimWhitespace()<CR> +" }}} diff --git a/vim.dot.link/plugin/lib.vim b/vim.dot.link/plugin/lib.vim index 0e4cafa..9e7b689 100644 --- a/vim.dot.link/plugin/lib.vim +++ b/vim.dot.link/plugin/lib.vim @@ -19,3 +19,14 @@ " call setline('.', substitute(line, '- ', '- \[ \] ', '')) " endif "endf + +" Remove trailing spaces +" +" Thanks https://vi.stackexchange.com/a/456 +fun! TrimWhitespace() + let l:save = winsaveview() + keeppatterns %s/\s\+$//e + call winrestview(l:save) +endfun + +command! TrimWhitespace call TrimWhitespace() |