vimrc cleanup
remove old/unused settings/mappings from vimrc and functions.vim
This commit is contained in:
@@ -13,30 +13,22 @@ function! WinMove(key)
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" tell me what syntax group the word below the cursor belongs to
|
|
||||||
function! <SID>SynStack()
|
|
||||||
if !exists("*synstack")
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" recursively search up from dirname, sourcing all .vimrc.local files along the way
|
" recursively search up from dirname, sourcing all .vimrc.local files along the way
|
||||||
function! ApplyLocalSettings(dirname)
|
function! ApplyLocalSettings(dirname)
|
||||||
" convert windows paths to unix style
|
" convert windows paths to unix style
|
||||||
let l:curDir = substitute(a:dirname, "\\", "/", "g")
|
let l:curDir = substitute(a:dirname, '\\', '/', 'g')
|
||||||
|
|
||||||
" walk to the top of the dir tree
|
" walk to the top of the dir tree
|
||||||
let l:parentDir = strpart(l:curDir, 0, strridx(l:curDir, "/"))
|
let l:parentDir = strpart(l:curDir, 0, strridx(l:curDir, '/'))
|
||||||
if isdirectory(l:parentDir)
|
if isdirectory(l:parentDir)
|
||||||
call ApplyLocalSettings(l:parentDir)
|
call ApplyLocalSettings(l:parentDir)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" now walk back down the path and source .vimsettings as you find them.
|
" now walk back down the path and source .vimsettings as you find them.
|
||||||
" child directories can inherit from their parents
|
" child directories can inherit from their parents
|
||||||
let l:settingsFile = a:dirname . "/.vimrc.local"
|
let l:settingsFile = a:dirname . '/.vimrc.local'
|
||||||
if filereadable(l:settingsFile)
|
if filereadable(l:settingsFile)
|
||||||
exec ":source" . l:settingsFile
|
exec ':source' . l:settingsFile
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@@ -47,18 +39,18 @@ function! Smart_TabComplete()
|
|||||||
let substr = strpart(line, -1, col('.')+1) " from the start of the current
|
let substr = strpart(line, -1, col('.')+1) " from the start of the current
|
||||||
" line to one character right
|
" line to one character right
|
||||||
" of the cursor
|
" of the cursor
|
||||||
let substr = matchstr(substr, "[^ \t]*$") " word till cursor
|
let substr = matchstr(substr, '[^ \t]*$') " word till cursor
|
||||||
if (strlen(substr)==0) " nothing to match on empty string
|
if (strlen(substr)==0) " nothing to match on empty string
|
||||||
return "\<tab>"
|
return '\<tab>'
|
||||||
endif
|
endif
|
||||||
let has_period = match(substr, '\.') != -1 " position of period, if any
|
let has_period = match(substr, '\.') != -1 " position of period, if any
|
||||||
let has_slash = match(substr, '\/') != -1 " position of slash, if any
|
let has_slash = match(substr, '\/') != -1 " position of slash, if any
|
||||||
if (!has_period && !has_slash)
|
if (!has_period && !has_slash)
|
||||||
return "\<C-X>\<C-P>" " existing text matching
|
return '\<C-X>\<C-P>' " existing text matching
|
||||||
elseif ( has_slash )
|
elseif ( has_slash )
|
||||||
return "\<C-X>\<C-F>" " file matching
|
return '\<C-X>\<C-F>' " file matching
|
||||||
else
|
else
|
||||||
return "\<C-X>\<C-O>" " plugin matching
|
return '\<C-X>\<C-O>' " plugin matching
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ set autoread " detect when a file is changed
|
|||||||
set backspace=indent,eol,start
|
set backspace=indent,eol,start
|
||||||
|
|
||||||
" set a map leader for more key combos
|
" set a map leader for more key combos
|
||||||
let mapleader = ","
|
let mapleader = ','
|
||||||
let g:mapleader = ","
|
let g:mapleader = ','
|
||||||
|
|
||||||
set history=10000 " change history to 1000
|
set history=10000 " change history to 1000
|
||||||
" set textwidth=80
|
" set textwidth=80
|
||||||
@@ -44,14 +44,11 @@ set clipboard=unnamed
|
|||||||
" faster redrawing
|
" faster redrawing
|
||||||
set ttyfast
|
set ttyfast
|
||||||
|
|
||||||
" allow matching of if/end, etc. with %
|
|
||||||
" runtime macros/matchit.vim
|
|
||||||
|
|
||||||
" highlight conflicts
|
" highlight conflicts
|
||||||
match ErrorMsg '^\(<\|=\|>\)\{7\}\([^=].\+\)\?$'
|
match ErrorMsg '^\(<\|=\|>\)\{7\}\([^=].\+\)\?$'
|
||||||
|
|
||||||
" file type specific settings
|
" file type specific settings
|
||||||
if has("autocmd") && !exists("autocommands_loaded")
|
if has('autocmd') && !exists('autocommands_loaded')
|
||||||
let autocommands_loaded = 1
|
let autocommands_loaded = 1
|
||||||
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
|
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
|
||||||
autocmd FileType make setlocal ts=8 sts=8 sw=8 noexpandtab
|
autocmd FileType make setlocal ts=8 sts=8 sw=8 noexpandtab
|
||||||
@@ -64,7 +61,7 @@ if has("autocmd") && !exists("autocommands_loaded")
|
|||||||
"autocmd WinLeave * setlocal nocursorline
|
"autocmd WinLeave * setlocal nocursorline
|
||||||
|
|
||||||
" automatically resize panes on resize
|
" automatically resize panes on resize
|
||||||
autocmd VimResized * exe "normal! \<c-w>="
|
autocmd VimResized * exe 'normal! \<c-w>='
|
||||||
autocmd BufWritePost .vimrc source %
|
autocmd BufWritePost .vimrc source %
|
||||||
autocmd BufWritePost .vimrc.local source %
|
autocmd BufWritePost .vimrc.local source %
|
||||||
" save all files on focus lost, ignoring warnings about untitled buffers
|
" save all files on focus lost, ignoring warnings about untitled buffers
|
||||||
@@ -77,6 +74,8 @@ if has("autocmd") && !exists("autocommands_loaded")
|
|||||||
" make quickfix windows take all the lower section of the screen when there
|
" make quickfix windows take all the lower section of the screen when there
|
||||||
" are multiple windows open
|
" are multiple windows open
|
||||||
autocmd FileType qf wincmd J
|
autocmd FileType qf wincmd J
|
||||||
|
|
||||||
|
autocmd! BufEnter * call ApplyLocalSettings(expand('<afile>:p:h'))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" code folding settings
|
" code folding settings
|
||||||
@@ -97,8 +96,6 @@ set noshowmode " don't show which mode disabled for PowerLine
|
|||||||
set wildmode=list:longest " complete files like a shell
|
set wildmode=list:longest " complete files like a shell
|
||||||
set scrolloff=3 " lines of text around cursor
|
set scrolloff=3 " lines of text around cursor
|
||||||
set shell=$SHELL
|
set shell=$SHELL
|
||||||
set ruler " show postiion in file
|
|
||||||
set rulerformat=%30(%=\:b%n%y%m%r%w\ %l,%c%V\ %P%) " a ruler on steroids"
|
|
||||||
set cmdheight=1 " command bar height
|
set cmdheight=1 " command bar height
|
||||||
|
|
||||||
set title " set terminal title
|
set title " set terminal title
|
||||||
@@ -124,9 +121,6 @@ set tm=500
|
|||||||
" switch syntax highlighting on
|
" switch syntax highlighting on
|
||||||
syntax on
|
syntax on
|
||||||
|
|
||||||
highlight ColorColumn ctermbg=magenta
|
|
||||||
call matchadd('ColorColumn', '\%81v', 100)
|
|
||||||
|
|
||||||
set encoding=utf8
|
set encoding=utf8
|
||||||
set t_Co=256 " Explicitly tell vim that the terminal supports 256 colors"
|
set t_Co=256 " Explicitly tell vim that the terminal supports 256 colors"
|
||||||
set background=dark
|
set background=dark
|
||||||
@@ -134,10 +128,9 @@ colorscheme hybrid
|
|||||||
|
|
||||||
" set number " show line numbers
|
" set number " show line numbers
|
||||||
set relativenumber " show relative line numbers
|
set relativenumber " show relative line numbers
|
||||||
set number
|
set number " show the current line number"
|
||||||
|
|
||||||
set wrap " turn on line wrapping
|
set nowrap "turn off line wrapping
|
||||||
"set nowrap "turn off line wrapping
|
|
||||||
set wrapmargin=8 " wrap lines when coming within n characters from side
|
set wrapmargin=8 " wrap lines when coming within n characters from side
|
||||||
set linebreak " set soft wrapping
|
set linebreak " set soft wrapping
|
||||||
set showbreak=… " show ellipsis at breaking
|
set showbreak=… " show ellipsis at breaking
|
||||||
@@ -145,11 +138,6 @@ set showbreak=… " show ellipsis at breaking
|
|||||||
set autoindent " automatically set indent of new line
|
set autoindent " automatically set indent of new line
|
||||||
set smartindent
|
set smartindent
|
||||||
|
|
||||||
try
|
|
||||||
lang en_US
|
|
||||||
catch
|
|
||||||
endtry
|
|
||||||
|
|
||||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
" => Files, backups, and undo
|
" => Files, backups, and undo
|
||||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
@@ -186,21 +174,23 @@ nmap <leader><space> :%s/\s\+$<cr>
|
|||||||
" shortcut to save
|
" shortcut to save
|
||||||
nmap <leader>, :w<cr>
|
nmap <leader>, :w<cr>
|
||||||
|
|
||||||
" disable Visual mode
|
" disable Ex mode
|
||||||
noremap Q <NOP>
|
noremap Q <NOP>
|
||||||
|
|
||||||
" set paste toggle
|
" set paste toggle
|
||||||
set pastetoggle=<F6>
|
set pastetoggle=<F6>
|
||||||
|
|
||||||
" toggle paste
|
" toggle paste mode
|
||||||
map <leader>v :set paste!<cr>
|
map <leader>v :set paste!<cr>
|
||||||
|
|
||||||
" edit ~/.vimrc
|
" edit ~/.vimrc
|
||||||
map <leader>e :e! ~/.vimrc<cr>
|
map <leader>ev :e! ~/.vimrc<cr>
|
||||||
" edit vim plugins
|
" edit vim plugins
|
||||||
map <leader>ep :e! ~/.vim/plugins.vim<cr>
|
map <leader>evp :e! ~/.vim/plugins.vim<cr>
|
||||||
" edit vim plugins
|
" edit vim functions
|
||||||
map <leader>ef :e! ~/.vim/functions.vim<cr>
|
map <leader>evf :e! ~/.vim/functions.vim<cr>
|
||||||
|
" edit gitconfig
|
||||||
|
map <leader>eg :e! ~/.gitconfig<cr>
|
||||||
|
|
||||||
" clear highlighted search
|
" clear highlighted search
|
||||||
noremap <space> :set hlsearch! hlsearch?<cr>
|
noremap <space> :set hlsearch! hlsearch?<cr>
|
||||||
@@ -221,10 +211,6 @@ vmap <leader>] >gv
|
|||||||
nmap <leader>[ <<
|
nmap <leader>[ <<
|
||||||
nmap <leader>] >>
|
nmap <leader>] >>
|
||||||
|
|
||||||
" buffer shortcuts
|
|
||||||
nmap <leader>n :bn<cr> " go to next buffer
|
|
||||||
nmap <leader>p :bp<cr> " go to prev buffer
|
|
||||||
nmap <leader>q :bd<cr> " close the current buffer
|
|
||||||
" switch between current and last buffer
|
" switch between current and last buffer
|
||||||
nmap <leader>. <c-^>
|
nmap <leader>. <c-^>
|
||||||
|
|
||||||
@@ -238,9 +224,6 @@ map <silent> <C-l> :call WinMove('l')<cr>
|
|||||||
|
|
||||||
map <leader>wc :wincmd q<cr>
|
map <leader>wc :wincmd q<cr>
|
||||||
|
|
||||||
" equalize windows
|
|
||||||
map <leader>= <C-w>=
|
|
||||||
|
|
||||||
" toggle cursor line
|
" toggle cursor line
|
||||||
nnoremap <leader>i :set cursorline!<cr>
|
nnoremap <leader>i :set cursorline!<cr>
|
||||||
|
|
||||||
@@ -252,15 +235,9 @@ nnoremap <C-y> 3<C-y>
|
|||||||
nnoremap <silent> j gj
|
nnoremap <silent> j gj
|
||||||
nnoremap <silent> k gk
|
nnoremap <silent> k gk
|
||||||
|
|
||||||
nnoremap <leader>/ :call ToggleNuMode()<cr>
|
|
||||||
|
|
||||||
" search for word under the cursor
|
" search for word under the cursor
|
||||||
nnoremap <leader>/ "fyiw :/<c-r>f<cr>
|
nnoremap <leader>/ "fyiw :/<c-r>f<cr>
|
||||||
|
|
||||||
" find out what syntax stack a statement belongs to
|
|
||||||
" nmap <leader>s :call <SID>SynStack()<cr>
|
|
||||||
autocmd! BufEnter * call ApplyLocalSettings(expand("<afile>:p:h"))
|
|
||||||
|
|
||||||
" inoremap <tab> <c-r>=Smart_TabComplete()<CR>
|
" inoremap <tab> <c-r>=Smart_TabComplete()<CR>
|
||||||
|
|
||||||
map <leader>r :call RunCustomCommand()<cr>
|
map <leader>r :call RunCustomCommand()<cr>
|
||||||
@@ -271,12 +248,6 @@ let g:silent_custom_command = 0
|
|||||||
" => Plugins
|
" => Plugins
|
||||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
|
|
||||||
" Powerline settings
|
|
||||||
" must have modified font installed to enable fancy
|
|
||||||
" let g:Powerline_symbols = 'fancy'
|
|
||||||
|
|
||||||
" let g:Powerline_stl_path_style = 'filename'
|
|
||||||
|
|
||||||
" close NERDTree after a file is opened
|
" close NERDTree after a file is opened
|
||||||
let g:NERDTreeQuitOnOpen=1
|
let g:NERDTreeQuitOnOpen=1
|
||||||
" Toggle NERDTree
|
" Toggle NERDTree
|
||||||
|
|||||||
Reference in New Issue
Block a user