From f0c74a76e04a07153fc11c386601fc03dff11d7a Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Tue, 2 Apr 2024 21:17:05 +0100 Subject: [PATCH] Add :RStrip command to strip trailing white space --- lua/commands.lua | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lua/commands.lua b/lua/commands.lua index 68902d9..f610ab8 100644 --- a/lua/commands.lua +++ b/lua/commands.lua @@ -1,3 +1,12 @@ +-- :RString Strip white psace from right of all lines +-- TODO: Make this work on a range +vim.api.nvim_create_user_command('RStrip', function(_) + local cursor_pos = vim.fn.getcurpos(vim.api.nvim_get_current_win()) + vim.cmd [[ execute '%s/\s\+$//e' ]] + vim.cmd [[ nohlsearch ]] + vim.fn.setpos('.', cursor_pos) +end, {}) + -- :TabWidth set the tab width for the current buffer vim.api.nvim_create_user_command('TabWidth', function(opts) -- Set the tab width for the current filetype