The Notebook Review forums were hosted by TechTarget, who shut down them down on January 31, 2022. This static read-only archive was pulled by NBR forum users between January 20 and January 31, 2022, in an effort to make sure that the valuable technical information that had been posted on the forums is preserved. For current discussions, many NBR forum users moved over to NotebookTalk.net after the shutdown.
Problems? See this thread at archive.org.

    vi editor - crash course

    Discussion in 'Linux Compatibility and Software' started by Tailic, Jun 20, 2008.

  1. Tailic

    Tailic Notebook Deity

    Reputations:
    78
    Messages:
    775
    Likes Received:
    0
    Trophy Points:
    30
    I was just doing a chapter in a unix book of mine about the vi editor and it was pretty... uh.. different. It has two different modes, append and command mode. You start out in command mode and you switch to append mode by hitting "a". Append mode is the mode you use to add text, you add text to the place in the document that your marker at. You change your marker in command mode, you go back to command mode by hitting "esc". You move your marker by either the arrow keys or "hjkl" keys. The settings command is ":set", the search document is "/" then what word you want. Most of the deleting happens in command mode, "x" deletes a single character, "dd" deletes a whole line. Searches only happen in command.

    Ok, you had your crash course in vi, now go open a document by using "vi" [document] and mess around a bit. Google if you want more commands because most of what I tell you is off the top of my head. ;) What I found interesting in vi is how many different keys you can navigate around a document.

    No more noobish editing with nano or kwrite! :D Your using the oldest editor now.
     
  2. Icewalker

    Icewalker Notebook Consultant

    Reputations:
    63
    Messages:
    105
    Likes Received:
    0
    Trophy Points:
    30
    I like emacs better. Especially the 'chained' hotkeys. Although emacs a pain to configure properly. Couldn't ever bring myself to using vi and I guess never will ;)
     
  3. INCSlayer

    INCSlayer Notebook Consultant

    Reputations:
    14
    Messages:
    185
    Likes Received:
    0
    Trophy Points:
    30
    vi is easy when you learn it i find nano hard never tried emacs though
     
  4. srunni

    srunni Notebook Deity

    Reputations:
    96
    Messages:
    854
    Likes Received:
    0
    Trophy Points:
    30
    Are you sure this wasn't in response to http://forum.notebookreview.com/showthread.php?t=262957 ? ;/

    Anyway, what you're referring to is called 'insert mode', not 'append mode'. If you use 'a', the cursor is inserted after the current character, whereas if you use 'i', the cursor is inserted before the current character.

    If you want to learn how to use vim, there's a program installed alongside it (on Ubuntu, at least) called 'vimtutor'. It can be pretty useful for a first time user.

    Also, vi isn't the oldest text editor. That would be ed ( http://en.wikipedia.org/wiki/Ed_(text_editor)). vi is based on ex, which is based on ed. Besides, what is referred to as vi nowadays is actually Vim, which is just one of many extended versions of vi; it just happens to be the most popular one.
     
  5. Dire NTropy

    Dire NTropy Notebook Deity

    Reputations:
    297
    Messages:
    720
    Likes Received:
    0
    Trophy Points:
    30
    also, don't forget these tips:

    to save and exit a document you have made changes to hit 'esc' ':x!' (without quotes)

    to exit a document without saving hit 'esc' ':q!'
     
  6. John Kotches

    John Kotches Notebook Evangelist

    Reputations:
    133
    Messages:
    381
    Likes Received:
    0
    Trophy Points:
    30
    vi (VIsual editor) was designed as a programmer's editor rather than as a word processor. When you're working with code, you don't want to have that file writable by default. It requires a conscious action on the part of the user to write to the file.

    It's a matter of the right tool for the right job; and vi is an excellent choice as a programmer's text editor.
     
  7. srunni

    srunni Notebook Deity

    Reputations:
    96
    Messages:
    854
    Likes Received:
    0
    Trophy Points:
    30
    You can also save and exit with 'ZZ' or ':wq'.

    That doesn't stop me from using it for word processing via LaTeX ;)
     
  8. theZoid

    theZoid Notebook Savant

    Reputations:
    1,338
    Messages:
    5,202
    Likes Received:
    22
    Trophy Points:
    206
    Maybe I can be a vi-p too? :D
     
  9. Tailic

    Tailic Notebook Deity

    Reputations:
    78
    Messages:
    775
    Likes Received:
    0
    Trophy Points:
    30
    From what my book told me its append mode, it can be called insert mode or whatever, but append is what they said its called.

    As for it not being the oldest editor, I think they've meant it was around in some form or another. Not necessarily the same name. Same goes for Vim, just a newer version. Both vim and vi call up the same program.

    As for vi vs. emacs. Vi comes with every unix version in some way or another. Emacs has to be downloaded if you want to use it. So if your on a machine that doesn't have a internet connection you're basically screwed.

    Also I noticed that emacs has an annoying welcome screen, does anyone know how to get rid of it? Just display have it display the file rather then show me info about the editor. It gives me a really bad impression everytime I see that, it reminds me of some kinda of windows shareware.

    Some more commands to quit vi ":wq" and ":q!" or ":!q". The first one means write quit and the last one means quit without writing.
     
  10. benx009

    benx009 Notebook Evangelist

    Reputations:
    184
    Messages:
    663
    Likes Received:
    0
    Trophy Points:
    30
    Eh, vi and emacs are a little too over my head. Too much to memorize :(

    I think for command line text editing I'll just stick to nano....
     
  11. timberwolf

    timberwolf Notebook Consultant

    Reputations:
    131
    Messages:
    288
    Likes Received:
    0
    Trophy Points:
    30
    Many modern linux users have no need to use a text editor, they tend to appeal more to system administrators, programmers and shell users.

    Vim (and emacs to a lesser extent) can be overwhelming, the answer is don't feel that you need to remember all the commands at once , you can start using Vim with only a handful of commands. To aid memory, there are also lots of Vim quick reference cards and sheets (too many to list here), that you can download and print off to keep handy by your computer.
     
  12. wearetheborg

    wearetheborg Notebook Virtuoso

    Reputations:
    1,282
    Messages:
    3,122
    Likes Received:
    0
    Trophy Points:
    105
    Hell yeah, I know like 0.1% of the commands of vi/emacs.
    To start off one needs to know how to opena file, save file, delete chracter, search and quit.
    And I use vi/emacs regularly :D They are my only editors.