Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have a file like this:

INSERT INTO `example`
(`name`, `location`, `height`)
VALUES
('A', '', ''),
('B', '', ''),
('C', '', '');

I want to fill in the middle set of quote marks (the ones under location) so that I end up with

INSERT INTO `example`
(`name`, `location`, `height`)
VALUES
('A', 'one',   ''),
('B', 'two',   ''),
('C', 'three', '');

What's a good way to do that? Aligning the third column of quotes isn't necessary, but preferred.

share|improve this question
1  
Where's the 'one,two,three' coming from? Are you typing it, pasting it, from another file, etc? –  kenny Aug 21 '12 at 17:10
    
@KennyYounger: Typing it. I'm trying to avoid having to navigate character-by-character to align my cursor with the middle column of quotes. –  Snowball Aug 21 '12 at 17:15
add comment

2 Answers

up vote 1 down vote accepted

I would suggest a similar approach to rush, but remaining more in insert mode:

/''/e lands you in between the quotes.

i one

Ctrl-o 2n

two

Ctrl-o 2n

three

Update

As for aligning the columns I would suggest using Dr. Chip's Align plugin, then a simple :'<,'>Align , would put the columns right.

share|improve this answer
    
What's /e in the first command? (Or, even better, where can I find the documentation for it?) –  Snowball Aug 21 '12 at 21:53
    
e means set cursor at the end of the match. This is the offset specification, you can go back, forward, up, and down. It's documented as search-offset. –  Thor Aug 21 '12 at 22:50
    
Comes in very handy when using the search as a motion for an operator, e.g. delete until pattern: d/pattern/-1. Or delete until pattern + 2 lines: d/pattern/2. –  Thor Aug 22 '12 at 11:19
add comment

gg # will jump to the first string

/'',Enter # will jump to the first '' occurence

a one Esc # will add one into '' into second column

W i Tab Esc # will jump to the third column and add Tab if necessary. optional step

n #this will move you to line 2

share|improve this answer
    
The n should be doubled or 2n. –  Thor Aug 21 '12 at 20:09
    
nope. As you can mention, the search pattern includes comma at the end. And it will match only the second column. Therefore I need only one n. –  rush Aug 21 '12 at 20:17
    
Ah I see, you're right. –  Thor Aug 21 '12 at 20:18
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.