📖
Resources
  • 👋Welcome!
  • Semesters
    • 🚀S1 & S2
      • 🔍Focus
      • âš—ī¸Chemistry
      • 🔭Physics
      • 📊LAC
      • 📈VCD
      • đŸ˜ī¸BCE - BME
      • 🔌BEE
      • 📐Graphics
      • âš™ī¸Mechanics
      • đŸ–Ĩī¸CP
      • â›ˇī¸Life Skills
      • 🧑‍đŸ’ŧPC
    • 📚S3
      • 📉DS
      • âš™ī¸DE
      • 📊DMS
      • 🧑‍đŸ’ģOOP
      • đŸ–Ĩī¸OOP Lab
      • đŸ—ī¸LSD
      • 🌱SE
      • 🔍Extras
    • 📓S4
      • 📊GT
      • 💾COA
      • đŸĒŖDBMS
      • đŸ’ŊOS
      • 😃PE
      • đŸ‡ŽđŸ‡ŗCOI
      • đŸĨŧDE Lab
      • đŸ’ģOS Lab
      • 🔐Number Theory
    • âœī¸S5
      • 💾FLAT
      • 🛜CN
      • đŸ’ŊSS
      • đŸ•šī¸MM
      • đŸ’ģMOSS
      • â˜ĸī¸DM
      • đŸĨŧSS&M Lab
      • đŸĒŖDBMS Lab
      • Cryptographic Algorithms
    • 📖S6
      • CD
      • CGIP
      • AAD
      • PIP (Elective)
      • IEFT
      • CCW
      • Networking Lab
      • Mini Project
    • 📝S7
    • 🎓S8
  • Resources
    • Git
      • Git installation
      • What is Git?
    • Linux
      • Introduction
        • History of Operating System
        • Rise of GNU Project
        • Basic Terminologies
      • Linux shell
      • Commands
        • The Linux man command
        • The Linux ls command
        • cd command
        • The Linux pwd command
        • The Linux mkdir command
        • The Linux rmdir command
        • mv command
        • cp command
        • open command
        • touch command
        • find command
        • Cat command
        • grep command
        • Echo command
        • Vim Editor
        • Emacs Editor
        • Nano editor
        • whoami command
        • who command
        • su command
        • sudo command
        • passwd command
        • clear command
        • History command
    • DSA
      • 1.2 Concepts of Sliding Window Technique
      • 2.2 Characteristics of Sliding Window Problems
      • 1.3 Introduction to Deque and Monotonic Stack
Powered by GitBook
On this page

Was this helpful?

Edit on GitHub
  1. Resources
  2. Linux
  3. Commands

Vim Editor

PreviousEcho commandNextEmacs Editor

Last updated 1 year ago

Was this helpful?

The Linux vim editor command

vim is a very popular file editor, especially among programmers. It's actively developed and frequently updated, and there's a big community around it. There's even a !

vi in modern systems is just an alias for vim, which means vi improved.

You start it by running vi on the command line.

Screenshot-2019-02-10-at-11.44.36

You can specify a filename at invocation time to edit that specific file:

vi test.txt

You have to know that Vim has 2 main modes:

  • command (or normal) mode

  • insert mode

When you start the editor, you are in command mode. You can't enter text like you expect from a GUI-based editor. You have to enter insert mode.

You can do this by pressing the i key. Once you do so, the -- INSERT -- word appears at the bottom of the editor:

Now you can start typing and filling the screen with the file contents:

You can move around the file with the arrow keys, or using the h - j - k - l keys. h-l for left-right, j-k for down-up.

Once you are done editing you can press the esc key to exit insert mode and go back to command mode.

One thing you might want to do now is save the file. You can do so by pressing : (colon), then w.

You can save and quit by pressing : then w and q: :wq

You can quit without saving by pressing : then q and !: :q!

You can undo and edit by going to command mode and pressing u. You can redo (cancel an undo) by pressing ctrl-r.

Those are the basics of working with Vim. From here starts a rabbit hole we can't go into in this little introduction.

I will only mention those commands that will get you started editing with Vim:

  • pressing the x key deletes the character currently highlighted

  • pressing A goes to the end of the currently selected line

  • press 0 to go to the start of the line

  • go to the first character of a word and press d followed by w to delete that word. If you follow it with e instead of w, the white space before the next word is preserved

  • use a number between d and w to delete more than 1 word, for example use d3w to delete 3 words forward

  • press d followed by d to delete a whole entire line. Press d followed by $ to delete the entire line from where the cursor is, until the end

Screenshot-2019-02-10-at-11.36.21
Screenshot-2019-02-10-at-11.47.39
Screenshot-2019-02-10-at-11.48.39

At this point you can navigate the file, but you can't add content to it (and be careful which keys you press, as they might be commands).

To find out more about Vim I can recommend the . You can also run the vimtutor command, which should already be installed in your system and will greatly help you start your vim exploration.

Vim FAQ
Vim conference
Screenshot-2019-02-10-at-11.48.44