Ver código fonte

Smart indent with `i` on (empty) newlines

Andrew Swistak 8 anos atrás
pai
commit
ac42e8a42b
1 arquivos alterados com 10 adições e 0 exclusões
  1. 10 0
      vimrc

+ 10 - 0
vimrc

@@ -363,6 +363,16 @@ if !has("nvim")
   endw
 endif
 
+" 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()