Posts

Showing posts with the label vi

vi/vim :move -2 :move +2 - moves line search text and replace :%s/search/replace/gc

vi :move -2 :move +2 - moves line in vi search text and replace :%s/search/replace/gc Here "pattern" represents the old string and "replace" represents the new string. For example, to replace each occurrence of the word "lemon" in a line with "orange," type: :s/lemon/orange/ The syntax for replacing  every  occurrence of a string in the  entire  text is similar. The only difference is the addition of a "%" in front of the "s": :%s/pattern/replace/

vimdiff rsync -rvnc

vimdiff  /path/to/file scp://username@remotehost//path/to/file If you just want to see what files are different, rather than a diff of the actual files, then you can use  rsync --dry-run You can use  rsync  in dry run mode, as suggested briefly in  another answer . It lists any files that are different. For that, use the  rvnc  options ( r =recursive,  v =verbose,  n = dry-run,  c =checksum). With  rsync  in pull mode ( rsync [OPTION...] [USER@]HOST:SRC... [DEST] ), an example is: rsync -rvnc root@182.18.158.207:/var/www/html/dev/ .

vim root permission :w !sudo tee %

/etc  consists of all configurations files so to edit the files under  /etc  you need the superuser permissions but sometime we forget to use  sudo . but at that time we can also use :w !sudo tee % then enter your administrator password :q! to exit successfully

vi hotkeys: set list G 1G yy p /str ?str I A !!cmd :.= @: :%s/foo/bar/g :s/foo/bar/g

set list G - end of file 1G/gg - begin of file 700G - line 700 :.= Shows current line number yy Yank the current line $ Move to the end of the line p Put after the position or after the line P Put before the position or before the line Control-u Move backward ½ screen Control-d Move forward ½ screen /string Search forward for string ?string Search back for string Insert before cursor I Insert before line a Append after cursor A Append after line o Open a new line after current line O Open a new line before current line !! cmd - Executes shell command cmd, places output in file starting at current line The "." command repeats the last change made in normal mode. For example, if you press dw to delete a word, you can then press . to delete another word (. is dot, aka period or full stop). The " @: " command repeats the last command-line change (a command invoked with ":", for example  :s/old/new/). Basic sea...

vi

Vi show column number :set number :set nonumber :%s/old/new/gc  - replace all occurences in file with confirmation /w search forward for w :s/(/[/  # replace only the current line from ( to [ r  filename   -  insert content of  filename  below cursor ----------- Vi + file – open at last line Vi +N file – open at N line 0, $ - first, last position of the file w,b forward, backward word HML – top, middle, last line of the screen Ctrl+U, Ctrl+D - scroll down, up one half of screen /pattern – search forward for pattern ?pattern – search backward for pattern N,n – repeat last search in same, opposite direction :11 – move to line 11 in file Insert: Insert text after and before the cursor a, i o,O – open new line for text below, above cursor cc – change current line dd – delete line dw – delete word p,P – put deleted text after, before cursor u – undo last edit J – join 2 lines :30,60w ne...