使用任何编辑器重新编号yaml文件中的列

时间:2017-10-16 07:16:41

标签: vim sublimetext3 atom-editor

我有一个yaml文件,其中包含很长的编号字段列表。

$('.numeric').keyup(function(event) {

var currentVal = $(this).val();

if (currentVal.length == 1 && (event.which == 48 || event.which == 96)) {
  currentVal = currentVal.slice(0, -1);
}
$(this).val(currentVal);

我试图去

git config --global --unset credential.helper

我需要做的是重新编号这些字段,从定义的数字开始,最多约400(每个文件多次)。

必须有一种方法可以在vim,atom或sublime中做到这一点,但我很难找到方法。

增加数字似乎在vim中使用^ X但是我真的需要将数字放在我重新编号的列上方并添加一个并将文本替换为:使用该数字。它可能是一个正则表达式问题,以使选择正确,宏可以使其工作,但我无法解决它。

1 个答案:

答案 0 :(得分:3)

详情请点击此处:How to replace finding words with the different in each occurrence in VI/VIM editor ?

这样的事情应该有效:

:let @a=1 | %s/^\s*\zs\d\{1,3}\ze:/\=(@a+setreg('a',@a+1))/g

当然你可以根据你的需要调整@a。如您所见,您的\d\{1,3}仍在使用中。但为了确保只匹配正确的部分,它会查找该行的开头。此外,它不会替换:,而是检查它。这可以通过\zs\ze实现。有关详细信息,请参阅:h \ze

相关问题