Skip to content

Instantly share code, notes, and snippets.

@matiasfha
Created January 23, 2018 12:40
Show Gist options
  • Save matiasfha/761677029ce81ed75af140eabd4da1f4 to your computer and use it in GitHub Desktop.
Save matiasfha/761677029ce81ed75af140eabd4da1f4 to your computer and use it in GitHub Desktop.
Delete current file in vim and close the buffer.
" Delete the current file and close the buffer
function! DeleteFileAndCloseBuffer()
let b:choice = confirm("Delete file and close buffer?", "&Yes\n&No",1)
if b:choice == 1
call delete(expand('%:p')) | bdelete!
endif
endfunction
" Map to ;rm
nnoremap <silent> <leader>rm :call DeleteFileAndCloseBuffer()<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment