How can I select all lines that do not contain the word “hello” in VIM? I need it yanked and then saved to a file. How can I do it? I am looking for something like:
:v/!(hello) > file
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The lines are now stored in register a, to paste them do “ap
Edit:
Can be abbreviated to
For those interested in what this means to vim:
:g = global search
! = negation of boolean test that follows
/hello/ = regular expression to match “hello”
y = command to perform upon each matched line, in this case “yank”
A = register argument to “yank” command. In this case register ‘a’ but in the form of upper case meaning append to the register rather than replace.