際際滷

際際滷Share a Scribd company logo
Text-Objects
vim's elegant function

2014/02/15 - Kanazawa.rb meetup 18 LT
vim operation

?

[operator] [motion]

?

target = from cursor potion to motion result
vim operator
?

c : change

?

d : delete

?

y : yank

?

p : paste

?

etc ...
vim motion
?

j : next line

?

w : next word head

?

$ : line end

?

/ : search

?

etc ...
example
1.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed
do eiusmod tempor incididunt ut labore et dolore magna
aliqua.

2.

Ut enim ad minim veniam, quis nostrud exercitation ullamco
laboris nisi ut aliquip ex ea commodo consequat.

3.

Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa
qui officia deserunt mollit anim id est laborum.
example
1.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed
do eiusmod tempor incididunt ut labore et dolore magna
aliqua.

2.

Ut enim ad minim veniam, quis nostrud exercitation ullamco
laboris nisi ut aliquip ex ea commodo consequat.

3.

Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa
qui officia deserunt mollit anim id est laborum.

d$
example
1.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed
do eiusmod tempor incididunt ut labore et dolore magna
aliqua.
delete

2.

Ut enim ad minim veniam, quis nostrud exercitation ullamco
laboris nisi ut aliquip ex ea commodo consequat.

3.

Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa
qui officia deserunt mollit anim id est laborum.

d$
example
1.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed
do eiusmod tempor incididunt ut labore et dolore magna
aliqua.
delete

2.

Ut enim ad

3.

Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa
qui officia deserunt mollit anim id est laborum.

d$
motion only?

?

You can use Text-Objects
Text Objects
?

blocked chars

?

word, sentence, paragraph block

?

special char surround block

?

"xxx", (xxx), <xxx>, <p>xxx</p>
Text Objects
?

blocked chars

?

word, sentence, paragraph block

?

special char surround block

?

"xxx", (xxx), <xxx>, <p>xxx</p>
Yes, corder friendly!!
How to use
?

[operator] [motion]
◎

?

[operator] [text-objects speci?er]

?

target = speci?ed text-objects
speci?er
?

[a|i][wsp])}>"'`t]

?

aw : a word

?

i> : inner >

?

at : a tag

?

etc...
example
1.

var superFunc = function() {

2.

console.log ('pretty good function');

3.

$("<div>")

4.

.html('<p>fancy html</p>')

5.

.appendTo('.super_anchor');

6.

};
example
1.

var superFunc = function() {

2.

console.log ('pretty good function');

3.

$("<div>")

4.

.html('<p>fancy html</p>')

5.

.appendTo('.super_anchor');

6.

};
example
1.

var superFunc = function() {

2.

console.log ('pretty good function');

3.

$("<div>")

4.

.html('<p>fancy html</p>')

5.

.appendTo('.super_anchor');

6.

};

di'
example
1.

var superFunc = function() {

2.

console.log ('');

3.

$("<div>")

4.

.html('<p>fancy html</p>')

5.

.appendTo('.super_anchor');

6.

};

di'
example
1.

var superFunc = function() {

2.

console.log ('pretty good function');

3.

$("<div>")

4.

.html('<p>fancy html</p>')

5.

.appendTo('.super_anchor');

6.

};
example
1.

var superFunc = function() {

2.

console.log ('pretty good function');

3.

$("<div>")

4.

.html('<p>fancy html</p>')

5.

.appendTo('.super_anchor');

6.

};

cit
example
1.

var superFunc = function() {

2.

console.log ('pretty good function');

3.

$("<div>")

4.

.html('<p>abc</p>')

5.

.appendTo('.super_anchor');

6.

};

cit
example
1.

var superFunc = function() {

2.

console.log ('pretty good function');

3.

$("<div>")

4.

.html('<p>fancy html</p>')

5.

.appendTo('.super_anchor');

6.

};

cat
example
1.

var superFunc = function() {

2.

console.log ('pretty good function');

3.

$("<div>")

include tag

4.

.html('<p>fancy html</p>')

5.

.appendTo('.super_anchor');

6.

};

cat
example
1.

var superFunc = function() {

2.

console.log ('pretty good function');

3.

$("<div>")

4.

.html('abc')

5.

.appendTo('.super_anchor');

6.

};

cat
example
1.

var superFunc = function() {

2.

console.log ('pretty good function');

3.

$("<div>")

4.

.html('<p>fancy html</p>')

5.

.appendTo('.super_anchor');

6.

};

yi}
example
1.

var superFunc = function() {

2.

console.log ('pretty good function');

3.

$("<div>")

4.

.html('<p>fancy html</p>')

5.

.appendTo('.super_anchor');

6.

};

yi}
Conclusion

?

