MySQL DBA - Tips and Techniques Magazine

3 Oct 2014

LINUX Text Editor : Vi

Vi (pronounced V I,  or vigh (rhymes with sigh) - very powerful text editor, standard one used across the industry. Small memory footprint , can be put onto recovery disks.

[Not Vim - is Vi iMproved  in newer distributions,  use that if its available).

3 modes to use Vi in:

               command mode : hit ESC  takes you to command mode can navigate the file

                              L H J K - move cursoe

                              yy or Y or 2yy - yank line 

                              p - paste underneath current line

                              P - paste on previous line

                              u - undo

                              G - move to  last line of file

5G - goto line 5

L - goto last line of terminal

H - goto top line of terminal

J - join lower line to current line

/   - searches left to right

?  -  searches right to left

               insert mode        :  entering text

                              i - insert

                              R - replace

                              cw - change word

                              cc - change line

               ex mode              :  hit ESC and press :   (colon) .

                              %s   - search and replace

                              w - write/save

                              q - quit,  wq!  - force quit

                              e   newfile.txt - edit a new file

                              r  oldfile.txt  - brings it in

                              !  run shell command eg ls /etc

No comments:

Post a Comment