现在假设如是nc10@your-5554c55be4 ~$ cat sheetserver 127.0.0.1 localhost connected yes 12-3-08server 127.0.0.1 localhost connected no 12-3-08server 127.0.0.1 localhost connected yes 14-9-09server 127.0.0.1 localhost connected yes 15-9-09server 127.0.0.1 localhost connected no 16-9-09nc10@your-5554c55be4 ~$ sed '/^server.*$/s//& test/g' sheet server 127.0.0.1 localhost connected yes 12-3-08 testserver 127.0.0.1 localhost connected no 12-3-08 testserver 127.0.0.1 localhost connected yes 14-9-09 testserver 127.0.0.1 localhost connected yes 15-9-09 testserver 127.0.0.1 localhost connected no 16-9-09 testnc10@your-5554c55be4 ~$ 希望没理解错你的意思,呵呵 如果文件这样也可的,因为 /^server/ 限定了 只是行头是server 才在行尾插入字符user@minix-nb:~$ cat sheetremote 127.0.0.1 localhost connected yes 12-3-08server 127.0.0.1 localhost connected no 12-3-08remote 127.0.0.1 localhost connected yes 14-9-09server 127.0.0.1 localhost connected yes 15-9-09remote 127.0.0.1 localhost connected no 16-9-09user@minix-nb:~$ sed '/^server.*$/s//& test/g' sheet remote 127.0.0.1 localhost connected yes 12-3-08server 127.0.0.1 localhost connected no 12-3-08 testremote 127.0.0.1 localhost connected yes 14-9-09server 127.0.0.1 localhost connected yes 15-9-09 testremote 127.0.0.1 localhost connected no 16-9-09user@minix-nb:~$
1. 可以定义快捷键Ctrl+a,用来在Command模式下在当前光标后面插入一个指定字符:map :a_r2. 使用o在当前行下面插入一个新行,使用大写的O在当前行的上面插入新行。
-----更新------看了本问题的讨论,这个其实见仁见智吧。
就按键次数来说确实并没有太多的变化,但是从操作流程来讲,进入Inert模式和进入Command模式是两种截然不同的情境,始终保持在Command模式下,操作者的思路不容易打断。
当然你如果习惯了这两个模式的切换,就已经不太重要了。
这是个小问题,不过充分证明了VIM就是强大,你想咋做就咋做。
你甚至可以直接定义一个快捷键在行末插入分号,那就只有两次按键了。
展开全部 现在假设如是nc10@your-5554c55be4 ~$ cat sheetserver 127.0.0.1 localhost connected yes 12-3-08server 127.0.0.1 localhost connected no 12-3-08server 127.0.0.1 localhost connected yes 14-9-09server 127.0.0.1 localhost connected yes 15-9-09server 127.0.0.1 localhost connected no 16-9-09nc10@your-5554c55be4 ~$ sed '/^server.*$/s//& test/g' sheet server 127.0.0.1 localhost connected yes 12-3-08 testserver 127.0.0.1 localhost connected no 12-3-08 testserver 127.0.0.1 localhost connected yes 14-9-09 testserver 127.0.0.1 localhost connected yes 15-9-09 testserver 127.0.0.1 localhost connected no 16-9-09 testnc10@your-5554c55be4 ~$ 希望没理解错你的意思,呵呵 如果文件这样也可的,因为 /^server/ 限定了 只是行头是server 才在行尾插入字符user@minix-nb:~$ cat sheetremote 127.0.0.1 localhost connected yes 12-3-08server 127.0.0.1 localhost connected no 12-3-08remote 127.0.0.1 localhost connected yes 14-9-09server 127.0.0.1 localhost connected yes 15-9-09remote 127.0.0.1 localhost connected no 16-9-09user@minix-nb:~$ sed '/^server.*$/s//& test/g' sheet remote 127.0.0.1 localhost connected yes 12-3-08server 127.0.0.1 localhost connected no 12-3-08 testremote 127.0.0.1 localhost connected yes 14-9-09server 127.0.0.1 localhost connected yes 15-9-09 testremote 127.0.0.1 localhost connected no 16-9-09user@minix-nb:~$
输入此命令则光标所在行向右移动一个 tab.5 输入此命令则光标后 5 行向右移动一个 tab.:12,24 此命令将12行到14行的数据都向右移动一个 tab.:12,24 此命令将12行到14行的数据都向右移动两个 tab.有的人希望 tab 完全用空格代替, 也有的人希望 tab 就是 tab. 没关系, vim 能帮助您.以下的配置一般也都先写入配置文档中, 免得老敲.