Kaynağa Gözat

Smart indent with `i` on (empty) newlines

Andrew Swistak 8 yıl önce
ebeveyn
işleme
d4abec3199
1 değiştirilmiş dosya ile 10 ekleme ve 0 silme
  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()