How to remove quotes surrounding the first two columns in Vim?

前端 未结 8 1213
遥遥无期
遥遥无期 2020-12-15 21:53

Say I have the following style of lines in a text file:

\"12\" \"34\" \"some text     \"
\"56\" \"78\" \"some more text\"
.
.
.
etc.

I want

8条回答
  •  一整个雨季
    2020-12-15 22:32

    Say if you want to delete all columns but the first one, the simple and easy way is to input this in Vim:

    :%!awk '{print $1}'
    

    Or you want all columns but the first one, you can also do this:

    :%!awk '{$1="";$0=$0;$1=$1;print}'
    

    Indeed it requires external tool to accomplish the quest, but awk is installed in Linux and Mac by default, and I think folks with no UNIX-like system experience rarely use Vim in Windows, otherwise you probably known how to get a Windows version of awk.

提交回复
热议问题