Vim set tabstop for file type


















My comment says use a single " , meaning don't close it with another ". Not sure why I commented that though. Paul Tomblin Paul Tomblin k 56 56 gold badges silver badges bronze badges. What's the advantage of this over by FileType? Is there any way to invert the match? I have had problems getting filetypes to work with html files since the. Filetypes doesn't seem recognize it as html, but this method will.

I could a change the default FileType settings b alter the filetype settings with a custom configuration or c quickly get what I want using this setting in my 1. It would be worth pointing out that - assuming my quick read of the docs is correct - you can add multiple commands per filetype s this way, and they are guaranteed to be executed in the order given. I usually work with expandtab set, but that's bad for makefiles.

I recently added: :autocmd FileType make set noexpandtab to the end of my. Jonathan Leffler Jonathan Leffler k gold badges silver badges bronze badges. The better option is to enable :filetype plugins. The default one for Vim includes :setl noet, so you don't even need that aucmd in your vimrc.

Can you explain the benefits of that, and what is involved in doing it? Why are filetype plugins better than autocmd? When should autocmd be used? Not used? The filetype plugins that come with Vim will do helpful things like "setlocal noexpandtab" for makefiles, for example.

Autocommands vs ftplugins for personal things like shiftwidth don't matter--it's just how you choose to structure your vim config. Personally, I use these settings in. Nello Nello 2 2 silver badges 2 2 bronze badges. Many languages have long established conventions, as do certain companies.

Take NodeJS as an example of the former. Tabs should be two spaces. Headache, and quite silly, but important. Why should tabs have to be the same for all circumstances?

For a configuration file, 8 space tabs work fine, but for code with a lot of indents, 2 is much easier to manage. And then there are fixed conventions: node.

The tab character has a long established tradition of meaning a jump to the next position at a multiple of 8 chars. It is only because people wanted to use tab for "the next indent that looks good in my language" and because some text editors didn't bother making the difference between "adding a tab character" and "adding spaces for indenting", and people tweaked their editor to have it their way, that we now have this mess where tabs never display the intended way.

Source code is text and the standard for text is 8-character tabs. For example: :set et :retab and the tabs in the file are replaced by enough spaces. To have tabs back simply do: :set noet :retab. Neysor 3, 11 11 gold badges 32 32 silver badges 65 65 bronze badges.

Juan Lanus Juan Lanus 2, 22 22 silver badges 15 15 bronze badges. Does this override the tab settings set by user config or indent provided by runtime or other plugins? Kaz Kaz Sign up or log in Sign up using Google. Sign up using Facebook.

See here to learn about Autocommand Groups. Sign up to join this community. The best answers are voted up and rise to the top. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Learn more. How can I change the default indentation based on filetype? Ask Question. Asked 6 years, 11 months ago. Active 2 years, 5 months ago. Viewed 13k times. How do I achieve that?

Improve this question. DeltaLima DeltaLima 2 2 gold badges 9 9 silver badges 8 8 bronze badges. Add a comment. Active Oldest Votes. Improve this answer. I will show you how to install and use the vim-plug plugin manager. The plugins we install will be added between the two function calls. In the mapping section we will add shortcuts to making typing longer commands easier. This will save you key strokes and lots of time, especially for long commands. A common mapping example is to map 'jj' to the escape key.

You will be pressing the escape key a lot. The escape key is in the far corner of the keyboard. The letter 'j' is in the middle of the keyboard so it is easier to press 'jj' instead of reaching for the escape key. The leader key, in conjunction with another key, will allow you to create new shortcuts. The backslash key is the default leader key but some people change it to a comma ",". Here are some common mappings that people use. See the comments above each line for the explanation.

Vimscript is a scripting language that lets you create scripts using variables, if else statements, and functions. Auto commands are waiting for events to occur in order to trigger a command. You can easily add color schemes to Vim to change the default colors. Do a search for Vim color schemes and you will find many, many choices.

You can configure your Vim status bar with useful information. For example, configure the file type, total number of lines in the file, path to the file, column number, row number, percentage through file, and much more.

In this article, I have only scratched the surface of how you can customize Vim. There are thousands of ways to configure and customize a. You can even write your own plugins and color schemes and share them with the world. I hope that you have learned a new trick or two by reading this article.

So if you use Vim, don't leave home without a.



0コメント

  • 1000 / 1000