dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

commit c45c7ad6392c0303353de6fcdf4bd465e38c5704
parent dfa83693be59d2f5ec848d2db704fcefaf68a19d
Author: Alex Balgavy <a.balgavy@gmail.com>
Date:   Fri,  7 Sep 2018 10:41:31 +0200

Improved vim config files as per idiomatic-vimrc

Diffstat:
Mvim/commands.vimrc | 18+++++++++---------
Mvim/editor.vimrc | 19++++++++++++-------
Mvim/general.vimrc | 9+++++++++
Mvim/map.vimrc | 13++++++++-----
4 files changed, 38 insertions(+), 21 deletions(-)

diff --git a/vim/commands.vimrc b/vim/commands.vimrc @@ -1,13 +1,13 @@ " Custom commands -command Todo vimgrep /TODO\C<Bslash><Bar>TO DO\C/ **/*.* | copen -command Note vimgrep /NOTE\C/ **/*.* | copen -command Fix vimgrep /FIXME\C/ **/*.* | copen -command ListFileTypes echo glob($VIMRUNTIME . '/syntax/*.vim') -command CDC cd %:p:h -command Maketab set noet ts=2 | %retab! -command Diff w !diff % - -command Diffc w !git diff % - -command Fuckwindows %s/ //g +command! Todo vimgrep /TODO\C<Bslash><Bar>TO DO\C/ **/*.* | copen +command! Note vimgrep /NOTE\C/ **/*.* | copen +command! Fix vimgrep /FIXME\C/ **/*.* | copen +command! ListFileTypes echo glob($VIMRUNTIME . '/syntax/*.vim') +command! CDC cd %:p:h +command! Maketab set noet ts=2 | %retab! +command! Diff w !diff % - +command! Diffc w !git diff % - +command! Fuckwindows %s/ //g function! InsertTabWrapper() let col = col('.') - 1 if !col || getline('.')[col - 1] !~ '\k' diff --git a/vim/editor.vimrc b/vim/editor.vimrc @@ -22,31 +22,36 @@ set expandtab set smarttab " and 1 tab == 4 spaces +" also, shift by 4 spaces set shiftwidth=4 set softtabstop=4 set shiftround set copyindent " Auto indent -set ai +set autoindent " Smart indent -set si +set smartindent " Folding set foldmethod=indent " Status bar set laststatus=2 " Always show status bar -set statusline=\ %F%m\%r%h\ %w " Full path, flags (modified, readonly, help, preview) -set statusline+=\ \ CWD:\ %r%{getcwd()}%h " Current working directory -set statusline+=%=%l,%c " Line number, column number +set statusline=\ %F " Full path +set statusline+=\ %m%r%h%w " Flags (modified, readonly, help, preview) set statusline+=\ %y " File type -set statusline+=\ \ B%n " Buffer number +set statusline+=\ \ CWD:\ %r%{getcwd()}%h " Current working directory +set statusline+=%= " Left/right separator +set statusline+=%c\ " cursor column +set statusline+=%l/%L\ " cursor line/total lines +set statusline+=\ B%n " Buffer number +set statusline+=\ \ %{strftime(\"%H:%M\")} " time " Show matching brackets set showmatch -set mat=2 +set matchtime=2 " Searching set ignorecase diff --git a/vim/general.vimrc b/vim/general.vimrc @@ -2,6 +2,9 @@ " Update file when changed from the outside " set autoread +" matchit.vim is default, why not enable it +runtime macros/matchit.vim + " For editing binaries set binary @@ -29,10 +32,16 @@ set ttyfast " Show partial command on last line set showcmd +" Command completion +set wildmenu + " ======= Colors and Fonts ======== " " Syntax highlighting syntax on +" Filetype-specific indenting +filetype plugin indent on + " Colorscheme colorscheme default diff --git a/vim/map.vimrc b/vim/map.vimrc @@ -7,7 +7,7 @@ nnoremap ; : nnoremap <leader>f :NERDTreeToggle<cr> " Disable q: cuz I hate it -map q: <Nop> +nnoremap q: <Nop> " Normal mode shortcuts nnoremap <leader>dif :Diff<cr> @@ -19,15 +19,15 @@ inoremap <expr> <tab> InsertTabWrapper() inoremap <s-tab> <c-p> " Retain visual mode after > and < -vmap < <gv -vmap > >gv +vnoremap < <gv +vnoremap > >gv " Move visual block vnoremap J :m '>+1<cr>gv=gv vnoremap K :m '<-2<cr>gv=gv " stfu and write the file -cmap w!! w !sudo tee > /dev/null % +cnoremap w!! w !sudo tee > /dev/null % " and don't break my colours (U for 'unfuck my screen please') nnoremap U :syntax sync fromstart<cr>:redraw!<cr> @@ -39,7 +39,7 @@ nnoremap <leader>qq mzggg?G`z nnoremap zh mzzt10<c-u>`z " Quick switch to shell -noremap <C-s> :sh<cr> +nnoremap <C-s> :sh<cr> " Tab mappings nnoremap <C-t> :tabnew<cr> @@ -57,3 +57,6 @@ nnoremap <leader>hs :set list!<cr> " List marks nnoremap <leader>mm :<C-u>marks<CR>:normal! ` nnoremap <leader>ml :<C-u>marks a-z<CR>:normal! ` + +" Map '0' to act as '^' on first press and '0' on second +nnoremap <expr> <silent> 0 col('.') == match(getline('.'),'\S')+1 ? '0' : '^'