machakann / vim-sandwich

Set of operators and textobjects to search/select/edit sandwiched texts.
1.44k stars 37 forks source link

Is there any insert mode mapping? #100

Open yyq123 opened 4 years ago

yyq123 commented 4 years ago

Hi @machakann ,

I am wondering if there is a way to insert pairs of surroundings in insert mode?

Like insert mode mapping on <C-G>s and <C-S> of vim-surround: https://github.com/tpope/vim-surround/blob/f51a26d3710629d031806305b6c8727189cd1935/doc/surround.txt#L82

Thanks

machakann commented 4 years ago

No, since I haven't used it. Could it be useful?

yyq123 commented 4 years ago

I am writing a blog post about vim-sandwich in Chinese.

I want to show some examples based on vim-surround experience. In the other words, I would like to fulfill some vim-surround functions in vim-sandwich way, so I can do comparison between these two plugins easily.

For example, the below text 'Hello World'

Using vim-surround command cS'<p> will replace ' with tag <p> and a new line: <p> Hello World </p>

How to do the same thing using vim-sandwich?

Please advice. Thank you.

HagaiHargil commented 4 years ago

I'm not the package author, but you can achieve almost the same behavior using sr'Tp. It will change 'Hello' to <p>Hello</p>, without the newline. I'm not sure how to add this newline automatically.

itainoam commented 3 years ago

Useful for autoclosing functionality. With vim surround you could:

provides Ctrl-s (same line surrounds) and Ctrl-s-s (spread over three lines) when in insert mode to add surrounds. Some examples in insert mode, vertical line is cursor:

Ctrl-s ( --> (|)

Ctrl-s [ --> [ | ]

Ctrl-s ] --> [|]

Ctrl-s

-->
|