×

Loading...

Topic

This topic has been archived. It cannot be replied.
  • 工作学习 / IT技术讨论 / 再说一个面世时曾经被问的问题
    有一段文本,例如

    I'm a student
    I lived in Canada,
    I don't like this stupid country,
    but I'd like to live here.

    用一个vi命令,把它变成
    I'm a student
    I lived in Canada,
    I don't like this stupid country,
    but I'd like to live here.
    • 空格没了
      有一段文本,例如

      I'm a student
      I lived in Canada,
      I don't like this stupid country,
      but I'd like to live here.

      用一个vi命令,把它变成
      __I'm a student
      __I lived in Canada,
      __I don't like this stupid country,
      but I'd like to live here.

      __代表空格
      • 1,$s/^/^_/ ( _代表空格)
        • 第2个^多于了吧?
          当时我是没回答上,不过工作还是找到了。
          • 面试嘛,安全起见,呵呵,我也记不清了,因为好久没有用了。看来我们是同行,注册个ID吧,咱们多交流交流。
      • :1,$ s/ //g
      • :1,$s/^I/_I/g
        • you're right. 忘了看but那句不用改了。
      • I should be : 1, $ s/^I/ I/
    • 什么命令也不用,呵呵,这不是一样的嘛!
      • Sorry. a simple question: where should I input these characters "$s/^/^_/ "? In EDIT mode or some other modes? tks.
        • Press Esc, and then press Enter. "1,$" means apply the following command from the first line to the last line. Don't break it into two parts.