diff options
| author | Aaron LI <aly@aaronly.me> | 2018-11-10 11:27:24 +0800 | 
|---|---|---|
| committer | Aaron LI <aly@aaronly.me> | 2018-11-10 11:27:24 +0800 | 
| commit | 5f102ae7873112f3abc8070382ef95058035f025 (patch) | |
| tree | 53817ce90c7aba2aacbcf9b6459324ac3faab422 | |
| parent | 49110ec450ed891c3915122f3da412fa6a38aa39 (diff) | |
| download | dotfiles-5f102ae7873112f3abc8070382ef95058035f025.tar.bz2 | |
vim: Various tweaks
* Overwrite previously defined command, allowing to reload the vimrc
  without restarting vim.
* Change statusline style.
* Enable mouse in terminal mode.
* Disable scrollbars for GUI mode.
* Set spelllang.
* Use full names for options.
* Clean up obvious/unnecessary comments.
* Some misc cleanups.
| -rw-r--r-- | _vimrc | 90 | 
1 files changed, 40 insertions, 50 deletions
| @@ -26,12 +26,18 @@ nmap <leader>w :w!<cr>  " :W sudo saves the file  " (useful for handling the permission-denied error) -command W w !sudo tee % > /dev/null +command! W w !sudo tee % >/dev/null  """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""  " => VIM user interface  """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +set mouse=a +set ignorecase +set smartcase +set hlsearch +set incsearch +  " Set 7 lines to the cursor - when moving vertically using j/k  set scrolloff=7 @@ -49,24 +55,12 @@ set ruler  set cmdheight=1  " A buffer becomes hidden when it is abandoned -set hid +set hidden  " Configure backspace so it acts as it should act  set backspace=eol,start,indent  set whichwrap+=<,>,h,l -" Ignore case when searching -set ignorecase - -" When searching try to be smart about cases -set smartcase - -" Highlight search results -set hlsearch - -" Makes search act like search in modern browsers -set incsearch -  " Don't redraw while executing macros (good performance config)  set lazyredraw @@ -76,13 +70,13 @@ set magic  " Show matching brackets when text indicator is over them  set showmatch  " How many tenths of a second to blink when matching brackets -set mat=2 +set matchtime=2  " No annoying sound on errors  set noerrorbells  set novisualbell  set t_vb= -set tm=500 +set timeoutlen=500  " Properly disable sound on errors on MacVim  if has("gui_macvim") @@ -96,7 +90,6 @@ set foldcolumn=1  """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""  " => Colors and Fonts  """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Enable syntax highlighting  syntax enable  set t_Co=256 @@ -111,28 +104,28 @@ endif  colorscheme flattened_light -" Set extra options when running in GUI mode  if has("gui_running") -    set guioptions-=T -    set guioptions-=e -    set guioptions-=m +    set guioptions-=T  " No toolbar +    set guioptions-=e  " No GUI tabs +    set guioptions-=m  " No menu bar +    set guioptions-=l  " No left scrollbar +    set guioptions-=L  " No left scrollbar +    set guioptions-=r  " No right scrollbar +    set guioptions-=R  " No right scrollbar      set guifont=IBM\ Plex\ Mono\ Medium\ 11      set guitablabel=%M\ %t  endif -" Set utf8 as standard encoding and en_US as the standard language -set encoding=utf8 - -" Use Unix as the standard file type -set ffs=unix,dos,mac -  """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""  " => Files, backups and undo  """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Turn backup off, since most stuff is in SVN, git et.c anyway... +set encoding=utf8 +set fileformats=unix,dos,mac + +" Turn backup off  set nobackup -set nowb +set nowritebackup  set noswapfile @@ -141,13 +134,12 @@ set noswapfile  """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""  set expandtab  set smarttab - -set shiftwidth=4  set tabstop=8 +set shiftwidth=4  " Linebreak on 500 characters -set lbr -set tw=500 +set linebreak +set textwidth=500  set autoindent  set smartindent @@ -197,26 +189,22 @@ map <leader>t<leader> :tabnext  " Let 'tl' toggle between this and the last accessed tab  let g:lasttab = 1 -nmap <Leader>tl :exe "tabn ".g:lasttab<CR> -au TabLeave * let g:lasttab = tabpagenr() - +nmap <leader>tl :exe "tabn ".g:lasttab<CR> +autocmd TabLeave * let g:lasttab = tabpagenr()  " Opens a new tab with the current buffer's path  " Super useful when editing files in the same directory -map <leader>te :tabedit <c-r>=expand("%:p:h")<cr>/ +map <leader>te :tabedit <C-r>=expand("%:p:h")<cr>/  " Switch CWD to the directory of the open buffer  map <leader>cd :cd %:p:h<cr>:pwd<cr>  " Specify the behavior when switching between buffers -try -    set switchbuf=useopen,usetab,newtab -    set stal=2 -catch -endtry +set switchbuf=useopen,usetab,newtab +set showtabline=2  " Return to last edit position when opening files (You want this!) -au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif +autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif  """""""""""""""""""""""""""""" @@ -226,7 +214,9 @@ au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g  set laststatus=2  " Format the status line -set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l\ \ Column:\ %c +set statusline=\ %{HasPaste()}%f%m%r%h\ %w +set statusline+=\ %=%y\ %{&fileencoding?&fileencoding:&encoding}\ %l:%c\ %P +set statusline+=\  " blank space  """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" @@ -246,22 +236,22 @@ if has("mac") || has("macunix")  endif  " Delete trailing white space on save, useful for some filetypes ;) -fun! CleanExtraSpaces() +function! CleanExtraSpaces()      let save_cursor = getpos(".")      let old_query = getreg('/')      silent! %s/\s\+$//e      call setpos('.', save_cursor)      call setreg('/', old_query) -endfun +endfunction -if has("autocmd") -    autocmd BufWritePre *.txt,*.js,*.py,*.wiki,*.sh,*.coffee :call CleanExtraSpaces() -endif +autocmd BufWritePre *.txt,*.js,*.py,*.wiki,*.sh,*.coffee :call CleanExtraSpaces()  """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""  " => Spell checking  """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +set spelllang=en_us,cjk +  " Pressing ,ss will toggle and untoggle spell checking  map <leader>ss :setlocal spell!<cr> @@ -276,7 +266,7 @@ map <leader>s? z=  " => Misc  """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""  " Remove the Windows ^M - when the encodings gets messed up -noremap <Leader>m mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm +noremap <leader>m mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm  " Quickly open a buffer for scribble  map <leader>q :e ~/buffer<cr> | 
