Skip to content

Instantly share code, notes, and snippets.

@amirrajan
Created June 18, 2018 18:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amirrajan/78636b292c8107d7689aaf014472beab to your computer and use it in GitHub Desktop.
Save amirrajan/78636b292c8107d7689aaf014472beab to your computer and use it in GitHub Desktop.
Start by pressing <esc>, that will put you in "command" mode. Now press "j".
See what happend? You're on this line now. "j" means down. Now press "5j".
if you see DASHED lines press "zR", otherwise ignore
if you see DASHED lines press "zR", otherwise ignore
What you did just there is "move down 5". Press "j"
If you mess your cursor position during this tutorial press "gg" to take you back to the top, try that now, next time press "j"
Time to follow the ascii road. press "j", then press the key that's highlighted by the blinking cursor
j <---- press "j" because j is curently under your cursor
j
j lllllllllllllj
j k j
j k j
llllllllllllk j
^ j
|___ new "motion" key! j
j
jhhhhhhhhhhhhhhhhhhhhhhhhh <---- "h" is move left, "k" (which you used earlier) is move up
j
j
j
Press "zz" to center the screen horizontally, then press "j" to move to the next line
Now press "i". This will put you in "insert mode". Type "I am awesome.<space>". Then press <esc> and then "j"
j<----- you cursor should be here after you pressed "j", follow the ascii road press "j"
j
jxxxxxxxxxxxxx
j ^
j |_ new key! "x" deletes a character!
j
llllj
jhhhh
xxxxxxxxxxxj
j
j
Press "zz" to center the screen horizontally, then press "j" to move to the next line
The cool thing about "x" is that whatever letter is deleted is put in the clip board. Move to the next line (press "j" in command mode)
press "p", after observing the result, then press 4j
^
|_________ see! the "x" got pasted
Fix the spelling error on the next line. By using a combination of "x" and "p". Move down 6 lines by pressing "6j"
...... press "xp".. this will switch the two characters
|
\|/
.
(Press "l" to move all the way to the character under the arrow) The quick brown fox jumsp over the lazy dog.... press "j" to move to the next line
j <--- another ascii road!!!
j
j back back b is for move back a word
j
j
j
Press "zz" to center the screen horizontally, then press "j" to move to the next line
There is a faster way to fix that spelling error above, Move down 6 lines by pressing "6j"
..... use "l" to move to the next arrow
|
\|/
.
(Press "w" to move to the FIRST arrow, THEN use "l") The quick brown fox jumsp over the lazy dog.... press "5j" to move to the next line
^
|
|_____ press "xp".. this will switch the two characters
The motion keys "w" and "b" are faster ways to move between words, use "b" to move to the beginning of this line, then "j" to move to the next line
j <--- ascii road! Time for some "w" and "b" practice!
j
j
word word word word word j
^ j
|____ "w" for word j
j
j
j back back back back b <---- "b" is for back
j
j
Press "zz" to center the screen horizontally, then press "j" to move to the next line
There is EVEN a faster way to get to the spelling error. Using "f" for find (don't press "f" yet). First, press "5j"
------- typing "fs" will FIND the first occurrance of "s"
|
|/
The quick brown fox jumsp over the lazy dog.... press "5j" (move down 5) to continue
^
|
|_____ press "xp".. this will switch the two characters
Here <------ your cursor is here, press "b" (back), then "j" (for down)
"fs" followed by ";" we'll find multiple occurences of the character following the FIND command, try it out on the next line move to the next line using "j"
Use "b" to move to the beginning of this line (if you're not already there), then "j" to move to the next line
j
j
j
press "fs" then keep pressing ";": she sells sea shelsl by the sea shore, 9j to move to the next part
^ ^ ^ ^
| | | |
| | -------- if you find yourself here, you overshot... press "Fs" to find in the opposite direction....
| |
| ---------------------------------------------
| |
------ press "fs" then keep pressing ";" until you are here --- then "xp" to fix the error
Press "zz" to center the screen horizontally, then press "j" to move to the next line
Taking off the training wheels... no more ascii roads, make your way to the next line.
By the way. "u" in command mode is undo, ctrl+R in command mode is redo. Remeber that if you mess up.
Now fix "=>" to be ">=" in the if statement below: (Hint: use "xp").
When you're done move to the next section.
public void SayHello(int age)
{
if(age => 18) //this is the line with the error, use "xp" to change "=>" to ">="
Console.WriteLine("Hello!");
else
Console.WriteLine("Hi!");
}
By the way. "u" in command mode is undo, ctrl+R in command mode is
redo. Remeber that if you mess up.
Fix the misspelled variable names. (Hint: jurisdiction is misspelled)
//remember "w", "b" and "f[char]" to move quickly
var jursidiction = "Federal";
if(jursidiction == GetCurrentJursidiction())
{
Console.WriteLine(jursidiction);
}
Press "zz" to center the screen horizontally, then press "j" to move to the next line
Insert the missing word in the sentance below. Remember "i" to go into insert mode then <esc> to go
back into command mode. (Hint insert "jumps")
The quick brown fox over the lazy dog.
^
|
|
-------- place your cursor here and press "i", type "jumps", press <esc>
You can also use "a" to go into insert mode. Using "a" moves the postion of the
cursor right before going into insert mode. It's like pressing "li".
Try it out:
The quick brown fox over the lazy dog.
^
|
|
-------- place your cursor here and press "a", type "jumps", press <esc>
Press "zz" to center the screen horizontally, then press "j" to move to the next line
Insert the missing characters in the code below (using "i" and/or "a", use <esc> to go back into command mode)
By the way. "u" in command mode is undo, ctrl+R in command mode is
redo. Remember that if you mess up.
public void SayHello(int age <--- this line is missing a parenthesis
{
if(age 18) <-- this line is missing the comparison operator
Console.WriteLine("Hello!");
else
Console.WriteLine("Hi!") <----- this line is missing a semicolon
}
Each one of the lines below is missing a semi colon, insert them using "a",
then go back into command mode using <esc>:
Console.WriteLine("a")
Console.WriteLine("b")
Console.WriteLine("c")
Console.WriteLine("d")
You can quickly go into insert mode at the end of a line be pressing "A" (capital "a") in command mode
You can quickly go into insert mode at the beginning of a line by pressing "I" (capital "i") in command mode
Use "A" to go to the end of the following line and add a semicolon
foreach(var person in kids) person.SayHello(15)
foreach(var person in adults) person.SayHello(18)
"o" is another way to quickly get into insert mode. "o" will put you into
insert mode AND add a line. Add the missing curly brace by placing the cursor
if(a > 15) <-- place the cursor on this line a and press "o", then add the "{"
Console.Writeline("a is greater than 15");
}
"O" (capital o) will put you into insert mode AND add a line ABOVE the cursor
position. Add a comment "//TODO, refactor" above the if statement
if(a > 15) <-- place the cursor on this line a and press "O", then type your comment
{
Console.Writeline("a is greater than 15");
}
"r" is yet another way to quickly go into insert mode and make a change. "r"
means replace. Pressing "r" will put you in insert mode for a single
character. Use that fix small errors in your code.
Try this now. Change the code below. Change the ">" to a "<" using "r".
if(a > 15) <-- place the cursor on the ">", press "r", then press "<" to preform the replace
{
Console.Writeline("a is greater than 15");
}
Try this one more time:
if(a > 15) <-- place the cursor on the ">", press "r", then press "<" to preform the replace
{
Console.Writeline("a is greater than 15");
}
Fix all the errors in the code below, take advantage of "a", "i", "o" and
their upper case versions too (if needed)
By the way. "u" in command mode is undo, ctrl+R in command mode is
redo. Remeber that if you mess up.
"zz" to center the screen
Check list:
- misspelled parameter "are", fix the parameter to read as "age": use "r"
- missing parenthesis for method definition: use "A"
- missing open curly brace for method definition: use "o"
- missing "." AND semicolon for the call to console writeline: use "i" or "a", "A"
- bad/misaligned spacing on second call to console writeline: use "I"
public void SayHello(int are
ConsoleWriteline("Say Hello")
Console.WriteLine("Say Hi");
}
I want you go through the manipulations above again. Press "u" a few times to undo your changes and try them again.
In fact, I'd STRONGLY encourage you to go through these exercies multiple times using "u" to undo.
Changing gears....
There are too many occurrances of the word "fox". Delete an occurance of a word
by using "dw" (delete word) in command mode. First navigate to the word "fox", then
press "dw":
The quick brown fox fox jumps over the lazy dog.
^
|
------------ delete this with "dw"
Try it one more time (this time with the word "dog"), remember: "d" is for delete, "w" is for word.
The quick brown fox jumps over the lazy dog dog.
^
|
------------ delete this with "dw"
Press "zz" to center the screen horizontally
Remember, whatever "x" and "d" removes is placed in the clipboard. In the next
sentance, the word "dog" is in the wrong place. Use "dw" to delete the word,
move to the end of the sentence, then press "p" to paste from the clipboard.
The quick brown fox dog jumps over the lazy .
^ ^
| |
| ----------- paste here with "p" and press "x" to delete the trailing space
|
------------ delete this with "dw", and move to the end of the sentance
Combining "dw" with "p", you can swap parameters pretty easily. Try that now.
Swap the variable below in the if clause, follow the steps below:
...... FIRST Step, Step 1. place your cursor here and press "dw"
|
\|/
.
if( age > maxAge )
{ ^ ^ ^
| | |
| | ------ 3. place your cursor here and press "dw"
| |
| ------ 2. move your cursor here and press "p"
|
|
|
-------- Step 4. place your cursor here and press "p"
}
You can delete a line (and place it in the clipboard) by pressing "dd"
Use "dd" and "p" to swap the line below.
person.LeaveHouse(); <--- press "dd" on this line and press "p" right after
person.GetDressed();
Put these lines in the right order using "dd", "j", "k", "p" AND "P" (capital "p" which means "paste above")
person.LeaveHouse();
person.GetDressed();
person.WakeUp();
person.TakeAShower();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment