aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2017-10-25 15:56:28 -0200
committerSilvio Rhatto <rhatto@riseup.net>2017-10-25 15:56:28 -0200
commit53369217cff33612e858b7a027ee65eb71d50745 (patch)
treed684675a2be36723e59735c13d3a9f6baa254dbc
parent449b3535d1c4b253fe9ef630008f7b667eb55dfb (diff)
downloadvim-53369217cff33612e858b7a027ee65eb71d50745.tar.gz
vim-53369217cff33612e858b7a027ee65eb71d50745.tar.bz2
Try a non-conflict key combo setup
-rw-r--r--vimrc.dot.link136
1 files changed, 97 insertions, 39 deletions
diff --git a/vimrc.dot.link b/vimrc.dot.link
index c207242..499ac81 100644
--- a/vimrc.dot.link
+++ b/vimrc.dot.link
@@ -101,32 +101,15 @@ let g:syntastic_mode_map={ 'mode': 'passive',
\ 'active_filetypes': [],
\ 'passive_filetypes': [] }
-" See https://www.johnhawthorn.com/2012/09/vi-escape-delays/
-set timeoutlen=1000 ttimeoutlen=0
-
-" 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
+"
+" Key Mappings
+" https://stackoverflow.com/questions/7501092/can-i-map-alt-key-in-vim
+" https://stackoverflow.com/questions/45244245/why-alt-and-esc-keys-behave-differently-in-emacs
+" http://vim.wikia.com/wiki/Mapping_fast_keycodes_in_terminal_Vim
+" https://github.com/vim-utils/vim-alt-mappings
+" https://github.com/drmikehenry/vim-fixkey
+"
+" Notes:
"
" Keys were chosen not to conflict of to be close to window manager combos
" Like Awesome has a combo (Meta-q) which could be confused with a VIM quit
@@ -143,24 +126,87 @@ imap <ESC>w <ESC>:w <CR>
" this event would be triggered by the window manager when killing VIM window,
" 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 :tabclose <CR>
-"map e :tabclose <CR>
-"map m :q! <CR>
-"map w :w <CR>
+"
+" Pressing Alt-<key> simultaneously is equivalent to pressing ESC and then <key>,
+" so the big difference between the ESC combos and Alt combos are mainly of
+" config file notation.
+"
+" Typing ESC keys combos have the advantage over Alt combos as they are
+" difficult to be mistaken for the Meta key, but thats mainly a user and not
+" config convention since they're almost the same in VIM.
+"
+" In the other hand, there's an disadvantage of using ESC simultaneously for
+" going to normal mode and doing other stuff, with can be in ambiguous.
+"
+" The sollution is to decrease ESC timeout.
+"
+" See https://www.johnhawthorn.com/2012/09/vi-escape-delays/
+"set timeoutlen=1000 ttimeoutlen=0
+set timeoutlen=0 ttimeoutlen=0
+
+" Write, quit and close shortcuts using Esc <key> notation (works also with <Alt-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 combo notation
+"map n :tabnew<CR>
+"map t :OpenNERDTree<CR>
+"map q :wqa<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>
+"imap n <ESC>:tabnew<CR>
+"imap t <ESC>:OpenNERDTree<CR>
+"imap q <ESC>:wqa<CR>
+"imap c <ESC>:wqa<CR>
+"imap f <ESC>:wq<CR>
+"imap c <ESC>:tabclose<CR>
+"imap e <ESC>:tabclose<CR>
+"imap m <ESC>:q!<CR>
+"imap w <ESC>:w<CR>
" Write, quit and close shortcuts using Ctrl-key combos
" We're using these due to a conflict with wyrd(1)
-"map <C-q> :wqa <CR>
-"map <C-f> :wq <CR>
-"map <C-c> :tabclose <CR>
-"map <C-m> :q! <CR>
-"map <C-w> :w <CR>
+"map <C-n> :tabnew<CR>
+"map <C-t> :OpenNERDTree<CR>
+"map <C-q> :wqa<CR>
+"map <C-c> :wqa<CR>
+"map <C-f> :wq<CR>
+"map <C-c> :tabclose<CR>
+"map <C-e> :tabclose<CR>
+"map <C-m> :q!<CR>
+"map <C-w> :w<CR>
+"imap <C-n> <ESC>:tabnew<CR>
+"imap <C-t> <ESC>:OpenNERDTree<CR>
+"imap <C-q> <ESC>:wqa<CR>
+"imap <C-c> <ESC>:wqa<CR>
+"imap <C-f> <ESC>:wq<CR>
+"imap <C-c> <ESC>:tabclose<CR>
+"imap <C-e> <ESC>:tabclose<CR>
+"imap <C-m> <ESC>:q!<CR>
+"imap <C-w> <ESC>:w<CR>
" Write, quit and close shortcuts
-"map q :wqa <CR>
+map q :wqa <CR>
"map f :wq <CR>
"map t :tabclose <CR>
"map m :q! <CR>
@@ -189,10 +235,22 @@ map Od :bprevious<CR>
map Oc :bnext<CR>
" Window navigation
+"map <C-Left> <C-w><Left>
+"map <C-Right> <C-w><Right>
+"map <C-Down> <C-w><Down>
+"map <C-Up> <C-w><Up>
+"imap <C-Left> <ESC><C-w><Left>
+"imap <C-Right> <ESC><C-w><Right>
+"imap <C-Down> <ESC><C-w><Down>
+"imap <C-Up> <ESC><C-w><Up>
"map <Left> <C-w><Left>
"map <Right> <C-w><Right>
"map <Down> <C-w><Down>
"map <Up> <C-w><Up>
+"imap <Left> <ESC><C-w><Left>
+"imap <Right> <ESC><C-w><Right>
+"imap <Down> <ESC><C-w><Down>
+"imap <Up> <ESC><C-w><Up>
nmap <ESC><Left> <C-w><Left>
nmap <ESC><Right> <C-w><Right>
nmap <ESC><Down> <C-w><Down>