C Programming Tutorial 17 – Vim Basics – Part 1

In this series we have been using Vim. Now, you don’t have to use vim if you don’t want. That’s fine. I too am very new to Vim, I just started using it this year. So I am still a beginner. When I first started using it, I found it to be very annoying, like it made everything more complex than it had to be. If you feel that way, I understand. One you learn some of the commands, you can see that it’s not so bad. One of the huge benefits of using vim is that it is so widely available. This means that if you have to connect to another computer through the command line, the chances are you can edit text files on the remote computer using Vim. Cool.

Let’s open a file in Vim.

vim tacos

The first thing I want to do with vim is make it not so ugly. The way we can do that is turn syntax highlighting on!

:syntax on

We can also add a line count:

:set number

This is great and all but watch what happens when we close and reopen vim.


vim tacos

You can see that the syntax highlighting and line count goes away. To fix this, we have to edit a file for our vim configuration. So let’s quit vim.


vim .vimrc

Put this in the file:

syntax on
set number

It’s okay if it is a new file. It should still work as long as we are in the home directory, which we are from running cd.

The next thing I wanted to discuss is the proper way to move the cursor around in vim. Let me open a small program to show you some commands. So far you’ve probably used the arrow keys to move your cursor around in vim. This is fine starting out, but a lot of people actually do it a different way. When you use the arrow keys, you often train yourself to stay in insert mode all of the time because you can move around while in insert mode. Well, you are actually not supposed to stay in insert mode but rather are supposed to only be in insert mode when you are about to type.

The recommended way to move your cursor around is with h, j, k, l. Give it a try and see if you can get used to it. Now, when you see something that needs changed, you are supposed to move there, then enter into insert mode, and then exit insert mode. Let’s give it a try.

Now, whether you use the arrow keys or not is ultimately up to you, but either way you will probably want to try to get into the habit of only being in insert mode when you really need to insert something and not all of the time. That’s because when you are not in insert mode there are other commands you can run to make coding a lot faster.

One of the easiest ways to move around is using G. Type a number followed by G to go to that line.


G by itself goes to the very end.

$ goes to the end of a line

^ goes to the beginning of a line.

a will enter insert mode after the character you are on.

w is used to move to the beginning of the next word

b is used to move to the beginning of the previous word

In the next video we are going to discuss how to copy and paste, undo and redo, and other cool stuff like that.


Support me! http://www.patreon.com/calebcurry

Subscribe to my newsletter: http://eepurl.com/-8qtH

Donate!: http://bit.ly/DonateCTVM2.

~~~~~~~~~~~~~~~Additional Links~~~~~~~~~~~~~~~

More content: http://CalebCurry.com
Facebook: http://www.facebook.com/CalebTheVideoMaker
Google+: https://plus.google.com/+CalebTheVideoMaker2
Twitter: http://twitter.com/calebCurry

Amazing Web Hosting – https://www.dreamhost.com/r.cgi?1487063 (The best web hosting for a cheap price!)


Timothy Syu says:

super useful thanks bro ! 😀

Vu Truong says:

VI = Virtually Impossible (to use).

Brofin says:

Vim is like the Dark Souls of text editors :p

Write a comment


Human Verification: In order to verify that you are a human and not a spam bot, please enter the answer into the following box below based on the instructions contained in the graphic.

Do you like our videos?
Do you want to see more like that?

Please click below to support us on Facebook!

Send this to a friend

▷ Other ReviewsVehicles   Show Cars   Motorbikes   Scooters   Bicycles   Rims & Tires   Luxury BoatsFashion   Sunglasses   Luxury Watches   Luxury Purses   Jeans Wear   High Heels   Kinis Swimwear   Perfumes   Jewellery   Cosmetics   Shaving Helpers   Fashion Hats   Modeling TipsFooding   Chef Club   Fooding Helpers   Coktails & LiquorsSports   Sport Shoes   Fitness & Detox   Golf Gear   Racquets   Hiking & Trek Gear   Diving Equipment   Ski Gear   Snowboards   Surf Boards   Rollers & SkatesEntertainment   DIY Guides   Zik Instruments   Published Books   Music Albums   Cine Movies   Trading Helpers   Make Money   Fishing Equipment   Paintball Supplies   Trading Card Games   Telescopes   Knives   Vapes   GameplaysHigh Tech   Flat Screens   Tech Devices   Camera Lenses   Audio HiFi   Printers   USB Devices   PC Hardware   Network Gear   Cloud Servers   Software Helpers   Programmer Helpers   Mobile Apps   Hearing AidsHome   Home Furniture   Home Appliances   Tools Workshop   Beddings   Floor Layings   Barbecues   Aquarium Gear   Safe Boxes   Office Supplies   Security Locks   Cleaning ProductsKids   Baby Strollers   Child Car Seats   Remote ControlledTravel   Luggages & Bags   Airlines Seats   Hotel Rooms   Fun Trips   Cruise Ships   Mexico Tours