- create new dir basic-vim and cd into it:
take basic-vim
- create new file
touch foo.js
- initilize a git repo
git init
- add some code to the foo file
const hello = (name) => {
const greet = `Well hello there, ${name}`;
console.log(greet);
}
hello('Bob');
- check the status
git status
- add the foo.js file in your working directory to the staging area:
git add foo.js
- check that your staging area is up to date with your working dir:
git status
- commit your changes to your local git repo:
git commit -m 'hello bob'
- commit your changes to your local git repo:git commit -m 'hello bob'
- check you commit history for your new changes:
git log
- Update your foo.js file so that we log out Bob's last name too.
const hello = (name) => {
const greet = `Well hello there, ${name}`;
console.log(greet);
}
hello('Bob Wiley'); \\ 👈
- check the status of your chnages:
git status
- add these changes to the staging area:
git add foo.js
- double chekck your stagin area is up-to-date with your working dir:
git status
- add these new changes to last commit:
git commit --amend
- You should now be in Vim world!
- You start off in Normal mode when you enter Vim. (says which mode you are in at the bottom)
- Try out the commands
h
j
k
l
- Try out
G
andgg
- Move the cursor to the end of the first line.
- press
a
to be put in Insert mode, look at the bottom of the screen to verify this. - you can now add text.
- Change your commit to say "hello Bob Wiley"
- press
esc
to exit Insert mode and go back to Normal mode. - We have just updated the commit message of our previous commit, now we just need to save this change.
- press
:
and you will see your cursor jump to the status bar at the bottom. - next press
w
, which stands for "write", and then hit return to save your changes. - Your cursor should jump back to the file at this point.
- At this point we are all done and want to quit out of vim.
- press
:
to go back to the status bar again, followed byq
and then hit return to quit. - if done correctly you will be back in your shell.
- run
git log
to check your commit history and see that your commit message has been updated.