[vim ] 保留前後字元,修改中間的字元
想在vim做一個功能
若文件內文是
good
help
student
school
希望可以的結果是
g__d
h__p
s_____t
s____l
目前只有推到下面這樣就卡住了
:%s/\(^.\)\|./\1_/gc
不知道各位大大有什麼提示嗎?
先感謝了
2017.06.05補充
若使用
%s/\a\(\a\)\@=\&\(\a\)\@<=\a/_/gc
也可以處理行裡面有多個單字的情況
take place
school
會變成
t__e p___e
s____l
謝謝akria,curist,fjm31714的分享
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 14.203.189.15
※ 文章網址: https://www.ptt.cc/bbs/Editor/M.1487685547.A.2CC.html
推
02/21 23:44, , 1F
02/21 23:44, 1F
推
02/22 00:40, , 2F
02/22 00:40, 2F
推
02/22 01:56, , 3F
02/22 01:56, 3F
→
02/22 01:56, , 4F
02/22 01:56, 4F
→
02/22 01:57, , 5F
02/22 01:57, 5F
→
02/22 01:57, , 6F
02/22 01:57, 6F
→
02/22 01:57, , 7F
02/22 01:57, 7F
→
02/22 01:58, , 8F
02/22 01:58, 8F
→
02/22 01:58, , 9F
02/22 01:58, 9F
→
02/23 01:22, , 10F
02/23 01:22, 10F
→
02/25 11:37, , 11F
02/25 11:37, 11F
→
02/25 11:37, , 12F
02/25 11:37, 12F
推
03/08 15:06, , 13F
03/08 15:06, 13F
→
03/08 15:06, , 14F
03/08 15:06, 14F
→
03/08 15:07, , 15F
03/08 15:07, 15F
推
03/11 23:25, , 16F
03/11 23:25, 16F
→
03/11 23:26, , 17F
03/11 23:26, 17F
→
03/11 23:29, , 18F
03/11 23:29, 18F
→
03/11 23:29, , 19F
03/11 23:29, 19F
→
03/11 23:31, , 20F
03/11 23:31, 20F
推
03/14 10:44, , 21F
03/14 10:44, 21F
→
06/04 13:36, , 22F
06/04 13:36, 22F
※ 編輯: javafang (203.213.93.179), 06/05/2017 07:14:28
※ 編輯: javafang (203.213.93.179), 06/05/2017 10:21:33
Editor 近期熱門文章
PTT數位生活區 即時熱門文章