dotfiles

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

commit 3d2c186ac2009acaea32e865c9843ccb3dd587be
parent 346d0a08e52a4f7565cd86b41dac1ac201e6f4e4
Author: Alex Balgavy <a.balgavy@gmail.com>
Date:   Sat, 18 Apr 2020 11:52:06 +0200

vim: misc + some text objects

Former-commit-id: b0b0ad0e149768be2ff2e55b3a9ca6bfc7e62040
Diffstat:
Avim/plugin/text-objects.vim | 40++++++++++++++++++++++++++++++++++++++++
Mvim/vimrc | 21++++++---------------
2 files changed, 46 insertions(+), 15 deletions(-)

diff --git a/vim/plugin/text-objects.vim b/vim/plugin/text-objects.vim @@ -0,0 +1,40 @@ +" Adapted from https://gist.github.com/romainl/c0a8b57a36aec71a986f1120e1931f20 +" text objects for symbols +for char in [ '_', '.', ':', ',', ';', '<bar>', '/', '<bslash>', '*', '+', '-', '#' ] + execute 'xnoremap i' . char . ' :<C-u>normal! T' . char . 'vt' . char . '<CR>' + execute 'onoremap i' . char . ' :normal vi' . char . '<CR>' + execute 'xnoremap a' . char . ' :<C-u>normal! F' . char . 'vf' . char . '<CR>' + execute 'onoremap a' . char . ' :normal va' . char . '<CR>' +endfor + +" Buffer text object +xnoremap i& :<C-u>let z = @/\|1;/^./kz<CR>G??<CR>:let @/ = z<CR>V'z +onoremap i& :<C-u>normal vi&<CR> +xnoremap a& GoggV +onoremap a& :<C-u>normal va&<CR> + +" 'Up to current line' text object +vnoremap u :<C-u>silent! normal! ggV``<CR> +onoremap u :normal Vu<CR>`` + +" aliases +xnoremap ir i[ +xnoremap ar a[ + +" number text object (integer and float) +" -------------------------------------- +" in +function! s:VisualNumber() + call search('\d\([^0-9\.]\|$\)', 'cW') + normal v + call search('\(^\|[^0-9\.]\d\)', 'becW') +endfunction +xnoremap in :<C-u>call <SID>VisualNumber()<CR> +onoremap in :<C-u>normal vin<CR> + +" last change text object +" ----------------------- +xnoremap ik `]o`[ +onoremap ik :<C-u>normal vik<CR> +onoremap ak :<C-u>normal vikV<CR> + diff --git a/vim/vimrc b/vim/vimrc @@ -557,16 +557,14 @@ endif " Highlight current line set cursorline -" Text wrap sucks most of the time -set nowrap - -" Linebreak when obsessive -set linebreak -set textwidth=150 - " Reduce waiting on keys (like esc) set timeoutlen=1000 ttimeoutlen=0 +" Wrap settings - no wrap by default +set nowrap +set textwidth=0 +set wrapmargin=0 +set linebreak " break at &breakat " Continue wrapped line on same indent as previous if has('breakindent') set breakindent @@ -838,14 +836,6 @@ nnoremap <leader>mc :Make clean<CR> " :silent make<CR>\|:redraw!<CR>\|:cwindow<CR> " :silent make clean<CR>\|:redraw!<CR> -" Buffer text object -vnoremap & :<C-U>silent! normal! ggVG<CR> -omap & :normal V&<CR> - -" 'Up to current line' text object -vnoremap u :<C-u>silent! normal! ggV``<CR> -omap u :normal Vu<CR>`` - " Allow scrolling popup menus with the mouse if has('mouse') inoremap <expr> <ScrollWheelUp> pumvisible() ? "<C-p>" : "<Esc><ScrollWheelUp>" @@ -857,6 +847,7 @@ if has('autocmd') autocmd! autocmd InsertEnter * setlocal nocursorline autocmd InsertLeave * setlocal cursorline + autocmd FileType * setlocal formatoptions=qnlj augroup END augroup vimrc_commands autocmd!