New answers tagged

1 vote

Remove blank lines at end of file

With some help from :help [range]: :$;?\S?+,$delete The range says from $;?\S?+ (roughly prevnonblank('$'), though with no special casing for the last line containing text) to $ (end of file), ...
D. Ben Knoble's user avatar
  • 25.8k
1 vote

Remove blank lines at end of file

Pretty straightforward solution with VimScript autocmd BufWritePre <buffer> call deletebufline('%', prevnonblank('$') + 1, '$')
Matt's user avatar
  • 20.6k
2 votes

Remove blank lines at end of file

The following substitution remove the last empty lines: %s/\_s*\%$//e The \_s atom match any white space including new line. The \%$ atom match the end of the buffer. You could do: autocmd FileType c,...
Vivian De Smedt's user avatar
0 votes

Detecting the Enter and Leave of Visual mode event

I went ahead and rewrote 3N4N's answer in Lua in case some Neovim users would like to take advantage of this: local visual_event_group = vim.api.nvim_create_augroup("visual_event", { clear ...
unrealapex's user avatar
0 votes

Remembering folds across sessions but in Lua

I would use the zM command: local folds_augroup = vim.api.nvim_create_augroup("Folds", { clear=true }) vim.api.nvim_create_autocmd("BufWritePost", { group = folds_augroup, ...
Vivian De Smedt's user avatar

Top 50 recent answers are included