This repository was archived by the owner on Apr 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 299
Expand file tree
/
Copy pathCopyPasteTutorial.tsx
More file actions
117 lines (108 loc) · 4.96 KB
/
CopyPasteTutorial.tsx
File metadata and controls
117 lines (108 loc) · 4.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/**
* CopyPasteTutorial.tsx
*
* Tutorial for learning how to copy and paste text.
*/
import * as React from "react"
import { ITutorial, ITutorialMetadata, ITutorialStage } from "./../ITutorial"
import * as Notes from "./../Notes"
import * as Stages from "./../Stages"
const Line1 = "Like the 'd' operator, 'y' can be used to yank (copy) text"
const Line2 = "Any deleted text or yanked can then be pasted with 'p'"
const Line2YankMarker = "Any deleted ".length
const Line2PasteMarker = "Any deleted text or yanked".length
const Line2PostPaste1 = "Any deleted text or yanked text can then be pasted with 'p'"
const Line2PostPaste2 = "text Any deleted text or yanked text can then be pasted with 'p'"
const TransposeLine = "Sipmle tpyos can aslo be fiexd with 'xp'"
const TransposeLine1 = "Simple tpyos can aslo be fiexd with 'xp'"
const TransposeLine2 = "Simple typos can aslo be fiexd with 'xp'"
const TransposeLine3 = "Simple typos can also be fiexd with 'xp'"
const TransposeLine4 = "Simple typos can also be fixed with 'xp'"
export class CopyPasteTutorial implements ITutorial {
private _stages: ITutorialStage[]
constructor() {
this._stages = [
new Stages.SetBufferStage([Line1, Line2]),
new Stages.MoveToGoalStage("Move to the word 'text'", 1, Line2YankMarker),
new Stages.WaitForRegisterStage("Yank this word with 'yw'", "text "),
new Stages.MoveToGoalStage("Move after the word 'yanked'", 1, Line2PasteMarker),
new Stages.WaitForStateStage("Paste after the cursor with 'p'", [
Line1,
Line2PostPaste1,
]),
new Stages.MoveToGoalStage("Move to the beginning of the line", 1, 0),
new Stages.WaitForStateStage("Paste before the cursor with 'P'", [
Line1,
Line2PostPaste2,
]),
new Stages.WaitForRegisterStage(
"Yank the entire line with 'yy'",
Line2PostPaste2 + "\n",
),
new Stages.WaitForStateStage("Paste the yanked line below the cursor with 'p'", [
Line1,
Line2PostPaste2,
Line2PostPaste2,
]),
new Stages.MoveToGoalStage("Move to the top of the file", 0, 0),
new Stages.WaitForStateStage("Paste _above_ the cursor with 'P'", [
Line2PostPaste2,
Line1,
Line2PostPaste2,
Line2PostPaste2,
]),
new Stages.MoveToGoalStage("Move to the next line", 1, 0),
new Stages.WaitForStateStage("Deleting also copies text. Delete a line with 'dd'", [
Line2PostPaste2,
Line2PostPaste2,
Line2PostPaste2,
]),
new Stages.WaitForStateStage("Again, paste with 'p'", [
Line2PostPaste2,
Line2PostPaste2,
Line1,
Line2PostPaste2,
]),
new Stages.WaitForStateStage(
"Copied text can be pasted multiple times, paste again with 'p'",
[Line2PostPaste2, Line2PostPaste2, Line1, Line1, Line2PostPaste2],
),
new Stages.SetBufferStage([TransposeLine]),
new Stages.MoveToGoalStage("Move to the first typo", 0, 2),
new Stages.WaitForStateStage(
"Since deleted text is also copied, transposing characters is simple. Try 'xp'",
[TransposeLine1],
),
new Stages.MoveToGoalStage("Move to the next typo", 0, 8),
new Stages.WaitForStateStage("Again, fix the typo with 'xp'", [TransposeLine2]),
new Stages.MoveToGoalStage("Move to the next typo", 0, 18),
new Stages.WaitForStateStage("Again, fix the typo with 'xp'", [TransposeLine3]),
new Stages.MoveToGoalStage("Move to the next typo", 0, 27),
new Stages.WaitForStateStage("Again, fix the typo with 'xp'", [TransposeLine4]),
]
}
public get metadata(): ITutorialMetadata {
return {
id: "oni.tutorials.copy_paste",
name: "Copy & Paste: y, p",
description:
"Now that you know the delete and change operators, let's learn vim's final operator: `y`. The `y` operator can be used to copy (\"yank\") text which can then be pasted with `p`. Using `p` pastes _after_ the cursor, and `P` pastes _before_ the cursor. The `y` operator behaves just like the `d` and `c` operators and can be paired with any motion.",
level: 220,
}
}
public get stages(): ITutorialStage[] {
return this._stages
}
public get notes(): JSX.Element[] {
return [
<Notes.YankOperatorKey />,
<Notes.YankWordKey />,
<Notes.YankLineKey />,
<Notes.DeleteOperatorKey />,
<Notes.DeleteWordKey />,
<Notes.DeleteLineKey />,
<Notes.pasteKey />,
<Notes.PasteKey />,
]
}
}