How to find contour lines for Appel's Hidden Line Removal Algorithm?

Vi Command - find a line but delete 2 lines above it.?

  • In Unix vi what is the command to find a line then delete a line that is 2 lines above it. For example I have a file that I have opened in vi. There are lots of occurences where something like this will happen: Config 1 Config 2 Config 3 the one I want That pattern repeats a lot through out the file. I want to fine the line that says "the one I want" but delete 2 lines above it (i.e. delete the line that says "Config 2"). Unforunately I can't just do a search and delete of a line that says "Config 2" because that occurs in other places that I want to keep it in.

  • Answer:

    jump to 'the one I want' 2k,dd and remember that recording macros in vim is dead easy. would be useful here.

razzacom at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

Like she said above. :1 <enter> (goto beginning of file) q r (begin recording macro named 'r', name must be one character) ('r' as in repeat or whatever you want) :/the one I want <enter> (search the one you want) 2kdd2j (2k: move cursor 2 lines above, dd: delete a line, 2j: move cursor 2lines below (below the one you want)) q (stop recording macro) @r (run macro named 'r' once) 100@r (run macro 'r' 100 times) Make sure not to run macro too much, otherwise it will start to delete other lines near the end of file. Gotta love Unix. Is there anything like this in Windows? Powershell maybe?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.