Format specific selected lines


#1

I added those lines in kakrc. And it is working, but it is formating all the file :

hook global WinSetOption filetype=c %{
set window formatcmd ‘clang-format’
}
map global normal = :format<ret> -docstring ‘format buffer’

Is there a way to format only selected line with ‘X’ ?


#2

you can pipe selection with | to clang format, although it will make no sense to clang format without surrounding information, and it will probably screw your formatting


#3

Thanks it is working well.
I added this map to format the selection with f3 (if it can help someone) :

map global normal ‘|clang-format’