How to replace CSV column separators with numbered labels in Vim?

后端 未结 2 576
梦如初夏
梦如初夏 2021-01-15 12:07

I want to replace a series of pipeline characters with different values. How would I do this with regular expressions?

Example:

This | is | a | sentenc         


        
2条回答
  •  爱一瞬间的悲伤
    2021-01-15 12:22

    Define a function:

    fun CountUp()
      let ret = g:i
      let g:i = g:i + 1
      return ret
    endf
    

    Now, use:

    :let i = 1 | %s/|/\="new" . CountUp()/g
    

提交回复
热议问题