mirror of
				https://github.com/tiyn/tidy.nvim.git
				synced 2025-10-30 10:41:21 +01:00 
			
		
		
		
	[docs,feat]: protect search history and jump list
- add `keepjumps` and `keeppatterns` modifiers to regex commands
    - update readme
			
			
This commit is contained in:
		| @@ -1,7 +1,5 @@ | |||||||
| -- MP | -- 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/a/7501902 |  | ||||||
|  |  | ||||||
| local M = {} | local M = {} | ||||||
|  |  | ||||||
| @@ -12,10 +10,10 @@ function M.tidy_up() | |||||||
|     local pos = vim.api.nvim_win_get_cursor( 0 ) |     local pos = vim.api.nvim_win_get_cursor( 0 ) | ||||||
|  |  | ||||||
|     -- delete all whitespace, see source 1 |     -- delete all whitespace, see source 1 | ||||||
|     vim.cmd[[:%s/\s\+$//e]] |     vim.cmd[[:keepjumps keeppatterns %s/\s\+$//e]] | ||||||
|  |  | ||||||
|     -- delete all lines at end of buffer, see source 2 |     -- delete all lines at end of buffer, see source 2 | ||||||
|     vim.cmd[[:silent! 0;/^\%(\n*.\)\@!/,$d]] |     vim.cmd[[:keepjumps keeppatterns silent! 0;/^\%(\n*.\)\@!/,$d]] | ||||||
|  |  | ||||||
|     -- get row count after line deletion |     -- get row count after line deletion | ||||||
|     local end_row = vim.api.nvim_buf_line_count( 0 ) |     local end_row = vim.api.nvim_buf_line_count( 0 ) | ||||||
|   | |||||||
| @@ -14,3 +14,6 @@ https://user-images.githubusercontent.com/59481467/138811091-05031eb1-96fc-4915- | |||||||
| Credits: | Credits: | ||||||
| 1. [Vim Tips Wiki entry for removing unwanted spaces](https://vim.fandom.com/wiki/Remove_unwanted_spaces#Automatically_removing_all_trailing_whitespace) | 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) | 2. ib., the author of [this stack overflow answer](https://stackoverflow.com/a/7501902) | ||||||
|  | 3. [This line](https://github.com/gpanders/editorconfig.nvim/blob/ae3586771996b2fb1662eb0c17f5d1f4f5759bb7/lua/editorconfig.lua#L180) | ||||||
|  | in [gpanders/editorconfig.nvim](https://github.com/gpanders/editorconfig.nvim) for exposing me to the `keepjumps` | ||||||
|  | and `keeppatterns` modifiers | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user