Jump to content


Photo

Using the VI Editor


4 replies to this topic

#1 jdifiglia

jdifiglia

    0010001100110001

  • Admin
  • 3,010 posts
  • Gender:Male
  • Location:Hackettstown, NJ
  • Interests:Nothin'
  • Referred by:Bruceleeon

Posted 10 January 2008 - 07:31 PM

Starting an Editing Session
vi filename

where filename is the name of the file to be edited.
Undo Command
u
undo the last command.

Screen Commands
CTL/l
Reprints current screen.

CTL/L
Exposes one more line at top of screen.

CTL/E
Exposes one more line at bottom of screen.

CTL/F
Pages forward one screen.

CTL/B
Pages back one screen.

CTL/D
Pages down half screen.

CTL/U
Pages up half screen.

Cursor Positioning Commands
j
Moves cursor down one line, same column.

k
Moves cursor up one line, same column.

h
Moves cursor back one character.

l
Moves cursor forward one character.

RET
Moves cursor to beginning of next line.

0
Moves cursor to beginning of current line.

$
Moves cursor to end of current line.

SPACE
Moves cursor forward one character.

nG
Moves cursor to beginning of line n. Default is last line of file.

0
Moves the cursor to the first character of the line.

:n
Moves cursor to beginning of line n.

b
Moves the cursor backward to the beginning of the previous word.

e
Moves the cursor backward to the end of the previous word.

w
Moves the cursor forward to the next word.

/pattern
Moves cursor forward to next occurrence of pattern.

?pattern
Moves cursor backward to next occurrence of pattern.

n
Repeats last / or ? pattern search.

Text Insertion Commands
a
Appends text after cursor. Terminated by escape key.

A
Appends text at the end of the line. Terminated the escape key.

i
Inserts text before cursor. Terminated by the escape key.

I
Inserts text at the beginning of the line. Terminated by the escape key.

o
Opens new line below the current line for text insertion. Terminated by
the escape key.

O
Opens new line above the current line for text insertion. Terminated by the escape key.

DEL
Overwrites last character during text insertion.

ESC
Stops text insertion. The escape key on the DECstations is the F11 key.

Text Deletion Commands
x
Deletes current character.

dd
Deletes current line.

dw
Deletes the current word.

d)
Deletes the rest of the current sentence.

D, d$
Deletes from cursor to end of line.

P
Puts back text from the previous delete.

Changing Commands
cw
Changes characters of current word until stopped with escape key.

c$
Changes text up to the end of the line.

C, cc
Changes remaining text on current line until stopped by pressing the escape key.

~
Changes case of current character.

xp
Transposes current and following characters.

J
Joins current line with next line.

s
Deletes the current character and goes into the insertion mode.

rx
Replaces current character with x.

R
Replaces the following characters until terminated with the escape key.

Cut and Paste Commands
yy
Puts the current line in a buffer. Does not delete the line from its current position.

p
Places the line in the buffer after the current position of the cursor.

Appending Files into Current File
:R filename
Inserts the file filename where the cursor was before the ``:'' was typed.

Exiting vi
ZZ
Exits vi and saves changes.

:wq
Writes changes to current file and quits edit session.

:q!
Quits edit session (no changes made).


#2 jazboy

jazboy
  • Members
  • 86 posts
  • Gender:Male
  • Interests:Tech Gadgets.
  • CPU: Intel Core 2 duo
  • Operating System: Windows 7 Ultimate

Posted 18 November 2011 - 07:10 PM

My contribution to vi editior:
vi filename --> edit the filename fle
vi +/str filename --> edit filename file at first occurence of str
vi + filename - edit filename at end of file.
vi +n edit filename file at line n

#3 jdifiglia

jdifiglia

    0010001100110001

  • Admin
  • 3,010 posts
  • Gender:Male
  • Location:Hackettstown, NJ
  • Interests:Nothin'
  • Referred by:Bruceleeon

Posted 19 November 2011 - 11:56 AM

You are running Ultimate... do you fiddle with linux on the side?


#4 jazboy

jazboy
  • Members
  • 86 posts
  • Gender:Male
  • Interests:Tech Gadgets.
  • CPU: Intel Core 2 duo
  • Operating System: Windows 7 Ultimate

Posted 21 November 2011 - 12:14 PM

Actually my main OS is windows 7 ultimate. But I have played a lot with Fedora, ubuntu in past. Apart from that I work on Unix environment so i know lit bit about Unix.

Currently i have ubuntu 10.10 installed on my virtual machine and time to time i play with that (to screw up my pc). Actually i was also thinking to install windows 8 beta on my laptop. If i does and get time then i will share my experience here.

#5 jdifiglia

jdifiglia

    0010001100110001

  • Admin
  • 3,010 posts
  • Gender:Male
  • Location:Hackettstown, NJ
  • Interests:Nothin'
  • Referred by:Bruceleeon

Posted 21 November 2011 - 08:23 PM

Windows 8 is ok... I find Metro hard to get used to. I hate to say this, but I am really going to miss the start menu. As far as Ubuntu goes... I CAN'T STAND UNITY!




Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users