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

[feature request] Comment block editing mode #76

Open
postmodern opened this issue Feb 19, 2020 · 4 comments
Open

[feature request] Comment block editing mode #76

postmodern opened this issue Feb 19, 2020 · 4 comments

Comments

@postmodern
Copy link

When editing Ruby files, if you start a comment block, any successive newlines will automatically start with a #. I would like to have the same functionality in vim-crystal.

@bew
Copy link
Contributor

bew commented Feb 19, 2020

Hello, I personally don't want this as the default behavior.

If you want this feature for your own setup you can enable this using the flag r & o of vim's formatoptions, see http://vimdoc.sourceforge.net/htmldoc/change.html#fo-table

@rhysd
Copy link
Member

rhysd commented Feb 20, 2020

Since the customization is done in one line, I think adding a section to show how it can be done in documentation would be good.

@robacarp
Copy link

I'm surprised that anyone wouldn't want this as the default, but here's the way to configure vim to make comment editing behave:

autocmd BufNewFile,BufRead *.cr set formatoptions+=roj

From the :help fo-table as linked above:

r	Automatically insert the current comment leader after hitting
        <Enter> in Insert mode.
o	Automatically insert the current comment leader after hitting 'o' or
        'O' in Normal mode.
j	Where it makes sense, remove a comment leader when joining lines.  For
        example, joining:
                int i;   // the index ~
                         // in the list ~
        Becomes:
                int i;   // the index in the list ~

Thanks for a tour into a world of vim options I didn't know existed in formatoptions, bew!

@bew
Copy link
Contributor

bew commented Aug 10, 2021

I'm surprised that anyone wouldn't want this as the default

In my case I always want normal keys o & O to add blank lines below/above the current line and only when in insert mode do I want Enter to continue a commented block for me.

This allows me to have other keybinds based on o/O/Enter to easily add many blank lines, whether I'm on a comment or not, and only when needed have another keybind to continue a comment block.

Thanks for a tour into a world of vim options I didn't know existed in formatoptions, bew!

🙃

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

4 participants