Skip to content

Instantly share code, notes, and snippets.

View mgarort's full-sized avatar

Miguel García-Ortegón mgarort

View GitHub Profile
@LanHikari22
LanHikari22 / vim-sneak - use s in operator mode.vim
Created February 15, 2021 01:17
Remap vim-surround to 'z' to allow vim-sneak to use 's' in operator mode
" documentation and source are credited to https://github.com/mgarort
" Make vim-sneak mappings more consistent in visual mode by making s go to next match and S
" go to previous match, while keeping vim-surround functionality through z
" (mnemonics: vim-zurround) Explained in this GitHub issue:
" https://github.com/justinmk/vim-sneak/issues/268
"
" So now the behaviour is:
" - Normal: s and S to move with sneak
" - Visual: s and S to move with sneak, z to surround (zurround)
@romainl
romainl / pseudo-text-objects.vim
Last active January 11, 2024 07:45
Custom pseudo-text objects
" 24 simple pseudo-text objects
" -----------------------------
" i_ i. i: i, i; i| i/ i\ i* i+ i- i#
" a_ a. a: a, a; a| a/ a\ a* a+ a- a#
" can take a count: 2i: 3a/
for char in [ '_', '.', ':', ',', ';', '<bar>', '/', '<bslash>', '*', '+', '-', '#' ]
execute "xnoremap i" . char . " :<C-u>execute 'normal! ' . v:count1 . 'T" . char . "v' . (v:count1 + (v:count1 - 1)) . 't" . char . "'<CR>"
execute "onoremap i" . char . " :normal vi" . char . "<CR>"
execute "xnoremap a" . char . " :<C-u>execute 'normal! ' . v:count1 . 'F" . char . "v' . (v:count1 + (v:count1 - 1)) . 'f" . char . "'<CR>"
execute "onoremap a" . char . " :normal va" . char . "<CR>"