2021年1月7日星期四

Indentation with Vim

I've been reading this article about Vim indentation settings. There are quite some of them, and they tend to be counter intuitive and even intimidating at the beginning. The reason could be that these settings are structured from Vim's perspective instead of from the user's. So I'll try to summarize them, based on how an indent is actually triggered.

Generally speaking an indent could happen both manually, by human inputs, and automatically, by a plugin.

The following would be better illustrated with a chart, which would then require more time and effort than I could afford at the moment. So please bear with the quick and dirty for the time being.

Manual trigger

By pressing the <TAB> key, you are instructing Vim to move the cursor softtabstop columns forward. The way how the blank is filled depends on the expandtab setting.

By entering >>, << or ==, you are instructing Vim to move the cursor shiftwidth columns forward. So it would make sense to set it to the same value as softtabstop.

Automatic trigger

Plugins would trigger indentation according to the shiftwidth setting.

没有评论:

发表评论