home/rc/core/formatter.kak
Maxime Coste fef0277998 Reorganise rc/ into subdirectories
* core: set of tools to work on kakoune source code
 * base: very common languages and tools
 * extra: less common languages and tools
2016-01-29 09:03:23 +00:00

15 lines
525 B
Plaintext

decl str formatcmd ""
def format -docstring "Format the entire buffer with an external utility" %{
%sh{
if [ ! -z "${kak_opt_formatcmd}" ]; then
## Save the current position of the cursor
readonly x=$((kak_cursor_column - 1))
readonly y="${kak_cursor_line}"
echo "exec -draft %{%|${kak_opt_formatcmd// /<space>}<ret>}"
## Try to restore the position of the cursor as it was prior to formatting
echo "exec gg ${y}g ${x}l"
fi
}
}