dotfiles

Personal dotfiles
git clone https://git.bracken.jp/dotfiles.git
Log | Files | Refs | LICENSE

commit b94bbe4f90fb6e257b45398064e7d2a698893833
parent 8e472f537396f6a6860352dda4b28f56c8b1fb95
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:
M.vim/vimrc | 14++++++++++++++
1 file changed, 14 insertions(+), 0 deletions(-)

diff --git a/.vim/vimrc b/.vim/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