Skip to content
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

Commenting auto-added } on Escape #36

Open
thirtythreeforty opened this issue Oct 26, 2015 · 3 comments
Open

Commenting auto-added } on Escape #36

thirtythreeforty opened this issue Oct 26, 2015 · 3 comments

Comments

@thirtythreeforty
Copy link

Hi! Fantastic plugin you've written. Far better, consistency-wise, than delimitMate, at least in my experience.

I've noticed behavior which is almost certainly wrong, but I'm not sure if it's lexima.vim's fault. When I type the following (| is the cursor):

void foo() {|

then it correctly expands to the following:

void foo() {
    |
}

But a common thing for me to do is to type out a bunch of empty functions and just put a comment in them, getting the skeleton ready for actual implementation later. From the above expansion, still in Insert mode, I type:

void foo() {
    // Frobnicate the bar.|
}

When I hit Escape, this happens:

void foo() {
    // Frobnicate the bar.|
    // }

Obviously this is not what I meant to happen; I'd rather the closing brace stay uncommented. Pressing u at this point corrects the issue, for whatever reason:

void foo() {
    // Frobnicate the bar.|
}

This only happens in files where a source code filetype is set (such as c, cpp, or rust). That is, in an empty buffer, the closing brace stays put.

Do you have any idea what could be causing this behavior, and how to make it stop?

@cohama
Copy link
Owner

cohama commented Nov 1, 2015

Sorry for slow response.
It is caused by r flag of formatoption option set by default filetype plugins.
As a workaround, remove r flag from formatoption like below

autocmd BufWinEnter c,cpp,rust setlocal formatoption-=r

Ideally, however, lexima should work despite formatoption.
I will try to fix this problem but need more time.

@thirtythreeforty
Copy link
Author

thirtythreeforty commented Nov 1, 2015 via email

@beavailable
Copy link

beavailable commented Feb 11, 2024

I have the same problem and there is another similar problem which I think may be the same as yours, to reproduce, say if I have (in a shell script):

foo(){
    |
}

Then I continue typing:

foo(){
    if [ 1 = 1| ]
}

After I press escape it becomes:

foo(){
    if [ 1 = 1 ]
    }

I tried to remove r from formatoptions but it didn't work, the problem still exists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants