I have a lot of org-mode code-blocks and I would like to delete all their names, so they are all unique when I run them again.
e.g.,
# NAME: 05298705-f04e-47df-b7f0-ca8bd2d0ef4c
# begin_src ein-r :session localhost :results output :exports both :eval no
life_2015_clean$Status <- as.numeric(as.factor(life_2015_clean$Status))
## life_2015_clean <- na.omit(life_2015_clean) ## eliminando muitos dados.
summary(life_2015_clean)
# end_src
Would become
# begin_src ein-r :session localhost :results output :exports both :eval no
life_2015_clean$Status <- as.numeric(as.factor(life_2015_clean$Status))
## life_2015_clean <- na.omit(life_2015_clean) ## eliminando muitos dados.
summary(life_2015_clean)
# end_src
as well as any line that has # NAME: (...) in it.
CodePudding user response:
Use command flush-lines
(also known as delete-matching-lines
) to delete lines that match a regexp.
You just need a regexp that matches (only) lines that you want to delete.
It sounds like you want to match # NAME: (...)
, so perhaps try a regexp such as this: ^#[ ]NAME: (
.
CodePudding user response:
M-x delete-matching-lines
You might not need a regexp here, if you just want to delete all lines containing "# NAME:". However, this will match any line containing this text anywhere, not just at the start of the line, so use with caution.
A more cautious approach for a manageable file size would be to create a macro that uses isearch for a line ending followed by "#_NAME:", then goes to the start of the line, and kills the line. This can then be run interactively for a little while to make sure it gets what you want, and turned into a brute-force nuke (if necessary) once you're more confident.
As always, there are millions of ways to do things in emacs, this is just one approach.