From 1b3cb450e1c537fea662080af9ece1c43058ac94 Mon Sep 17 00:00:00 2001 From: Thomas Buckley-Houston Date: Tue, 16 May 2017 09:03:16 +0700 Subject: Better rules for entering insertmode --- plugin/novim-mode.vim | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'plugin') diff --git a/plugin/novim-mode.vim b/plugin/novim-mode.vim index ef72015..000d0cb 100644 --- a/plugin/novim-mode.vim +++ b/plugin/novim-mode.vim @@ -1,7 +1,18 @@ " Make sure insert mode is the default mode when opening/switching to files +function! InsertMode() + if &buftype ==# 'nofile' + \|| !&modifiable + \|| &readonly + \|| bufname('%') =~# 'NERD_tree_' + exe "set noinsertmode" + else + exe "set insertmode" + endif +endfunction + augroup start_insertmode autocmd! - autocmd BufEnter * if &modifiable | startinsert | endif + autocmd BufEnter * call InsertMode() augroup END " Copy and paste stuff @@ -24,6 +35,8 @@ vnoremap <gv " CTRL+q to exit pane/app inoremap :q +" Useful for exiting buffers like NERDTree that don't use insertmode +nnoremap :q " Find inoremap / @@ -33,6 +46,7 @@ inoremap n inoremap :noh " Undo/redo +" Doesn't use Ctrl+Z because that's already a significant *nix shortcut inoremap u inoremap @@ -43,7 +57,7 @@ inoremap :update inoremap "_dd " CTRL+d duplicates current line -" TODO: don't put it vim's clipboard, so CTRL+V works as expected +" TODO: don't put it in vim's clipboard, so CTRL+V works as expected inoremap yyp " Alt+/- moves the current line up and down @@ -57,8 +71,7 @@ inoremap ^ au BufNewFile,BufRead *.txt,*.md,*.markdown setlocal linebreak spell " Make arrow keys move through wrapped lines " TODO: -" * Scroll 1 wrapped soft line at a time rather an entire block of wrapped +" * Scroll window 1 wrapped soft line at a time rather an entire block of wrapped " lines. au BufNewFile,BufRead *.txt,*.md,*.markdown inoremap gk au BufNewFile,BufRead *.txt,*.md,*.markdown inoremap gj - -- cgit v1.2.3-70-g09d2