Reputation: 582
While I mostly use Sublime Text (with the Vintageous plugin) I'm trying to adopt Vim-style practices into my workflow. As you might expect, I'd like to learn how to more quickly jump around a document to edit its content.
For example, let's say I want to jump around and edit the ID values in a JSON file or perhaps jump from the first line of the document down to edit the first name of Gale Gomez.
I understand some of the basic commands like 'change inside quotes' (ci") or 'change word' (cw), I'm hoping to get better at page navigation.
Thoughts or suggestions?
{
"id": 5,
"firstName": "Jayne",
"lasttName": "Norris",
"email": "[email protected]"
},
{
"id": 6,
"firstName": "Gale",
"lasttName": "Gomez",
"email": "[email protected]"
},
{
"id": 7,
"firstName": "Garner",
"lasttName": "Crane",
"email": "[email protected]"
},
{
"id": 7,
"firstName": "Gill",
"lasttName": "Carter",
"email": "[email protected]"
},
{
"id": 8,
"firstName": "Evans",
"lasttName": "Douglas",
"email": "[email protected]"
}
Upvotes: 2
Views: 123
Reputation: 926
And don't forget *
to search the word under the cursor (for example id
in your case), then n
for next occurrence, N
for previous occurrence.
#
is the same as *
, only it searches backward. Actually, I never use that.
If you press /
and then <UP>
and <DOWN>
, then <CR>
, you can select and repeat one of your previous searches.
And sometimes when a search hits the last line of the window you may wish to type zz
to scroll the window so that the current line will be in the middle of it and you will see some lines below.
Also, you can press %
while over an opening/closing parenthesis to jump to the corresponding closing/opening parenthesis.
Upvotes: 1
Reputation: 20276
To jump to the next ID and edit it:
/"id<return>3wcw
(searches for string "id, goes forward 3 words, then edits the next word, which is the ID's value)
To edit another ID:
n3wcw
(repeats the last search with “n”, then same as before)
Go to the first line of the document:
gg
Change first name of Gale Gomez:
/Gale<return>cw
(searches for “Gale”, then edits it)
Upvotes: 4