7

In a one line Vim ex command:

I am trying to do a command and then move to another location and execute the same command.

is there any way to move the cursor position (need both left/right and up/down)?

Trevor Boyd Smith
  • 18,164
  • 32
  • 127
  • 177

2 Answers2

9

The '|' is the command separator in Vim scripts.

:command the_first | second command

executes two commands.

There is also the :normal command which allows you to execute normal mode commands, like motion commands, from the Ex command line. So maybe you can do something like

:/pat.*$/d | exec "normal 32G5w" | /pat.*$/d

There's probably an easier way to do what you're trying to do, however, if you can be more specific.

Zenexer
  • 18,788
  • 9
  • 71
  • 77
Steve K
  • 2,124
  • 16
  • 19
  • Normal does not allow to use another commands after it, so you will have to use `:execute`. And you do not have closing `/` in substitute. – ZyX Mar 12 '10 at 18:10
  • @ZyX You don't need to close a substitute unless you're adding flags. – Zenexer Jun 11 '13 at 05:52
  • @Zenexer You do have to close the `:substitute` though, since there are more commands coming afterwards. – glts Jun 11 '13 at 17:19
  • @glts Interesting. vim is one thing that I can never quite seem to conquer. – Zenexer Jun 11 '13 at 22:22
2

Your question is not completely clear but I think you mean to use recording. I hope you know h,j,k,l movement commands. Try this:

    <goto command mode>
    qa
    i
    dddd
    <esc>
    j
    q
    @a

qa is the command to start recording in the buffer a. q is used to stop recording. You can use the buffer a by @a. Also try 10@a to do the operation 10 times.

amit kumar
  • 20,438
  • 23
  • 90
  • 126