t9md / atom-vim-mode-plus

vim-mode improved
https://atom.io/packages/vim-mode-plus
MIT License
1.4k stars 111 forks source link

Implements support for custom surround pairs #1102

Closed isundaylee closed 5 years ago

isundaylee commented 5 years ago

(This is my first atom-vim-mode-plus PR, so definitely let me know if I've missed something, or if there already exists similar feature to this :) )

This PR adds a config option customSurroundPairs that allows the user to define custom pairs of texts to be used with surround operators.

Example use case: Adding surrounding PHP tags

By setting customSurroundPairs to

[{alias: 'p', start: '<?php ', end: ' ?>'}]

the user can change (| for cursor)

so|mething

to

<?php so|mething ?>

using the key sequence y s i w p.

Setting accessibility

Since the schema of this setting is rather complex (it is an array consisting of objects with certain properties), atom-settings will not render it in the settings panel. Instead, the only way to set it seems to be manually modifying the user's config.cson file.

Should we switch to use a simpler config schema so that this option can be shown in the settings panel? For example, we can make the setting be an array of strings of format "trigger|start|end".

Alternatively, we can keep the current schema. But in that case we might want to document this option somewhere since it's not gonna be in the settings panel.

t9md commented 5 years ago

Thanks for PR, when I saw your PR, I felt that I want custom-surround works in other surround operation(delete-surround, change-surround).

So I started evaluation if its possible with current vmp implementation, then that grows to #1104. Although its implementation is different, it is greatly inspired by your idea.

If you have any opinion, suggestion, please put it on #1104.

isundaylee commented 5 years ago

Even better! Thanks for implementing this and for making this awesome plugin :)

I'll close this PR then.