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 non boolean options • Skimming commands
Skimming Commands • Review:
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.
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)
Skimming Commands Keycount: 2 (+1?)
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...
• Bare bones commands • Setting non boolean options • Skimming commands
Vimscript :-(
Vimscript :-(
Javascript... is sematically bad (aka it makes no sense) http://xkcd.com/1537/
Vimscript ... is syntatically bad • Which is why you should be careful! • What appears to work may not actually work!
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.
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.
Setting non boolean options • What if the option is not a boolean (requires a number/string/etc)? • General syntax: set <optionname>=<value>
Setting non boolean options • What if the option is not a boolean (requires a number/string/etc)? • General syntax: set <optionname>=<value>
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!
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?
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!
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)
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!!
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!
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?
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!
Setting non boolean options • Why? Because the 'set' command can set multiple things at the same time. In a bad way.
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'!
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.
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!
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!
Shennanigans of vimscript
Setting non boolean options • One last thing about vimscript: set <optionname>? • still works for non boolean options.
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>
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.
Skimming Commands
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.
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.
Skimming Commands Keycount: 2
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.
Skimming Commands
Skimming Commands • Summary: • Most frequently used: • <C-d>, <C-u>, • Then: • <C-e>, <C-y>, • gg, G, • zz, • <C-f>, <C-b>, • zt, zb
Skimming Commands • Use Case: • Skimming -- trying to read through text, instead of editing.
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.
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!
Recommend
More recommend