From d9f6bea1dc979aad3e14f60590a3fdcd2c43beb8 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 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lua/commands.lua b/lua/commands.lua index 68902d9..b6aef83 100644 --- a/lua/commands.lua +++ b/lua/commands.lua @@ -1,3 +1,11 @@ +-- :RString Strip white psace from right of all lines +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