Closed bogdan0083 closed 7 years ago
"newProp": true
to each of properties.Sample text:
{
"groupId": "11488395",
"likePosts": false,
"likeComments": true,
"writeComments": false,
"doRepost": false,
"postsToProcess": 10,
"chanceToLikeComment": 0,
"chanceToRepost": 0.1,
"postDelay": 100000
},
{
"groupId": "1345287283",
"likePosts": false,
"likeComments": true,
"writeComments": false,
"doRepost": false,
"postsToProcess": 10,
"chanceToLikeComment": 0,
"chanceToRepost": 0.1,
"postDelay": 100000
}
g o cmd-a I cmd-e enter
then insert new prop.g o I cmd-a cmd-e enter
then insert new prop.( require enabling keymapIAndAToInsertAtTargetWhenHasOccurrence
).g cmd-d cmd-a I cmd-e enter
then insert new prop.g o cmd-a cmd-d escape o
then insert new prop.g o cmd-a enter I
then insert new prop.( require enabling keymapIAndAToInsertAtTargetWhenHasOccurrence
) using persistent-selection
feat.You can replace cmd-a part to v i e
or v a e
(omit v
based on context).
For cmd-e enter
part, you can use cmd-enter
(editor:newline-blow
) unless some pkg overwrite this atom's default keymap.
FYI: I remap m
for g o
, and M
for g O
, since I use occurrence
a lot, but don't use mark
.
So, my answer would be m cmd-a I cmd-enter
then insert new prop.
But in that step, you use c o p to change each occurence. Do we have a command to add cursor for each occurence?
Direct answer for this is vim-mode-plus:select-occurrence
.
g cmd-d
in normal-mode
cmd-d
in visual-mode
By default enter
in visual-mode
is mapped to vim-mode-plus:create-persistent-selection
.
But if you don't use persistent-selection
feature(I don't use than I though initially), you can remap enter
like this in your keymap.cson
.
And also remap m
and M
.
'atom-text-editor.vim-mode-plus.visual-mode.is-narrowed':
'enter': 'vim-mode-plus:select-occurrence'
'atom-text-editor.vim-mode-plus.normal-mode, atom-text-editor.vim-mode-plus.visual-mode':
'm': 'vim-mode-plus:toggle-preset-occurrence'
'M': 'vim-mode-plus:toggle-preset-subword-occurrence'
Then keystroke flow get really simple.
Answer: m cmd-a enter
.
Answer:
m cmd-a enter
.
@t9md Holy Molly, it worked! Thank you very much. Learn something new everyday with vmp :smile:
You don't need cool IDE for refactoring features if know how to use preset-occurence + narrow plugin. Crazy stuff! :+1:
Closing
You don't need cool IDE for refactoring features if know how to use preset-occurence + narrow plugin. Crazy stuff! 👍
Yah! that's what I wanted. Preset-occurrence is technically marker-edit(mark > select-target > apply operator). It's general-purpose fundamental building-block of your advanced editing, it's not depends on language grammar, not depending of analysis of language semantics, thus always available!
After some experimenting/evaluating different way I explained in original answer section.
Here is current my conclusion for "recommended keystroke".
m cmd-a I escape o
then enter new prop.
(Provided having 'm': 'vim-mode-plus:toggle-preset-occurrence'
keymap.)Why I recommend this is, this is a pattern you can use in variety of situation.
No need to remember/master situation specific keymap like m cmd-a enter
.
The pattern appar here is.
m
cmd-a
here).I
to insert start of target, user A
to insert at end of target).escape
to return normal-mode
.(clearMultipleCursorsOnEscapeInsertMode
setting should be false
for this pattern to work).Why this is good is, you can use this pattern for delete
, change
, insert text.
Thus most general-purpose.
I want to remember/use small set of pattern which is usable in many situation than remembering different situation specific keymap.
Here is current my conclusion for "recommended keystroke".
m cmd-a I
escape o then enter new prop. (Provided having 'm': 'vim-mode-plus:toggle-preset-occurrence' keymap.)
@t9md this combination doesn't work on Ubuntu actually and i think the problem is on the 2nd step:
- select target (
cmd-a
here).
cmd-a is mapped to vim-mode-plus:inner-entire
(the same as i e
) so it should probably be used after vim-mode-plus:select-occurrence
, otherwise it doesn't work for me
I've also noticed that vim-mode-plus:select-occurrence
is mapped to g cmd-d
which works only on Mac i guess. I cannot reproduce g cmd-d
on Linux. (maybe is it just me, i don't know). I checked default keymap and didn't found an alias for g cmd-d
(for those who don't have cmd key).
If i add custom mapping like this:
'g d': 'vim-mode-plus:select-occurrence'
i can do m g d i e I escape o
and it does the same stuff as m cmd-a I escape o
select target (cmd-a here). cmd-a is mapped to vim-mode-plus:inner-entire (the same as i e) so it should probably be used after vim-mode-plus:select-occurrence, otherwise it doesn't work for me
cmd-a
here is executed in normal-mode
(not mapped to inner-entire
in this mode) and invoke core:select-all
(vmp auto-start visual-mode
by detecting selection change).
In your Linux environment, ctrl-a
is mapped to core:select-all
, but its conflicting with vim-mode-plus:increase
, that's why not working in your environment.
Adding yet another answer based on upcoming v1.8.0.
When keymapSToSelect
enabled(which makes s
work as select
operator).
s o i e escape o
:
s o
) in inner-entire
(i e
) and escape
to normal-mode
, then o
i e
(inner-entire
) can be replaceable with shorter keystroke available in operator-pending-mode
cmd-a
(full keystroke would be s o cmd-a escape o
)ctrl-a
(full keystroke would be s o ctrl-a escape o
)Or user preset-occurrence
like this.
g o s i e escape o
: preset-occurrence(m
) then select inner-entire
and escape
to normal-mode
, then o
Hello! I've been looking at 5th step in advanced tutorial and found that preset occurence one of the best things i use every day in mvp.
But in that step, you use
c o p
to change each occurence. Do we have a command to add cursor for each occurence?Real example:
Let's say we have a long json file with many objects (about 100 objects with the same properties):
And we decided to add new property to each object. We can set cursor on
likePosts
property, pressg o
and then we can usec a e
and get something like this:We have our cursors, and we could use
o
to go on line below and add new property, but as you can see we have our property changed, so we need to writelikePosts
before going on line below.It would be awesome to have some command that only add cursor on each occurence and doesn't change/deletes/yanks anything, like this:
It's probably very easy to do, but i can't find any info how to do it quickly with mvp
Thanks! :)