nvim delete current file ━━━━━━━━━━━━━━━━━━━━━━━━ This one is one that I've been using quite often, I did't have a hotkey for it, I just used the shell command. Date: September 2, 2025 This one is one that I’ve been using quite often, I did’t have a hotkey for it, I just used the rm shell command. ``` !!rm % ``` When you type !! from normal mode it will automatically put you in command mode with .! pre-filled, then you just type rm and to auto-complete the current file name, and to execute the command. ``` :.!rm % ``` Making it better ──────────────── The one quirk that I don’t like about this is that the buffer remains open after deleting, and sometimes I forget to close it and end up re-creating it by mistake when running :wall or :xall. Create a DeleteFile command with vim command. ``` :command! DeleteFile execute "!rm %" | bdelete! ``` Create a DeleteFile command with lua. ``` vim.api.nvim_create_user_command( 'DeleteFile', function() -- Delete the current file from disk vim.cmd('!rm %') -- Close the buffer without saving vim.cmd('bdelete!') end, {} ) ```