1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Using VI

Discussion in 'Papers' started by Stéphane Lenclud, Apr 2, 2017.

  1. Stéphane Lenclud

    Stéphane Lenclud Founder Staff Member

    Let's make it clear I'm a practical guy and I like straight forward things, in other words: I dislike VI.
    Yet I thought I better teach myself some basic VI usage, that would allow me to edit text file from command line on pretty much every Unix/Linux machine running out there.

    To start with, finding practical VI guide on the internet seems quite hard. It's almost like the geeks don't want to teach you how to use it ;) It's their little secret. Or maybe I was not looking at the right place. Anyhow here is the most practical VI guide I found.

    And here is what I retained from it. To open a file from the command line:
    Code (Bash):
    1. vi <filename>
    Now once in vi it displays the content of your file but you can't just enter some text from there you have to use vi commands to perform operations on the content of your file:
    • To edit a file from your cursor position press: a
    • To stop editing your file and return to vi command press: esc
    • To delete the current character: x
    • To delete the current line press: dd ('d' 2 times)
    • To duplicate the current line press: yyp
    • To save your changes and exit vi enter :x and press enter
    • To exit vi and forget your changes enter :q! and press enter
    You can even do proper copy/paste apparently but it looks like you need a master in vi. Am I being cynical? Me? NoOoo! Anyhow follow the link above to find out how to do that ;)
     
    Last edited: May 29, 2017

Share This Page