this post was submitted on 24 Mar 2024
355 points (95.6% liked)

linuxmemes

20880 readers
9 users here now

I use Arch btw


Sister communities:

Community rules

  1. Follow the site-wide rules and code of conduct
  2. Be civil
  3. Post Linux-related content
  4. No recent reposts

Please report posts and comments that break these rules!

founded 1 year ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 4 points 8 months ago* (last edited 8 months ago)

Use suda.vim for automatically dealing with such cases. Works with neovim as well.

I'll also recommend adding the following to your init.lua or some config file because suda doesn't play nicely with nvim -d or vimdiff.

-- Disable Suda in diff views
if not vim.api.nvim_win_get_option(0, 'diff') then
    vim.g.suda_smart_edit = 1
end

The vimscript version of the same would be:

" Disable Suda in diff views
if ! &diff
    let g:suda_smart_edit = 1
endif