vim

vim config files
git clone https://git.bracken.jp/vim.git
Log | Files | Refs | LICENSE

commit 32cd8c793a61c72ae757daa813d1529ee25655c8
parent f5fe4874f56e0ac10a066c80acd716a5171dbb59
Author: Chris Bracken <chris@bracken.jp>
Date:   Tue,  9 Oct 2018 21:19:47 -0700

Define ClangFormat() map to C-K

If a visual selection exists, formats the selected lines; otherwise,
formats the entire file.

Diffstat:
Mvimrc | 14++++++++++++++
1 file changed, 14 insertions(+), 0 deletions(-)

diff --git a/vimrc b/vimrc @@ -38,6 +38,20 @@ noremap <Down> <NOP> noremap <Left> <NOP> noremap <Right> <NOP> +" Map clang-format +map <C-K> :call ClangFormat()<cr> +imap <C-K> <c-o> :call ClangFormat()<cr> + +function ClangFormat() + let l:line_start = getpos("'<")[1] + let l:line_end = getpos("'>")[1] + let l:lines = "all" + if l:line_start != 0 && l:line_end != 0 + let l:lines = l:line_start . ":" . l:line_end + endif + py3f ~/share/clang/clang-format.py +endfunction + " Retain selection on <,> vmap < <gv vmap > >gv