소스 검색

Smart indent with `i` on (empty) newlines

Andrew Swistak 8 년 전
부모
커밋
d4abec3199
1개의 변경된 파일10개의 추가작업 그리고 0개의 파일을 삭제
  1. 10 0
      vimrc

+ 10 - 0
vimrc

@@ -370,6 +370,16 @@ function! IndentWithI()
 endfunction
 nnoremap <expr> i IndentWithI()
 
+" Smart indent when entering insert mode with i on empty lines
+function! IndentWithI()
+    if len(getline('.')) == 0
+        return "\"_cc"
+    else
+        return "i"
+    endif
+endfunction
+nnoremap <expr> i IndentWithI()
+
 " For auto-aligning '|' delimited tables
 inoremap <silent> <Bar>   <Bar><Esc>:call <SID>align()<CR>a
 function! s:align()