diff --git a/book/src/generated/typable-cmd.md b/book/src/generated/typable-cmd.md index cf1b550dc..2511d34b1 100644 --- a/book/src/generated/typable-cmd.md +++ b/book/src/generated/typable-cmd.md @@ -86,5 +86,6 @@ | `:clear-register` | Clear given register. If no argument is provided, clear all registers. | | `:redraw` | Clear and re-render the whole UI | | `:move` | Move the current buffer and its corresponding file to a different path | +| `:move!` | Force move the current buffer and its corresponding file to a different path, overwriting the destination. | | `:yank-diagnostic` | Yank diagnostic(s) under primary cursor to register, or clipboard by default | | `:read`, `:r` | Load a file into buffer | diff --git a/helix-term/src/commands/typed.rs b/helix-term/src/commands/typed.rs index 62009b717..eb8a2ad76 100644 --- a/helix-term/src/commands/typed.rs +++ b/helix-term/src/commands/typed.rs @@ -2431,6 +2431,19 @@ fn move_buffer( move_buffer_impl(cx, args.first().unwrap(), false) } +fn force_move_buffer( + cx: &mut compositor::Context, + args: &[Cow], + event: PromptEvent, +) -> anyhow::Result<()> { + if event != PromptEvent::Validate { + return Ok(()); + } + + ensure!(args.len() == 1, format!(":move! takes one argument")); + move_buffer_impl(cx, args.first().unwrap(), true) +} + fn yank_diagnostic( cx: &mut compositor::Context, args: &[Cow], @@ -3111,6 +3124,13 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[ fun: move_buffer, signature: CommandSignature::positional(&[completers::filename]), }, + TypableCommand { + name: "move!", + aliases: &[], + doc: "Force move the current buffer and its corresponding file to a different path, overwriting the destination.", + fun: force_move_buffer, + signature: CommandSignature::positional(&[completers::filename]), + }, TypableCommand { name: "yank-diagnostic", aliases: &[],