Skip to content

Commit 333a1f2

Browse files
hokacchamarijnh
authored andcommitted
[vim mode] Add keymap to indent
1 parent 8ecbdc5 commit 333a1f2

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

keymap/vim.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@
190190
{ keys: '.', type: 'action', action: 'repeatLastEdit' },
191191
{ keys: '<C-a>', type: 'action', action: 'incrementNumberToken', isEdit: true, actionArgs: {increase: true, backtrack: false}},
192192
{ keys: '<C-x>', type: 'action', action: 'incrementNumberToken', isEdit: true, actionArgs: {increase: false, backtrack: false}},
193+
{ keys: '<C-t>', type: 'action', action: 'indent', actionArgs: { indentRight: true }, context: 'insert' },
194+
{ keys: '<C-d>', type: 'action', action: 'indent', actionArgs: { indentRight: false }, context: 'insert' },
193195
// Text object motions
194196
{ keys: 'a<character>', type: 'motion', motion: 'textObjectManipulation' },
195197
{ keys: 'i<character>', type: 'motion', motion: 'textObjectManipulation', motionArgs: { textObjectInner: true }},
@@ -2616,6 +2618,9 @@
26162618
}
26172619
repeatLastEdit(cm, vim, repeat, false /** repeatForInsert */);
26182620
},
2621+
indent: function(cm, actionArgs) {
2622+
cm.indentLine(cm.getCursor().line, actionArgs.indentRight);
2623+
},
26192624
exitInsertMode: exitInsertMode
26202625
};
26212626

test/vim_test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3393,6 +3393,21 @@ testVim('[m, ]m, [M, ]M', function(cm, vim, helpers) {
33933393
helpers.assertCursorAt(7,3);
33943394
}, { value: squareBracketMotionSandbox});
33953395

3396+
testVim('i_indent_right', function(cm, vim, helpers) {
3397+
cm.setCursor(0, 3);
3398+
var expectedValue = ' word1\nword2\nword3 ';
3399+
helpers.doKeys('i', '<C-t>');
3400+
eq(expectedValue, cm.getValue());
3401+
helpers.assertCursorAt(0, 5);
3402+
}, { value: ' word1\nword2\nword3 ', indentUnit: 2 });
3403+
testVim('i_indent_left', function(cm, vim, helpers) {
3404+
cm.setCursor(0, 3);
3405+
var expectedValue = ' word1\nword2\nword3 ';
3406+
helpers.doKeys('i', '<C-d>');
3407+
eq(expectedValue, cm.getValue());
3408+
helpers.assertCursorAt(0, 1);
3409+
}, { value: ' word1\nword2\nword3 ', indentUnit: 2 });
3410+
33963411
// Ex mode tests
33973412
testVim('ex_go_to_line', function(cm, vim, helpers) {
33983413
cm.setCursor(0, 0);

0 commit comments

Comments
 (0)