免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1163 | 回复: 0
打印 上一主题 下一主题

vim学习 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-11-20 20:27 |只看该作者 |倒序浏览

                                                                                                vim的学习过程--学习的最好方法就是使用
一:tutor 初学
      初学linux编程,要会用gcc,gdb。。。。。。,但是首先要会一个编辑工具,先选择vim来学习吧,在网上查询了资料,发现有翻译好了的vim文档,就当教材来学习吧。
这是文档地址:在线的,http://vcd.gro.clinux.org/doc/usr_toc.html
      文档里讲了个vimtutor,我打开乱码,使用vimtutor en就不乱码了,en是语言吧应该,试了ch,没用,估计没有中文的。教程里的列子很典型,浅显易懂,非常好学。比我以前看的vim的书清晰多了。
PS:(网上搜到添加中文vim文档的方法:
http://vcd.gro.clinux.org    (中文)
下载的文件包应该是类似这样的: vimcdoc-1.5.0.tar.gz
解压后其中有个doc文件夹, 将其中的内容全部复制到~/.vim/doc, 或者vim安装目录下的doc目录中, 此时vim中的help信息已经是中文的了.
注意:
a. 如果无法显示中文, 在~/.vimrc中增加下面这句试试:
   set helplang=cn
b. 帮助文件的文本是utf-8编码的, 如果想用vim直接查看, 需要在~/.vimrc中设置:
   set encoding=utf-8
      gvim--gui版本;
      vim--控制台版本;
说是30 分钟的教程,花了两个多小时,慢慢来,心急吃不了热豆腐。Lesson 1 SUMMARY
光标的移动;删除(delete)操作;离开vim;文本编辑
  1. The cursor is moved using either the arrow keys or the hjkl keys.
         h (left)       j (down)       k (up)       l (right)
  2. To start Vim from the shell prompt type:  vim FILENAME
  3. To exit Vim type:        :q!     to trash all changes.
             OR type:         :wq     to save the changes.
  4. To delete the character at the cursor type:  x
  5. To insert or append text type:
         i   type inserted text            insert before the cursor
         A   type appended text            append after the line
NOTE: Pressing  will place you in Normal mode or will cancel
      an unwanted and partially completed command.
LESSON 2 SUMMARY
d motion的操作;undo,reundo;
  1. To delete from the cursor upto the next word type:    dw
  2. To delete from the cursor to the end of a line type:    d$
  3. To delete a whole line type:    dd
  4. To repeat a motion prepend it with a number:   2w
  5. The format for a change command is:
               operator   [number]   motion
     where:
       operator - is what to do, such as  d  for delete
       [number] - is an optional count to repeat the motion
       motion   - moves over the text to operator on, such as  w (word),
                  $ (to the end of line), etc.
  6. To move to the start of the line use a zero:  0
      move to the end of the line use : $
  7. To undo previous actions, type:           u  (lowercase u)
     To undo all the changes on a line, type:  U  (capital U)
     To undo the undo's, type:                 CTRL-R
LESSON 3 SUMMARY
put;replace;change;
  1. To put back text that has just been deleted, type   p .  This puts the
     deleted text AFTER the cursor (if a line was deleted it will go on the
     line below the cursor).
  2. To replace the character under the cursor, type   r   and then the
     character you want to have there.
     R: replace a word!(in lesson 6)
  3. The change operator allows you to change from the cursor to where the
     motion takes you.  eg. Type  ce  to change from the cursor to the end of
     the word,  c$  to change to the end of a line.
  4. The format for change is:
         c   [number]   motion
Lesson 4 SUMMARY
光标定位;查找替换;括号匹配;
CURSOR LOCATION AND FILE STATUS
  ** Type CTRL-G to show your location in the file and the file status.
     Type  G  to move to a line in the file. **
THE SEARCH COMMAND
** Type  /  followed by a phrase to search for the phrase. **
MATCHING PARENTHESES SEARCH
** Type  %  to find a matching ),], or } . **
Note: This is very useful in debugging a program with unmatched parentheses!
THE SUBSTITUTE COMMAND
** Type  :s/old/new/g  to substitute 'new' for 'old'. **
1. CTRL-G  displays your location in the file and the file status.
             G  moves to the end of the file.
     number  G  moves to that line number.
            gg  moves to the first line.
  2. Typing  /  followed by a phrase searches FORWARD for the phrase.
     Typing  ?  followed by a phrase searches BACKWARD for the phrase.
     After a search type  n  to find the next occurrence in the same direction
     or  N  to search in the opposite direction.
     CTRL-O takes you back to older positions, CTRL-I to newer positions.
  3. Typing  %  while the cursor is on a (,),[,],{, or } goes to its match.
Note: This is very useful in debugging a program with unmatched parentheses!
  4. To substitute new for the first old in a line type    :s/old/new
     To substitute new for all 'old's on a line type       :s/old/new/g
     To substitute phrases between two line #'s type       :#,#s/old/new/g
     To substitute all occurrences in the file type        :%s/old/new/g
     To ask for confirmation each time add 'c'             :%s/old/new/gc
LESSON 5 SUMMARY
执行外部命令;保存;选择性保存;替换文件内容;
  1.  :!command  executes an external command.
      Some useful examples are:
         (MS-DOS)         (Unix)
          :!dir            :!ls            -  shows a directory listing.
          :!del FILENAME   :!rm FILENAME   -  removes file FILENAME.
  2.  :w FILENAME  writes the current Vim file to disk with name FILENAME.
  3.  v  motion  :w FILENAME  saves the Visually selected lines in file
      FILENAME.
  4.  :r FILENAME  retrieves disk file FILENAME and puts it below the
      cursor position.
  5.  :r !dir  reads the output of the dir command and puts it below the
      cursor position
LESSON 6 SUMMARY
拷贝;查找模式;
  1. Type  o  to open a line BELOW the cursor and start Insert mode.
     Type  O  to open a line ABOVE the cursor.
  2. Type  a  to insert text AFTER the cursor.
     Type  A  to insert text after the end of the line.
  3. The  e  command moves to the end of a word.
  4. The  y  operator yanks (copies) text,  p  puts (pastes) it.
  5. Typing a capital  R  enters Replace mode until    is pressed.
  6. Typing ":set xxx" sets the option "xxx".  Some options are:
        'ic' 'ignorecase'       ignore upper/lower case when searching
        'is' 'incsearch'        show partial matches for a search phrase
        'hls' 'hlsearch'        highlight all matching phrases
     You can either use the long or the short option name.
  7. Prepend "no" to switch an option off:   :set noic
LESSON 7 SUMMARY
帮助;自动补全;
  1. Type  :help  or press  or   to open a help window.
  2. Type  :help cmd  to find help on  cmd .
  3. Type  CTRL-W CTRL-W  to jump to another window
  4. Type  :q  to close the help window
  5. Create a vimrc startup script to keep your preferred settings.
  6. When typing a  :  command, press CTRL-D to see possible completions.
     Press  to use one completion.
               
               
               
               
               
               
               
               
               
               
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/54537/showart_426930.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP