0

I am trying to use visual block mode to append a , to the end of root_dir, where [] is the cursor.

lspconfig.html.setup{
  root_dir = root_di[r]
}
lspconfig.cssls.setup{
  root_dir = root_dir
}

I tried to enter visual block mode, go down until I am on another root_dir and append comma.

<c-v> 3j A ,

But then it will become this:

lspconfig.html.setup{
  root_dir = root_dir,
}                    ,
lspconfig.cssls.setup,{
  root_dir = root_dir,
}

Is it possible to achieve what I want with visual block mode? I know I can use search and replace but I want to know if there is some other alternatives.

2
  • 1
    No, Visual Block mode will not work for that, you can't use A or I from Visual Block to affect only a few of the lines... You should use a macro or similar to make these edits if you have too many to do manually. For example, to add a comma to every line with a root_dir I'd use :g/root_dir/norm A, which will do the job. :s with a pattern matching $ (end of the line) to add the comma there also an option.
    – filbranden
    May 13, 2021 at 3:26
  • 1
    :g/root_dir/norm A is really smart. Thanks May 13, 2021 at 6:43

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.