Remove all arbitary spaces before a line in Vim

前端 未结 9 2257
感动是毒
感动是毒 2020-12-01 02:56

I\'v written a plugin where it comes to parsing a XML tag. The content inside the tag is indented and when i copy the parsed string into the file it\'s gettting like:

<
9条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-01 03:22

    Yet another way to achieve this is using the the normal command :h :normal-range

    :%norm d^
    

    This goes to column 0 in each line (%) and deletes (d) to the first non-white character(^).

    This is slightly more to type as the accepted answer, but allows for easy extension if you have a more complex scenario in mind, such as additional un-commenting or so:

    :%norm d^I# 
    

    Resulting in:

    #Example line
    #This is part of the parsed line
    #Thats goes one
    #End of line
    

提交回复
热议问题