Double vim-surround with *

Suppose my cursor is inside a word word. Using vim-surround, entering the sequence ysiw*will replace wordwith *word*.

Question: Is there one sequence that I can print that I create instead **word**(i.e., a general markdown method for word displacement)? This runs counter to typing ysiw*twice, which seems cumbersome.

+4
source share
5 answers

@ Dan Lowe's answer about using repeat.vim and is .included. However, you can also create custom environments to make regular activities faster.

Add the ~/.vim/after/ftplugin/markdown.vimfollowing to your file:

let b:surround_{char2nr('b')} = "**\r**"

ysiwb * (b ).

. :h surround-customizing.

+8

vim-repeat, . ( ).

, , ysiw*l. , ( , ) surround.vim , , . ***word*.

:. , , , , , Vim. , .vimrc, :

autocmd FileType markdown,octopress let b:surround_{char2nr('i')} = "*\r*"
autocmd FileType markdown,octopress let b:surround_{char2nr('b')} = "**\r**"
+4

, - vim.

, , , , q.

qqysiw*q

.

@q

, , , .

 qqysiw*ysiw*q
+1

lh-brackets _ , . \* , .

0
source

As a slightly different approach, we can define new commands:

1) visual cloud cloud command, for example:

:vmap \q di****<ESC>hP

(delete the visual area, insert "****", put it back in the middle). Use it as ve\q.

2) the insert-mode command to undo the last recorded word:

:imap \q <ESC>diwi****<ESC>hPlla

3) the word boldify with normal mode under the cursor:

:map \q diwi****<ESC>hP
0
source

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


All Articles