commands
play

Commands Part I Recurring Themes Part II Core Commands - PowerPoint PPT Presentation

Lecture 5: Review + Basic Commands Part I Recurring Themes Part II Core Commands Announcements Homework 2 is due now! Midterm next week! Format is similar to hws, focus on writing clear descriptions that do exactly what you want to


  1. Lecture 5: Review + Basic Commands Part I Recurring Themes Part II Core Commands

  2. Announcements • Homework 2 is due now! • Midterm next week! • Format is similar to hws, focus on writing clear descriptions that do exactly what you want to do. • Describe don't explain. • Covers everything in previous lectures, and parts of hws that do not have a '*'.

  3. Case Study: Simple Class declaration to definition in C++ • This is a very simplistic example! • C++ is well known for being notoriously hard to parse. • More complicated examples involve a lot of case handling (macro termination). • We will assume that the class declaration is consistent in style, with no templates, virtuals, inlines, etc. (you do not have to know what that means, you can do it easily with a few tweaks though, we won't explicitly state it in the interest of time) • We will assume that the class declaration follows a specific format, including comments. • We won't worry about indenting and extra lines for now.

  4. Class declaration

  5. Class declaration

  6. Class definition

  7. Walkthrough • Things to remove: • #includes • usings • class ... • member variables • We will try to do it to match a general format.

  8. Walkthrough • Descriptions: • Locate '#include' • Delete Line. • Repeat (...) • Locate 'using' • Delete Line. • ...

  9. Walkthrough • Descriptions: • Locate 'public:' • Delete Line • ... • Locate 'private:' • Delete Line • ...

  10. Walkthrough • Descriptions • Locate 'm_' • Delete Line • ... • Locate 'variables' • Delete Line

  11. Walkthrough • Descriptions • Locate 'class' • Delete Line • Locate '};' • Delete Line • Goto top of document. • insert '#include "extclass.h"' • So now we've done the most trivial part.

  12. Walkthrough • Declaration -> definitions • Complication: there are comments • First thing: is it a comment? • For now, reasonably assume that the comment probably does not contain '(' • Hence, we will exploit the macro termination behavior (shown in hw).

  13. Walkthrough • Description: • goto the ';' within the line • goto the beginning of line

  14. Walkthrough • Description: • goto the ';' within the line • goto the beginning of line • If it is a comment, it will terminate, since we assume that comments will not contain ';'. • Macro termination • (you can also come up with more complicated checks, such as '(', ')' and ';')

  15. Walkthrough • Description: • goto the ';' within the line • goto the beginning of line • Functions in C++ have this format: • <type> <name>(<params>) { <body> }

  16. Walkthrough • Functions in C++ have this format: • <type> <name>(<params>) { <body> } • However, we are using a definition file, so we will have to add a class scope (this is syntatic).

  17. Walkthrough • Description: • goto the ';' within the line • goto the beginning of line • Functions in C++ have this format: • <type> <name>(<params>) { <body> }

  18. Walkthrough

  19. Walkthrough • Description: • goto the ';' within the line • goto the beginning of line • Functions in C++ have this format: • <WORD> <WORD>(<> object>) { <} object> }

  20. Walkthrough • Description: • goto the ';' within the line • goto the beginning of line • goto next word • insert 'FindCat::' • goto the ';' within the line • change the word ';' to '<CR>{<CR>}' • Functions in C++ have this format: • <WORD> <WORD>(<> object>) { <} object> }

  21. Walkthrough • Description: • goto the ';' within the line • goto the beginning of line • goto next word Record macro to • insert 'FindCat::' register 'a' • goto the ';' within the line • change the word ';' to '<CR>{<CR>}'

  22. Walkthrough • Description: • goto the ';' within the line • goto the beginning of line • goto next word Record macro to • insert 'FindCat::' register 'a' • goto the ';' within the line • change the word ';' to '<CR>{<CR>}' • Next line. Run macro on register 'a'. • ...

  23. Walkthrough • Questions?

  24. Walkthrough • Questions? • Good news: this will be the first question in the midterm

  25. Walkthrough • Questions? • Good news: this will be the first question in the midterm • Good news 2: we've already covered everything you need to know for the midterm! (you do NOT need to know commands for the midterm!)

  26. Quick Review • We have talked about these topics: • ergonomics • descriptions • relative numbers are bad • fuzzy descriptions • cheating/relative/distinctive • cursor/screen policy • dot command • macros and termination

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

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

  29. Bare bones commands • Buffers are... – not windows

  30. Bare bones commands • Buffers are... – not windows – vim's way of keeping track an opened file or scratch file – do not guarantee one to one mappings to windows

  31. Bare bones commands • Buffers are... – not windows – vim's way of keeping track an opened file or scratch file – do not guarantee one to one mappings to windows – Oftentimes hidden, cannot be 'closed', may hide instead – Bottom line: buffers can be hidden, loaded and deleted. Windows can be opened and closed. Buffers are still there when you close a window. – demo ( :ls<CR> )

  32. Bare bones commands • As per unix standard, starting up vim: vim <flags/options> <filenames> • on the command line.

  33. Bare bones commands • As per unix standard, starting up vim: vim <flags/options> <filenames> • on the command line. • Running 'vim' with no flags and filenames just loads up vim with 1 window, 1 empty buffer, 0 args.

  34. Bare bones commands • As per unix standard, starting up vim: vim <flags/options> <filenames> • Ex. vim hello.txt goodbye.txt • Loads both hello.txt and goodbye.txt in two buffers, but 1 window.

  35. Bare bones commands • As per unix standard, starting up vim: vim <flags/options> <filenames> • Ex. vim hello.txt goodbye.txt • Loads both hello.txt and goodbye.txt in two buffers, but 1 window. We'll talk about windows/buffer in great detail in the future.

  36. Bare bones commands • As per unix standard, starting up vim: vim <flags/options> <filenames> • Ex. vim -O hello.txt goodbye.txt • Loads both hello.txt and goodbye.txt in two buffers, with 2 corresponding vertical windows.

  37. Bare bones commands • As per unix standard, starting up vim: vim <flags/options> <filenames> • Important flags: • -o -- opens <filenames> in seperate horizontal windows • -O -- vertical windows • -d -- diff mode • - -- reads from pipe • More in :h vim-arguments

  38. Bare bones commands • Within vim: • the ex command :e <filenames><CR> • opens files in different buffers, but does not change the number of windows. • Buffers and windows are NOT the same thing... We will only deal with single files (and single buffers) for now.

  39. Bare bones commands • Writing to a file • the ex command :w <filename><CR> • writes to <filename>. If no params are given, writes to current file in current buffer. :wa<CR> • writes to all files in all current buffers.

  40. Bare bones commands • Quiting Vim • the ex command :qa<CR> • Quits Vim. • Quit behavior: • If there are edited yet unsaved buffers , it will prompt an error instead of quiting! • Safety feature.

  41. Bare bones commands • Quiting Vim without writing (Force quiting) • the ex command :qa!<CR> • Quits Vim. • If there are edited yet unsaved buffers , it will quit but not save!

  42. Bare bones commands • Quit Vim and writes all files in all buffers. • the ex command :xa<CR> • Quits Vim and ... 1. If a buffer is edited yet unsaved, it is written/saved. 2. If a buffer is unedited, it is left as-is, and untouched. This is probably what you want most of the time (demo hello.cpp).

  43. Next Time • Midterm! • Remember: everything covered in previous lectures and hws except marked with '*'. • Then it's break, yay! :-)

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