Skip to content

Commit

Permalink
Auto new line { added
Browse files Browse the repository at this point in the history
  • Loading branch information
davixcky committed Apr 9, 2020
1 parent cce6fe6 commit f6a74ce
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions .vimrc
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ noremap <leader>ss :call StripWhitespace()<CR>
" Save a file as root (,W)
noremap <leader>W :w !sudo tee % > /dev/null<CR>
" Add a new line before {
function! SpaceBeforeLeftParen()
:silent! %s/\(\s\+\)\@<!{/\r{/
:g/^\s*$/d
endfunction

" Automatic commands
if has("autocmd")
" Enable file type detection
Expand All @@ -110,6 +116,8 @@ if has("autocmd")
autocmd BufWritePre *.c,*.py :normal gg=G
"Trim blank lines in the end of file
autocmd BufWritePre *.c,*.py $put _ | $;?\(^\s*$\)\@!?+2,$d
" Apply betty style on c
autocmd BufWritePost *.c :call SpaceBeforeLeftParen()
endif

" Commands for splitting windows
Expand All @@ -120,14 +128,5 @@ nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
" Auto close
inoremap " ""<left>
inoremap ' ''<left>
inoremap ( ()<left>
inoremap [ []<left>
inoremap { {}<left>
inoremap {<CR> {<CR>}<ESC>O
inoremap {;<CR> {<CR>};<ESC>O
" Vertical linex
let g:indentLine_enabled = 1

0 comments on commit f6a74ce

Please sign in to comment.