LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1051|回复: 6

请教一个gvim的用法,这样的情况有什么好的解决方法.

[复制链接]
发表于 2006-10-13 18:03:26 | 显示全部楼层 |阅读模式
1 /* Our own header. Tabs are set for 4 spaces, not 8 */

  2 #ifndef __unp_h
  3 #define __unp_h

  4 #include    "../config.h"      /* configuration options for current OS */
  5                            /* "../config.h" is generated by configure */

  6 /* If anything changes in the following list of #includes, must change
  7    acsite.m4 also, for configure's tests. */

  8 #include    <sys/types.h>       /* basic system data types */
  9 #include    <sys/socket.h>      /* basic socket definitions */
10 #include    <sys/time.h>        /* timeval{} for select() */
11 #include    <time.h>            /* timespec{} for pselect() */
12 #include    <netinet/in.h>      /* sockaddr_in{} and other Internet defns */
13 #include    <arpa/inet.h>       /* inet(3) functions */
14 #include    <errno.h>
15 #include    <fcntl.h>           /* for nonblocking */
16 #include    <netdb.h>
17 #include    <signal.h>
18 #include    <stdio.h>
19 #include    <stdlib.h>
20 #include    <string.h>
21 #include    <sys/stat.h>        /* for S_xxx file mode constants */
22 #include    <sys/uio.h>         /* for iovec{} and readv/writev */
23 #include    <unistd.h>
24 #include    <sys/wait.h>
25 #include    <sys/un.h>          /* for Unix domain sockets */

26 #ifdef  HAVE_SYS_SELECT_H
27 # include   <sys/select.h>      /* for convenience */
28 #endif
.................................................................
像这样的一段代码,在gvim里用什么方法比较合理和方便地去年第一行代码前面的数字,
我用了很笨的方法:  到每一行的行首, 然后用命令 2dw, 可是有200多行啊.这个办法太笨了. 大家有什么好办法吗?
发表于 2006-10-13 18:13:51 | 显示全部楼层
试试:
  1. :%s/^\d\+//
复制代码
回复 支持 反对

使用道具 举报

发表于 2006-10-13 21:16:18 | 显示全部楼层
用命令记录的办法。
在命令模式下按aq ,显示记录中
然后操作一行。
然后按q结束记录,注意这里a是表示记录在寄存器a中。
推出记录后,
然后在命令模式下直接输入200@a
这样就会把你刚才的做法重复200遍。像宏的做法。

good luck
回复 支持 反对

使用道具 举报

发表于 2006-10-13 22:28:24 | 显示全部楼层
用正则表¾式ÿ换嘛
回复 支持 反对

使用道具 举报

发表于 2006-10-13 23:19:53 | 显示全部楼层
我对VIM不熟,不过想问一下这些序数是不是行数?如果是,试一下
  1. :set nu!
复制代码
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-10-14 12:29:38 | 显示全部楼层
首先谢谢各位!

zlbruce的方法可以(very fantastic,呵呵).但还不知道具体是什么意思,呵呵.这种方法是quhan兄说的正则表达式的替换吗?

对于黄叶兄的方法,思路是正确的,但是描述上有一些问题.
应该是在命令模式输入qa,然后再执行操作,最后输入q退出.(试了几把aq,总是插入一个q字母,查了一些资料看到的.)
回复 支持 反对

使用道具 举报

发表于 2006-10-15 00:39:10 | 显示全部楼层
嗯,正则表达式,可以在 vim 中使用如下命令查看他的帮助
  1. :help regexp
复制代码
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表