Semper Phone

Effortless
LEARNING

  • Improve effortlessly – just by living your life
  • Learn while waiting for your apps to load
  • Recommended by 5 universities
  • Community of over 1,000,000 learners
  • 50,000+ expert-made packs, or create your own
"One of the best learning apps" - CNET
  • Apple Play Store
  • Install Semper from the Play Store
vi editor

vi editor

Last update 

This contains an overview over the commands that are used inside the linux/unix command-line editor "vi". You will learn all of the important (and less important) commands you'll need to run vi and vim. If you like to have questions and answers the other way around, please check "vi editor inverted" Adopted from: http://goo.gl/cH89YF

Items (55)

  • edit file "filename"

    vi filename

  • recover filename that was being edited when system crashed

    vi -r filename

  • quit vi, and save (option 1)

    :x

  • quit vi, and save (option 2)

    :wq

  • quit (or exit) vi

    :q

  • quit vi without save

    :q!

  • move cursor down one line

    j or <Return>

  • move cursor up one line

    k [or up-arrow]

  • move cursor left one character

    h or <Backspace>   [or left-arrow]

  • move cursor right one character

    l or <Space>   [or right-arrow]

  • move cursor to start of current line

    0 (zero)

  • move cursor to end of current line

    $

  • move cursor to beginning of next word

    w

  • move cursor back to beginning of preceding word

    b

  • move cursor to first line in file

    :0<Return> or 1G

  • move cursor to line n

    :n or nG

  • move cursor to last line in file

    :$ or G

  • move forward one screen

    ^f

  • move backward one screen

    ^b

  • move down one half screen

    ^d

  • move up one half screen

    ^u

  • redraws the screen

    ^l

  • redraws the screen, removing deleted lines

    ^r

  • undo (toggle)

    u

  • insert text before cursor, until <Esc>

    i

  • insert text at beginning of current line, until <Esc>

    I

  • append text after cursor, until <Esc>

    a

  • append text to end of current line, until <Esc>

    A

  • open and put text in a new line below current line, until <Esc>

    o

  • open and put text in a new line above current line, until <Esc>

    O

  • replace single character under cursor

    r

  • replace characters, starting at current cursor

    R

  • change the current word with new text, starting with the character under cursor, until <Esc>

    cw

  • change N words beginning with character under cursor, until <Esc>

    cNw

  • change the characters in the current line, until <Esc>

    C

  • change the entire current line, stopping when <Esc>

    cc

  • change the next N lines stopping when <Esc>

    Ncc or cNc

  • delete single character under cursor

    x

  • delete N characters

    Nx

  • delete the single word

    dw

  • delete N words

    dNw

  • delete the remainder of the line

    D

  • delete entire current line

    dd

  • delete N lines

    Ndd or dNd

  • copy (yank, cut) the current line into the buffer

    yy

  • copy (yank, cut) the next N into the buffer

    Nyy or yNy

  • put (paste) the line(s) in the buffer into the text after the current line

    p

  • search forward for occurrence of string in text

    /string

  • search backward for occurrence of string in text

    ?string

  • move to next occurrence of search string

    n

  • move to next occurrence of search string in opposite direction

    N

  • read file named filename and insert after current line

    :r filename

  • write current contents to file named in original vi call

    :w

  • write current contents to a new file named newfile

    :w newfile

  • write current contents over a pre-existing file named prevfile

    :w! prevfile