VIM - PowerPoint PPT Presentation

1 / 21
About This Presentation
Title:

VIM

Description:

Ie. hjkl are all used in command mode. To enter command mode ... Ie. To exit without saving, to force write on a read-only file, etc. Append ! To any command ... – PowerPoint PPT presentation

Number of Views:113
Avg rating:3.0/5.0
Slides: 22
Provided by: csN8
Category:
Tags: vim | ieonly

less

Transcript and Presenter's Notes

Title: VIM


1
VIM
  • The editor that can and will fulfill your every
    desire.

2
(No Transcript)
3
Basic Navigational commands
  • k up
  • j down
  • l right
  • h left
  • w move forward by word
  • b move backward by word

4
Basic Navigational Commands
  • f page down
  • b page up
  • beginning of line
  • end of line

5
VIM Modes
  • Command Mode
  • Insertion Mode
  • Sed Mode

6
Command Mode
  • Certain keys perform certain actions.
  • Ie. hjkl are all used in command mode.
  • To enter command mode simply press escape.

7
Insertion Mode
  • In Insert mode, anything you type is simply text
    in your file.
  • To enter insertion mode
  • i insert
  • a append
  • Among others

8
Sed Mode
  • In Command mode type to enter Sed Mode.
  • In sed mode any SED command can be applied to
    your text.
  • Ie. g/\t/s/\t/ /g will substitute all tabs
    with 4 spaces in your text file.

9
Copy Paste
  • To copy paste you yank the lines
  • yxy will yank x number of lines
  • To cut you delete the lines
  • dxd will delete x number of lines and store
    them in the buffer
  • To delete lines simply cut them.

10
Copy and Paste
  • To Paste use the P command
  • p insert line after current position.
  • P insert line before current position.
  • Note you can cut/paste in sed mode as well as
    command mode.

11
Replacing Text
  • rreplace current character
  • R enters insertion mode in Replace mode

12
MOST IMPORTANT CMD
  • The most important command for any newbie.
  • U/u undo
  • It might just save your life.or your code.

13
Searching for text.
  • /Pattern will search for pattern specified.
  • /?Pattern will search for pattern specified
    backwards.
  • n find next occurrence
  • N find prev occurrence

14
Open-Close-Save, etc.
  • To Save a file
  • Sed Mode
  • w writes changes
  • x writes and quits
  • Cmd Mode
  • ZZ writes and quits
  • To Close a file
  • q closes and quits program.

15
Open-Close-Save, etc.
  • To override any command
  • Ie. To exit without saving, to force write on a
    read-only file, etc.
  • Append ! To any command
  • q! quiets w/o saving
  • w! writes read-only

16
Coding uses.
  • Assuming uve run ctags on your program
  • advances to next function
  • advances to previous function
  • !make compiles program
  • !pgm-name runs program
  • ALL within VIM.

17
Tips Tricks
  • r !my_cmd
  • Runs my_cmd and inserts output in current
    session.
  • g/./m0
  • File line reversal (line 1 , line line1)
  • g//m0 same as above
  • 1,sMg
  • Remoes dos \r from text file, ie. Converts to
    unix format

18
Tips n Tricks
  • set number
  • Display line numbering, useful for sed use
  • Set nonumber to disable
  • set ts4
  • Sets tabspace to any number of spaces desired.

19
Tips n Tricks
  • line-num will take u directly to that line.
  • Ie. Compiler error line 157
  • Vim file 157 or.
  • 157 while in vi

20
Customized startup
  • Create a .exrc file in your HOME dir to start
    vim the way you like it.
  • Setting tabspaces, behavior, colors scheme, etc.

21
URLS of note.
  • www.vim.org
  • Scripts, themes, macros, and goodies as well as
    tutorials
  • Source file.vim to load a script/macro.
  • www.oreilly.com
  • Some excellent e-books as well as hardcover books
    on sed and vim
Write a Comment
User Comments (0)
About PowerShow.com