Email Newsletter icon, E-mail Newsletter icon, Email List icon, E-mail List icon Sign up for our Email Newsletter




VIM for File Editing

Info

  • Level: Beginner
  • Presenter: Eli the Computer Guy
  • Date Created: September 14, 2010
  • Length of Class: 35 Minutes

Tracks

Prerequisites

  1. Introduction to Linux
  2. Installing Linux
  3. Basic Linux Tasks

Purpose of Class

  • This class teaches students how to edit configuration files in Linux using the text editor VIM.

Topics Covered

  • Starting VIM
  • Editing Files
  • Searching in Files
  • Opening, Saving and Exiting Files

Class Notes

  1. Introduction
    1. No .txt – no file association
  2. Starting VIM
    1. Sudo vim XXX (opens a file, or creates file)
      1. Sudo – sometimes you need, sometimes not… if you use it it will always work…
    2. To change ownership of a file (Sometimes needed to edit .ini and configuration files)- Sudo chown user file
  3. Editing and Navigating
    1. a = insert, esc = exit insert
    2. :/ = find (use wildcards)
    3. :/?  = Find backward
    4. n = next
  4. Exiting and Saving
    1. :q = quit
    2. :q! = quit no save
    3. :wq = save and quit
    4. :e = open file
    5. :w = save as
  5. Final Thoughts…
    1. Very complicated… Lots of options… these are good enough to start with….

Resources



Eli the Computer Guy (429 Posts)

Eli the Computer Guy has 16 years experience in technology being the guy to fix "it". From the Army, to building out new satellite offices for the enterprise, to running his own shop with 9 full time employees Eli has real world experience with almost all systems that technicians will be working with. Eli has 1600 hours of formal technical beyond his Bachelors Degree in Criminal Justice on technologies ranging from Avaya PBX/ Audix to Microsoft, Red Hat Linux, MySQL, Cisco and much more.


  • Andre

    Watched VIM thanks good info

    1. volume control between and white board and actual computer screen can be a little painful
    2. Little confused about :e are you saying you can have multiple files open in vim at one time?

    I really appreciate these videos. you are very generous with your time. I am sure if I live out there I would be a regular at your shop. If you open one in the San Francisco area let me know.

    thanks

    Andre

  • Eli the Computer Guy

    As far as the volume control… I’ve been learning how to create these videos as I’ve been doing them. The newer videos don’t have the same volume issues.

    As for :e. Think of Vim like Notepad where you can only have one document open at a time. So when Vim is open you can use :e to go to a different file. So you might open a config file to see what it has and then open another file by using :e vs. exiting out of Vim and opening the file from the Linux command line.

    Cheer,
    Eli

  • Suresh Panchanathan

    Hi Eli,

    Thanks for the wonderful classes, I am a novice in Linux, I was able to install Linux Oracle 6.2 version successfully. After installing I tried the sudo vim anewfilename, I got the following message:
    We trust you have received the usual lecture from the local System
    Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

    [sudo] password for suresh:

    When I typed the password and hit the enter key, following message was displayed and I was unable to get into the vim editor to create a new file name, please advise.

    “suresh is not in the sudoers file. This incident will be reported.”

    Do you provide live online classes on Linux?

    Regards

    Suresh Panchanathan

  • Eli the Computer Guy

    The biggest thing when learning Linux is to realize all distrobutions of Linux are a bit different. In my classes I was using Ubuntu.

    With Oracle try doing it without the sudo…

  • Suresh Panchanathan

    Hi Eli,

    Thanks for the reply, can you please advise how to add a user to sudoers file? Also do you conduct Linux online training sessions?

    Regards,

    Suresh Panchanathan

  • IamDUFF

    Thanks for doing these.
    =)
    @Suresh
    su
    chmod +w /etc/sudoers
    echo ‘suresh ALL=(ALL) NOPASSWD:ALL’ >> /etc/sudoers
    chmod -w /etc/sudoers

    help.ubuntu.com/community/Sudoers
    mjmwired.net/resources/mjm-fedora-fc6.html#sudo
    The “blahblah ALL=(ALL)” is the important part. Replace with admin, or your group. Or just type in su. It’s really the same amount of typing, although I like how ubuntu has root disabled by default.

  • http://everymanit.com M Israr Masood

    Hi Mr. Eli my name is Israr and i am from Pakistan i haved watched all your videos of linux classes you have done a great work specially for the people like us becouse in our country learning linux is just like a rocket science becouse we dont have good teacher as well as better institue for learning the linux so for us your online classes is just like a precious gift however i will request you to give your presentation in a slower voice so that those country people where english is secondry language can understand you properly rest of this i really appreciate your work and i am really thankful to you for increasing my knowledge. Thanks .

  • gunnar

    thanks for doing your videos, which are helpfull about many things I think.

    please allow some critisism about this one on vim

    1) no need to change ownership of any configuration file as you are suposed to change it using sudo. also it is not adviseable to do so.

    2) your comment about “don’t worry about security” is misleading and contradicts the idea of linux

    3) the comment on the end “if you want to write the next big american novel … use windows” … well … never mind.

  • ds

    Superb! This is what is called teaching!! u in-scripted the concepts in mind permanently! its mind blowing! I am addicted to your classes. Feels like, I should cover all as early as possible. Not for any professional gain or anything, just enjoying the learning! Thanks- thanks- thanks a ton!

  • Babar Iqbal

    Mr. Eli plzzz make tutorial about OpenLDAP server and LDAP client authentication in Ubuntu 12.04 server i need that plzzz…
    You are so good teacher that why i request you your teaching method is too good i really appreciate you..
    Thanks…

  • Vani

    Your Videos are helping me a lot in gaining knowledge in software, I want to be a Linux administrator, and these Linux videos are helping me a lot. Thank you so much for uploading these videos for FREE.

    Regards,
    Vani.

  • Amgad

    Thanks for simplifying things Eli, I really appreciated. I’m new to Linux and I can’t tell you how many people out their are making Linux a very complex things to do, but with your simple way things are becoming so simple and easy.
    I appreciate the efforts once a gain,
    Sincerely,
    –Amgad

  • haziz

    Your emphasis on doing all text editing with vim (or any other text editor) as a superuser is I think misguided. Greater emphasis on teaching the concept of privileges and root privileges would have been better. A lot of the editing can be done as a regular user, it is when manipulating certain config files that resorting to superuser or root privileges necessary. I am not sure about vim but when I use emacs it does inform me when a particular file had to be opened in read only mode since I do not have privileges for the directory or file

  • Terry

    Thank you once again Eli, You have made this the best thing on the internet for new users. Really can’t thank you enough.
    Terry



















Subscribe to me on YouTube