Home tmade.de

Home Wiki

VI

^                    #A line beginns with
$                    #A line ends with
\<                   #A word beginns with
\>                   #A word ends with
:set hlsearch        #Highlight spaces
%                    #Jump to closing bracket

Edit

D                    #Delete text from curser to end of the line
A                    #Insert text at the end of the current line
o                    #Change to insert mode (if not already in) and enter text in the following line
u                    #Undo
ctrl + r             #Redo
r                    #Replace single character
R                    #Replace mode
cw                   #Change single word (until space, character, special character etc.)
c4w                  #Change 4 words
ct"                  #Change all until tag "
.                    #Repeat last command/ insert etc.
:%d                  #Clear all lines

Replace

:%s/Novell/NOVELL/g                           #Replace all appearance
:s/Novell/NOVELL/                             #Replace single appearance of "Novell"
:%s/ERROR/error/g   
:%s#/old/path/#/replace/new_path/#            #Replace path      
:%s#/var/lib/named/#/var/lib/bind/#           #Replace path  
:%s/\/old\/path/\/replace\/new_path/g         #Replace path         

Useful Commands

:e                  #Reload file
:e!                 #Reload file, changes are lost
Shift + G           #Jump to end of file
1 + G               #Jump to beginning of file
:se nu              #Show line number
:set number         #Show line number
:se nonu            #Hide line numbers
:set nonumber       #Hide line numbers
:5                  #Jump to line 5
:set list           #Show special caracters
:w !sudo tee %      #Save file with sudo rights
:wq !sudo tee %     #Save and quit file with sudo rights

Visual Mode

If you can´t enter text with putty and right mouse click, set

set mouse-=a

in file

~/.vimrc

or

:set mouse=

inside VI.

Adapt to it - with mouse mode turned on, the new way to paste is

shift-right-click 
linux/vi.txt · Last modified: 2019/10/31 00:54 by tmade
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 4.0 International
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki