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

Remove every n line #772

Closed
frlan opened this issue Sep 10, 2018 · 4 comments
Closed

Remove every n line #772

frlan opened this issue Sep 10, 2018 · 4 comments

Comments

@frlan
Copy link
Member

frlan commented Sep 10, 2018

It would be awesome, if the plugin offer a way to delete every n line. I've got regular cases were I need to delete just every second line and somehow I miss this feature. Example:

line 1
line 2
line 3
line 4
line 5

would become

line 1
line 3
line 5
@codebrainz
Copy link
Member

As an alternative you could do that in a "custom command", like maybe a python command (untested):

python -c \
  'import sys; sys.stdout.write("\n".join([l for l in sys.stdin.readlines() if l % 2]))'

@b4n
Copy link
Member

b4n commented Sep 10, 2018

The same way as @codebrainz's suggestion, you can get this to work easily with sed:

sed -n '1~2p'

Replace 1 with the starting line, and 2 with the step you want -- here it does exactly what you asked for, print every second line starting at line 1, effectively giving every odd line.

@frlan
Copy link
Member Author

frlan commented Sep 11, 2018

Yepp... As all of the options offered by the plugin there is some sed/awk/* way to do it ;)
But it's having an advantage: All in one place and "build in" ;)

lpaulsen93 added a commit to lpaulsen93/geany-plugins that referenced this issue May 13, 2019
Imlements a new feature which allows to remove every n-th line.
The user can enter the value of 'n' in a dialog. Implements geany#772.
@lpaulsen93
Copy link
Contributor

@frlan: I implemented the feature in PR #860. As I am not the author of the plugin the maintainer is up to decide if he wants to accept it or not.

lpaulsen93 added a commit to lpaulsen93/geany-plugins that referenced this issue May 13, 2019
Imlements a new feature which allows to remove every n-th line.
The user can enter the value of 'n' in a dialog. Implements geany#772.
lpaulsen93 added a commit to lpaulsen93/geany-plugins that referenced this issue May 14, 2019
Imlements a new feature which allows to remove every n-th line.
The user can enter the value of 'n' in a dialog. Implements geany#772.
@frlan frlan closed this as completed Jul 16, 2019
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