У меня есть такой блок текста:
var a = [
{"id": 1, "name": "Name 1", "description": "Description for item #1"},
{"id": 2, "name": "Name 2", "description": "Description for item #2"},
{"id": 4, "name": "Name 4", "description": "Description for item #4"},
{"id": 5, "name": "Name 5", "description": "Description for item #5"},
{"id": 6, "name": "Name 6", "description": "Description for item #6"},
{"id": 7, "name": "Name 7", "description": "Description for item #7"},
{"id": 8, "name": "Name 8", "description": "Description for item #8"},
{"id": 9, "name": "Name 9", "description": "Description for item #9"},
{"id": 10, "name": "Name 10", "description": "Description for item #10"},
{"id": 11, "name": "Name 11", "description": "Description for item #11"},
{"id": 12, "name": "Name 12", "description": "Description for item #12"},
{"id": 13, "name": "Name 13", "description": "Description for item #13"},
{"id": 14, "name": "Name 14", "description": "Description for item #14"},
{"id": 15, "name": "Name 15", "description": "Description for item #15"},
]
Я хочу добавить элемент «lastName» во все объекты-члены списка, и они должны выглядеть примерно так:
var a = [
{"id": 1, "name": "Name 1", "lastName": "Last Name 1", "description": "Description for item #1"},
{"id": 2, "name": "Name 2", "lastName": "Last Name 2", "description": "Description for item #2"},
{"id": 4, "name": "Name 4", "lastName": "Last Name 4", "description": "Description for item #4"},
{"id": 5, "name": "Name 5", "lastName": "Last Name 5", "description": "Description for item #5"},
{"id": 6, "name": "Name 6", "lastName": "Last Name 6", "description": "Description for item #6"},
{"id": 7, "name": "Name 7", "lastName": "Last Name 7", "description": "Description for item #7"},
{"id": 8, "name": "Name 8", "lastName": "Last Name 8", "description": "Description for item #8"},
{"id": 9, "name": "Name 9", "lastName": "Last Name 9", "description": "Description for item #9"},
{"id": 10, "name": "Name 10", "lastName": "Last Name 10", "description": "Description for item #10"},
{"id": 11, "name": "Name 11", "lastName": "Last Name 11", "description": "Description for item #11"},
{"id": 12, "name": "Name 12", "lastName": "Last Name 12", "description": "Description for item #12"},
{"id": 13, "name": "Name 13", "lastName": "Last Name 13", "description": "Description for item #13"},
{"id": 14, "name": "Name 14", "lastName": "Last Name 14", "description": "Description for item #14"},
{"id": 15, "name": "Name 15", "lastName": "Last Name 15", "description": "Description for item #15"},
]
мой макрос такой
:reg l
--- Registers ---
"l 0f:2lyiw2f,a "lastName": "Last Name 0",^[2hmi2F,hyiw`iviw"0p
и отлично работает в одну строку или отлично работает, если я добавляю j
для перемещения вниз в конце и работает как 14@l
.
Что я не могу сделать, так это визуально выделить все строки с помощью V
, а затем набрать :normal @l
, так как он будет работать только в первой выбранной строке (независимо от того, есть ли j
или не добавлен вконец).Как заставить его работать во всех выделенных строках?