Skip to content

Commit 9bcacef

Browse files
committed
Handle asterisk & space output
1 parent d69370e commit 9bcacef

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

keymap/vim.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
{ keys: 's\'<character>', type: 'action', forceMatch: true, action: 'vimChangeSurround', actionArgs: { search: '\'' } },
9191
{ keys: 's\"<character>', type: 'action', forceMatch: true, action: 'vimChangeSurround', actionArgs: { search: '\"' } },
9292
{ keys: 's\`<character>', type: 'action', forceMatch: true, action: 'vimChangeSurround', actionArgs: { search: '\`' } },
93+
{ keys: 's\*<character>', type: 'action', forceMatch: true, action: 'vimChangeSurround', actionArgs: { search: '\*' } },
9394
{ keys: 's\(<character>', type: 'action', forceMatch: true, action: 'vimChangeSurround', actionArgs: { search: '\(' } },
9495
{ keys: 's\)<character>', type: 'action', forceMatch: true, action: 'vimChangeSurround', actionArgs: { search: '\)' } },
9596
{ keys: 's\{<character>', type: 'action', forceMatch: true, action: 'vimChangeSurround', actionArgs: { search: '\{' } },
@@ -2833,7 +2834,7 @@
28332834
var openCs = ['{', '(', '[']
28342835
var mirroredPairs = {'(': ')', ')': '(',
28352836
'[': ']', ']': '[',
2836-
'\'': true, '"': true, '`': true};
2837+
'\'': true, '"': true, '`': true, '*': true};
28372838
var multilinePairs = { '{': '}', '}': '{' };
28382839

28392840
function transformCharacterPair (character) {
@@ -2866,10 +2867,19 @@
28662867

28672868
var inner = lineContent.slice(openIndex + 1, closeIndex + cursor.ch)
28682869

2870+
var addSpace = openCs.includes(replaceCharacter)
2871+
28692872
var openPos = { ch: openIndex, line: cursor.line }
28702873
var closePos = { ch: cursor.ch + closeIndex + 1, line: cursor.line }
28712874

2872-
cm.replaceRange(replacePair[0] + inner + replacePair[1], openPos, closePos)
2875+
var text
2876+
if (addSpace) {
2877+
text = replacePair[0] + ' ' + inner + ' ' + replacePair[1]
2878+
} else {
2879+
text = replacePair[0] + inner + replacePair[1]
2880+
}
2881+
2882+
cm.replaceRange(text, openPos, closePos)
28732883
}
28742884

28752885
function replaceMultilineSurround () {

0 commit comments

Comments
 (0)