[docs,style]:

- clean readme again
    - change function name from what I had it as in my configs to
      something more fitting for the repo
main
McAuleyPenney 3 years ago
parent 472ce3b347
commit 9acc5686ce

@ -1,12 +1,12 @@
-- MP
-- These sources did all the work
-- 1. https://vim.fandom.com/wiki/Remove_unwanted_spaces#Automatically_removing_all_trailing_whitespace
-- 2. https://stackoverflow.com/questions/7495932/how-can-i-trim-blank-lines-at-the-end-of-file-in-vim
-- 2. https://stackoverflow.com/a/7501902
local M = {}
function M.clear_spaces()
function M.tidy_up()
-- get tuple of cursor position before making changes
local pos = vim.api.nvim_win_get_cursor( 0 )
@ -26,11 +26,10 @@ function M.clear_spaces()
position tuple is greater than the
line count after empty line deletion
(meaning that the cursor was inside of
the empty lines at the end of the file
when they were deleted), set the cursor
row to the last line
the group of empty lines at the end of
the file when they were deleted), set
the cursor row to the last line
]]
if pos[1] > end_row then
pos[1] = end_row
end

@ -1,5 +1,5 @@
augroup Tidy
au!
au BufWritePre * lua require( "tidy.init" ).clear_spaces()
au BufWritePre * lua require( "tidy.init" ).tidy_up()
augroup END

@ -1,12 +1,16 @@
## tidy.nvim 🧹
A function and autocommand pair that removes all trailing whitespace \
and all empty lines at the end of the buffer on every `BufWritePre`.
A function and autocommand pair that removes all
- trailing whitespace
- empty lines at the end of the buffer
on every `BufWritePre`.
https://user-images.githubusercontent.com/59481467/138811091-05031eb1-96fc-4915-a349-e41d87c921ea.mp4
Credits:
1. https://vim.fandom.com/wiki/Remove_unwanted_spaces#Automatically_removing_all_trailing_whitespace
2. ib. from https://stackoverflow.com/questions/7495932/how-can-i-trim-blank-lines-at-the-end-of-file-in-vim
1. [Vim Tips Wiki entry for removing unwanted spaces](https://vim.fandom.com/wiki/Remove_unwanted_spaces#Automatically_removing_all_trailing_whitespace)
2. ib., the author of [this stack overflow answer](https://stackoverflow.com/a/7501902)

Loading…
Cancel
Save