[英]How to replace every occurrences except the first one on every line - VIM
我的數據看起來像這樣:
母音,vowel
備考,note, remarks, NB
基本形,,fundamental form, basic form, basic pattern, basic model, basic type, prototype
受身,,the defensive, passive attitude, passivity, passiveness, the passive, passive voice, ukemi (the art of falling safely)
受身形,passive voice, passive form
否定,negation, denial, repudiation, NOT operation
不規則,irregularity, unsteadiness, disorderly
如何替換除每行之外的每個事件?
我想更換每一個,
對除第一次出現的每行,
每行。
結果:
母音,vowel
備考,noteREPLACED remarksREPLACED NB
基本形,REPLACEDfundamental formREPLACED basic formREPLACED basic patternREPLACED basic modelREPLACED basic typeREPLACED prototype
受身,REPLACEDthe defensiveREPLACED passive attitudeREPLACED passivityREPLACED passivenessREPLACED the passiveREPLACED passive voiceREPLACED ukemi (the art of falling safely)
受身形,passive voiceREPLACED passive form
否定,negationREPLACED denialREPLACED repudiationREPLACED NOT operation
不規則,irregularityREPLACED unsteadinessREPLACED disorderly
你可以使用正面的lookbehind:
:%s/\m\%(,.*\)\@<=,/REPLACED/g
由於每個逗號后面都有一個空格字符,除了第一行之外,您可以執行以下操作。
%s/, /REPLACED /g
%s/,\+/,/g
第二個命令處理多個連續的逗號,就像第三行一樣。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.