How do vi and vim modify tab to be a 4 space method example

  • 2020-09-28 09:19:41
  • OfStack

preface

This paper mainly introduces the contents related to vi and vim's modification of tab into 4 Spaces, and shares them for your reference and study. The following words are not enough, let's have a look at the detailed introduction

The methods are as follows:

Configuration file locations: /etc/virc and /etc/vimrc

If you want to add a comment in the configuration file, use "instead of" #"


" add by school1024.com
set ts=4
set softtabstop=4
set shiftwidth=4
set expandtab
set autoindent
ts is short for tabstop. Set the width of TAB to 4 Spaces. softtabstop represents the length of the indent to be returned when the backspace key is pressed in edit mode, and is especially useful when using expandtab. shiftwidth represents the length of each indent, and 1 is generally set to look like softtabstop 1. expandtab represents indentation as a space, and noexpandtab as a TAB for an indent. autoindent indents automatically

Previous files can be interchanged with TAB using the following command for Spaces

TAB is replaced with Spaces


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

Replace the Spaces with TAB


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

Add! Is the TAB after processing non-white space characters, that is, all TAB, if not added! , processing only TAB at the beginning of the row.

conclusion


Related articles: