VIM 编辑器

v 模式apache

进入v模式移动光标选择区域、编程

编程的时候须要进行多行注释:
1注释:ctrl+v 进入列编辑模式vim

2向下或向上移动光标bash

3把须要注释的行的开头标记起来dom

4而后按大写的Issh

5再插入注释符,好比"#"。tcp

6再按Esc,就会所有注释了。ide

替换
ui

:% s/this/that 每一行的第一个this被替换成that  
:% s/this/that/g 将文本中全部的this替换成that
this

 :5,10 s/sbin/nologin/g               #替换5到10行 的sbin

:set nu/nonu                     #显示行号

/ 正向查找 :/target     n 往下查找,N 往上查找

  :!ifconfig 调用系统命令

 编辑文目录:

若是不当心打开目录,直接退出就能够了。

 vim中定位到某行:

gg  定位到行首

定位到最后一行,行首

#G 定位到某一行

:#    定位到某一行

#gg 定位到某一行                 


[root@IP-65 test]# vim -O /etc/passwd /etc/hosts  vim 之下作对比 O 左右对比,o 上下对比

2 files to edit


haldaemon:x:68:68:HAL daemon|127.0.0.1   localhost local

:/:/sbin/nologin            |host.localdomain localhost4

gdm:x:42:42::/var/lib/gdm:/s| localhost4.localdomain4

bin/nologin                 |::1         localhost local

ntp:x:38:38::/etc/ntp:/sbin/|host.localdomain localhost6

nologin                     | localhost6.localdomain6

apache:x:48:48:Apache:/var/w|192.168.1.63            IP-

ww:/sbin/nologin            |63           server01

pulse:x:497:495:PulseAudio S|192.168.1.64            IP-

ystem Daemon:/var/run/pulse:|64           client01

/sbin/nologin               |~                          

sshd:x:74:74:Privilege-separ|~                          

ated SSH:/var/empty/sshd:/sb|~                          

in/nologin                  |~                          

tcpdump:x:72:72::/:/sbin/nol|~                          

ogin                        |~                          

IP-63:x:500:500:IP-63:/home/|~                          

IP-63:/bin/bash             |~                          

/etc/passwd   34,1       Bot /etc/hosts    4,1       All

Type  :quit<Enter>  to exit Vim

相关文章
相关标签/搜索