Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
Nick Ballard edited this pageDec 14, 2023 ·7 revisions

Kakoune keeps track of every modification you make to a buffer.

It does this bookkeeping in a non linear way: it means that if you undo a few changes and then decide to make a new one, it will create a branch in the history tree.

Let's see how it works through a concrete example.

Example

Open a new buffer and insert the texthello. Next make your first change by adding world. Finally you decide this is better to changeworld touniverse.Here's how your history looks:

   hello     ↓  modif 1     ↓ hello world     ↓  modif 2     ↓hello universe

By pressing theu key youundo your change and go back tohello world. Now pressU to redo your change and get back tohello universe. For now the path is linear, soundo andredo let you move back or forward on this unique branch.

Pressu to undo to get back tohello world again. You change your mind and decide to writehello galaxy. By doing so, you've juste created a branch in the history!

           hello             ↓           modif 1             ↓        hello world     ↓               ↓    modif 2         modif 3     ↓               ↓hello universe   hello galaxy

If you do a simple undo (u), you will get back tohello world and doing a redo (U) will teleport you tohello galaxy. Using only these 2 commands, you're trapped in the new history branch you created, and there seems to be no way to retrieve thehello universe state. Is it really lost forever?

Fear not, there's a way to teleport to it! As you see in the diagram above, each modification has a unique autoincrement id. This number is independent of your current branch. By pressing<c-k> from thehello world state, which has number 3, your go the the state number 2hello universe.<c-j> goes the opposite direction by incrementing the history id.

So to recap the coupleu andU lets you move backward and forward in the last branch while their alternative versions<c-k><c-j> follow absolute history id which may be located somewhere else in the history tree.

UI and scripting

You can know your position in the tree by looking at the status bar after pressing<c-k> or<c-j>. The messagemoved to change #3 (11) indicates that you are currently on the history node3 on a total of11.

While scripting you have access to the$kak_history_id

Clone this wiki locally

[8]ページ先頭

©2009-2025 Movatter.jp