vi编辑器在左侧显示括号日期和时间戳

时间:2023-01-17 19:35:01

I am fairly new to Linux and am trying to edit a file in the vi editor. when I access the file, I have date and time strings running down the left hand side and it makes it very cumbersome to edit the file. any advice would be appreciated. Thank you.

我对Linux很新,我正在尝试在vi编辑器中编辑文件。当我访问该文件时,我的左侧有日期和时间字符串,这使得编辑文件非常麻烦。任何意见,将不胜感激。谢谢。

1 个解决方案

#1


Since vi/vim doesn't insert dates by default, this strongly suggests that the dates are in the data itself. You have several choices that occur to me:

由于vi / vim默认情况下不插入日期,因此强烈建议日期在数据本身中。您有几种选择:

  1. You can delete the dates from the actual file content with something like :%s/^\d\{4}-\d\d-\d\d \d\d:\d\d:\d\d\s* (assuming the dates are in "YYYY-MM-DD HH:MM:SS" format)

    您可以使用以下内容从实际文件内容中删除日期:%s / ^ \ d \ {4} - \ d \ d- \ d \ d \ d \ d:\ d \ d:\ d \ d \ s *(假设日期为“YYYY-MM-DD HH:MM:SS”格式)

  2. With a recent version of vim (check the output of :version for +conceal) you can leave the dates in the file but have them hidden unless you're on the actual line:

    使用最新版本的vim(检查输出:版本为+隐藏),您可以将日期保留在文件中,但隐藏它们,除非您在实际行上:

    :set conceallevel=2
    :syn match Comment /^\d\{4}-\d\d-\d\d \d\d:\d\d:\d\d\s*/ conceal
    

#1


Since vi/vim doesn't insert dates by default, this strongly suggests that the dates are in the data itself. You have several choices that occur to me:

由于vi / vim默认情况下不插入日期,因此强烈建议日期在数据本身中。您有几种选择:

  1. You can delete the dates from the actual file content with something like :%s/^\d\{4}-\d\d-\d\d \d\d:\d\d:\d\d\s* (assuming the dates are in "YYYY-MM-DD HH:MM:SS" format)

    您可以使用以下内容从实际文件内容中删除日期:%s / ^ \ d \ {4} - \ d \ d- \ d \ d \ d \ d:\ d \ d:\ d \ d \ s *(假设日期为“YYYY-MM-DD HH:MM:SS”格式)

  2. With a recent version of vim (check the output of :version for +conceal) you can leave the dates in the file but have them hidden unless you're on the actual line:

    使用最新版本的vim(检查输出:版本为+隐藏),您可以将日期保留在文件中,但隐藏它们,除非您在实际行上:

    :set conceallevel=2
    :syn match Comment /^\d\{4}-\d\d-\d\d \d\d:\d\d:\d\d\s*/ conceal