Skip Navigation
keymap to inspect unsaved changes
  • I just use it all the time when I forget what I changed and want to make sure I’m ok with all changes before saving.

    It is very similar to a command in emacs called M-x diff-buffer-with-file.

  • keymap to inspect unsaved changes

    Hello, I wanted to share a small keymap I made. It lets you inspect unsaved changes in the current file. It uses diff mode, in a vertical split.

    To close the diff mode, just press q in the scratch buffer.

    lua vim.keymap.set( 'n', '<M-C-D>', function() local tmpft = vim.bo.filetype vim.cmd.vnew() vim.bo.filetype = tmpft vim.bo.buftype = 'nofile' vim.keymap.set( 'n', 'q', '<cmd>bw<cr>', { noremap = true, silent = true, buffer = true } ) vim.cmd('silent r#|0d_') vim.bo.modifiable = false vim.cmd('diffthis|wincmd p|diffthis') end, { noremap = true } )

    edit: I discovered that this functionality is actually documented in the help pages (:h :DiffOrig). It’s basically the same action but bound to a command

    7
    InitialsDiceBearhttps://github.com/dicebear/dicebearhttps://creativecommons.org/publicdomain/zero/1.0/„Initials” (https://github.com/dicebear/dicebear) by „DiceBear”, licensed under „CC0 1.0” (https://creativecommons.org/publicdomain/zero/1.0/)SX
    sxwpb @lemmy.world
    Posts 1
    Comments 2