1

I want to delete everything from start of the document upto some regex match, such as _tmm. I wrote the following custom command:

command! FilterTmm exe 'g/^_tmm\\>/,/^$/mo$' | norm /_tmm<CR> | :0,-1 d

This doesn't work as expected. But when I execute these commands directly using the command line, they work.

Do you have any alternative suggestions to accomplish this job using custom commands?

1
  • I don't know about vimscript, but this is simply ggV/_tmm<CR>d Commented Oct 9, 2013 at 22:41

1 Answer 1

1

It seems that you want to remove from beginning to the line above the matched line.

/pattern could have offset option. like /pattern/{offset}, :h / for detail, for your needs, you could do (no matter where your cursor is):

ggd/_tmm/-1<cr>

EDIT

I read your question twice, it seems that you want to do it in a single command line.

Your script has problem, normal doesn't support |, that is, it must be the last command.

try this line, if it works for you:

exe 'norm gg'|/_tmm/-1|0,.d
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.