diff --git a/complete.go b/complete.go index e31a3caa..7e300024 100644 --- a/complete.go +++ b/complete.go @@ -101,6 +101,7 @@ var ( "cmd-delete-home", "cmd-delete-end", "cmd-delete-unix-word", + "cmd-delete-word-back", "cmd-yank", "cmd-transpose", "cmd-transpose-word", diff --git a/doc.go b/doc.go index cec820a1..6ecd8562 100644 --- a/doc.go +++ b/doc.go @@ -111,6 +111,7 @@ The following command line commands are provided by lf: cmd-word (default '') cmd-word-back (default '') cmd-delete-word (default '') + cmd-delete-word-back (default '' and '') cmd-capitalize-word (default '') cmd-uppercase-word (default '') cmd-lowercase-word (default '') @@ -632,6 +633,10 @@ Move the cursor by one word in forward/backward direction. Delete the next word in forward direction. + cmd-delete-word-back (default '' and '') + +Delete the previous word in backward direction. + cmd-capitalize-word (default '') cmd-uppercase-word (default '') cmd-lowercase-word (default '') diff --git a/docstring.go b/docstring.go index 36893927..92335026 100644 --- a/docstring.go +++ b/docstring.go @@ -114,6 +114,7 @@ The following command line commands are provided by lf: cmd-word (default '') cmd-word-back (default '') cmd-delete-word (default '') + cmd-delete-word-back (default '' and '') cmd-capitalize-word (default '') cmd-uppercase-word (default '') cmd-lowercase-word (default '') @@ -661,6 +662,10 @@ Move the cursor by one word in forward/backward direction. Delete the next word in forward direction. + cmd-delete-word-back (default '' and '') + +Delete the previous word in backward direction. + cmd-capitalize-word (default '') cmd-uppercase-word (default '') cmd-lowercase-word (default '') diff --git a/eval.go b/eval.go index 0c38c793..79036e12 100644 --- a/eval.go +++ b/eval.go @@ -2665,6 +2665,17 @@ func (e *callExpr) eval(app *app, args []string) { ind := loc[3] app.ui.cmdAccRight = []rune(string(app.ui.cmdAccRight)[ind:]) update(app) + case "cmd-delete-word-back": + if len(app.ui.cmdAccLeft) == 0 { + return + } + locs := reWordBeg.FindAllStringSubmatchIndex(string(app.ui.cmdAccLeft), -1) + if locs == nil { + return + } + ind := locs[len(locs)-1][3] + app.ui.cmdAccLeft = app.ui.cmdAccLeft[:ind] + update(app) case "cmd-uppercase-word": if len(app.ui.cmdAccRight) == 0 { return diff --git a/lf.1 b/lf.1 index c325374a..1394e70a 100644 --- a/lf.1 +++ b/lf.1 @@ -128,6 +128,7 @@ The following command line commands are provided by lf: cmd-word (default '') cmd-word-back (default '') cmd-delete-word (default '') + cmd-delete-word-back (default '' and '') cmd-capitalize-word (default '') cmd-uppercase-word (default '') cmd-lowercase-word (default '') @@ -776,6 +777,12 @@ Move the cursor by one word in forward/backward direction. .PP Delete the next word in forward direction. .PP +.EX + cmd-delete-word-back (default '' and '') +.EE +.PP +Delete the previous word in backward direction. +.PP .EX cmd-capitalize-word (default '') cmd-uppercase-word (default '') diff --git a/opts.go b/opts.go index 45bf3b60..bbce7997 100644 --- a/opts.go +++ b/opts.go @@ -351,6 +351,8 @@ func init() { gOpts.cmdkeys[""] = &callExpr{"cmd-word-back", nil, 1} gOpts.cmdkeys[""] = &callExpr{"cmd-capitalize-word", nil, 1} gOpts.cmdkeys[""] = &callExpr{"cmd-delete-word", nil, 1} + gOpts.cmdkeys[""] = &callExpr{"cmd-delete-word-back", nil, 1} + gOpts.cmdkeys[""] = &callExpr{"cmd-delete-word-back", nil, 1} gOpts.cmdkeys[""] = &callExpr{"cmd-uppercase-word", nil, 1} gOpts.cmdkeys[""] = &callExpr{"cmd-lowercase-word", nil, 1} gOpts.cmdkeys[""] = &callExpr{"cmd-transpose-word", nil, 1}