Move the cursor to another word (say "third"). Repeat the operation (change word and replace it with "first"). Move the cursor to another word and press . to repeat the change. Yank inner text (text containing cursor which is in quotes).
Use c$ or just C to quickly change from the cursor to the end of a line, cc to change an entire line, or cis for a sentence. The standard change word command requires you to type cw , then a new word, then press Escape.
To search in the current file, you just need to type / in normal mode. Then, you need to type your search pattern, press enter , and the result becomes highlighted in your file. To go backward and forward through the results, you can type n and N (for n ext) respectively. Using / will search forward in the file.
Press y to replace the match or l to replace the match and quit. Press n to skip the match and q or Esc to quit substitution. The a option substitutes the match and all remaining occurrences of the match. To scroll the screen down, use CTRL+Y , and to scroll up, use CTRL+E .
Vp
: select line, paste what was yanked
What I would do :
aG
Y
xG
Vp
You don't have to leave normal mode, but it does yank the line. You can however use V"0p
which will always put the line yanked in step 2.
This has the additional disadvantage that line X is now in the default register, which is annoying if I find another line that should be replaced with A.
To delete text without affecting the normal registers, you can use the Black hole register "_
:
"_dd
Building on the answers that suggest using Vp
or VP
to paste over a line -- to avoid changing the contents of the yank register I find the most ergonomic command is simply:
VPY
I would use commandline (Ex) mode and do the following two commands
:XmA
:Ad
This simply moves line X to just under A, then deleting A moves that line up
For example
:7m3
:3d
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With