From 6ebc231f438c9d379832561c437f3f4384b3e989 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sat, 14 Oct 2017 17:21:00 -0300 Subject: Sort .vimrc and switch to ESC-based key maps --- vimrc.dot.link | 114 +++++++++++++++++++++++++++++++++++---------------------- 1 file 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 n :tabnew +nmap t :OpenNERDTree +nmap q :wqa +"map c :wqa +"map f :wq +nmap c :tabclose +"map e :tabclose +nmap m :q! +nmap w :w +imap n :tabnew +imap t :OpenNERDTree +imap q :wqa +"map c :wqa +"map f :wq +imap c :tabclose +"map e :tabclose +imap m :q! +imap w :w " Write, quit and close shortcuts using Alt-key combos " @@ -122,12 +141,12 @@ nmap n :tabnew " 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 -map c :wqa -map f :wq +"map c :wqa +"map f :wq "map c :tabclose -map e :tabclose -map m :q! -map w :w +"map e :tabclose +"map m :q! +"map w :w " 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 "map m :q! "map w :w +" Tab navigation +" See http://vim.wikia.com/wiki/Alternative_tab_navigation +" http://comments.gmane.org/gmane.os.cygwin.xfree/16419 +nmap [5^ +nmap [6^ +nnoremap :tabn +nnoremap :tabp +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 +map Oc :bnext + +" Window navigation +"map  +"map  +"map  +"map  +nmap +nmap +nmap +nmap +imap +imap +imap +imap + " 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() command -nargs=1 -complete=customlist,nerdtree#completeBookmarks B :call TabNewBookmark() command -nargs=0 OpenNERDTree :call OpenNERDTree() -nmap t :OpenNERDTree " See http://superuser.com/questions/10588/how-to-make-cut-copy-paste-in-gvim-on-ubuntu-work-with-ctrlx-ctrlc-ctrlv "imap + @@ -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 [5^ -nmap [6^ -nnoremap :tabn -nnoremap :tabp -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 -map Oc :bnext - -" Window navigation -map  -map  -map  -map  - " 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 -- cgit v1.2.3