Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to modify Tab to 4 spaces in VIM Editor by Linux

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how Linux modifies Tab to 4 spaces in the VIM editor". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how Linux modifies Tab to 4 spaces in the VIM editor.

The editor most frequently used by Linux users is the VIM editor. In order to improve our editing speed, we often set some shortcuts in the editor. Today the editor will share with you the method of setting the Tab key to 4 spaces in the VIM editor.

Setting method:

Editing

Vim / .vimrc

If the new file does not exist, the file already exists and is appended to the tail

Add

"this part of the code is executed only if autocommands is supported.

If has ("autocmd")

"use file type checking and file-based automatic tightening

Filetype plugin indent on

"the length of tab in Makefiles file is 8. 0.

Autocmd FileType make set tabstop=8 shiftwidth=8 softtabstop=0 noexpandtab

Endif

"for other cases, use a 4-space width TAB

The width of the set tabstop=4 "TAB is set to 4 spaces.

"but it's still\ t. It's just that vim interprets it as four space widths, using other editors or\ t symbols.

"Vim will interpret it to be having

"a width of 4.

The "set shiftwidth=4" indent uses a width of 4 spaces.

"set softtabstop=4" sets the number of columns occupied by tab, which is set to the width of 4 spaces when entering tab.

Set expandtab "extends tab to a space.

Vim temporarily turns off indentation and comment auto indentation settings

VIM automatically indents the code when it is pasted, making the code a mess and may even cause the rest of the code to be commented out because of a comment on a line

Method one

Set pastetoggle

Automatic indentation can be turned off

Or set it as a shortcut key, the most convenient way is to add a sentence to .vimrc:

Set pastetoggle= "F9"

Later, in insert mode, just press F9 to toggle automatic indentation.

When you need to write your own handwritten code, enter insert mode, and the default is automatic indentation.

Method two

Set paste

Then paste in insert mode, and the code will not be indented automatically.

You need to indent automatically when typing the code, and you need to change it back:

Set nopaste

At this point, I believe you have a deeper understanding of "how Linux modifies Tab to 4 spaces in the VIM editor". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report