.vimrc配置

syntax enable
syntax on
set relativenumber
set autoindent
set tabstop=4
set expandtab " 使用4个空格代替tab键

如何替换已经打开的文件中的tab呢

对于已保存的文件,可以使用下面的方法进行空格和TAB的替换:
TAB替换为空格:

:set ts=4
:set expandtab
:%retab!

空格替换为TAB:

:set ts=4
:set noexpandtab
:%retab!

!是用于处理非空白字符之后的TAB,即所有的TAB,若不加!,则只处理行首的TAB。

相关文章:

  • 2022-03-06
  • 2022-12-23
  • 2022-12-23
  • 2021-09-30
  • 2022-12-23
  • 2021-05-26
猜你喜欢
  • 2021-12-16
  • 2021-09-18
  • 2021-11-03
  • 2022-02-12
  • 2022-01-14
  • 2021-12-06
相关资源
相似解决方案