Difference between revisions of "VI Quick Reference"

From The Linux Source
Jump to: navigation, search
(Created page with "=== search and replace === global :%s/search/replace/ global, multiple occurrences on each line :%s/search/replace/g remove end of line spaces :%s/ +$// === global com...")
 
(No difference)

Latest revision as of 18:32, 8 May 2017

search and replace

global

:%s/search/replace/

global, multiple occurrences on each line

:%s/search/replace/g

remove end of line spaces

:%s/ +$//

global commands

global delete

:g/some text in lines to delete/d

automatic formatting

check autoformat options

:set formatoptions

set autoformat options

:set formatoptions=croql

format options

1 - single letter words on next line
2 - keep 2nd line indent
c - comments (plus leader)
n - numbered lists
q - allow 'gq' to work
r - (in mail) comment leader after
t - textwidth

other format options

:set autoindent
:set noautoindent
:set expandtab
:set noexpandtab
:set shiftwidth=3
:set smartindent
:set nosmartindent
:set tabstop=3
:set textwidth
:set wrapmargin
:set nowrapmargin