Skip to content

Commit

Permalink
Merge pull request #306 from alisonatwork/more-wrapped-line
Browse files Browse the repository at this point in the history
add g^ and gm
  • Loading branch information
alisonatwork committed Oct 30, 2022
2 parents 9268229 + cdc97af commit 0b0f1ab
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Mappers/SpecialKeys/Motion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,10 @@ export class SpecialKeyMotion extends GenericMapper implements SpecialKeyCommon
{ keys: '0', motionGenerators: [MotionLine.start] },
{ keys: '$', motionGenerators: [MotionLine.end] },

{ keys: 'g ^', motionGenerators: [MotionWrappedLine.firstNonBlank] },
{ keys: 'g 0', motionGenerators: [MotionWrappedLine.start] },
{ keys: 'g $', motionGenerators: [MotionWrappedLine.end] },
{ keys: 'g m', motionGenerators: [MotionWrappedLine.middle] },
{ keys: 'g k', motionGenerators: [MotionWrappedLine.up] },
{ keys: 'g j', motionGenerators: [MotionWrappedLine.down] },

Expand Down
16 changes: 16 additions & 0 deletions src/Motions/WrappedLine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ export class MotionWrappedLine extends Motion {
this.cursorMove = args.cursorMove;
}

static firstNonBlank(): Motion {
return new MotionWrappedLine({
cursorMove: {
to: 'wrappedLineFirstNonWhitespaceCharacter',
},
});
}

static start(): Motion {
return new MotionWrappedLine({
cursorMove: {
Expand All @@ -29,6 +37,14 @@ export class MotionWrappedLine extends Motion {
});
}

static middle(): Motion {
return new MotionWrappedLine({
cursorMove: {
to: 'wrappedLineColumnCenter',
},
});
}

static up(args: { n?: number } = {}): Motion {
return new MotionWrappedLine({
isLinewise: true,
Expand Down

0 comments on commit 0b0f1ab

Please sign in to comment.