Use "text objects" for elegant vim operation

?

:help text-objects
Thank you
Tomokazu Kiyohara
http://github.com/kiyohara
http://facebook.com/tomokazu.kiyohara

More Related Content

Viewers also liked (17)

イベント@Aのコツイベント@Aのコツ
イベント@Aのコツ
Tomokazu Kiyohara
?
Web API をデバックするときに駅勣なたったひとつのこと
Web API をデバックするときに駅勣なたったひとつのことWeb API をデバックするときに駅勣なたったひとつのこと
Web API をデバックするときに駅勣なたったひとつのこと
Tomokazu Kiyohara
?
Google Cloud Platform を屶える室g ´のごく匯何
Google Cloud Platform を屶える室g ´のごく匯何Google Cloud Platform を屶える室g ´のごく匯何
Google Cloud Platform を屶える室g ´のごく匯何
Tomokazu Kiyohara
?
JavaScript で OS X を徭啣掀
JavaScript で OS X を徭啣掀JavaScript で OS X を徭啣掀
JavaScript で OS X を徭啣掀
Tomokazu Kiyohara
?
雨皆意檎掘粥珂の篇楕を貧げよう
雨皆意檎掘粥珂の篇楕を貧げよう雨皆意檎掘粥珂の篇楕を貧げよう
雨皆意檎掘粥珂の篇楕を貧げよう
Tomokazu Kiyohara
?
Planning
PlanningPlanning
Planning
stoner84
?
Zen coding15min
Zen coding15minZen coding15min
Zen coding15min
Tomokazu Kiyohara
?
Beginner's Sinatra
Beginner's SinatraBeginner's Sinatra
Beginner's Sinatra
Tomokazu Kiyohara
?
サイバ`好張▲薊`トシステム ^DAEDALUS ̄┘瀬ぅ瀬蹈坑のB初
サイバ`好張▲薊`トシステム ^DAEDALUS ̄┘瀬ぅ瀬蹈坑のB初サイバ`好張▲薊`トシステム ^DAEDALUS ̄┘瀬ぅ瀬蹈坑のB初
サイバ`好張▲薊`トシステム ^DAEDALUS ̄┘瀬ぅ瀬蹈坑のB初
Tomokazu Kiyohara
?
????????????????????
????????????????????????????????????????
????????????????????
supawadee13
?
こわくないプルリク
こわくないプルリクこわくないプルリク
こわくないプルリク
Tomokazu Kiyohara
?
Github's HUB
Github's HUBGithub's HUB
Github's HUB
Tomokazu Kiyohara
?
苧晩から聞えるコ`ディングツ`ル
苧晩から聞えるコ`ディングツ`ル苧晩から聞えるコ`ディングツ`ル
苧晩から聞えるコ`ディングツ`ル
Tomokazu Kiyohara
?
LiveStyle for Vim - Quick start
LiveStyle for Vim - Quick startLiveStyle for Vim - Quick start
LiveStyle for Vim - Quick start
Tomokazu Kiyohara
?
Compact Web - Remind "web compression" -
Compact Web - Remind "web compression" -Compact Web - Remind "web compression" -
Compact Web - Remind "web compression" -
Tomokazu Kiyohara
?
イベント@Aのコツイベント@Aのコツ
イベント@Aのコツ
Tomokazu Kiyohara
?
Web API をデバックするときに駅勣なたったひとつのこと
Web API をデバックするときに駅勣なたったひとつのことWeb API をデバックするときに駅勣なたったひとつのこと
Web API をデバックするときに駅勣なたったひとつのこと
Tomokazu Kiyohara
?
Google Cloud Platform を屶える室g ´のごく匯何
Google Cloud Platform を屶える室g ´のごく匯何Google Cloud Platform を屶える室g ´のごく匯何
Google Cloud Platform を屶える室g ´のごく匯何
Tomokazu Kiyohara
?
JavaScript で OS X を徭啣掀
JavaScript で OS X を徭啣掀JavaScript で OS X を徭啣掀
JavaScript で OS X を徭啣掀
Tomokazu Kiyohara
?
雨皆意檎掘粥珂の篇楕を貧げよう
雨皆意檎掘粥珂の篇楕を貧げよう雨皆意檎掘粥珂の篇楕を貧げよう
雨皆意檎掘粥珂の篇楕を貧げよう
Tomokazu Kiyohara
?
サイバ`好張▲薊`トシステム ^DAEDALUS ̄┘瀬ぅ瀬蹈坑のB初
サイバ`好張▲薊`トシステム ^DAEDALUS ̄┘瀬ぅ瀬蹈坑のB初サイバ`好張▲薊`トシステム ^DAEDALUS ̄┘瀬ぅ瀬蹈坑のB初
サイバ`好張▲薊`トシステム ^DAEDALUS ̄┘瀬ぅ瀬蹈坑のB初
Tomokazu Kiyohara
?
????????????????????
????????????????????????????????????????
????????????????????
supawadee13
?
苧晩から聞えるコ`ディングツ`ル
苧晩から聞えるコ`ディングツ`ル苧晩から聞えるコ`ディングツ`ル
苧晩から聞えるコ`ディングツ`ル
Tomokazu Kiyohara
?
LiveStyle for Vim - Quick start
LiveStyle for Vim - Quick startLiveStyle for Vim - Quick start
LiveStyle for Vim - Quick start
Tomokazu Kiyohara
?
Compact Web - Remind "web compression" -
Compact Web - Remind "web compression" -Compact Web - Remind "web compression" -
Compact Web - Remind "web compression" -
Tomokazu Kiyohara
?

