-
Notifications
You must be signed in to change notification settings - Fork 30.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Smart Tabs - Feature Request #33974
Comments
Note that #4039 (comment) is a request for the same feature. However, #4039 tracks a different issue, so this is not a duplicate. |
Another non-duplicate: #14982 calls for the "Smart tabs" option from Visual Studio to be implemented in VS Code. However, despite sharing a name, this is not the same feature as what is being requested here. The "Smart tabs" option in Visual Studio is language-aware indentation: pressing Enter after typing an opening brace will automatically indent the next line by one more indentation unit without the user needing to press the Tab key. This feature request, on the other hand, is to implement what Emacs calls Smart Tabs: correctly mixing tabs and spaces at the start of the line, in the only way that will work for everyone. (I.e., tabs for indentation and spaces for alignment). |
Here's a page devoted to "indent with tabs, align with spaces" for those who are new to the distinction: https://dmitryfrank.com/articles/indent_with_tabs_align_with_spaces I'm going to look into whether this could be done with a VS Code extension. I've searched, but was unable to find one(*). If anyone knows of one, please do tell. (*) I did find 'Dynamic Tab Insertion' by zhiayang (https://github.com/zhiayang/vscode-tabindentspacealign), but as of Aug 25, 2018 it didn't work for me in VS Code 1.26.1. |
Since there seems to be no interest nor understanding from the VS Code team for supporting tabs for indentation and spaces for alignment (as seen by the responses or lack thereof to this and related issues), I ended up writing an extension to achieve this: I've used it a fair bit before publishing it and it has worked great for me, but I am sure that there are some corner cases that I overlooked. Feedback is very welcome! |
Emacs also supports this for a long time and has a good wiki article on the topic: https://www.emacswiki.org/emacs/SmartTabs @j-zeppenfeld you can also just use prettier(js) and the corresponding vscode plugin. They support smart tabs. |
We try to keep VS Code lean and we think the functionality you're asking for is great for a VS Code extension. Maybe you can already find one that suits you in the VS Code Marketplace. Just in case, in a few simple steps you can get started writing your own extension. See also our issue reporting guidelines. Happy Coding! |
Did a robot just decide the fate of this issue because of inactivity? I'm very confused by this and I think it makes way more sense if it's built in. Be nice to have a human from Microsoft weigh in on this conversation. |
I fear that writing an extension to provide basic support for smart tabs was a mistake if it lead to this issue being closed... Indentation is such a fundamental feature of an editor that writing an extension to perform it will always have issues. For example, autoindentation is impossible to implement in an extension, given that the current language configuration cannot be retrieved. Many other features integral to the editor (such as adjusting indentation on paste, etc.) would all have to be reimplemented by an extension. As stated above, indentation is simply too fundamental a feature to be completely replaced by an extension - it quickly turns into reimplementing significant parts of the editor. @jedmao I believe the bot closed this because it was tagged as extension candidate. |
This kind of tabs/spaces trade-off really ought to be the preferred 'good practice'. I suspect it isn't only because it's not widely implemented yet. Seems like it should be a core behavior, but I've been watching this with the intent of writing (or at least contributing to) the extension if this doesn't eventually get any love from the dev team. Right now I'm slammed, but in another couple of months, who knows? |
@roblourens can you clarify why the |
I yield to @bpasero... |
Back then it didn't cause the issue to be closed, it was just a suggestion |
Thanks @bpasero! ❤️ Is there any additional context that the community can provide about this feature or is it completely clear? Just wondering what the next steps would be before being pulled into a milestone? |
@LAK132 this is not an example of Smart Tabs. The whole point behind Smart Tabs is, that you use tabs for indentation and spaces for alignment. Your example just shows that someone didn't use them properly, namely spaces for indentation of the |
Suggesting an extension for something as fundamental as this, is like making an editor that only supports spaces and saying write an extension to support tabs if you want that. |
It’s like a smart phone, with all its bells and whistles; yet, can’t perform basic phone features. I loved how Windows Phone would let you link contacts without merging them. It’s a feature I miss so much these days and I consider it to be a pretty basic requirement of a “phone.” Show us how it’s done, Microsoft! You have an excellent team here. |
Did anyone find an alternative for this? |
I just came back here after watching the latest video by Scott Hanselman where they shortly touched the topic tabs VS spaces, and thought, hey, let's discuss this for VSCode. To my surprise there already was an issue and I already commented here years ago. I'd rather open a discussion thread though, but those are limited to discussing extensions here, which is a bit of a pity. So if someone has a better suggestion where to discuss this, because I think an issue / feature request is not the right place, yet, before the fundamentals of how deep these changes would reach into the architecture, have been discussed. In particular I'm referring to, how and what would need to be changed to allow support for smart tabs in VSCode. Which APIs would need to be touched in the data and visual layers and how the storage layer would look like. Probably language server protocols too. But first, so we are on the same page, what are smart tabs? It basically boils down to differentiating between alignment and indentation when it comes to the use of whitespace. Indentation is a unit-less measure, so it works nicely with both spaces (fixed width) and tabs (dynamic width based on user choice in the visual layer). And because tabs have been used for alignment in the past, they started this whole tabs VS spaces debate. So I'm asking again. If anyone knows a better place to discuss the fundamentals of this, please let me know. Or which maintainer to ping for input. |
Hi @totkeks I'm glad to see any kind of action/interest on this issue, but I'm not sure this is the best place to discuss what smart tabs are. There are a number of places where they're discussed, e.g. what they are and why you want them. I don't think there's debate about what this feature should be, there just seems to be a lack of interest in actually implementing it. |
Yes, I see that lack. Which is why I don't want to discuss what smart tabs are, but instead what needs to be done to implement them. Analyze it first, so a more elaborate feature request can be created that makes it easier to estimate the actual work required and impact on the VSCode core. |
Some editors support what's called "smart tabs." The spec for vscode might look like the following:
Conceptually, this would ensure that mixed tabs and spaces for indentation would never occur.
IntelliJ IDEA | Tabs and Indents | Smart Tabs
Related discussion: editorconfig/editorconfig#323 (comment)
The text was updated successfully, but these errors were encountered: