motions and visual mode
play

Motions and Visual Mode Part II Core Commands The World as Everyone - PowerPoint PPT Presentation

Lecture 7: Text Objects, Motions and Visual Mode Part II Core Commands The World as Everyone Else Sees it The World as Everyone Else Sees it The World as Everyone Else Sees it The World as Everyone Else Sees it Other editors see text as a


  1. Lecture 7: Text Objects, Motions and Visual Mode Part II Core Commands

  2. The World as Everyone Else Sees it

  3. The World as Everyone Else Sees it

  4. The World as Everyone Else Sees it

  5. The World as Everyone Else Sees it Other editors see text as a string of characters

  6. The World as Everyone Else Sees it Other editors see text as a string of characters

  7. The World as Everyone Else Sees it Other "editors" see text as a string of characters

  8. The World as Vim Sees It

  9. The World as Vim Sees It

  10. The World as Vim Sees It

  11. The World as Vim Sees It Vim (and you) see text as a sequence of objects.

  12. • Editing Commands • Text Objects • Motions • Visual Mode

  13. • Editing Commands • Text Objects • Motions • Visual Mode

  14. If you still recall.... • Editing...

  15. If you still recall.... • Editing... – is the process of making changes to text. • Hence, we have editing commands.

  16. If you still recall.... • Editing... – is the process of making changes to text. • Hence, we have editing commands. • Focus of today: the c and d commands (and the like)!

  17. If you still recall.... • Editing... – is the process of making changes to text. • Hence, we have editing commands. • Focus of today: the c and d commands (and the like)! • Focus of next lecture: the i and a commands for inserting/drafting, along with a rehash of the /<pattern><CR> , and f<char> commands.

  18. Editing Commands c<object> • Change <object> under current cursor to... (goes to insert mode). d<object> • Delete <object> under cursor. • Main focus of today!

  19. Other editing commands • Are still important. • Follow pretty much the same syntax/principles. • Every editing command can be repeated with the dot command!

  20. Other editing commands y<object> • Yanks <object> under current cursor to register. =<object> • Reformats code for <objects> under current cursor.

  21. Other editing commands gu/gU<object> • Decapitalize/Capitalize <object> under current cursor. >/<<object> • Indent/Dedent for <objects> under current cursor.

  22. Other editing commands (from plugins) gc<object> • Comment <object> under current cursor. • From vim-commentary by Tim Pope. cs/ds<object> • Change/Delete surrounding for <objects> under current cursor. • From vim-surround by Tim Pope.

  23. And then there are others • Other commands that do not follow this format: • Single Character Commands. • Special Purpose Commands. • And others that don't even categorize to these... • Not the focus of today!

  24. Today: Editing Commands c<object> • Change <object> under current cursor to... (goes to insert mode). d<object> • Delete <object> under cursor.

  25. • Editing Commands • Text Objects • Motions • Visual Mode

  26. Text Objects • Vim sees the world as inherently composed of objects.

  27. Text Objects • Vim sees the world as inherently composed of objects. • They are: – The most important part of Vim's commands that you NEED TO KNOW on top of your head.

  28. Text Objects • Vim sees the world as inherently composed of objects. • They are: – The most important part of Vim's commands that you NEED TO KNOW on top of your head. – Most used part of Vim's commands.

  29. Text Objects • Vim sees the world as inherently composed of objects. • They are: – The most important part of Vim's commands that you NEED TO KNOW on top of your head. – Most used part of Vim's commands. – You should be using them almost all of the time, unless you are not describing an object.

  30. Fundamental Objects: #1 word and WORD

  31. Fundamental Objects: #1 word and WORD • Probably one of the most confusing parts of Vim.

  32. Fundamental Objects: #1 word and WORD • Probably one of the most confusing parts of Vim. • A word is... an almost C-Style variable name.

  33. Fundamental Objects: #1 word and WORD • Probably one of the most confusing parts of Vim. • A word is... an almost C-style variable name. – A consecutive string of characters containing only of letters, digits and underscores.

  34. Fundamental Objects: #1 word and WORD • Probably one of the most confusing parts of Vim. • A word is... an almost C-style variable name. – A consecutive string of characters containing only of letters, digits and underscores. – Can be modified through the 'iskeyword' option, if you are working with a language that has slightly different specification of variable names! – They are meant to indicate variable name and values!

  35. Fundamental Objects: #1 word and WORD

  36. Fundamental Objects: #1 word and WORD l_list is a word! (variable name)

  37. Fundamental Objects: #1 word and WORD NULL is a word! (variable value)

  38. Fundamental Objects: #1 word and WORD • Why word? • Do the following: change variable name, function name, change values, fix variable/function name typos...

  39. Fundamental Objects: #1 word and WORD • Why word? • Do the following: change variable name, function name, change values, fix variable/function name typos... • Without having to retype everything in that WORD! (convenience)

  40. Fundamental Objects: #1 word and WORD • Probably one of the most confusing parts of Vim. • A word is... an almost C-Style variable name. • A WORD is... what unix standard thinks is a word (lol).

  41. Fundamental Objects: #1 word and WORD • Probably one of the most confusing parts of Vim. • A word is... an almost C-Style variable name. • A WORD is... what unix standard thinks is a word (lol). – A sequence of characters delimited by any kind of whitespace characters .

  42. Fundamental Objects: #1 word and WORD l_list->next is a WORD!

  43. Fundamental Objects: #1 word and WORD • Why WORD? • Do the following: making phrasal changes such as email addresses (with @'s and .'s), fixing completely wrong variables or structures... • Entirely different purpose.

  44. Fundamental Objects #1 word and WORD • So how to express a word or WORD object?

  45. Fundamental Objects #1 word and WORD • So how to express a word or WORD object? • Before that: • Text objects (generally) come in two different flavors!

  46. Two flavors of text objects • Two flavors: 1.i - also known as "inside" 2.a - also known as "around"

  47. Fundamental Objects #1 word and WORD • What does it mean to be "inside" a word/WORD, or "around" a word/WORD?

  48. Fundamental Objects #1 word and WORD • What does it mean to be "inside" a word/WORD, or "around" a word/WORD? "inside" a word means the word itself . iw

  49. Fundamental Objects #1 word and WORD • What does it mean to be "inside" a word/WORD, or "around" a word/WORD? "around" a word means the word itself + a succeding space . aw

  50. Fundamental Objects #1 word and WORD • iw - inside word. • aw - around word. • iW - inside WORD. • aW - around WORD.

  51. Fundamental Objects #1 word and WORD • iw - inside word. • aw - around word. • iW - inside WORD. • aW - around WORD. • Why do we care?

  52. Fundamental Objects #1 word and WORD • iw - inside word. • aw - around word. • iW - inside WORD. • aW - around WORD. • Why do we care?

  53. Fundamental Objects #1 word and WORD • Compare: diw

  54. Fundamental Objects #1 word and WORD • Compare: daw

  55. Fundamental Objects #1 word and WORD • Compare: ciwlot<Esc>

  56. Fundamental Objects #1 word and WORD • Compare: cawlot<Esc>

  57. Fundamental Objects: #1 word and WORD • Vim allow you to express precisely what you want to do! • When you are deleting a word, do you want to preserve the space after the word? Or do you want to delete it? • When you are changing a word, do you want to change the space after the word as well? Or are you okay with leaving it as-is?

  58. Fundamental Objects: #1 word and WORD • Is this an issue?

  59. Fundamental Objects: #1 word and WORD • Is this an issue? – If you are editing prose, generally NO! • Too much thinking? • When you are deleting a word, you probably want to delete the whitespace after it, otherwise there might be duplicate spaces. • When you are changing a word, you probably don't need to change the space after it.

  60. Fundamental Objects #1 word and WORD • Hence, make this your muscle memory! da ci

  61. Fundamental Objects #1 word and WORD • Hence, make this your muscle memory! da ci • Note: depending on language, may not apply to programming! • Figure out your language style conventions, and make it a habit!

  62. Fundamental Objects #2 enclosed objects • "strings" • (cons (1 nil)) • {document} • etc... • Are wrapped with matching characters: "", (), [], {}, even html tags!

  63. Fundamental Objects #2 enclosed objects • General syntax for <enclosed object>: • i<closing delimiter> • a<closing delimiter>

  64. Fundamental Objects #2 enclosed objects • Example:

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend