centos 中用vi 显示代码高亮(vim 才有高亮)(自测有效)

    1.首先看系统带不带vim
        [root@N151 ~]# vim host.info 
        -bash: vim: command not found
        [root@N151 ~]# rpm -qa|grep vim
        vim-minimal-7.2.411-1.8.el6.x86_64    //(出现一个就需要在线安装vim包)
        [root@N151 ~]# yum -y install vim*  
        [root@N151 ~]# rpm -qa|grep vim
        vim-filesystem-7.4.629-5.el6_8.1.x86_64
        vim-enhanced-7.4.629-5.el6_8.1.x86_64
        vim-X11-7.4.629-5.el6_8.1.x86_64
        vim-minimal-7.4.629-5.el6_8.1.x86_64
        vim-common-7.4.629-5.el6_8.1.x86_64
    2.如果yum不能在线联网安装,则进行这一步:
        [root@N151 sbin]# ping 8.8.8.8
        connect: Network is unreachable
        [root@N151 sbin]# cd /etc/sysconfig/network-scripts/
        [root@N151 network-scripts]# cp ifcfg-eth0 ifcfg-eth0:1
        [root@N151 network-scripts]# vi ifcfg-eth0:1  //修改IP为2网段联网IP,网关改为192.168.2.1 
        1 DEVICE=eth0:1
        2 BOOTPROTO=static
        3 ONBOOT=yes
        4 TYPE=Ethernet
        5 IPADDR=192.168.2.151
        6 NETMASK=255.255.255.0
        7 USERCTL=no
        8 PEERDNS=yes
        9 GATEWAY=192.168.2.1
        [root@N151 network-scripts]# service network restart
        Shutting down interface eth0:                              [  OK  ]
        Shutting down interface eth1:                              [  OK  ]
        Shutting down interface eth2:                              [  OK  ]
        Shutting down interface eth3:                              [  OK  ]
        Shutting down loopback interface:                          [  OK  ]
        Bringing up loopback interface:                            [  OK  ]
        Bringing up interface eth0:                                [  OK  ]
        Bringing up interface eth1:                                [  OK  ]
        Bringing up interface eth2:                                [  OK  ]
        Bringing up interface eth3:                                [  OK  ]
        [root@N151 network-scripts]# ping 8.8.8.8
        PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
        64 bytes from 8.8.8.8: icmp_seq=1 ttl=42 time=152 ms
        64 bytes from 8.8.8.8: icmp_seq=2 ttl=42 time=156 ms
        ^C
        --- 8.8.8.8 ping statistics ---
        2 packets transmitted, 2 received, 0% packet loss, time 1959ms
        rtt min/avg/max/mdev = 152.665/154.780/156.895/2.115 ms
        [root@N151 network-scripts]# ping www.baidu.com
        ping: unknown host www.baidu.com
        [root@N151 network-scripts]# vi /etc/resolv.conf 
        [root@N151 network-scripts]# ping www.baidu.com
        PING www.a.shifen.com (115.239.210.27) 56(84) bytes of data.
        64 bytes from 115.239.210.27: icmp_seq=1 ttl=56 time=8.66 ms
        64 bytes from 115.239.210.27: icmp_seq=2 ttl=56 time=6.30 ms
        ^C
        --- www.a.shifen.com ping statistics ---
        2 packets transmitted, 2 received, 0% packet loss, time 1787ms
        rtt min/avg/max/mdev = 6.307/7.487/8.668/1.183 ms
    3.修改/etc/bashrc
      vi /etc/bashrc  //在最后加一行:  alias vi='vim'
    4.修改 /etc/vimrc
      安装vim后系统中就会有vimrc
      vi /etc/vimrc   
      加入这几行设置;
      set nu   //永久显示行号
      syntax on  //代码高亮
      set tabstop = 2  //tab缩进
    5.reboot  重启系统后代码高亮及其他功能显示

  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值