aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2017-10-14 17:21:00 -0300
committerSilvio Rhatto <rhatto@riseup.net>2017-10-14 17:21:00 -0300
commit6ebc231f438c9d379832561c437f3f4384b3e989 (patch)
tree9d85807db14d5778f17572d28cdff190bccc6734
parent7453c059a776f7bed49901efad44c1ed66ff5c3c (diff)
downloadvim-6ebc231f438c9d379832561c437f3f4384b3e989.tar.gz
vim-6ebc231f438c9d379832561c437f3f4384b3e989.tar.bz2
Sort .vimrc and switch to ESC-based key maps
-rw-r--r--vimrc.dot.link114
1 files changed, 70 insertions, 44 deletions
diff --git a/vimrc.dot.link b/vimrc.dot.link
index 54806ee..1b829cb 100644
--- a/vimrc.dot.link
+++ b/vimrc.dot.link
@@ -1,12 +1,12 @@
" VIM configuration
+
+" Basic options
syn on
set nu
-
set background=dark
set nobackup
set nowritebackup
set noswapfile
-
set noautoindent
set nosmartindent
set tabstop=2
@@ -17,20 +17,14 @@ set autoread
set nocompatible
set laststatus=2
set shortmess+=I
-
set ignorecase
set smartcase
+" Window title handling
set title
set titleold="terminal"
set titlestring=vim:\ %F
-" Command mode completion
-" See https://stackoverflow.com/questions/526858/how-do-i-make-vim-do-normal-bash-like-tab-completion-for-file-names
-"set wildmode=longest,list
-set wildmode=longest,list,full
-set wildmenu
-
" Thanks to http://stackoverflow.com/questions/1673649/vimrc-action-onclose
function! ResetTitle(title)
" disable vim's ability to set the title
@@ -44,6 +38,12 @@ endfunction
au VimLeave *mutt/* silent call ResetTitle("mutt")
au VimLeave *remind/* silent call ResetTitle("wyrd")
+" Command mode completion
+" See https://stackoverflow.com/questions/526858/how-do-i-make-vim-do-normal-bash-like-tab-completion-for-file-names
+"set wildmode=longest,list
+set wildmode=longest,list,full
+set wildmenu
+
" Folding
set foldmethod=syntax
set foldlevelstart=99
@@ -101,8 +101,27 @@ let g:syntastic_mode_map={ 'mode': 'passive',
\ 'active_filetypes': [],
\ 'passive_filetypes': [] }
-" Shortcut to open a new tab
+" Write, quit and close shortcuts using Esc-key combos
+" ESC keys have the advantage over Alt shortcuts as they
+" are difficult to be mistaken for the Meta key
nmap <ESC>n :tabnew<CR>
+nmap <ESC>t :OpenNERDTree<CR>
+nmap <ESC>q :wqa <CR>
+"map <ESC>c :wqa <CR>
+"map <ESC>f :wq <CR>
+nmap <ESC>c :tabclose <CR>
+"map <ESC>e :tabclose <CR>
+nmap <ESC>m :q! <CR>
+nmap <ESC>w :w <CR>
+imap <ESC>n <ESC>:tabnew<CR>
+imap <ESC>t <ESC>:OpenNERDTree<CR>
+imap <ESC>q <ESC>:wqa <CR>
+"map <ESC>c <ESC>:wqa <CR>
+"map <ESC>f <ESC>:wq <CR>
+imap <ESC>c <ESC>:tabclose <CR>
+"map <ESC>e <ESC>:tabclose <CR>
+imap <ESC>m <ESC>:q! <CR>
+imap <ESC>w <ESC>:w <CR>
" Write, quit and close shortcuts using Alt-key combos
"
@@ -122,12 +141,12 @@ nmap <ESC>n :tabnew<CR>
" but this does not seem to be the case. Anyway there's interesting discussion at
" https://stackoverflow.com/questions/5142099/how-to-auto-save-vim-session-on-quit-and-auto-reload-on-start-including-split-wi
"map q :wqa <CR>
-map c :wqa <CR>
-map f :wq <CR>
+"map c :wqa <CR>
+"map f :wq <CR>
"map c :tabclose <CR>
-map e :tabclose <CR>
-map m :q! <CR>
-map w :w <CR>
+"map e :tabclose <CR>
+"map m :q! <CR>
+"map w :w <CR>
" Write, quit and close shortcuts using Ctrl-key combos
" We're using these due to a conflict with wyrd(1)
@@ -144,6 +163,42 @@ map w :w <CR>
"map m :q! <CR>
"map w :w <CR>
+" Tab navigation
+" See http://vim.wikia.com/wiki/Alternative_tab_navigation
+" http://comments.gmane.org/gmane.os.cygwin.xfree/16419
+nmap <ESC>[5^ <C-PageUp>
+nmap <ESC>[6^ <C-PageDown>
+nnoremap <C-PageDown> :tabn<CR>
+nnoremap <C-PageUp> :tabp<CR>
+nmap 1 1gt
+nmap 2 2gt
+nmap 3 3gt
+nmap 4 4gt
+nmap 5 5gt
+nmap 6 6gt
+nmap 7 7gt
+nmap 8 8gt
+nmap 9 9gt
+nmap 0 10gt
+
+" Buffer navigation: Alt-{Up,Down}
+map Od :bprevious<CR>
+map Oc :bnext<CR>
+
+" Window navigation
+"map <Left> <C-w><Left>
+"map <Right> <C-w><Right>
+"map <Down> <C-w><Down>
+"map <Up> <C-w><Up>
+nmap <ESC><Left> <C-w><Left>
+nmap <ESC><Right> <C-w><Right>
+nmap <ESC><Down> <C-w><Down>
+nmap <ESC><Up> <C-w><Up>
+imap <ESC><Left> <ESC><C-w><Left>
+imap <ESC><Right> <ESC><C-w><Right>
+imap <ESC><Down> <ESC><C-w><Down>
+imap <ESC><Up> <ESC><C-w><Up>
+
" NERDTree section
" Thanks to http://stackoverflow.com/questions/1447334/how-do-you-add-nerdtree-to-your-vimrc
@@ -177,7 +232,6 @@ cnoreabbrev ssave SaveSession
command -nargs=1 -complete=dir T :call TabNew(<f-args>)
command -nargs=1 -complete=customlist,nerdtree#completeBookmarks B :call TabNewBookmark(<f-args>)
command -nargs=0 OpenNERDTree :call OpenNERDTree()
-nmap <ESC>t :OpenNERDTree<CR>
" See http://superuser.com/questions/10588/how-to-make-cut-copy-paste-in-gvim-on-ubuntu-work-with-ctrlx-ctrlc-ctrlv
"imap <C-v> <C-r><C-o>+
@@ -218,34 +272,6 @@ set laststatus=2 " Always display the statusline in all windows
set showtabline=2 " Always display the tabline, even if there is only one tab
set noshowmode " Hide the default mode text (e.g. -- INSERT -- below the statusline)
-" Tab navigation
-" See http://vim.wikia.com/wiki/Alternative_tab_navigation
-" http://comments.gmane.org/gmane.os.cygwin.xfree/16419
-nmap <ESC>[5^ <C-PageUp>
-nmap <ESC>[6^ <C-PageDown>
-nnoremap <C-PageDown> :tabn<CR>
-nnoremap <C-PageUp> :tabp<CR>
-nmap 1 1gt
-nmap 2 2gt
-nmap 3 3gt
-nmap 4 4gt
-nmap 5 5gt
-nmap 6 6gt
-nmap 7 7gt
-nmap 8 8gt
-nmap 9 9gt
-nmap 0 10gt
-
-" Buffer navigation: Alt-{Up,Down}
-map Od :bprevious<CR>
-map Oc :bnext<CR>
-
-" Window navigation
-map <Left> <C-w><Left>
-map <Right> <C-w><Right>
-map <Down> <C-w><Down>
-map <Up> <C-w><Up>
-
" See
" http://vim.wikia.com/wiki/Have_Vim_check_automatically_if_the_file_has_changed_externally
" http://stackoverflow.com/questions/2490227/how-does-vims-autoread-work