diff --git a/README.md b/README.md index 9bf45e0..4d016ab 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ + vim emulator for VSCode ![vimanimetion](https://raw.githubusercontent.com/74th/vscode-vim/master/tutorial/tutorial1.gif) @@ -41,11 +42,11 @@ npm run-script build ## support -* h j k l 0 $ w W b B e E tx fx Tx Fx gg G +* h j k l 0 $ ^ w W b B e E tx fx Tx Fx gg G * Nh Nj Nk Nl Nw NW Nb NB Ne NE Ntx Nfx NTx NFx NG * i a s o x I A S O X * Nx -* d y c dd yy cc D C p P +* d y c dd yy cc D C p P d$ y$ c$ ... * Ndd Nyy Ncc * v V * . @@ -100,6 +101,13 @@ MIT License ## update +### 0.3.3 + +* support ^ +* change icon + +![icon](https://raw.githubusercontent.com/74th/vscode-vim/master/vim.png) + ### 0.3.2 * update for vscode 1.0.0 diff --git a/package.json b/package.json index cd5c462..7c802f6 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "type": "git", "url": "https://github.com/74th/vscode-vim.git" }, - "version": "0.3.2", + "version": "0.3.3", "publisher": "74th", "engines": { "vscode": "^1.0.0" diff --git a/src/core/CommandFactory.ts b/src/core/CommandFactory.ts index 89c4b53..56e03c6 100644 --- a/src/core/CommandFactory.ts +++ b/src/core/CommandFactory.ts @@ -18,7 +18,7 @@ import {HomeMotion} from "../motion/HomeMotion"; import {EndMotion} from "../motion/EndMotion"; import {FindCharacterMotion} from "../motion/FindCharacterMotion"; import {WordMotion} from "../motion/WordMotion"; -import {LineHeadMotion} from "../motion/LineHeadMotion"; +import {LineHeadMotion, LineHeadTarget} from "../motion/LineHeadMotion"; export class CommandFactory implements ICommandFactory { @@ -187,6 +187,9 @@ export class CommandFactory implements ICommandFactory { case CommandName.moveEndAction: this.moveEndAction(); return; + case CommandName.moveFirstNonBlankCharAction: + this.moveFirstNonBlankCharAction(); + return; case CommandName.moveFindCharacterAction: this.moveFindCharacterAction(command.isReverse); return; @@ -234,6 +237,9 @@ export class CommandFactory implements ICommandFactory { case CommandName.endMotion: this.endMotion(); return; + case CommandName.firstNonBlankCharMotion: + this.firstNonBlankCharMotion(); + return; case CommandName.findCharacterMotion: this.findCharacterMotion(command.isReverse); return; @@ -349,7 +355,7 @@ export class CommandFactory implements ICommandFactory { // I private insertHomeAction() { let m = new LineHeadMotion(); - m.SetCurrentLineOption(); + m.TargetLine = LineHeadTarget.Current; this.action = new ApplyInsertModeAction(m); } @@ -466,6 +472,13 @@ export class CommandFactory implements ICommandFactory { this.action = this.createMoveAction(new EndMotion()); } + // ^ + private moveFirstNonBlankCharAction() { + let m = new LineHeadMotion(); + m.TargetLine = LineHeadTarget.Current; + this.action = this.createMoveAction(m); + } + // fx Fx private moveFindCharacterAction(isReverse) { let a = new MoveAction(); @@ -510,7 +523,7 @@ export class CommandFactory implements ICommandFactory { private moveLastLineAction() { let a = new MoveAction(); let m = new LineHeadMotion(); - m.SetLastLineOption(); + m.TargetLine = LineHeadTarget.Last; a.SetMotion(m); this.action = a; } @@ -519,7 +532,7 @@ export class CommandFactory implements ICommandFactory { private moveFirstLineAction() { let a = new MoveAction(); let m = new LineHeadMotion(); - m.SetFirstLineOption(); + m.TargetLine = LineHeadTarget.First; a.SetMotion(m); this.action = a; } @@ -575,6 +588,14 @@ export class CommandFactory implements ICommandFactory { let a = this.action; a.SetMotion(new EndMotion()); } + + // c^ + private firstNonBlankCharMotion() { + let a = this.action; + let m = new LineHeadMotion(); + m.TargetLine = LineHeadTarget.Current; + a.SetMotion(m); + } // fx Fx private findCharacterMotion(isReverse) { @@ -619,7 +640,7 @@ export class CommandFactory implements ICommandFactory { // cG private lastLineMotion() { let m = new LineHeadMotion(); - m.SetLastLineOption(); + m.TargetLine = LineHeadTarget.Last; let a = this.action; a.SetMotion(m); a.SetLineOption(); @@ -628,7 +649,7 @@ export class CommandFactory implements ICommandFactory { // cgg private firstLineMotion() { let m = new LineHeadMotion(); - m.SetFirstLineOption(); + m.TargetLine = LineHeadTarget.First; let a = this.action; a.SetMotion(m); a.SetLineOption(); diff --git a/src/core/KeyBindings.ts b/src/core/KeyBindings.ts index 8a86f36..ce2220c 100644 --- a/src/core/KeyBindings.ts +++ b/src/core/KeyBindings.ts @@ -223,6 +223,9 @@ const DefaultKeyBindings: IKeyBindings = { "$": { cmd: CommandName.moveEndAction }, + "^": { + cmd: CommandName.moveFirstNonBlankCharAction + }, ".": { cmd: CommandName.repeat } @@ -512,6 +515,9 @@ const DefaultKeyBindings: IKeyBindings = { }, "$": { cmd: CommandName.endMotion + }, + "^": { + cmd: CommandName.firstNonBlankCharMotion } }, diff --git a/src/motion/LineHeadMotion.ts b/src/motion/LineHeadMotion.ts index 0058d9c..8fcada8 100644 --- a/src/motion/LineHeadMotion.ts +++ b/src/motion/LineHeadMotion.ts @@ -2,7 +2,7 @@ import {AbstractMotion} from "./AbstractMotion"; import * as Utils from "../Utils"; import {Position} from "../VimStyle"; -enum Target { +export enum LineHeadTarget { Current, First, Last, @@ -11,42 +11,33 @@ enum Target { export class LineHeadMotion extends AbstractMotion { - private targetLine: Target; + public TargetLine: LineHeadTarget; + public IsSkipSpaces: boolean; constructor() { super(); - this.targetLine = Target.Number; - } - - public SetFirstLineOption() { - this.targetLine = Target.First; - } - - public SetLastLineOption() { - this.targetLine = Target.Last; - } - public SetCurrentLineOption() { - this.targetLine = Target.Current; + this.TargetLine = LineHeadTarget.Number; + this.IsSkipSpaces = false; } public CalculateEnd(editor: IEditor, start: IPosition): IPosition { let lineDocument: string; let lineNumber: number; - switch (this.targetLine) { - case Target.Current: + switch (this.TargetLine) { + case LineHeadTarget.Current: lineDocument = editor.ReadLineAtCurrentPosition(); lineNumber = start.Line; break; - case Target.First: + case LineHeadTarget.First: lineNumber = 0; lineDocument = editor.ReadLine(lineNumber); break; - case Target.Last: + case LineHeadTarget.Last: lineNumber = editor.GetLastLineNum(); lineDocument = editor.ReadLine(lineNumber); break; - case Target.Number: + case LineHeadTarget.Number: lineNumber = this.GetCount(); let lastLineNum = editor.GetLastLineNum(); if (lineNumber > lastLineNum) { diff --git a/typings/vscode-vim.d.ts b/typings/vscode-vim.d.ts index 1dcf0cd..cfb8d24 100644 --- a/typings/vscode-vim.d.ts +++ b/typings/vscode-vim.d.ts @@ -325,6 +325,7 @@ declare const enum CommandName { moveWORDEndAction, moveHomeAction, moveEndAction, + moveFirstNonBlankCharAction, moveFindCharacterAction, moveTillCharacterAction, moveGotoLineAction, @@ -342,6 +343,7 @@ declare const enum CommandName { WORDEndMotion, homeMotion, endMotion, + firstNonBlankCharMotion, findCharacterMotion, tillCharacterMotion, gotoLineMotion,