Vi Notes: Difference between revisions

From Federal Burro of Information
Jump to navigationJump to search
m (Vi notes moved to Vi Notes)
No edit summary
Line 20: Line 20:
  set tabstop=4
  set tabstop=4
  set expandtab
  set expandtab
=== turn off colour===
:syntax off


===fancy find replace===
===fancy find replace===
Line 50: Line 55:
  brackets2 stuff brackets1
  brackets2 stuff brackets1


=Also See=
== Also See ==


* http://www.geocities.com/volontir/ - tuns of good stuff.
* http://www.geocities.com/volontir/ - tuns of good stuff.

Revision as of 19:21, 21 March 2010

edit binary file in vi

:%!xxd

tai64nlocal file in vi

:%!tai64nlocal

insert today's date

:r !date

set tabs to be the ENGDEV way in vi

also called indenting

in the file:

/* ex: set tabstop=4 expandtab: */

or in ~/.vimrc

set tabstop=4
set expandtab

turn off colour

:syntax off


fancy find replace

uses match substitution. (X) -> \1

convert:

Target[server-5.location-5.mem]: `/usr/local/bin/snmp_mem_usage.pl public 192.168.5.5 real`

to

Target[server-1.location-5.Swap]: memTotalSwap.0&memTotalSwap.0:public@192.168.5.129:161::::2 - memAvailSwap.0&memAvailSwap.0:public@192.168.5.129:161::::2

in two (in vi):

%s: `/usr/local/bin/snmp_mem_usage.pl public ::g
%s/:\(.\+\) real`/ memTotalReal.0\&memTotalReal.0:public@\1:161::::2 - memAvailReal.0\&memAvailReal.0:public@\1:161::::2/

or more generically, reversing stuff:

%s/(brackets1) stuff (brackets2)/\2stuff\1/g

converts:

brackets1 stuff brackets2

to

brackets2 stuff brackets1

Also See