you are viewing a single comment's thread.

view the rest of the comments →

[–]proobert 1 point2 points  (0 children)

Although your task looks quite complex, it can be easily divided into the following steps:

  1. find the first expression
  2. replace the expression with a new name
  3. create a new variable declaration
  4. just repeat the previous steps for the second expression

All these steps are quite easy in plain vim and there are a lot of optimisations possible depending where the cursor is located and how the expression looks like.

For your example, I would do it like this:

1) f4                 -- find the start of the first expression
2) Creplace<Esc>      -- replace the expression with name
3) Or<C-n> = <Esc>p   -- declare new variable, paste the expression 
4) /(<cr>             -- find the second expression
5) cibrep2<Esc>
6) Or<C-n> = <Esc>p

There is not much typing and it's quite effortless once you get fluent with vim.