Detect file type for dotfiles & change background
autocmd is used to hard code the file type to certain file names, since vim expects them to have the standard names starting with a dot but the files are tracked in the repository without the leading dot. Add a <leader> mapping to quickly toggle between the current and previous file. Add a <leader> mapping to quickly toggle dark/light background. Cosmetic change: all key codes are lower case.
This commit is contained in:
parent
0a6bfd04eb
commit
195a682fb8
1 changed files with 36 additions and 21 deletions
57
vimrc
57
vimrc
|
@ -79,7 +79,7 @@ let mapleader = ","
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
" tagbar {{{
|
" tagbar {{{
|
||||||
nnoremap <leader>t :TagbarToggle<CR>
|
nnoremap <leader>t :TagbarToggle<cr>
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
" vim-airline {{{
|
" vim-airline {{{
|
||||||
|
@ -92,50 +92,65 @@ let mapleader = ","
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
" vim-trailing-whitespace {{{
|
" vim-trailing-whitespace {{{
|
||||||
nnoremap <leader>w :FixWhitespace<CR>
|
nnoremap <leader>w :FixWhitespace<cr>
|
||||||
" }}}
|
" }}}
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
" Autocmds {{{
|
augroup vimrc " {{{
|
||||||
autocmd FileType vim setlocal foldmethod=marker
|
autocmd!
|
||||||
autocmd FileType *.py setlocal foldmethod=indent | setlocal foldnestmax=2
|
au BufNewFile,BufRead *.md set ft=markdown
|
||||||
" }}}
|
au BufNewFile,BufRead bash_profile,bashrc set ft=sh
|
||||||
|
au BufNewFile,BufRead gitconfig set ft=gitconfig
|
||||||
|
au BufNewFile,BufRead rcrc set ft=sh
|
||||||
|
|
||||||
|
au FileType vim setl foldmethod=marker
|
||||||
|
au FileType python setl foldmethod=indent
|
||||||
|
au FileType markdown,text setl formatoptions+=t | setl spell
|
||||||
|
au FileType gitcommit setl formatoptions+=t | setl spell | setl textwidth=72
|
||||||
|
augroup END " }}}
|
||||||
|
|
||||||
" Key mappings {{{
|
" Key mappings {{{
|
||||||
" split navigations and resizing
|
" split navigations and resizing
|
||||||
nnoremap <C-J> <C-W><C-J>
|
nnoremap <c-j> <c-w><c-j>
|
||||||
nnoremap <C-K> <C-W><C-K>
|
nnoremap <c-k> <c-w><c-k>
|
||||||
nnoremap <C-L> <C-W><C-L>
|
nnoremap <c-l> <c-w><c-l>
|
||||||
nnoremap <C-H> <C-W><C-H>
|
nnoremap <c-h> <c-w><c-h>
|
||||||
nnoremap <C-W><C-K> :execute "resize " . (winheight(0) * 5/4)<CR>
|
nnoremap <c-w><c-k> :execute "resize " . (winheight(0) * 5/4)<cr>
|
||||||
nnoremap <C-W><C-J> :execute "resize " . (winheight(0) * 4/5)<CR>
|
nnoremap <c-w><c-j> :execute "resize " . (winheight(0) * 4/5)<cr>
|
||||||
nnoremap <C-W><C-H> :execute "vertical resize " . (winwidth(0) * 5/4)<CR>
|
nnoremap <c-w><c-h> :execute "vertical resize " . (winwidth(0) * 5/4)<cr>
|
||||||
nnoremap <C-W><C-L> :execute "vertical resize " . (winwidth(0) * 4/5)<CR>
|
nnoremap <c-w><c-l> :execute "vertical resize " . (winwidth(0) * 4/5)<cr>
|
||||||
|
|
||||||
" fast navigation of matchpairs ({[]})
|
" fast navigation of matchpairs ({[]})
|
||||||
nnoremap <TAB> %
|
nnoremap <tab> %
|
||||||
vnoremap <TAB> %
|
vnoremap <tab> %
|
||||||
|
|
||||||
" retain selection when indenting/unindenting in visual mode
|
" retain selection when indenting/unindenting in visual mode
|
||||||
vnoremap > ><CR>gv
|
vnoremap > ><cr>gv
|
||||||
vnoremap < <<CR>gv
|
vnoremap < <<cr>gv
|
||||||
|
|
||||||
" case insensitive searching
|
" case insensitive searching
|
||||||
nnoremap // /\c
|
nnoremap // /\c
|
||||||
nnoremap ?? ?\c
|
nnoremap ?? ?\c
|
||||||
|
|
||||||
" quickly exit insert mode
|
" quickly exit insert mode
|
||||||
inoremap jk <ESC>
|
inoremap jk <esc>
|
||||||
|
|
||||||
" better navigation for wrapped lines
|
" better navigation for wrapped lines
|
||||||
noremap j gj
|
noremap j gj
|
||||||
noremap k gk
|
noremap k gk
|
||||||
|
|
||||||
" space opens/closes folds
|
" space opens/closes folds
|
||||||
nnoremap <SPACE> za
|
nnoremap <space> za
|
||||||
|
|
||||||
" turn off search highlight
|
" turn off search highlight
|
||||||
nnoremap <LEADER><SPACE> :nohlsearch<CR>
|
nnoremap <leader><leader> :nohlsearch<cr>
|
||||||
|
|
||||||
|
" switch between last two files
|
||||||
|
nnoremap <leader><space> <c-^>
|
||||||
|
|
||||||
|
" quickly change background
|
||||||
|
nnoremap <leader>bd :set background=dark<cr>
|
||||||
|
nnoremap <leader>bl :set background=light<cr>
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
if filereadable(expand("~/.vimrc.local"))
|
if filereadable(expand("~/.vimrc.local"))
|
||||||
|
|
Loading…
Add table
Reference in a new issue