VIM: The basics - PowerPoint PPT Presentation

1 / 19
About This Presentation
Title:

VIM: The basics

Description:

VIM is one of the most powerful text editor in which you can enter the most ... gd , gD Checking pairing brackets: % DEMO TIME! Configuration ... – PowerPoint PPT presentation

Number of Views:154
Avg rating:3.0/5.0
Slides: 20
Provided by: matthewtan
Category:
Tags: vim | basics | gd

less

Transcript and Presenter's Notes

Title: VIM: The basics


1
VIM The basics
  • Tang Wai-Chung, Matthew (MaFai)
  • 29/12/2006

2
Contents
  • Why VIM?
  • Basic Editing
  • Searching
  • Copy Paste
  • Programmers Tools
  • Configuration

3
Why VIM?
  • VIM is one of the most powerful text editor in
    which you can enter the most letters with less
    number of keystrokes.
  • Readers Choice of Linux Journel in 2003.
  • Highly configuarable
  • Strong support community, including me.

4
Modes in VIM
  • In normal mode of VIM, you issue commands instead
    of inserting letters.
  • You can enter to insert mode by pressing ltigt, ltagt
    ,ltogt, etc ..
  • Insert mode, you can type as you do in notepad.
  • Return to normal mode by pressing ltESCgt
  • Visual mode will be explained later.

5
Move around
  • You can use cursor keys or lthgt left ltlgt
    right ltjgt down ltkgt up
  • ltCtrl-ugt up half pageltCtrl-dgt down half
    pageltCtrl-bgt back 1 pageltCtrl-fgt forward 1
    page

6
Move around (cont...)
  • ltgt end of line ltgt beginning of line lt0gt
    first position.
  • ltnoGgt go to line no
  • ltgggt beginning of file
  • ltGgt end of file

7
To Insert Mode ...
  • ltigt insert at current position.
  • ltagt insert ONE letter after current position.
  • ltIgt insert at beginning of line.
  • ltAgt insert at end of line.
  • ltogt insert in a new line down.
  • ltOgt insert in a new line up.

8
Save Quit
  • ltZZgt write file and exit (time to sleep!)
  • ltwgt save with same name
  • ltqgt quit
  • ltwqgt save and quit
  • When you add ! at the end of w or q, you force
    to execute the command.
  • ltsav filenamegt save as.

9
Deleting ... Undo / Redo
  • ltdtypegt delete 1 object of type
  • ltddgt delete a line
  • ltdwgt delete one word
  • ltdlgt delete one letter ltxgt
  • ltctypegt change 1 object
  • ltstypegt substitute 1 object
  • ltugt undo
  • ltCtrl-rgt redo

10
Counting in Commands
  • Actually you can put numbers in most commands in
    VIM, e.g. ltogt, ltdgt, ltcgt
  • ltd3wgt delete 3 words
  • lt3dwgt delete 1 word 3 times
  • lt10xgt delete 10 letters
  • Also, you can repeat the last commands by lt.gt
  • ltx..gt will delete 3 letters.

11
DEMO TIME!
12
Searching
  • lt/keygt search the word key in the file
  • ltngt next match
  • ltNgt last match
  • lt?gt Change direction
  • lt/.gt any single char (wildcard)e.g. lt/.agt
    search a
  • ltgt search the word under the cursor (forward)
  • ltgt search the word under the cursor (backward)

13
Copy Paste
  • Copy is called yank in VIM
  • ltyntypegt yank n object
  • lty2006ygt yank 2006 lines
  • lty2020lgt yank 2020 letters
  • ltpgt paste down / after
  • ltPgt paste up / in front of
  • How about CUT? use ltdntypegt

14
Editing More Files
  • You can edit several files in one instance of VIM
  • ltsplitgt split the window and get one more
    editing space
  • ltnew filenamegt edit the file in new space
  • ltCtrl-wgt ltngt Open a new horizontal space
  • ltCtrl-wgt ltvgt split vertically
  • ltCtrl-wgt lth,j,k,lgt (or cursors) move around
    space
  • File browser lte directory namegt ? you can get
    a file listing
  • O open in last space

15
Programmers Tools
  • Syntax Highlighting automatically loaded(if you
    have a good .vimrc)ltsyn ongt or ltsyn offgt
  • Auto-indentation ltaigt or ltnoaigtindentation
    style for C, C, Javaltset cindentgt
  • Finding out variable declaration ltgdgt, ltgDgt
  • Checking pairing brackets ltgt

16
DEMO TIME!
17
Configuration
  • VIM reads .vimrc from home directory (or
    installation directory in M) whenever it starts.
  • .vimrc contains all basic mapping, declaration
    and setting.
  • Initialize the editing environment.
  • You can use my .vimrc freely and edit to suit
    your own needs.
  • See the contents!

18
Finding Help
  • http//www.vim.org/Download, install,
    documentation, plugin, tips much more
  • Tutorialhttp//www.newriders.com/books/opl/ebooks
    /0735710015.htmlin which this presentation based
    on
  • Vi Lovershttp//www.thomer.com/vi/vi.html
  • lthelp featuregt show the help content built in.

19
Q A
  • You may ask anything you want to know about vim.
  • I will try to answer as far as I know the
    solution.
  • Finally thank you once again your attendance.
Write a Comment
User Comments (0)
About PowerShow.com