Text-Objects - vim's elegant function

  • 2. vim operation ? [operator] [motion] ? target = from cursor potion to motion result
  • 3. vim operator ? c : change ? d : delete ? y : yank ? p : paste ? etc ...
  • 4. vim motion ? j : next line ? w : next word head ? $ : line end ? / : search ? etc ...
  • 5. example 1. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. 2. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. 3. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
  • 6. example 1. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. 2. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. 3. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. d$
  • 7. example 1. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. delete 2. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. 3. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. d$
  • 8. example 1. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. delete 2. Ut enim ad 3. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. d$
  • 9. motion only? ? You can use Text-Objects
  • 10. Text Objects ? blocked chars ? word, sentence, paragraph block ? special char surround block ? "xxx", (xxx), <xxx>, <p>xxx</p>
  • 11. Text Objects ? blocked chars ? word, sentence, paragraph block ? special char surround block ? "xxx", (xxx), <xxx>, <p>xxx</p> Yes, corder friendly!!
  • 12. How to use ? [operator] [motion] ◎ ? [operator] [text-objects speci?er] ? target = speci?ed text-objects
  • 13. speci?er ? [a|i][wsp])}>"'`t] ? aw : a word ? i> : inner > ? at : a tag ? etc...
  • 14. example 1. var superFunc = function() { 2. console.log ('pretty good function'); 3. $("<div>") 4. .html('<p>fancy html</p>') 5. .appendTo('.super_anchor'); 6. };
  • 15. example 1. var superFunc = function() { 2. console.log ('pretty good function'); 3. $("<div>") 4. .html('<p>fancy html</p>') 5. .appendTo('.super_anchor'); 6. };
  • 16. example 1. var superFunc = function() { 2. console.log ('pretty good function'); 3. $("<div>") 4. .html('<p>fancy html</p>') 5. .appendTo('.super_anchor'); 6. }; di'
  • 17. example 1. var superFunc = function() { 2. console.log (''); 3. $("<div>") 4. .html('<p>fancy html</p>') 5. .appendTo('.super_anchor'); 6. }; di'
  • 18. example 1. var superFunc = function() { 2. console.log ('pretty good function'); 3. $("<div>") 4. .html('<p>fancy html</p>') 5. .appendTo('.super_anchor'); 6. };
  • 19. example 1. var superFunc = function() { 2. console.log ('pretty good function'); 3. $("<div>") 4. .html('<p>fancy html</p>') 5. .appendTo('.super_anchor'); 6. }; cit
  • 20. example 1. var superFunc = function() { 2. console.log ('pretty good function'); 3. $("<div>") 4. .html('<p>abc</p>') 5. .appendTo('.super_anchor'); 6. }; cit
  • 21. example 1. var superFunc = function() { 2. console.log ('pretty good function'); 3. $("<div>") 4. .html('<p>fancy html</p>') 5. .appendTo('.super_anchor'); 6. }; cat
  • 22. example 1. var superFunc = function() { 2. console.log ('pretty good function'); 3. $("<div>") include tag 4. .html('<p>fancy html</p>') 5. .appendTo('.super_anchor'); 6. }; cat
  • 23. example 1. var superFunc = function() { 2. console.log ('pretty good function'); 3. $("<div>") 4. .html('abc') 5. .appendTo('.super_anchor'); 6. }; cat
  • 24. example 1. var superFunc = function() { 2. console.log ('pretty good function'); 3. $("<div>") 4. .html('<p>fancy html</p>') 5. .appendTo('.super_anchor'); 6. }; yi}
  • 25. example 1. var superFunc = function() { 2. console.log ('pretty good function'); 3. $("<div>") 4. .html('<p>fancy html</p>') 5. .appendTo('.super_anchor'); 6. }; yi}
  • 26. Conclusion ? Use "text objects" for elegant vim operation ? :help text-objects