vim 替换

命令:substitude

:s/{from}/{to}

其中 ssubstitude

  • :s/{from}/{to} 当前行的第一个 from 替换为 to
  • :s/{from}/{to}/g 将当前行中的 from 替换为 to
  • :s/{from}/{to}/gc 将当前行中的 from 替换为 to,并在执行前进行确认询问
  • :%s/{from}/{to}/g 将所有行中的 from 替换为 to
version: '3'

services:
  example-redis:
    image: redis:5.0.5
    container_name: example-redis
    restart: always
    ports:
      - 63791:6379
    volumes:
      - ./data:/data
      - ./conf/redis.conf:/etc/redis/redis.conf
    networks:
      - redis-net
networks:
  redis-net:

将上面的 example-redis 替换为 redis

:%s/example-redis/redis/g

version: '3'

services:
  redis:
    image: redis:5.0.5
    container_name: redis
    restart: always
    ports:
      - 63791:6379
    volumes:
      - ./data:/data
      - ./conf/redis.conf:/etc/redis/redis.conf
    networks:
      - redis-net
networks:
  redis-net:
posted @ 2023-02-28 13:44  艺言弈行  阅读(24)  评论(0编辑  收藏  举报