Soares / smarttab.vim

Tabs for indentation, spaces for alignment.
5 stars 3 forks source link

Indent normally after ';' in C #1

Open schivmeister opened 11 years ago

schivmeister commented 11 years ago

Pressing ENTER on any line containing parentheses would invoke the smart functionality for expressions and bring the cursor to the next line aligned to the first item within the parentheses.

This is unwanted when the line is a qualified statement with a terminator, i.e. when the ';' character is present at the end of the line. This can be worked around by pressing SHIFT-ENTER, but that may not work in all environments, and is not comfortable to employ.

Adding the ';' character to the chars for the unless function appears to fix this. Python is not affected.

--- a/plugin/smarttab.vim
+++ b/plugin/smarttab.vim
@@ -36,7 +36,7 @@ function! SmartIndentUnless(chars, to)
 endfunction

 function! CSmartIndent()
-       return SmartIndentUnless([')', '{'], ['('])
+       return SmartIndentUnless([')', '{', ';'], ['('])
 endfunction

 function! PySmartIndent()

P.S.: I know this repo looks abandoned, or at least, not in high demand, but this appears to have solved my problem of indenting with hard tabs and aligning with spaces. I have not found anything else that works.

In particular, the better known Smart-Tabs plug-in¹ only appears to work for C and only C with specific cindent options. WIth your plug-in, it looks like adding support for more languages wouldn't be much of a problem.

Anyway, it's still only been a couple of days. Let's see how it works out ;)

¹ http://vim.wikia.com/wiki/Indent_with_tabs,_align_with_spaces#Continuation_lines

schivmeister commented 11 years ago

Sorry, this actually does not work as expected. The proposed fix is simply wrong.

Soares commented 11 years ago

Well, it's still an issue, and I appreciate the report. I found a number of corner cases myself and switched to pure tabs. I do plan to come back to it at some point, I just haven't had the time. When I do, I'll try to address this issue.

schivmeister commented 11 years ago

Great, would be really useful to have something like this working. Thanks!