Vim Tutorial Study(4)
来源:互联网 发布:淘宝手机壳进货渠道 编辑:程序博客网 时间:2024/06/02 20:21
Chapter 4 Text Blocks and Multiple Files
The Vim editor has the concept of a register. This enables you to hold data for multiple cut, copy, or paste operations. Most other editors are limited to a single cut/paste clipboard. With the Vim registers you get more than 26 clipboards.
Cut, Paste and Copy
when you delete something with the d, x, or another command, the text is saved
you can use p command to paste it back (technical name is put) 3p is also correct
if you delete an entire line, the p command places the text on the line after the cursor
if you delete part of a line(like dw), the p command puts it just after the charater under the cursor
他会在你光标所在位置的下一行,或者下一个字符开始
Charater Twiddling (twiddle)
change 'teh' into 'the': xp
More on "Putting"
insert count times: 3p
Marks: enable you to place marks in your text
mcharater: ma (marks the place under the cursor as mark a)
to go to a mark, use the command: `mark (which moves you to the marked line and column)
moves you to the beginning of the line containing the mark: 'mark
'mark command can be very useful when deleting a long series of lines:
move the cursor to the begining of the text you want to delete
mark it using the command ma
go to the end of the text to be removed, use d'a
(其实在这里,头和尾都不重要。他会删除整行而不是从起始光标开始末尾光标结束)
反过来做也是可以的:就是你从后面的行开始标记,到前面的行删
由于你在这里删除了文字,所以照样可以用p进行put
Where are the marks?
list all the marks: :marks
view specific marks: :marks args (:marks a)
Yanking
the y command "yanks" text into a register(without removing it from the file), general form: ymotion
yanks the current line into the buffer: yy
mark ma from the beginning line, the y'a end with the ending line: then the text block have been copied
use p to paste
Y, yy are the same; so are 3Y and 3yy
Filtering
!motion command takes a block of text and filters it through another program
it runs the system command represented by command, giving it the blocks of text represented by motion as input.
the output of this command then replaces the selected block
suppose you are at first line, line 1
then use !10Gsort<Enter>
!! command runs the current line through a filter (a good way to get the output of system commands into a file)
Example:
!!ls
!!date
Editing another file
:vi filename you must use this command after :write or :w
or force Vim to discard your changes and edit the new file using: :vi! file
New file opened in read-only mode
:view file
you can also force the Vim to write the changes into the read-only file using: :write!
Dealing with Multiple files
$gvim one.c two.c three.c, by default vim displays just the first file
to edit the next file: :next after :write
a shorthand command for this: :wnext
if you use :next! you will lose the changes in the current file
turn auto write option on:
:set autowrite
to turn it off
:set noautowrite
:2next or :2 next is also correct and acts the same
caution: if it reaches the last file, it will not automatically turn to the very beginning to continue, it just stops
Which File Am I On?
:args
Going Back a File
:previous or :Next
:wprevious or :wNext
Editing the First or Last File
the first: :rewind **caution: not :first**
the last: : last
Editing Three Files
$gvim one.c two.c three.c
1CTRL-^ will turn to one.c
2CTRL-^ will turn to two.c
3CTRL-^ will turn to three.c
while you are using just CTRL-^, it will just switch you to the file you previously edited, will not iterate all the candidate files
- Vim Tutorial Study(4)
- Vim Tutorial Study(1)
- Vim Tutorial Study(2)
- Vim Tutorial Study(3)
- Vim Tutorial Study(5)
- Vim Tutorial Study(6)
- Vim Tutorial Study(7)
- Vim Tutorial Study(8)
- Vim Tutorial Study(9)
- Vim Tutorial Study(10)
- Vim Tutorial Study(11)
- vim study
- vim tutorial
- VIM Tutorial
- vim tutorial
- XUL Tutorial Study Notes - Introduction
- VIM interactive tutorial
- Vim Introduction and Tutorial
- 控件焦点和键盘事件
- IP正则表达式
- cout重定向到文件
- Javascript 面向对象编程(一):封装
- 领悟 JavaScript 中的面向对象
- Vim Tutorial Study(4)
- 数据库语句http://www.w3school.com.cn/sql
- 炮轰移动MM
- 数据结构就这么考完了
- C语言中变量的初始化问题
- 程序员和架构师常去的网站(持续更新,欢迎交流)
- ffmpeg【百度百科】
- nand flash 裸板驱动,介绍的比较精辟
- 2010年度ESB产品盘点:开篇--开源和商业ESB产品----待完善