diff --git a/doc.go b/doc.go index dea4e95..d511b2b 100644 --- a/doc.go +++ b/doc.go @@ -74,6 +74,7 @@ keybindings: cmd-word (default '') cmd-word-back (default '') cmd-capitalize-word (default '') + cmd-delete-word (default '') The following options can be used to customize the behavior of lf: diff --git a/docstring.go b/docstring.go index 36cacc7..7a8c150 100644 --- a/docstring.go +++ b/docstring.go @@ -78,6 +78,7 @@ keybindings: cmd-word (default '') cmd-word-back (default '') cmd-capitalize-word (default '') + cmd-delete-word (default '') The following options can be used to customize the behavior of lf: diff --git a/eval.go b/eval.go index 901feca..66d72d0 100644 --- a/eval.go +++ b/eval.go @@ -642,6 +642,15 @@ func (e *callExpr) eval(app *app, args []string) { app.ui.cmdAccLeft = append(app.ui.cmdAccLeft, app.ui.cmdAccRight[:ind]...) app.ui.cmdAccRight = app.ui.cmdAccRight[ind:] } + case "cmd-delete-word": + if len(app.ui.cmdAccRight) > 0 { + loc := reWordEnd.FindStringIndex(string(app.ui.cmdAccRight)) + if loc == nil { + return + } + ind := loc[0] + 1 + app.ui.cmdAccRight = app.ui.cmdAccRight[ind:] + } default: cmd, ok := gOpts.cmds[e.name] if !ok { diff --git a/opts.go b/opts.go index c189951..9764b49 100644 --- a/opts.go +++ b/opts.go @@ -145,6 +145,7 @@ func init() { gOpts.cmdkeys[""] = &callExpr{"cmd-word", nil, 1} gOpts.cmdkeys[""] = &callExpr{"cmd-word-back", nil, 1} gOpts.cmdkeys[""] = &callExpr{"cmd-capitalize-word", nil, 1} + gOpts.cmdkeys[""] = &callExpr{"cmd-delete-word", nil, 1} // TODO: implement the rest of readline keys