Skip to content

Commit 57a6e81

Browse files
committed
statusline: Provide overwrite mode indicator
1 parent c61670e commit 57a6e81

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

internal/config/settings.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ var defaultCommonSettings = map[string]interface{}{
9393
"softwrap": false,
9494
"splitbottom": true,
9595
"splitright": true,
96-
"statusformatl": "$(filename) $(modified)($(line),$(col)) $(status.paste)| ft:$(opt:filetype) | $(opt:fileformat) | $(opt:encoding)",
96+
"statusformatl": "$(filename) $(modified)$(overwrite)($(line),$(col)) $(status.paste)| ft:$(opt:filetype) | $(opt:fileformat) | $(opt:encoding)",
9797
"statusformatr": "$(bind:ToggleKeyMenu): bindings, $(bind:ToggleHelp): help",
9898
"statusline": true,
9999
"syntax": true,

internal/display/statusline.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ var statusInfo = map[string]func(*buffer.Buffer) string{
4747
}
4848
return ""
4949
},
50+
"overwrite": func(b *buffer.Buffer) string {
51+
if b.OverwriteMode && !b.Type.Readonly {
52+
return "[ovwr] "
53+
}
54+
return ""
55+
},
5056
"lines": func(b *buffer.Buffer) string {
5157
return strconv.Itoa(b.LinesNum())
5258
},

runtime/help/options.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -415,11 +415,11 @@ Here are the available options:
415415
* `statusformatl`: format string definition for the left-justified part of the
416416
statusline. Special directives should be placed inside `$()`. Special
417417
directives include: `filename`, `modified`, `line`, `col`, `lines`,
418-
`percentage`, `opt`, `bind`.
418+
`percentage`, `opt`, `overwrite`, `bind`.
419419
The `opt` and `bind` directives take either an option or an action afterward
420420
and fill in the value of the option or the key bound to the action.
421421

422-
default value: `$(filename) $(modified)($(line),$(col)) $(status.paste)|
422+
default value: `$(filename) $(modified)$(overwrite)($(line),$(col)) $(status.paste)|
423423
ft:$(opt:filetype) | $(opt:fileformat) | $(opt:encoding)`
424424

425425
* `statusformatr`: format string definition for the right-justified part of the
@@ -578,7 +578,7 @@ so that you can see what the formatting should look like.
578578
"splitbottom": true,
579579
"splitright": true,
580580
"status": true,
581-
"statusformatl": "$(filename) $(modified)($(line),$(col)) $(status.paste)| ft:$(opt:filetype) | $(opt:fileformat) | $(opt:encoding)",
581+
"statusformatl": "$(filename) $(modified)$(overwrite)($(line),$(col)) $(status.paste)| ft:$(opt:filetype) | $(opt:fileformat) | $(opt:encoding)",
582582
"statusformatr": "$(bind:ToggleKeyMenu): bindings, $(bind:ToggleHelp): help",
583583
"statusline": true,
584584
"sucmd": "sudo",

0 commit comments

Comments
 (0)