emacs-evil / emacs-evil/evil

joining comment lines

Open
#606 26 comments 7 reactions 0 assignees View on GitHub
commands major proposal
Dominant language
Emacs Lisp
Stars
3.9k
Forks
307
PR merge metrics
No merged PRs in 30d

Description

Originally reported by: **Jorge Israel Peña (Bitbucket: [blaenk](https://bitbucket.org/blaenk), GitHub: [blaenk](https://github.com/blaenk))**

----------------------------------------

It would be amazing if there were a way to join comment lines such that the comment leaders were removed. vim has this functionality when you do:

```
set formatoptions+=j
```

The [documentation](http://vimhelp.appspot.com/change.txt.html#fo-table) for it (`:help fo-table`) is:

```
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
```

The mailing list thread which discussed the change and contains the patch is [here](https://groups.google.com/forum/#!topic/vim_dev/RGlWX35ZK8Q).

Is this already possible and perhaps I have overlooked it? If not, would you be open to implementing it? If not, is it something that can be done on the user-end using the existing evil infrastructure, and if so, would you have any advice on that?

I absolutely love and miss this functionality.

I tried doing it myself by creating a function that would check if the point was in a comment (by checking the syntax table) and do some things to achieve this, otherwise defer to `evil-join`. My problem was that it didn't compose well with existing `evil-join`, for example given a selection of multiple lines to join.

----------------------------------------
- Bitbucket: https://bitbucket.org/lyro/evil/issue/606

Contributor guide

Open the contributing guide

Research direction

Start with the existing evil-join behavior and the syntax-table approach described in the issue, then compare it with Vim's formatoptions+=j documentation and the linked mailing-list patch. Done means joining comment lines removes appropriate comment leaders while composing correctly with evil-join for multi-line selections.

Written by the indexing model from the issue text.

Assessment

Tech stack
emacs-lisp, vim
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.