使用vim在多行中交换各种大小的字
我有一些代码可以进行手动编码/解码,我需要对其进行扩展。编码如下所示:使用vim在多行中交换各种大小的字,vim,vi,Vim,Vi,我有一些代码可以进行手动编码/解码,我需要对其进行扩展。编码如下所示: map[“some_key”]=some_struct.member; map[“some_other_key”]=some_other_struct.member; 要解码,我需要交换“=”周围的文本部分(例如have some_struct.member=map[“some_key”])。不用说,我需要编辑很多行,所以我想以某种方式实现自动化。我正在使用vim,但我能想到的最好办法是将“]部分填充到“\uuuuuuuu
map[“some_key”]=some_struct.member;
map[“some_other_key”]=some_other_struct.member;
要解码,我需要交换“=”周围的文本部分(例如have some_struct.member=map[“some_key”])。不用说,我需要编辑很多行,所以我想以某种方式实现自动化。我正在使用vim,但我能想到的最好办法是将“]部分填充到“\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu。。。你知道的。有更好的方法吗?使用宏:
" start macro, saving in q register
qq
" (edit one line to do what you want)
" end recording
q
" visually select other lines, hit :, vim starts command line with '<,'>
:'<,'>norm @q
我将jk映射到esc,您可能需要其他东西。我也会使用宏来完成,无论是否录制:
:%norm! di"t;vBpF"P
:%norm! $dBF"vi"p$P
Vimgolf:
:%norm 2Wdt^vEp;p
。根据需要将%
范围替换为可视范围VimGolf::%norm$dB^vEp$P
;)
:%norm! di"t;vBpF"P
:%norm! $dBF"vi"p$P