Text-Objects - vim's elegant function

797 views

Published on

vim の機能である Text-Objects の紹介。
kanazawa.rb meetup 18 LT 資料。

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
797
On SlideShare
0
From Embeds
0
Number of Embeds
42
Actions
Shares
0
Downloads
7
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Text-Objects - vim's elegant function

  1. 1. Text-Objects vim's elegant function 2014/02/15 - Kanazawa.rb meetup 18 LT
  2. 2. vim operation • [operator] [motion] • target = from cursor potion to motion result
  3. 3. vim operator • c : change • d : delete • y : yank • p : paste • etc ...
  4. 4. vim motion • j : next line • w : next word head • $ : line end • / : search • etc ...
  5. 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. 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. 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. 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. 9. motion only? • You can use Text-Objects
  10. 10. Text Objects • blocked chars • word, sentence, paragraph block • special char surround block • "xxx", (xxx), <xxx>, <p>xxx</p>
  11. 11. Text Objects • blocked chars • word, sentence, paragraph block • special char surround block • "xxx", (xxx), <xxx>, <p>xxx</p> Yes, corder friendly!!
  12. 12. How to use • [operator] [motion] ↓ • [operator] [text-objects specifier] • target = specified text-objects
  13. 13. specifier • [a|i][wsp])}>"'`t] • aw : a word • i> : inner > • at : a tag • etc...
  14. 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. 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. 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. 17. example 1. var superFunc = function() { 2. console.log (''); 3. $("<div>") 4. .html('<p>fancy html</p>') 5. .appendTo('.super_anchor'); 6. }; di'
  18. 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. 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. 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. 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. 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. 23. example 1. var superFunc = function() { 2. console.log ('pretty good function'); 3. $("<div>") 4. .html('abc') 5. .appendTo('.super_anchor'); 6. }; cat
  24. 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. 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. 26. Conclusion • Use "text objects" for elegant vim operation • :help text-objects
  27. 27. Thank you Tomokazu Kiyohara http://github.com/kiyohara http://facebook.com/tomokazu.kiyohara

×