Skip to content

Commit

Permalink
Merge pull request #66 from josephliccini/master
Browse files Browse the repository at this point in the history
'$' and '^' for Moving to beginning and end of line
  • Loading branch information
jpoon committed Dec 1, 2015
2 parents 46df0b6 + eb6de1b commit ada2dac
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ export function activate(context: vscode.ExtensionContext) {
registerCommand(context, 'extension.vim_8', () => handleKeyEvent("8"));
registerCommand(context, 'extension.vim_9', () => handleKeyEvent("9"));

registerCommand(context, 'extension.vim_$', () => handleKeyEvent("$"));
registerCommand(context, 'extension.vim_^', () => handleKeyEvent("^"));

registerCommand(context, 'extension.vim_ctrl_r', () => handleKeyEvent("ctrl+r"));
registerCommand(context, 'extension.vim_ctrl_[', () => handleKeyEvent("ctrl+["));

Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,15 @@
{ "key": "8", "command": "extension.vim_8", "when": "editorTextFocus" },
{ "key": "9", "command": "extension.vim_9", "when": "editorTextFocus" },

{ "key": "Shift+4", "command": "extension.vim_$", "when": "editorTextFocus" },
{ "key": "Shift+6", "command": "extension.vim_^", "when": "editorTextFocus" },

{ "key": "Ctrl+[", "command": "extension.vim_ctrl_[", "when": "editorTextFocus" },
{ "key": "Ctrl+r", "command": "extension.vim_ctrl_r", "when": "editorTextFocus" },

{ "key": "Shift+,", "command": "extension.vim_<", "when": "editorTextFocus" },
{ "key": "Shift+.", "command": "extension.vim_>", "when": "editorTextFocus" }

]
},
"scripts": {
Expand Down
2 changes: 2 additions & 0 deletions src/mode/modeNormal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export default class CommandMode extends Mode {
"j" : () => { Cursor.move(Cursor.down()); },
"k" : () => { Cursor.move(Cursor.up()); },
"l" : () => { Cursor.move(Cursor.right()); },
"$" : () => { Cursor.move(Cursor.lineEnd()); },
"^" : () => { Cursor.move(Cursor.lineBegin()); },
"w" : () => { vscode.commands.executeCommand("cursorWordRight"); },
"b" : () => { vscode.commands.executeCommand("cursorWordLeft"); },
">>" : () => { vscode.commands.executeCommand("editor.action.indentLines"); },
Expand Down

2 comments on commit ada2dac

@rashwell
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just an observation, I haven't made a pull request with my version of this type of addition to keep from stepping on peoples toes, but the ^ shouldn't be mapped to the current version of lineBegin. Instead unless my vim fu is suspect that should be mapped to 0 (zero). The ^ actually goes to beginning of first non white space. In mine I have created a seperate function in Cursor like below to map the ^ too:

    static nonBlankLineBegin() : vscode.Position {
        let pos = this.currentPosition();
        const linetext = TextEditor.ReadLine(pos.line);
        if (linetext.length !==0) {
            var fc = linetext.length - linetext.replace(/^\s+/,"").length;              
            return new vscode.Position(pos.line, fc);
        }
        return new vscode.Position(pos.line, 0);    
    }

@josephliccini
Copy link
Contributor

@josephliccini josephliccini commented on ada2dac Dec 1, 2015 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.