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

lecture 6 wrap up
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

Lecture 6: Wrap Up

Part II Core Commands

slide-2
SLIDE 2

Quick Review!

  • vim flags
  • :e <filenames><CR>
  • :w <filename><CR>
  • :wa<CR>
  • :qa<CR>
  • :qa!<CR>
  • :xa<CR>
slide-3
SLIDE 3
  • Bare bones commands
  • Setting non boolean options
  • Skimming commands
slide-4
SLIDE 4

Skimming Commands

  • Review:
slide-5
SLIDE 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.

slide-6
SLIDE 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)
slide-7
SLIDE 7

Skimming Commands

Keycount: 2 (+1?)

slide-8
SLIDE 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...

slide-9
SLIDE 9
  • Bare bones commands
  • Setting non boolean options
  • Skimming commands
slide-10
SLIDE 10

Vimscript

:-(

slide-11
SLIDE 11

Vimscript

:-(

slide-12
SLIDE 12

Javascript... is sematically bad (aka it makes no sense)

http://xkcd.com/1537/

slide-13
SLIDE 13

Vimscript ... is syntatically bad

  • Which is why you should be careful!
  • What appears to work may not actually

work!

slide-14
SLIDE 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.

slide-15
SLIDE 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
  • r not.
slide-16
SLIDE 16

Setting non boolean options

  • What if the option is not a boolean

(requires a number/string/etc)?

  • General syntax:

set <optionname>=<value>

slide-17
SLIDE 17

Setting non boolean options

  • What if the option is not a boolean

(requires a number/string/etc)?

  • General syntax:

set <optionname>=<value>

slide-18
SLIDE 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!
slide-19
SLIDE 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?
slide-20
SLIDE 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!
slide-21
SLIDE 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)
slide-22
SLIDE 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!!
slide-23
SLIDE 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
  • ptions, do not use "" for strings!
slide-24
SLIDE 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?
slide-25
SLIDE 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!
slide-26
SLIDE 26

Setting non boolean options

  • Why? Because the 'set' command can

set multiple things at the same time. In a bad way.

slide-27
SLIDE 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'!
slide-28
SLIDE 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.

slide-29
SLIDE 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!

slide-30
SLIDE 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!

slide-31
SLIDE 31

Shennanigans of vimscript

slide-32
SLIDE 32

Setting non boolean options

  • One last thing about vimscript:

set <optionname>?

  • still works for non boolean options.
slide-33
SLIDE 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>
slide-34
SLIDE 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.
slide-35
SLIDE 35

Skimming Commands

slide-36
SLIDE 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.
slide-37
SLIDE 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.

slide-38
SLIDE 38

Skimming Commands

Keycount: 2

slide-39
SLIDE 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.

slide-40
SLIDE 40

Skimming Commands

slide-41
SLIDE 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
slide-42
SLIDE 42

Skimming Commands

  • Use Case:
  • Skimming -- trying to read through

text, instead of editing.

slide-43
SLIDE 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.

slide-44
SLIDE 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!