📜 ⬆️ ⬇️

Replacing 'on' and back with one click

Add to .vimrc:
function! s:ToggleQuote() let q = searchpos("'", 'n', line('.')) let qb = searchpos("'", 'bn', line('.')) let dq = searchpos('"', 'n', line('.')) let dqb = searchpos('"', 'bn', line('.')) if q[0] > 0 && qb[0] > 0 && (dq[0] == 0 || dq[0] > q[0]) execute "normal mzcs'\"`z" elseif dq[0] > 0 && dqb[0] > 0 execute "normal mzcs\"'`z" endif endfunction nnoremap <silent>' :<CU>call <SID>ToggleQuote()<CR> 


If you move the cursor inside the quotes and press', the quotes will change to double / single.

ps. The script uses vim-surround .

')

Source: https://habr.com/ru/post/172045/


All Articles