Skip to content

Commit

Permalink
Update README: add improved undojoin solution.
Browse files Browse the repository at this point in the history
@hoschi proposed a nice fix for issue sbdchd#134, I hope it can be put on the front page, in README.md.
  • Loading branch information
bachhh authored Sep 12, 2021
1 parent 3924dad commit 9fbf974
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,16 @@ augroup fmt
augroup END
```

However, undojoin is not allowed after undo, and save the buffer , the
following script will attempts to catch that error and perform a normal
format instead:
```viml
augroup fmt
autocmd!
au BufWritePre * try | undojoin | Neoformat | catch /^Vim\%((\a\+)\)\=:E790/ | finally | silent Neoformat | endtry
augroup END
```

When `undojoin` is used this way pressing `u` will "skip over" the Neoformat
changes - it will revert both the changes made by Neoformat and the change
that caused Neoformat to be invoked.
Expand Down

0 comments on commit 9fbf974

Please sign in to comment.