public
Last active

  • Download Gist
multiediting_notes.vim
VimL
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
" Plugins:
"
" Markmultiple:
" https://github.com/adinapoli/vim-markmultiple
"
" ChangeGlobally:
" http://www.vim.org/scripts/script.php?script_id=4321
"
" vim-multiedit (abandoned):
" https://github.com/felixr/vim-multiedit
"
" Multichange:
" https://github.com/AndrewRadev/multichange.vim
"
" Foldutils:
" http://www.vim.org/scripts/script.php?script_id=158
"
" writable_search (should be more complete after the upcoming weekend):
" https://github.com/AndrewRadev/writable_search.vim
 
" Tricks:
"
" Pre-filled :substitute
nnoremap & :'{,'}s/<c-r><c-w>//gc<left><left><left>
 
" * and # without moving the cursor
nnoremap <Leader>* m`*``
nnoremap <Leader># m`#``
 
" My own attempt at a cleverer version of the above:
" https://gist.github.com/AndrewRadev/4239736
nnoremap g* :call <SID>SmartStar()<cr>
function! s:SmartStar()
let cword = expand('<cword>')
 
if cword == ''
echo "No word under the cursor"
return
endif
 
let current_col = col('.')
 
call search('\<'.cword.'\>', 'bWc', line('.'))
 
let cword_start_col = col('.')
let cword_start = strpart(cword, 0, current_col - cword_start_col)
let cword_end = strpart(cword, current_col - cword_start_col)
 
let search_pattern = '\<\%('.cword_start.'\zs'.cword_end.'\)\>'
 
call histadd('search', search_pattern)
let @/ = search_pattern
normal! n
 
echo 'Search for: '.cword
endfunction
 
" Return the cursor where it was when executing a .
nnoremap . .`[
 
" Same as above, but works with repeat.vim
runtime autoload/repeat.vim
nnoremap . mr:call repeat#run(v:count)<bar>call feedkeys('`r', 'n')<cr>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.