1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-09-11 04:46:05 +03:00

Add a heading for each example, and document the new cursor_char_value feature.

Screwtapello 2017-09-12 16:11:49 +10:00
parent f75a82a266
commit c8c3fceb36

@ -42,7 +42,11 @@ DisplayLine mode_line() const override
}
```
---
# Examples
Here's some simple things you might want to include in your status line.
## The current date and time
The modeline is regularly updated, so:
@ -51,7 +55,15 @@ set global modelinefmt '%sh{date}'
```
will display the current date with elapsing seconds.
Display how many buffers are currently opened:
## Codepoint of the character under the cursor
Many Unicode characters are quite similar, and it can be difficult to tell at a glance whether the character you're looking at is (say) U+0027 APOSTROPHE or U+2019 RIGHT SINGLE QUOTE. If you display the codepoint of the character under the cursor in the status bar, even if you don't recognise the specific code-point, at least you've got a specific value you can look up.
```
set global modelinefmt 'U+%sh{printf "%04x" "$kak_cursor_char_value"}'
```
## How many buffers are currently open:
```
set global modelinefmt '%sh{bs=${kak_buflist//[^:]};echo $((${#bs}+1))} buffers'
@ -65,6 +77,8 @@ Explanation:
}
```
## Cursor position as a percentage of the whole file
To show the [relative position of the cursor in percent](https://github.com/lenormf/kakoune-extra/blob/master/widgets/percent.kak) using `wc`:
```
@ -86,6 +100,7 @@ hook global WinCreate .* %{
}
```
## Git branch integration
Here's another [example by lenormf](https://github.com/mawww/kakoune/issues/657) on how to add more info to the modeline, like the current git branch (status bar)