Difference between revisions of "Vi, Vim, Vscode editors"

From Ever changing code
Jump to navigation Jump to search
Line 1: Line 1:
= VI or VIM =
= VI or VIM =
This section describes both editors however these days vi command is an alias to vim. Therefore bear in mind although all have been tested the test itself was made on VIM.
;drop to bash
;drop to bash
  :!bash  or  :!sh
  :!bash  or  :!sh
Line 8: Line 10:
;show line number
;show line number
  :set number    or  :set nu
  :set number    or  :set nu
;[http://vim.wikia.com/wiki/Search_and_replace find and replace] VI translates to substitute
;[http://vim.wikia.com/wiki/Search_and_replace find and replace] in VI called substitute (ref. sed)
  :%s/wily/trusty/g    #substitute all ''wily'' with ''trusty'' in all document
  :%s/wily/trusty/g    #substitute all ''wily'' with ''trusty'' in all document
  :s/wily/trusty/g    #substitute only in the current line
  :s/wily/trusty/g    #substitute only in the current line
Line 14: Line 16:
   u -undo last change
   u -undo last change
   Ctrl-R -redo changes which were undone (undo the undos). '.' to repeat a previous change, at the current cursor position
   Ctrl-R -redo changes which were undone (undo the undos). '.' to repeat a previous change, at the current cursor position
;Visual mode
v -visual selection using arrows and navigation keys
^v -visual block selection, y-yank, d-delete, i-insert still work


= VIM only =
= VIM only =

Revision as of 14:45, 2 April 2016

VI or VIM

This section describes both editors however these days vi command is an alias to vim. Therefore bear in mind although all have been tested the test itself was made on VIM.

drop to bash
:!bash   or   :!sh
edit other file
:e file.txt    #autocomplite works
redirect command STDOUT to the current edited file in the cursor position
:r!dir
show line number
:set number    or  :set nu
find and replace in VI called substitute (ref. sed)
:%s/wily/trusty/g    #substitute all wily with trusty in all document
:s/wily/trusty/g     #substitute only in the current line
Undo and redo
 u -undo last change
 Ctrl-R -redo changes which were undone (undo the undos). '.' to repeat a previous change, at the current cursor position
Visual mode
v -visual selection using arrows and navigation keys
^v -visual block selection, y-yank, d-delete, i-insert still work

VIM only

Split
:split   or   :vsplit
C^w, c -close current window
C^w, C^w - switch between windows