search

Home  >  Q&A  >  body text

How to delete all content after specified columns in multiple lines in vim?

For example:

111,a
222,bb
333,ccc
444,dddd
555,eeeee
666,ffffff
777,ggggggg

You can use Ctrl + v to select all the columns where the comma is located. If you want to delete all the content to the right of it, is there any shortcut?

怪我咯怪我咯2776 days ago740

reply all(4)I'll reply

  • 黄舟

    黄舟2017-05-16 16:36:47

    First select all the lines you want to replace, then :'<,'>s/,.*$//

    reply
    0
  • 大家讲道理

    大家讲道理2017-05-16 16:36:47

    Directly control-v and then $d or D Not finished yet?

    reply
    0
  • 仅有的幸福

    仅有的幸福2017-05-16 16:36:47

    Use awk

    awk  -F ','  '{print }'

    reply
    0
  • 天蓬老师

    天蓬老师2017-05-16 16:36:47

    You can also do this using visual-block:

    gg
    f,
    <c>v
    $
    G
    x

    reply
    0
  • Cancelreply