ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • HPUX - vi
    IoT 과정 2017. 6. 20. 15:00
    반응형

    vi "filename" : start a vi edit session of file 

    cursor, line, page move

    h, j, k, l. ctrl + b, f.

    ("command mode") + ":"  + "( )" + "Return"

    "wq" (write and quit)

    "q" (quit)

    "q!" (force quit)

    "w" (write)


    vi Modes

    command mode : keystrokes intepreted as commands

    input mode : vi input with keystrokes entered into the file ( from command mode -> "i, a, o, I, A, O" )

    last line mode : ex and search inputs  ( from command mode -> " : ", " / ", " ? " )


    cursor control

    b : back word

    w : front word

    "number" + b or w : "number" back or front word

    $ : end of line

    ^ : start of line

    G : end line of text

    "num" + G : Go to the "num" line

    ctrl + g : display cursor location

    "last line mode" + ": num" + "Return" : go to the "num" line


    input control

    i : insert new text

    a : append new text

    o : input new next line 

    O : input new prev line 


    text control

    (#)x : work as "delete"

    (#)X : work as "backspace"

    (#)dw : delete word

    (#)dd : delete the current line,  delete "#" line from the current line

    dG : delete through the last line of the file

    u : undo the last modofication

    U : Undo all modifications to current line

    p : paste words or texts, lines (append)

    P : past words or texts, lines (insert)

    (#)yw : copy words

    (#)yy : copy lines

    (#)r : replace a character, # characters

    R : replace mode (overwrite mode)

    ~ : toggle 대문자/소문자

    cw : replace a word

    . : repeat last change operation


    search text

    /text : search word, texts, regular expression

    n : find the next occurrence of 

    N : find the next occurrence of the previously 


    Regular Expression

    [oO]ne : search for one and One  [  [Oo][Nn][Ee] ]

    ^text : search for text at the beginning of a line

    text$ : search for text at the end of a line

    . : Match any single character [ /o.e matches o[a-z,A-Z ...]e ]

    character* : Match zero or more occurrences of character [ /on*e matches oe, one, onne, onnne, ... ]

    .* : [ /o.*e matches oe, oae, obe, oaae, oabe, obbe, obae, occce, oczfe ... ]


     global search and replace

    :$,$s/original/replaced/ [all lines, but only one substitute each lines]

    :$,$s/original/replaced/g [all lines, substitutes every occurrence of the text pattern]

    {  

    eg) 1,$s/com/@@@/g [replaces every "com" to "@@@" through end of the file from the beginning of the file] 

    }


    ex Commands

    :w : write the current buffer to disk 

    :$,$w file : writhe lines $ through $ of the current buffer to file

    :w file : write the current buffer to file 

    :e file : bring file into the edit buffer discarding the old buffer

    :e! : discard all changes to the buffer reload the file from the disk

    :r file : read in the contents of file after the current cursor location

    :! command : execute the shell command, without exit vi editor

    :set all : display all edit session options

    :set number : turn on line numbering option [ create or edit a file called .exrc in your HOME directory, set automatically every time you enter vi ]

    $ vi .exrc

    ".exrc" 20 lines, 322 characters

    set ts=4 wm=8 showmode number autoindent autowrite showmatch report=1

    map  ^[h  1G

    map  ^[F  G

    map  ^[V  ^B

    ...

    }


    반응형

    'IoT 과정' 카테고리의 다른 글

    HPUX - File Name Generation  (0) 2017.06.21
    HPUX - Shell Advanced Features  (0) 2017.06.21
    HPUX - Shell Basic  (0) 2017.06.21
    HPUX - vi  (0) 2017.06.20
    HPUX - File Permissions and Access  (0) 2017.06.20
    HPUX - Navigating the File System, Managing Files  (0) 2017.06.19

    댓글 0

Designed by Tistory.