lecture 6 wrap up
play

Lecture 6: Wrap Up Part II Core Commands Quick Review! vim flags - PowerPoint PPT Presentation

Lecture 6: Wrap Up Part II Core Commands Quick Review! vim flags :e <filenames><CR> :w <filename><CR> :wa<CR> :qa<CR> :qa!<CR> :xa<CR> Bare bones commands Setting


  1. Lecture 6: Wrap Up Part II Core Commands

  2. Quick Review! • vim flags • :e <filenames><CR> • :w <filename><CR> • :wa<CR> • :qa<CR> • :qa!<CR> • :xa<CR>

  3. • Bare bones commands • Setting non boolean options • Skimming commands

  4. Skimming Commands • Review:

  5. Skimming Commands • Review: • Skimming -- don't know about the contents of the file previously. Want to read the file. Have not yet decided to edit the file. • Hence, skimming commands are normal mode commands.

  6. Skimming Commands • Most important skimming commands: • <C-d> : scroll half page down • <C-u> : scroll half page up • by default • This is unix standard. (less)

  7. Skimming Commands Keycount: 2 (+1?)

  8. Skimming Commands • Most important skimming commands: • <C-d> : scroll half page down • <C-u> : scroll half page up • by default • If your font is small, half page may be too fast. This is customizable. But before that...

  9. • Bare bones commands • Setting non boolean options • Skimming commands

  10. Vimscript :-(

  11. Vimscript :-(

  12. Javascript... is sematically bad (aka it makes no sense) http://xkcd.com/1537/

  13. Vimscript ... is syntatically bad • Which is why you should be careful! • What appears to work may not actually work!

  14. Vimscript ... is syntatically bad • Which is why you should be careful! • What appears to work may not actually work! • For this course, you will have to know some of Vimscript's syntatic gotchas... • Because many people make these mistakes.

  15. Review of setting boolean options set <optionname> • sets a boolean option to true set no<optionname> • sets a boolean option to false set <optionname>? • queries whether a boolean option is set or not.

  16. Setting non boolean options • What if the option is not a boolean (requires a number/string/etc)? • General syntax: set <optionname>=<value>

  17. Setting non boolean options • What if the option is not a boolean (requires a number/string/etc)? • General syntax: set <optionname>=<value>

  18. Setting non boolean options • What if the option is not a boolean (requires a number/string/etc)? • General syntax: set <optionname>=<value> • Ex. set background=dark • Is this correct? Yes!

  19. Setting nonboolean options • What if the option is not a boolean (requires a number/string/etc)? • General syntax: set <optionname>=<value> • Ex. set background="dark" • Is this correct?

  20. Setting nonboolean options • What if the option is not a boolean (requires a number/string/etc)? • General syntax: set <optionname>=<value> • Ex. set background="dark" • Is this correct? Uh... sometimes!

  21. Setting non boolean options • When you are in a session of Vim, and entering as ex command, it will work. • When it is written and loaded as vimscript, it may or may not work. • (version dependent)

  22. Setting non boolean options • When you are in a session of Vim, and entering as ex command, it will work. • When it is written and loaded as vimscript, it may or may not work. • Why? • " indicates a start of a comment!!

  23. Setting non boolean options • When you are in a session of Vim, and entering as ex command, it will work. • When it is written and loaded as vimscript, it may or may not work. • Why? • " indicates a start of a comment!! • Moral of the story: when setting options, do not use "" for strings!

  24. Setting non boolean options • What if the option is not a boolean (requires a number/string/etc)? • General syntax: set <optionname>=<value> • Ex. set background = dark • Is this correct?

  25. Setting non boolean options • What if the option is not a boolean (requires a number/string/etc)? • General syntax: set <optionname>=<value> • Ex. set background = dark • Is this correct? NO!

  26. Setting non boolean options • Why? Because the 'set' command can set multiple things at the same time. In a bad way.

  27. Setting non boolean options • Why? Because the 'set' command can set multiple things at the same time. In a bad way. set ignorecase nohlsearch • sets both 'ignorecase' and 'nohlsearch'!

  28. Setting non boolean options • Why? Because the 'set' command can set multiple things at the same time. In a bad way. set ignorecase nohlsearch • sets both 'ignorecase' and 'nohlsearch'! • Therefore: set background = dark • sets 'background', '=' and 'dark' to true.

  29. Setting non boolean options • Why? Because the 'set' command can set multiple things at the same time. In a bad way. set ignorecase nohlsearch • sets both 'ignorecase' and 'nohlsearch'! • Therefore: set background = dark • sets 'background', '=' and 'dark' to true. • Moral of the story? Do not put spaces between '='s in set commands!

  30. Setting non boolean options • Why? Because the 'set' command can set multiple things at the same time. In a bad way. set ignorecase nohlsearch • sets both 'ignorecase' and 'nohlsearch'! • Therefore: set background = dark • sets 'background', '=' and 'dark' to true. • Moral of the story? Do not put spaces between '='s in set commands!

  31. Shennanigans of vimscript

  32. Setting non boolean options • One last thing about vimscript: set <optionname>? • still works for non boolean options.

  33. Skimming Commands • Most important skimming commands: • <C-d> : scroll half page down • <C-u> : scroll half page up • by default • set scroll=10 • " These two commands will scroll 10 lines at a time. Put this in vimrc. • :h scroll<CR>

  34. Skimming Commands • Other skimming commands: • <C-e> : scroll 1 line down • <C-y> : scroll 1 line up • ... if you just want to scroll little by little... • This is unix standard.

  35. Skimming Commands

  36. Skimming Commands • <C-f> : full page down • <C-b> : full page up • This is unix standard. • If you REALLY are in a hurry. • Probably won't use it much.

  37. Skimming Commands • gg : go to top of document • G : go to bottom of document • Somewhat follows unix standard... • Surprisingly useful for editing (visual mode). Used for skimming as well.

  38. Skimming Commands Keycount: 2

  39. Skimming Commands • One last class of skimming commands: • Positioning commands: • zz -- Center screen • zt -- Adjust screen s.t. cursor is at top • zb -- Adjust screen s.t. cursor is at bottom. • Used most frequently with insert- normal mode.

  40. Skimming Commands

  41. Skimming Commands • Summary: • Most frequently used: • <C-d>, <C-u>, • Then: • <C-e>, <C-y>, • gg, G, • zz, • <C-f>, <C-b>, • zt, zb

  42. Skimming Commands • Use Case: • Skimming -- trying to read through text, instead of editing.

  43. Skimming Command (Extra) • gg : move to top of document • G : move to bottom of document • Primarily for relocation. • Sometimes used before recording macro for edit sanity.

  44. Next Time • Text Objects, Motions and Visual Mode. • (aka, how to edit text. The editing process). • Very IMPORTANT lecture! • Memorize these commands through finger memory! • Understand the shennanigans of Vimscript!

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