Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim - ex mode command - is there any way to move the cursor position?

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)?

like image 583
Trevor Boyd Smith Avatar asked Mar 12 '10 16:03

Trevor Boyd Smith


People also ask

How do I go back to previous cursor position in vim?

Example. To jump back to line # 300 or previous position press CTRL-O (press and hold Ctrl key and press letter O). To jump back forwards press CTRL-I (press and hold Ctrl key and press letter I).

How do you move the cursor to the end of the line in vi?

Press ^ to move the cursor to the start of the current line. Press $ to move the cursor to the end of the current line.


1 Answers

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.

like image 82
Steve K Avatar answered Nov 12 '22 14:11

Steve K