Vim Study Book(1)
Today,I have decided to study Vim that is said an excellent editor in the Linux system. So I think that I will use it in future, especially in editing the verilog.
No talks any more, just let's explore the mazing world of the Vim together.
Basic knowledge about VIM:
vim is a text editor. A text editor is a software that help you create and modify text files. There are a lot of text editors, but vim is the best of them. If all you need is small, light-weight and casual text editing, perhaps simple editors like notepad in Windows, pico in Unix, will make you happy. If most of your time is devoted to text editing, perhaps you should consider an editor of power, which is vim, of course. Choosing vim may bring dramatic changes to your productivity and your life.
What is good in vim as an editor
- vim is efficient and elegant. It does things quickly by the best way.
- vim is healthful. It doesn't make your fingers and arms painful.
- vim is small and fast. It fits in one or two floppies and starts instantly.
- vim is powerful. No feature useful for text editing is missing.
- vim is simple and clean. It doesn't offer to do things irrelevant to text editing.
- vim is running everywhere. If you're willing to use it, you can, no matter what computers and operating systems you use.
- vim is free.
What about Vi
The Unix editor vi has a long history, and is the one that vim is based on. I believe that the power, beauty and essence of vim always come from vi. A real vim user doesn't mind using vi temporarily, but feels great pain if forced a thing like Emacs. vim retains all the powers of vi, plus a lot of improvements and new features. And now vim is running virtually all platforms. So I see no reason to choose vi over vim.-------------------------------------------------------------------------------------
--First Chapter:Basic Operations
-------------------------------------------------------------------------------------
1)How to start Vim: #vim file_name
2)save your file before you exit: press ESC, then type
3)exit the files without saving:# :q!
4)exit the files with saving: # :wq or ZZ
-------------------------------------------------------------------------------------
- SEOND-------How to move the cursor
-------------------------------------------------------------------------------------
The most effective ways of moving cursor is first go to the command mode
by pressing ESC and then use vim's cursor-moving commands to move around. The
4 basic commands are
* j move down one line
* k move up one line
* h move left one character
* l move right one character
* you can also key number+j/k/h/l, for example,
if you key in:5j, the cursor will move down by 5 lines.
* $ move the cursor to the end of the line.
* ^ or 0 : move the cursor to the head of the line.
Remember: these commands work only in command mode
-------------------------------------------------------------------------------------
--THIRD----How to delete
-------------------------------------------------------------------------------------
Deletion commands in command mode.
1. Make sure you are in command mode by press ESC
2. move the cursor to the character you want to delete
3. press x , this character disappears
-------------------------------------------------------------------------------------
FORTH----How to COPY,Paste.
-------------------------------------------------------------------------------------
1. Enter the command mode by pressing ESC
2. Move the cursor to the line which you want to make a copy, by pressing j
or k
3. press
yy
to make a copy of the line, or
dd
to cut it and make a copy
4. now move cursor (by pressing k or j) to the the location where you want
to put this copy
5. press
p
to put the buffer after current line, or
P
to put the buffer before current line
If you want to copy or cut several lines, put a number before the yy or dd
command,
like
8yy
to copy 8 lines frome the place where is cursor on.
-------------------------------------------------------------------------------------
---How to search for a word
-------------------------------------------------------------------------------------
1. Make sure you are in command mode
by hitting ESC
2. type
/apple
followed by ENTER to find an occurrence of apple. When you type the
slash, it and the following characters will be shown on the bottom of the
screen. After you press ENTER, the cursor will go to the first occurrence of
apple if found, and the target will be highlighted.
3. after you got the first apple, you can keep typing
n
to find other apples
-------------------------------------------------------------------------------------
---How to substitude a word with another one
-------------------------------------------------------------------------------------
sure you're in command mode by pressing ESC.
* replace first occurrence of old in current line with new
:s/old/new/
* replace all occurrence of old in current line with new
:s/old/new/g
* replace the first occurrence of old in each line between line n1 and n2
* with new
:n1,n2s/old/new/
* replace all occurrence of oldbetween line n1 and n2 with new
:n1,n2s/old/new/g
* replace all occurrence of old in the whole buffer with new, prompt for
* confirmation.
:1,$s/old/new/gc
* replace all occurrence of old in the whole buffer with new, prompt for
* confirmation.
:%s/old/new/
Labels: ASIC/IC Studybook
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home