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

Suggestion: Provide a delimiter for comments #122

Open
idbrii opened this issue Feb 25, 2019 · 2 comments
Open

Suggestion: Provide a delimiter for comments #122

idbrii opened this issue Feb 25, 2019 · 2 comments

Comments

@idbrii
Copy link

idbrii commented Feb 25, 2019

I often have trouble using regular expressions with easy-align and I think I've tracked it down to #53: it's probably always with aligning comments.

Could easy-align provide a comment delimiter that uses commentstring to determine the pattern?

Something like this:

" Provide a / delimiter for the current filetype's comment marker.
augroup easyalign_comment
    au!
    au BufEnter * let g:easy_align_delimiters['/'] = { 'pattern': substitute(&commentstring, '%s.*', '', ''), 'ignore_groups': ['!Comment'] }
augroup END
@matthiasdebernardini
Copy link

I'm having problems figuring out how to comment this

  /* TCP A                                                TCP B */

/* 1.  CLOSED                                               LISTEN */

/* 2.  SYN-SENT    --> <SEQ=100><CTL=SYN>               --> SYN-RECEIVED */

/* 3. ESTABLISHED <-- <SEQ=300><ACK=101><CTL=SYN,ACK> <-- SYN-RECEIVED */

/* 4.  ESTABLISHED --> <SEQ=101><ACK=301><CTL=ACK>       --> ESTABLISHED */

/* 5.  ESTABLISHED --> <SEQ=101><ACK=301><CTL=ACK><DATA> --> ESTABLISHED */

    /*     Basic 3-Way Handshake for Connection Synchronization */

     /*                           Figure 7. */

I use tpopes commentary to make these comments.

@idbrii
Copy link
Author

idbrii commented Sep 28, 2020

@matthiasdebernardini Looks like the * in cpp's commentstring needs to be escaped.

Try this in the augroup I posted above:

au BufEnter * let g:easy_align_delimiters['/'] = { 'pattern': substitute(escape(&commentstring, '*'), '%s.*', '', ''), 'ignore_groups': ['!Comment'] }

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

No branches or pull requests

2 participants