├── LICENSE.txt ├── README.md ├── auto_complete ├── bg-colors.css ├── omni-setup.vim ├── sea-shells.txt └── webapp │ ├── config.ru │ └── public │ ├── index.html │ └── js │ └── application.js ├── copy_and_paste ├── collection.js └── fizz.rb ├── ctags ├── anglophone.rb ├── francophone.rb ├── speaker.rb ├── tags └── tags-abridged ├── customizations ├── filetype-indentation.vim ├── ftplugin │ └── javascript.vim └── two-space-indent.vim ├── essential.vim ├── ex_mode ├── duplicate.todo ├── emails.csv ├── foobar.js ├── history-scrollers.vim ├── loop.js ├── practical-vim.html └── shopping-list.todo ├── files ├── .chapters ├── a.txt ├── b.txt ├── letters │ ├── a.txt │ ├── b.txt │ ├── c.txt │ ├── d.txt │ └── e.txt ├── mvc │ ├── app.js │ ├── app │ │ ├── controllers │ │ │ ├── Mailer.js │ │ │ ├── Main.js │ │ │ └── Navigation.js │ │ ├── models │ │ │ └── User.js │ │ └── views │ │ │ ├── Home.js │ │ │ ├── Main.js │ │ │ └── Settings.js │ ├── index.html │ └── lib │ │ ├── framework.js │ │ └── theme.css └── mvc_paths.vim ├── global ├── episodes.html ├── example.txt ├── markdown.js └── unsorted.css ├── grep ├── department-store.txt └── goldrush.txt ├── insert_mode ├── auto-complete-1.tutor ├── auto-complete-2.tutor ├── auto-complete-3.tutor ├── auto-complete.tutor ├── back-of-envelope.txt ├── practical-vim.txt └── replace.txt ├── jumps ├── practical_vim.rb └── practical_vim │ ├── core.rb │ ├── jumps.rb │ ├── more.rb │ └── motions.rb ├── macros ├── broken-lines.txt ├── consecutive-lines.txt ├── incremental.txt ├── mixed-lines.txt ├── rc.vim └── ruby_module │ ├── animal.rb │ ├── banker.rb │ ├── frog.rb │ └── person.rb ├── motions ├── cursor-maps.vim ├── disable-arrowkeys.vim ├── parentheses.rb ├── search-haiku.txt └── template.js ├── normal_mode ├── sprite.css └── the_end.txt ├── patterns ├── color.css ├── dynamic-escape.vim ├── escape-problem-characters.vim ├── excerpt-also-known-as.txt ├── search-url.markdown ├── springtime.txt ├── urls.txt ├── visual-star.vim └── windows-paths.markdown ├── quickfix ├── err-fizz-1 ├── err-fizz-2 ├── fizzbuzz-errors ├── fizzbuzz.js ├── format_vimrc ├── ftplugin.javascript.vim └── wakeup │ ├── Makefile │ ├── wakeup.c │ └── wakeup.h ├── search ├── escape-register.vim ├── headings.md ├── langs.txt ├── quoted-strings.txt └── tag-heirarchy.rb ├── spell_check ├── moustache.txt ├── mustache.txt ├── spellfile.vim └── yoru-moustache.txt ├── substitution ├── buttons.js ├── fudge.js ├── get-rolling.txt ├── headings.html ├── mixin.js ├── qargs.vim ├── refactor-project │ ├── about.txt │ ├── author.txt │ ├── extra │ │ ├── praise.txt │ │ └── titles.txt │ └── license.txt ├── subscribers.csv └── who-bites.txt ├── the_vim_way ├── 0_mechanics.txt ├── 1_copy_content.txt ├── 2_foo_bar.js └── 3_concat.js └── visual_mode ├── chapter-table.txt ├── fibonacci-malformed.py ├── fibonacci.py ├── indentation-fix.html ├── list-of-links.html └── sprite.css /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright © 2012 Drew Neil 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Examples from [Practical Vim] by Drew Neil 2 | 3 | [Practical Vim]: https://pragprog.com/book/dnvim/practical-vim 4 | 5 | ## License 6 | 7 | Copyrights apply to this source code. 8 | You may use the source code in your own projects 9 | however the source code may not be used to create 10 | training material, courses, books, articles, and the like. 11 | We make no guarantees that this source code is fit for any purpose. 12 | 13 | ## Warranty 14 | 15 | This software is provided "as is" and without any express or 16 | implied warranties, including, without limitation, the implied 17 | warranties of merchantibility and fitness for a particular 18 | purpose. 19 | -------------------------------------------------------------------------------- /auto_complete/bg-colors.css: -------------------------------------------------------------------------------- 1 | .top { 2 | background-color: #ef66ef; } 3 | .bottom { 4 | -------------------------------------------------------------------------------- /auto_complete/omni-setup.vim: -------------------------------------------------------------------------------- 1 | set nocompatible 2 | filetype plugin on 3 | -------------------------------------------------------------------------------- /auto_complete/sea-shells.txt: -------------------------------------------------------------------------------- 1 | She sells sea shells by the s 2 | -------------------------------------------------------------------------------- /auto_complete/webapp/config.ru: -------------------------------------------------------------------------------- 1 | use Rack::Static, :urls => { "/" => "index.html" }, :root => "public" 2 | run Rack::Directory.new("public") -------------------------------------------------------------------------------- /auto_complete/webapp/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | Practical Vim - the app 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /auto_complete/webapp/public/js/application.js: -------------------------------------------------------------------------------- 1 | /*** 2 | * Excerpted from "Practical Vim", 3 | * published by The Pragmatic Bookshelf. 4 | * Copyrights apply to this code. It may not be used to create training material, 5 | * courses, books, articles, and the like. Contact us if you are in doubt. 6 | * We make no guarantees that this code is fit for any purpose. 7 | * Visit http://www.pragmaticprogrammer.com/titles/dnvim for more book information. 8 | ***/ 9 | // Application code... 10 | -------------------------------------------------------------------------------- /copy_and_paste/collection.js: -------------------------------------------------------------------------------- 1 | /*** 2 | * Excerpted from "Practical Vim", 3 | * published by The Pragmatic Bookshelf. 4 | * Copyrights apply to this code. It may not be used to create training material, 5 | * courses, books, articles, and the like. Contact us if you are in doubt. 6 | * We make no guarantees that this code is fit for any purpose. 7 | * Visit http://www.pragmaticprogrammer.com/titles/dnvim for more book information. 8 | ***/ 9 | collection = getCollection(); 10 | process(somethingInTheWay, target); 11 | -------------------------------------------------------------------------------- /copy_and_paste/fizz.rb: -------------------------------------------------------------------------------- 1 | #--- 2 | # Excerpted from "Practical Vim", 3 | # published by The Pragmatic Bookshelf. 4 | # Copyrights apply to this code. It may not be used to create training material, 5 | # courses, books, articles, and the like. Contact us if you are in doubt. 6 | # We make no guarantees that this code is fit for any purpose. 7 | # Visit http://www.pragmaticprogrammer.com/titles/dnvim for more book information. 8 | #--- 9 | [1,2,3,4,5,6,7,8,9,10].each do |n| 10 | if n%5==0 11 | puts "fizz" 12 | else 13 | puts n 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /ctags/anglophone.rb: -------------------------------------------------------------------------------- 1 | #--- 2 | # Excerpted from "Practical Vim", 3 | # published by The Pragmatic Bookshelf. 4 | # Copyrights apply to this code. It may not be used to create training material, 5 | # courses, books, articles, and the like. Contact us if you are in doubt. 6 | # We make no guarantees that this code is fit for any purpose. 7 | # Visit http://www.pragmaticprogrammer.com/titles/dnvim for more book information. 8 | #--- 9 | require './speaker.rb' 10 | class Anglophone < Speaker 11 | def speak 12 | puts "Hello, my name is #{@name}" 13 | end 14 | end 15 | Anglophone.new('Jack').speak 16 | -------------------------------------------------------------------------------- /ctags/francophone.rb: -------------------------------------------------------------------------------- 1 | #--- 2 | # Excerpted from "Practical Vim", 3 | # published by The Pragmatic Bookshelf. 4 | # Copyrights apply to this code. It may not be used to create training material, 5 | # courses, books, articles, and the like. Contact us if you are in doubt. 6 | # We make no guarantees that this code is fit for any purpose. 7 | # Visit http://www.pragmaticprogrammer.com/titles/dnvim for more book information. 8 | #--- 9 | require './speaker.rb' 10 | class Francophone < Speaker 11 | def speak 12 | puts "Bonjour, je m'appelle #{@name}" 13 | end 14 | alias :parler :speak 15 | end 16 | Francophone.new('Jacques').parler 17 | -------------------------------------------------------------------------------- /ctags/speaker.rb: -------------------------------------------------------------------------------- 1 | #--- 2 | # Excerpted from "Practical Vim", 3 | # published by The Pragmatic Bookshelf. 4 | # Copyrights apply to this code. It may not be used to create training material, 5 | # courses, books, articles, and the like. Contact us if you are in doubt. 6 | # We make no guarantees that this code is fit for any purpose. 7 | # Visit http://www.pragmaticprogrammer.com/titles/dnvim for more book information. 8 | #--- 9 | class Speaker 10 | def initialize(name) 11 | @name = name 12 | end 13 | def speak 14 | puts "#{name}" 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /ctags/tags: -------------------------------------------------------------------------------- 1 | !_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/ 2 | !_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/ 3 | !_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/ 4 | !_TAG_PROGRAM_NAME Exuberant Ctags // 5 | !_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/ 6 | !_TAG_PROGRAM_VERSION 5.8 // 7 | Anglophone anglophone.rb /^class Anglophone < Speaker$/;" c 8 | Francophone francophone.rb /^class Francophone < Speaker$/;" c 9 | Speaker speaker.rb /^class Speaker$/;" c 10 | initialize speaker.rb /^ def initialize(name)$/;" f class:Speaker 11 | speak anglophone.rb /^ def speak$/;" f class:Anglophone 12 | speak francophone.rb /^ def speak$/;" f class:Francophone 13 | speak speaker.rb /^ def speak$/;" f class:Speaker 14 | -------------------------------------------------------------------------------- /ctags/tags-abridged: -------------------------------------------------------------------------------- 1 | !_TAG_FILE_FORMAT 2 /extended format/ 2 | !_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/ 3 | !_TAG_PROGRAM_AUTHOR Darren Hiebert // 4 | !_TAG_PROGRAM_NAME Exuberant Ctags // 5 | !_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/ 6 | !_TAG_PROGRAM_VERSION 5.8 // 7 | Anglophone anglophone.rb /^class Anglophone < Speaker$/;" c 8 | Francophone francophone.rb /^class Francophone < Speaker$/;" c 9 | Speaker speaker.rb /^class Speaker$/;" c 10 | initialize speaker.rb /^ def initialize(name)$/;" f 11 | speak anglophone.rb /^ def speak$/;" f class:Anglophone 12 | speak francophone.rb /^ def speak$/;" f class:Francophone 13 | speak speaker.rb /^ def speak$/;" f class:Speaker 14 | -------------------------------------------------------------------------------- /customizations/filetype-indentation.vim: -------------------------------------------------------------------------------- 1 | if has("autocmd") 2 | filetype on 3 | autocmd FileType ruby setlocal ts=2 sts=2 sw=2 et 4 | autocmd FileType javascript setlocal ts=4 sts=4 sw=4 noet 5 | endif 6 | -------------------------------------------------------------------------------- /customizations/ftplugin/javascript.vim: -------------------------------------------------------------------------------- 1 | setlocal ts=4 sts=4 sw=4 noet 2 | compiler nodelint 3 | -------------------------------------------------------------------------------- /customizations/two-space-indent.vim: -------------------------------------------------------------------------------- 1 | " Use two spaces for indentation 2 | set tabstop=2 3 | set softtabstop=2 4 | set shiftwidth=2 5 | set expandtab 6 | -------------------------------------------------------------------------------- /essential.vim: -------------------------------------------------------------------------------- 1 | set nocompatible 2 | filetype plugin on 3 | -------------------------------------------------------------------------------- /ex_mode/duplicate.todo: -------------------------------------------------------------------------------- 1 | Shopping list 2 | Hardware store 3 | Buy new hammer 4 | Beauticians 5 | Buy nail polish remover 6 | Buy nails 7 | -------------------------------------------------------------------------------- /ex_mode/emails.csv: -------------------------------------------------------------------------------- 1 | first name,last name,email 2 | john,smith,john@example.com 3 | drew,neil,drew@vimcasts.org 4 | jane,doe,jane@example.com 5 | -------------------------------------------------------------------------------- /ex_mode/foobar.js: -------------------------------------------------------------------------------- 1 | /*** 2 | * Excerpted from "Practical Vim", 3 | * published by The Pragmatic Bookshelf. 4 | * Copyrights apply to this code. It may not be used to create training material, 5 | * courses, books, articles, and the like. Contact us if you are in doubt. 6 | * We make no guarantees that this code is fit for any purpose. 7 | * Visit http://www.pragmaticprogrammer.com/titles/dnvim for more book information. 8 | ***/ 9 | var foo = 1 10 | var bar = 'a' 11 | var baz = 'z' 12 | var foobar = foo + bar 13 | var foobarbaz = foo + bar + baz 14 | -------------------------------------------------------------------------------- /ex_mode/history-scrollers.vim: -------------------------------------------------------------------------------- 1 | cnoremap 2 | cnoremap 3 | -------------------------------------------------------------------------------- /ex_mode/loop.js: -------------------------------------------------------------------------------- 1 | /*** 2 | * Excerpted from "Practical Vim", 3 | * published by The Pragmatic Bookshelf. 4 | * Copyrights apply to this code. It may not be used to create training material, 5 | * courses, books, articles, and the like. Contact us if you are in doubt. 6 | * We make no guarantees that this code is fit for any purpose. 7 | * Visit http://www.pragmaticprogrammer.com/titles/dnvim for more book information. 8 | ***/ 9 | var tally; 10 | for (tally=1; tally <= 10; tally++) { 11 | // do something with tally 12 | }; 13 | -------------------------------------------------------------------------------- /ex_mode/practical-vim.html: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | Practical Vim 12 |

Practical Vim

13 | 14 | -------------------------------------------------------------------------------- /ex_mode/shopping-list.todo: -------------------------------------------------------------------------------- 1 | Shopping list 2 | Hardware Store 3 | Buy new hammer 4 | Beauty Parlor 5 | Buy nail polish remover 6 | Buy nails 7 | -------------------------------------------------------------------------------- /files/.chapters: -------------------------------------------------------------------------------- 1 | the_vim_way.pml 2 | normal_mode.pml 3 | insert_mode.pml 4 | visual_mode.pml 5 | ex_mode.pml 6 | managing_files.pml 7 | files.pml 8 | motions.pml 9 | jumps.pml 10 | copy_and_paste.pml 11 | macros.pml 12 | patterns.pml 13 | search.pml 14 | substitution.pml 15 | global_commands.pml 16 | ctags.pml 17 | quickfix.pml 18 | grep.pml 19 | auto_complete.pml 20 | spell_check.pml 21 | -------------------------------------------------------------------------------- /files/a.txt: -------------------------------------------------------------------------------- 1 | AAA 2 | A:::A 3 | A:::::A 4 | A:::::::A 5 | A:::::::::A 6 | A:::::A:::::A 7 | A:::::A A:::::A 8 | A:::::A A:::::A 9 | A:::::A A:::::A 10 | A:::::AAAAAAAAA:::::A 11 | A:::::::::::::::::::::A 12 | A:::::AAAAAAAAAAAAA:::::A 13 | A:::::A A:::::A 14 | A:::::A A:::::A 15 | A:::::A A:::::A 16 | AAAAAAA AAAAAAA 17 | -------------------------------------------------------------------------------- /files/b.txt: -------------------------------------------------------------------------------- 1 | BBBBBBBBBBBBBBBBB 2 | B::::::::::::::::B 3 | B::::::BBBBBB:::::B 4 | BB:::::B B:::::B 5 | B::::B B:::::B 6 | B::::B B:::::B 7 | B::::BBBBBB:::::B 8 | B:::::::::::::BB 9 | B::::BBBBBB:::::B 10 | B::::B B:::::B 11 | B::::B B:::::B 12 | B::::B B:::::B 13 | BB:::::BBBBBB::::::B 14 | B:::::::::::::::::B 15 | B::::::::::::::::B 16 | BBBBBBBBBBBBBBBBB 17 | -------------------------------------------------------------------------------- /files/letters/a.txt: -------------------------------------------------------------------------------- 1 | AAA 2 | A:::A 3 | A:::::A 4 | A:::::::A 5 | A:::::::::A 6 | A:::::A:::::A 7 | A:::::A A:::::A 8 | A:::::A A:::::A 9 | A:::::A A:::::A 10 | A:::::AAAAAAAAA:::::A 11 | A:::::::::::::::::::::A 12 | A:::::AAAAAAAAAAAAA:::::A 13 | A:::::A A:::::A 14 | A:::::A A:::::A 15 | A:::::A A:::::A 16 | AAAAAAA AAAAAAA 17 | -------------------------------------------------------------------------------- /files/letters/b.txt: -------------------------------------------------------------------------------- 1 | BBBBBBBBBBBBBBBBB 2 | B::::::::::::::::B 3 | B::::::BBBBBB:::::B 4 | BB:::::B B:::::B 5 | B::::B B:::::B 6 | B::::B B:::::B 7 | B::::BBBBBB:::::B 8 | B:::::::::::::BB 9 | B::::BBBBBB:::::B 10 | B::::B B:::::B 11 | B::::B B:::::B 12 | B::::B B:::::B 13 | BB:::::BBBBBB::::::B 14 | B:::::::::::::::::B 15 | B::::::::::::::::B 16 | BBBBBBBBBBBBBBBBB 17 | -------------------------------------------------------------------------------- /files/letters/c.txt: -------------------------------------------------------------------------------- 1 | CCCCCCCCCCCCC 2 | CCC::::::::::::C 3 | CC:::::::::::::::C 4 | C:::::CCCCCCCC::::C 5 | C:::::C CCCCCC 6 | C:::::C 7 | C:::::C 8 | C:::::C 9 | C:::::C 10 | C:::::C 11 | C:::::C 12 | C:::::C CCCCCC 13 | C:::::CCCCCCCC::::C 14 | CC:::::::::::::::C 15 | CCC::::::::::::C 16 | CCCCCCCCCCCCC 17 | -------------------------------------------------------------------------------- /files/letters/d.txt: -------------------------------------------------------------------------------- 1 | DDDDDDDDDDDDD 2 | D::::::::::::DDD 3 | D:::::::::::::::DD 4 | DDD:::::DDDDD:::::D 5 | D:::::D D:::::D 6 | D:::::D D:::::D 7 | D:::::D D:::::D 8 | D:::::D D:::::D 9 | D:::::D D:::::D 10 | D:::::D D:::::D 11 | D:::::D D:::::D 12 | D:::::D D:::::D 13 | DDD:::::DDDDD:::::D 14 | D:::::::::::::::DD 15 | D::::::::::::DDD 16 | DDDDDDDDDDDDD 17 | -------------------------------------------------------------------------------- /files/letters/e.txt: -------------------------------------------------------------------------------- 1 | EEEEEEEEEEEEEEEEEEEEEE 2 | E::::::::::::::::::::E 3 | E::::::::::::::::::::E 4 | EE::::::EEEEEEEEE::::E 5 | E:::::E EEEEEE 6 | E:::::E 7 | E::::::EEEEEEEEEE 8 | E:::::::::::::::E 9 | E:::::::::::::::E 10 | E::::::EEEEEEEEEE 11 | E:::::E 12 | E:::::E EEEEEE 13 | EE::::::EEEEEEEE:::::E 14 | E::::::::::::::::::::E 15 | E::::::::::::::::::::E 16 | EEEEEEEEEEEEEEEEEEEEEE 17 | -------------------------------------------------------------------------------- /files/mvc/app.js: -------------------------------------------------------------------------------- 1 | /*** 2 | * Excerpted from "Practical Vim", 3 | * published by The Pragmatic Bookshelf. 4 | * Copyrights apply to this code. It may not be used to create training material, 5 | * courses, books, articles, and the like. Contact us if you are in doubt. 6 | * We make no guarantees that this code is fit for any purpose. 7 | * Visit http://www.pragmaticprogrammer.com/titles/dnvim for more book information. 8 | ***/ 9 | // app.js 10 | -------------------------------------------------------------------------------- /files/mvc/app/controllers/Mailer.js: -------------------------------------------------------------------------------- 1 | /*** 2 | * Excerpted from "Practical Vim", 3 | * published by The Pragmatic Bookshelf. 4 | * Copyrights apply to this code. It may not be used to create training material, 5 | * courses, books, articles, and the like. Contact us if you are in doubt. 6 | * We make no guarantees that this code is fit for any purpose. 7 | * Visit http://www.pragmaticprogrammer.com/titles/dnvim for more book information. 8 | ***/ 9 | // app/controllers/Mailer.js 10 | -------------------------------------------------------------------------------- /files/mvc/app/controllers/Main.js: -------------------------------------------------------------------------------- 1 | /*** 2 | * Excerpted from "Practical Vim", 3 | * published by The Pragmatic Bookshelf. 4 | * Copyrights apply to this code. It may not be used to create training material, 5 | * courses, books, articles, and the like. Contact us if you are in doubt. 6 | * We make no guarantees that this code is fit for any purpose. 7 | * Visit http://www.pragmaticprogrammer.com/titles/dnvim for more book information. 8 | ***/ 9 | // app/controllers/Main.js 10 | -------------------------------------------------------------------------------- /files/mvc/app/controllers/Navigation.js: -------------------------------------------------------------------------------- 1 | /*** 2 | * Excerpted from "Practical Vim", 3 | * published by The Pragmatic Bookshelf. 4 | * Copyrights apply to this code. It may not be used to create training material, 5 | * courses, books, articles, and the like. Contact us if you are in doubt. 6 | * We make no guarantees that this code is fit for any purpose. 7 | * Visit http://www.pragmaticprogrammer.com/titles/dnvim for more book information. 8 | ***/ 9 | // app/controllers/Navigation.js 10 | -------------------------------------------------------------------------------- /files/mvc/app/models/User.js: -------------------------------------------------------------------------------- 1 | /*** 2 | * Excerpted from "Practical Vim", 3 | * published by The Pragmatic Bookshelf. 4 | * Copyrights apply to this code. It may not be used to create training material, 5 | * courses, books, articles, and the like. Contact us if you are in doubt. 6 | * We make no guarantees that this code is fit for any purpose. 7 | * Visit http://www.pragmaticprogrammer.com/titles/dnvim for more book information. 8 | ***/ 9 | // app/models/User.js 10 | -------------------------------------------------------------------------------- /files/mvc/app/views/Home.js: -------------------------------------------------------------------------------- 1 | /*** 2 | * Excerpted from "Practical Vim", 3 | * published by The Pragmatic Bookshelf. 4 | * Copyrights apply to this code. It may not be used to create training material, 5 | * courses, books, articles, and the like. Contact us if you are in doubt. 6 | * We make no guarantees that this code is fit for any purpose. 7 | * Visit http://www.pragmaticprogrammer.com/titles/dnvim for more book information. 8 | ***/ 9 | // app/views/Home.js 10 | -------------------------------------------------------------------------------- /files/mvc/app/views/Main.js: -------------------------------------------------------------------------------- 1 | /*** 2 | * Excerpted from "Practical Vim", 3 | * published by The Pragmatic Bookshelf. 4 | * Copyrights apply to this code. It may not be used to create training material, 5 | * courses, books, articles, and the like. Contact us if you are in doubt. 6 | * We make no guarantees that this code is fit for any purpose. 7 | * Visit http://www.pragmaticprogrammer.com/titles/dnvim for more book information. 8 | ***/ 9 | // app/views/Main.js 10 | -------------------------------------------------------------------------------- /files/mvc/app/views/Settings.js: -------------------------------------------------------------------------------- 1 | /*** 2 | * Excerpted from "Practical Vim", 3 | * published by The Pragmatic Bookshelf. 4 | * Copyrights apply to this code. It may not be used to create training material, 5 | * courses, books, articles, and the like. Contact us if you are in doubt. 6 | * We make no guarantees that this code is fit for any purpose. 7 | * Visit http://www.pragmaticprogrammer.com/titles/dnvim for more book information. 8 | ***/ 9 | // app/views/Settings.js 10 | -------------------------------------------------------------------------------- /files/mvc/index.html: -------------------------------------------------------------------------------- 1 | 9 | 10 | -------------------------------------------------------------------------------- /files/mvc/lib/framework.js: -------------------------------------------------------------------------------- 1 | /*** 2 | * Excerpted from "Practical Vim", 3 | * published by The Pragmatic Bookshelf. 4 | * Copyrights apply to this code. It may not be used to create training material, 5 | * courses, books, articles, and the like. Contact us if you are in doubt. 6 | * We make no guarantees that this code is fit for any purpose. 7 | * Visit http://www.pragmaticprogrammer.com/titles/dnvim for more book information. 8 | ***/ 9 | // lib/framework.js 10 | -------------------------------------------------------------------------------- /files/mvc/lib/theme.css: -------------------------------------------------------------------------------- 1 | /* lib/theme.css */ 2 | -------------------------------------------------------------------------------- /files/mvc_paths.vim: -------------------------------------------------------------------------------- 1 | set path=. 2 | set path+=app/views 3 | set path+=app/controllers 4 | -------------------------------------------------------------------------------- /global/episodes.html: -------------------------------------------------------------------------------- 1 | 9 |
    10 |
  1. 11 | 12 | Show invisibles 13 | 14 |
  2. 15 |
  3. 16 | 17 | Tabs and Spaces 18 | 19 |
  4. 20 |
  5. 21 | 22 | Whitespace preferences and filetypes 23 | 24 |
  6. 25 |
26 | -------------------------------------------------------------------------------- /global/example.txt: -------------------------------------------------------------------------------- 1 | Global commands 2 | 3 | Select or reject lines containing a pattern 4 | 5 | Collect TODO items in a register 6 | -------------------------------------------------------------------------------- /global/markdown.js: -------------------------------------------------------------------------------- 1 | /*** 2 | * Excerpted from "Practical Vim", 3 | * published by The Pragmatic Bookshelf. 4 | * Copyrights apply to this code. It may not be used to create training material, 5 | * courses, books, articles, and the like. Contact us if you are in doubt. 6 | * We make no guarantees that this code is fit for any purpose. 7 | * Visit http://www.pragmaticprogrammer.com/titles/dnvim for more book information. 8 | ***/ 9 | Markdown.dialects.Gruber = { 10 | lists: function() { 11 | // TODO: Cache this regexp for certain depths. 12 | function regex_for_depth(depth) { /* implementation */ } 13 | }, 14 | "`": function inlineCode( text ) { 15 | var m = text.match( /(`+)(([\s\S]*?)\1)/ ); 16 | if ( m && m[2] ) 17 | return [ m[1].length + m[2].length ]; 18 | else { 19 | // TODO: No matching end code found - warn! 20 | return [ 1, "`" ]; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /global/unsorted.css: -------------------------------------------------------------------------------- 1 | html { 2 | margin: 0; 3 | padding: 0; 4 | border: 0; 5 | font-size: 100%; 6 | font: inherit; 7 | vertical-align: baseline; 8 | } 9 | body { 10 | line-height: 1.5; 11 | color: black; 12 | background: white; 13 | } 14 | -------------------------------------------------------------------------------- /grep/department-store.txt: -------------------------------------------------------------------------------- 1 | Waldo is beside the boot counter. 2 | Someone is burning trousers with an iron. 3 | There's a long thin man with a long thin tie. 4 | A vacuum cleaner is stripping a woman of her dress. 5 | A man is being attacked by a glove. 6 | -------------------------------------------------------------------------------- /grep/goldrush.txt: -------------------------------------------------------------------------------- 1 | A man has found gold. 2 | Everyone is rushing to the same spot. 3 | Even the cactii are joining the frey. 4 | A steam train is off the rails. 5 | Most people are carrying a shovel or a pick axe. 6 | Waldo is studying his clipboard. 7 | A clown is riding a unicycle. 8 | A victorian gentleman is riding a penny farthing. 9 | The penny farthing is 10 paces ahead of Waldo. 10 | -------------------------------------------------------------------------------- /insert_mode/auto-complete-1.tutor: -------------------------------------------------------------------------------- 1 | Go faster; au 2 | 3 | This list of words will fuel the auto-complete menu: 4 | aubergine auctioneer audibly audience aureole 5 | auspicious author automate autumnal 6 | 7 | Using and to navigate the popup menu 8 | ------------------------------------------------ 9 | 10 | - ggA to enter insert mode at end of first line 11 | - to trigger keyword auto-completion 12 | [Note: the first match ('auto') is selected] 13 | - press cursor until 'automate' is selected 14 | - having selected 'automate', press to insert it 15 | [Note: you're dropped back into insert mode] 16 | - finish up by typing " everything." 17 | -------------------------------------------------------------------------------- /insert_mode/auto-complete-2.tutor: -------------------------------------------------------------------------------- 1 | Go faster; au 2 | 3 | This list of words will fuel the auto-complete menu: 4 | aubergine auctioneer audibly audience aureole 5 | auspicious author automate autumnal 6 | 7 | Using and to navigate the popup menu 8 | ------------------------------------------------ 9 | 10 | - ggA to enter insert mode at end of first line 11 | - to trigger keyword auto-completion 12 | - press repeatedly, until 'automate' is selected 13 | [Note: the word in the document and popup selection are synchronized] 14 | - having selected 'automate', continue typing 15 | [Note: the popup menu disappears] 16 | - finish up by typing " everything." 17 | -------------------------------------------------------------------------------- /insert_mode/auto-complete-3.tutor: -------------------------------------------------------------------------------- 1 | Go faster; au 2 | 3 | This list of words will fuel the auto-complete menu: 4 | aubergine auctioneer audibly audience aureole 5 | auspicious author automate autumnal 6 | 7 | Refining the wordlist 8 | --------------------- 9 | 10 | - ggA to enter insert mode at end of first line 11 | - to trigger keyword auto-completion 12 | - to return to word fragment 13 | [Note: the popup menu is still present] 14 | - type the characters 't', 'o', 'm' one at a time 15 | [Note: the wordlist is refined as you type] 16 | - to select the first (and only) item in the list 17 | - finish up by typing " everything." 18 | -------------------------------------------------------------------------------- /insert_mode/auto-complete.tutor: -------------------------------------------------------------------------------- 1 | Go faster; au 2 | 3 | This list of words will fuel the auto-complete menu: 4 | aubergine auctioneer audibly audience aureole 5 | auspicious author automate autumnal 6 | 7 | Using and to navigate the popup menu 8 | ------------------------------------------------ 9 | 10 | - ggA to enter insert mode at end of first line 11 | - to trigger keyword auto-completion 12 | [Note: the first match ('auto') is selected] 13 | - press cursor until 'automate' is selected 14 | - having selected 'automate', press to insert it 15 | [Note: you're dropped back into insert mode] 16 | - finish up by typing " everything." 17 | 18 | 19 | Using and to navigate the popup menu 20 | ------------------------------------------------ 21 | 22 | - ggA to enter insert mode at end of first line 23 | - to trigger keyword auto-completion 24 | - press repeatedly, until 'automate' is selected 25 | [Note: the word in the document and popup selection are synchronized] 26 | - having selected 'automate', continue typing 27 | [Note: the popup menu disappears] 28 | - finish up by typing " everything." 29 | 30 | 31 | Refining the wordlist 32 | --------------------- 33 | 34 | - ggA to enter insert mode at end of first line 35 | - to trigger keyword auto-completion 36 | - to return to word fragment 37 | [Note: the popup menu is still present] 38 | - type the characters 'F', 'I', 'X' one at a time 39 | [Note: the wordlist is refined as you type] 40 | - to select the first item in the list 41 | - having selected 'USEME', finish up by typing " everything." 42 | 43 | -------------------------------------------------------------------------------- /insert_mode/back-of-envelope.txt: -------------------------------------------------------------------------------- 1 | 6 chairs, each costing $35, totals $ 2 | -------------------------------------------------------------------------------- /insert_mode/practical-vim.txt: -------------------------------------------------------------------------------- 1 | Practical Vim, by Drew Neil 2 | Read Drew Neil's 3 | -------------------------------------------------------------------------------- /insert_mode/replace.txt: -------------------------------------------------------------------------------- 1 | Typing in Insert mode extends the line. But in Replace mode 2 | the line length doesn't change. 3 | -------------------------------------------------------------------------------- /jumps/practical_vim.rb: -------------------------------------------------------------------------------- 1 | #--- 2 | # Excerpted from "Practical Vim", 3 | # published by The Pragmatic Bookshelf. 4 | # Copyrights apply to this code. It may not be used to create training material, 5 | # courses, books, articles, and the like. Contact us if you are in doubt. 6 | # We make no guarantees that this code is fit for any purpose. 7 | # Visit http://www.pragmaticprogrammer.com/titles/dnvim for more book information. 8 | #--- 9 | require 'practical_vim/core' 10 | require 'practical_vim/more' 11 | -------------------------------------------------------------------------------- /jumps/practical_vim/core.rb: -------------------------------------------------------------------------------- 1 | #--- 2 | # Excerpted from "Practical Vim", 3 | # published by The Pragmatic Bookshelf. 4 | # Copyrights apply to this code. It may not be used to create training material, 5 | # courses, books, articles, and the like. Contact us if you are in doubt. 6 | # We make no guarantees that this code is fit for any purpose. 7 | # Visit http://www.pragmaticprogrammer.com/titles/dnvim for more book information. 8 | #--- 9 | # Implementation of core functionality... 10 | -------------------------------------------------------------------------------- /jumps/practical_vim/jumps.rb: -------------------------------------------------------------------------------- 1 | #--- 2 | # Excerpted from "Practical Vim", 3 | # published by The Pragmatic Bookshelf. 4 | # Copyrights apply to this code. It may not be used to create training material, 5 | # courses, books, articles, and the like. Contact us if you are in doubt. 6 | # We make no guarantees that this code is fit for any purpose. 7 | # Visit http://www.pragmaticprogrammer.com/titles/dnvim for more book information. 8 | #--- 9 | # Implementation of jumps... 10 | -------------------------------------------------------------------------------- /jumps/practical_vim/more.rb: -------------------------------------------------------------------------------- 1 | #--- 2 | # Excerpted from "Practical Vim", 3 | # published by The Pragmatic Bookshelf. 4 | # Copyrights apply to this code. It may not be used to create training material, 5 | # courses, books, articles, and the like. Contact us if you are in doubt. 6 | # We make no guarantees that this code is fit for any purpose. 7 | # Visit http://www.pragmaticprogrammer.com/titles/dnvim for more book information. 8 | #--- 9 | require 'practical_vim/motions' 10 | require 'practical_vim/jumps' 11 | # Implementation of additional functionality... 12 | -------------------------------------------------------------------------------- /jumps/practical_vim/motions.rb: -------------------------------------------------------------------------------- 1 | #--- 2 | # Excerpted from "Practical Vim", 3 | # published by The Pragmatic Bookshelf. 4 | # Copyrights apply to this code. It may not be used to create training material, 5 | # courses, books, articles, and the like. Contact us if you are in doubt. 6 | # We make no guarantees that this code is fit for any purpose. 7 | # Visit http://www.pragmaticprogrammer.com/titles/dnvim for more book information. 8 | #--- 9 | # Implementation of motions... 10 | -------------------------------------------------------------------------------- /macros/broken-lines.txt: -------------------------------------------------------------------------------- 1 | 1. one 2 | 2. two 3 | // break up the monotony 4 | 3. three 5 | 4. four 6 | -------------------------------------------------------------------------------- /macros/consecutive-lines.txt: -------------------------------------------------------------------------------- 1 | 1. one 2 | 2. two 3 | 3. three 4 | 4. four 5 | -------------------------------------------------------------------------------- /macros/incremental.txt: -------------------------------------------------------------------------------- 1 | partridge in a pear tree 2 | turtle doves 3 | French hens 4 | calling birds 5 | golden rings 6 | -------------------------------------------------------------------------------- /macros/mixed-lines.txt: -------------------------------------------------------------------------------- 1 | 1. One 2 | 2. Two 3 | 3. three 4 | 4. four 5 | -------------------------------------------------------------------------------- /macros/rc.vim: -------------------------------------------------------------------------------- 1 | set nocompatible 2 | filetype plugin indent on 3 | set hidden 4 | if has("autocmd") 5 | autocmd FileType ruby setlocal ts=2 sts=2 sw=2 expandtab 6 | endif 7 | -------------------------------------------------------------------------------- /macros/ruby_module/animal.rb: -------------------------------------------------------------------------------- 1 | #--- 2 | # Excerpted from "Practical Vim", 3 | # published by The Pragmatic Bookshelf. 4 | # Copyrights apply to this code. It may not be used to create training material, 5 | # courses, books, articles, and the like. Contact us if you are in doubt. 6 | # We make no guarantees that this code is fit for any purpose. 7 | # Visit http://www.pragmaticprogrammer.com/titles/dnvim for more book information. 8 | #--- 9 | # ...[end of copyright notice] 10 | class Animal 11 | # implementation 12 | end 13 | -------------------------------------------------------------------------------- /macros/ruby_module/banker.rb: -------------------------------------------------------------------------------- 1 | #--- 2 | # Excerpted from "Practical Vim", 3 | # published by The Pragmatic Bookshelf. 4 | # Copyrights apply to this code. It may not be used to create training material, 5 | # courses, books, articles, and the like. Contact us if you are in doubt. 6 | # We make no guarantees that this code is fit for any purpose. 7 | # Visit http://www.pragmaticprogrammer.com/titles/dnvim for more book information. 8 | #--- 9 | # ...[end of copyright notice] 10 | class Banker 11 | # implementation... 12 | end 13 | -------------------------------------------------------------------------------- /macros/ruby_module/frog.rb: -------------------------------------------------------------------------------- 1 | #--- 2 | # Excerpted from "Practical Vim", 3 | # published by The Pragmatic Bookshelf. 4 | # Copyrights apply to this code. It may not be used to create training material, 5 | # courses, books, articles, and the like. Contact us if you are in doubt. 6 | # We make no guarantees that this code is fit for any purpose. 7 | # Visit http://www.pragmaticprogrammer.com/titles/dnvim for more book information. 8 | #--- 9 | # ...[end of copyright notice] 10 | class Frog 11 | # implementation... 12 | end 13 | -------------------------------------------------------------------------------- /macros/ruby_module/person.rb: -------------------------------------------------------------------------------- 1 | #--- 2 | # Excerpted from "Practical Vim", 3 | # published by The Pragmatic Bookshelf. 4 | # Copyrights apply to this code. It may not be used to create training material, 5 | # courses, books, articles, and the like. Contact us if you are in doubt. 6 | # We make no guarantees that this code is fit for any purpose. 7 | # Visit http://www.pragmaticprogrammer.com/titles/dnvim for more book information. 8 | #--- 9 | # ...[end of copyright notice] 10 | class Person 11 | # implementation... 12 | end 13 | -------------------------------------------------------------------------------- /motions/cursor-maps.vim: -------------------------------------------------------------------------------- 1 | nnoremap k gk 2 | nnoremap gk k 3 | nnoremap j gj 4 | nnoremap gj j 5 | -------------------------------------------------------------------------------- /motions/disable-arrowkeys.vim: -------------------------------------------------------------------------------- 1 | noremap 2 | noremap 3 | noremap 4 | noremap 5 | -------------------------------------------------------------------------------- /motions/parentheses.rb: -------------------------------------------------------------------------------- 1 | #--- 2 | # Excerpted from "Practical Vim", 3 | # published by The Pragmatic Bookshelf. 4 | # Copyrights apply to this code. It may not be used to create training material, 5 | # courses, books, articles, and the like. Contact us if you are in doubt. 6 | # We make no guarantees that this code is fit for any purpose. 7 | # Visit http://www.pragmaticprogrammer.com/titles/dnvim for more book information. 8 | #--- 9 | cities = %w{London Berlin New\ York} 10 | -------------------------------------------------------------------------------- /motions/search-haiku.txt: -------------------------------------------------------------------------------- 1 | search for your target 2 | it only takes a moment 3 | to get where you want 4 | -------------------------------------------------------------------------------- /motions/template.js: -------------------------------------------------------------------------------- 1 | /*** 2 | * Excerpted from "Practical Vim", 3 | * published by The Pragmatic Bookshelf. 4 | * Copyrights apply to this code. It may not be used to create training material, 5 | * courses, books, articles, and the like. Contact us if you are in doubt. 6 | * We make no guarantees that this code is fit for any purpose. 7 | * Visit http://www.pragmaticprogrammer.com/titles/dnvim for more book information. 8 | ***/ 9 | var tpl = [ 10 | '{title}' 11 | ] 12 | -------------------------------------------------------------------------------- /normal_mode/sprite.css: -------------------------------------------------------------------------------- 1 | .blog, .news { background-image: url(/sprite.png); } 2 | .blog { background-position: 0px 0px } 3 | -------------------------------------------------------------------------------- /normal_mode/the_end.txt: -------------------------------------------------------------------------------- 1 | The end is nigh 2 | -------------------------------------------------------------------------------- /patterns/color.css: -------------------------------------------------------------------------------- 1 | body { color: #3c3c3c; } 2 | a { color: #0000EE; } 3 | strong { color: #000; } 4 | -------------------------------------------------------------------------------- /patterns/dynamic-escape.vim: -------------------------------------------------------------------------------- 1 | escape(@u, getcmdtype()) 2 | -------------------------------------------------------------------------------- /patterns/escape-problem-characters.vim: -------------------------------------------------------------------------------- 1 | substitute(escape(@", '\'.getcmdtype()), '\n', '\\n', 'g') 2 | -------------------------------------------------------------------------------- /patterns/excerpt-also-known-as.txt: -------------------------------------------------------------------------------- 1 | The N key searches backward... 2 | ...the \v pattern switch (a.k.a. very magic search)... 3 | -------------------------------------------------------------------------------- /patterns/search-url.markdown: -------------------------------------------------------------------------------- 1 | Search items: [http://vimdoc.net/search?q=/\\][s] 2 | ... 3 | [s]: http://vimdoc.net/search?q=/\\ 4 | -------------------------------------------------------------------------------- /patterns/springtime.txt: -------------------------------------------------------------------------------- 1 | I love Paris in the 2 | the springtime. 3 | -------------------------------------------------------------------------------- /patterns/urls.txt: -------------------------------------------------------------------------------- 1 | http://vimcasts.org 2 | https://pragprog.com 3 | pragprog.com 4 | -------------------------------------------------------------------------------- /patterns/visual-star.vim: -------------------------------------------------------------------------------- 1 | xnoremap * :call VSetSearch()/=@/ 2 | xnoremap # :call VSetSearch()?=@/ 3 | 4 | function! s:VSetSearch() 5 | let temp = @s 6 | norm! gv"sy 7 | let @/ = '\V' . substitute(escape(@s, '/\'), '\n', '\\n', 'g') 8 | let @s = temp 9 | endfunction 10 | -------------------------------------------------------------------------------- /patterns/windows-paths.markdown: -------------------------------------------------------------------------------- 1 | Switch to `C:\PHP` directory... 2 | ...extensions are found in `C:\PHP\ext`... 3 | -------------------------------------------------------------------------------- /quickfix/err-fizz-1: -------------------------------------------------------------------------------- 1 | fizzbuzz.js, line 2, character 22: Unexpected '++'. 2 | fizzbuzz.js, line 3, character 15: Expected '===' and instead saw '=='. 3 | fizzbuzz.js, line 5, character 21: Expected '===' and instead saw '=='. 4 | fizzbuzz.js, line 7, character 21: Expected '===' and instead saw '=='. 5 | fizzbuzz.js, line 12, character 2: Unexpected ';'. 6 | -------------------------------------------------------------------------------- /quickfix/err-fizz-2: -------------------------------------------------------------------------------- 1 | fizzbuzz.js, line 2, character 22: Unexpected '++'. 2 | for (i=1; i <= 100; i++) { 3 | fizzbuzz.js, line 3, character 15: Expected '===' and instead saw '=='. 4 | if(i % 15 == 0) { 5 | fizzbuzz.js, line 5, character 21: Expected '===' and instead saw '=='. 6 | } else if(i % 5 == 0) { 7 | fizzbuzz.js, line 7, character 21: Expected '===' and instead saw '=='. 8 | } else if(i % 3 == 0) { 9 | fizzbuzz.js, line 12, character 2: Unexpected ';'. 10 | }; 11 | 5 errors 12 | -------------------------------------------------------------------------------- /quickfix/fizzbuzz-errors: -------------------------------------------------------------------------------- 1 | fizzbuzz.js, line 2, character 22: Unexpected '++'. 2 | for (i=1; i <= 100; i++) { 3 | fizzbuzz.js, line 3, character 15: Expected '===' and instead saw '=='. 4 | if(i % 15 == 0) { 5 | fizzbuzz.js, line 5, character 21: Expected '===' and instead saw '=='. 6 | } else if(i % 5 == 0) { 7 | fizzbuzz.js, line 7, character 21: Expected '===' and instead saw '=='. 8 | } else if(i % 3 == 0) { 9 | fizzbuzz.js, line 12, character 2: Unexpected ';'. 10 | }; 11 | 5 errors 12 | -------------------------------------------------------------------------------- /quickfix/fizzbuzz.js: -------------------------------------------------------------------------------- 1 | /*** 2 | * Excerpted from "Practical Vim", 3 | * published by The Pragmatic Bookshelf. 4 | * Copyrights apply to this code. It may not be used to create training material, 5 | * courses, books, articles, and the like. Contact us if you are in doubt. 6 | * We make no guarantees that this code is fit for any purpose. 7 | * Visit http://www.pragmaticprogrammer.com/titles/dnvim for more book information. 8 | ***/ 9 | var i; 10 | for (i=1; i <= 100; i++) { 11 | if(i % 15 == 0) { 12 | console.log('Fizzbuzz'); 13 | } else if(i % 5 == 0) { 14 | console.log('Buzz'); 15 | } else if(i % 3 == 0) { 16 | console.log('Fizz'); 17 | } else { 18 | console.log(i); 19 | } 20 | }; 21 | -------------------------------------------------------------------------------- /quickfix/format_vimrc: -------------------------------------------------------------------------------- 1 | set nocompatible 2 | " set errorformat=%W%f\,\ line\ %l,\ character\ %c:\ %m 3 | set errorformat=%f, 4 | let &efm='%A%.%*' 5 | 6 | let &efm='%A' 7 | let &efm.='%f\, ' 8 | let &efm.='line %l\, ' 9 | let &efm.='character %c:' 10 | let &efm.='%m' . ',' 11 | let &efm.='%Z%.%#' . ',' 12 | let &efm .= '%-G%.%#' 13 | -------------------------------------------------------------------------------- /quickfix/ftplugin.javascript.vim: -------------------------------------------------------------------------------- 1 | setlocal makeprg=NODE_DISABLE_COLORS=1\ nodelint\ % 2 | 3 | let &l:efm='%A' 4 | let &l:efm.='%f\, ' 5 | let &l:efm.='line %l\, ' 6 | let &l:efm.='character %c:' 7 | let &l:efm.='%m' . ',' 8 | let &l:efm.='%Z%.%#' . ',' 9 | let &l:efm.='%-G%.%#' 10 | -------------------------------------------------------------------------------- /quickfix/wakeup/Makefile: -------------------------------------------------------------------------------- 1 | TARGET=wakeup 2 | CC=gcc 3 | OBJS=wakeup.o 4 | SRCS=wakeup.c 5 | 6 | ${TARGET}: ${OBJS} 7 | ${CC} -o ${TARGET} ${OBJS} 8 | 9 | clean: 10 | rm -rf *.o ${TARGET} 11 | 12 | wakeup.o: wakeup.c 13 | -------------------------------------------------------------------------------- /quickfix/wakeup/wakeup.c: -------------------------------------------------------------------------------- 1 | /*** 2 | * Excerpted from "Practical Vim", 3 | * published by The Pragmatic Bookshelf. 4 | * Copyrights apply to this code. It may not be used to create training material, 5 | * courses, books, articles, and the like. Contact us if you are in doubt. 6 | * We make no guarantees that this code is fit for any purpose. 7 | * Visit http://www.pragmaticprogrammer.com/titles/dnvim for more book information. 8 | ***/ 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include "wakeup.h" 20 | 21 | int main(int argc, char *argv[]) 22 | { 23 | int sockfd; 24 | struct sockaddr_in theiraddr; 25 | struct hostent *he; 26 | uint8_t mac[6] = {0, 0, 0, 0, 0, 0}; 27 | uint8_t packet[102] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; 28 | int broadcast = 1; 29 | 30 | if (argc != 3) 31 | { 32 | fprintf(stderr, "Usage: %s \n", argv[0]); 33 | exit(1); 34 | } 35 | 36 | if ((he = gethostbyname(argv[1])) == NULL) 37 | { 38 | perror("gethostbyname"); 39 | exit(1); 40 | } 41 | 42 | if ((sockfd = socket(PF_INET, SOCK_DGRAM, 0)) == -1) 43 | { 44 | perror("socket"); 45 | exit(1); 46 | } 47 | 48 | if (setsockopt(sockfd, SOL_SOCKET, SO_BROADCAST, &broadcast, sizeof(broadcast)) == -1) 49 | { 50 | perror("setsockopt (SO_BROADCAST)"); 51 | exit(1); 52 | } 53 | 54 | memset(&theiraddr, 0, sizeof(theiraddr)); 55 | theiraddr.sin_family = PF_INET; 56 | theiraddr.sin_port = htons(PORT); 57 | theiraddr.sin_addr = *((struct in_addr *) he->h_addr); 58 | 59 | sscanf(argv[2], "%02"SCNx8":%02"SCNx8":%02"SCNx8":%02"SCNx8":%02"SCNx8":%02"SCNx8, &mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5]); 60 | 61 | generatePacket(mac, packet); 62 | 63 | if ((sendto(sockfd, packet, sizeof(packet), 0, (struct sockaddr *)&theiraddr, sizeof(struct sockaddr))) == -1) 64 | { 65 | perror("sendto"); 66 | exit(1); 67 | } 68 | 69 | printf("Sent a wakeup call to %s.\n", inet_ntoa(theiraddr.sin_addr)); 70 | 71 | close(sockfd); 72 | return 0; 73 | } 74 | 75 | void generatePacket(uint8_t *mac, uint8_t *packet) 76 | { 77 | int i, j, k; 78 | k = 6; 79 | 80 | for (i = 0; i <= 15; i++) 81 | { 82 | for (j = 0; j <= 5; j++, k++) 83 | { 84 | packet[k] = mac[j]; 85 | } 86 | } 87 | } 88 | 89 | -------------------------------------------------------------------------------- /quickfix/wakeup/wakeup.h: -------------------------------------------------------------------------------- 1 | /*** 2 | * Excerpted from "Practical Vim", 3 | * published by The Pragmatic Bookshelf. 4 | * Copyrights apply to this code. It may not be used to create training material, 5 | * courses, books, articles, and the like. Contact us if you are in doubt. 6 | * We make no guarantees that this code is fit for any purpose. 7 | * Visit http://www.pragmaticprogrammer.com/titles/dnvim for more book information. 8 | ***/ 9 | #define PORT 9 10 | 11 | void generatePacket(char *, char *); 12 | -------------------------------------------------------------------------------- /search/escape-register.vim: -------------------------------------------------------------------------------- 1 | cnoremap =PasteEscaped() 2 | 3 | function! s:PasteEscaped() 4 | echo "\\".getcmdline()."\"" 5 | let char = getchar() 6 | if char == "\" 7 | return '' 8 | else 9 | let register_content = getreg(nr2char(char)) 10 | let escaped_register = escape(register_content, '\'.getcmdtype()) 11 | return substitute(escaped_register, '\n', '\\n', 'g') 12 | endif 13 | endfunction 14 | -------------------------------------------------------------------------------- /search/headings.md: -------------------------------------------------------------------------------- 1 | A markdown heading 2 | ================== 3 | 4 | lorem ipsum dolor sit amet etc. etc. 5 | 6 | A level two markdown heading 7 | ---------------------------- 8 | 9 | lorem ipsum dolor sit amet etc. etc. 10 | -------------------------------------------------------------------------------- /search/langs.txt: -------------------------------------------------------------------------------- 1 | Aim to learn a new programming lang each year. 2 | Which lang did you pick up last year? 3 | Which langs would you like to learn? 4 | -------------------------------------------------------------------------------- /search/quoted-strings.txt: -------------------------------------------------------------------------------- 1 | This string contains a 'quoted' word. 2 | This string contains 'two' quoted 'words.' 3 | This 'string doesn't make things easy.' 4 | -------------------------------------------------------------------------------- /search/tag-heirarchy.rb: -------------------------------------------------------------------------------- 1 | #--- 2 | # Excerpted from "Practical Vim", 3 | # published by The Pragmatic Bookshelf. 4 | # Copyrights apply to this code. It may not be used to create training material, 5 | # courses, books, articles, and the like. Contact us if you are in doubt. 6 | # We make no guarantees that this code is fit for any purpose. 7 | # Visit http://www.pragmaticprogrammer.com/titles/dnvim for more book information. 8 | #--- 9 | class XhtmlDocument < XmlDocument; end 10 | class XhtmlTag < XmlTag; end 11 | -------------------------------------------------------------------------------- /spell_check/moustache.txt: -------------------------------------------------------------------------------- 1 | Your mum has a moustache. 2 | -------------------------------------------------------------------------------- /spell_check/mustache.txt: -------------------------------------------------------------------------------- 1 | Your mom has a mustache. 2 | -------------------------------------------------------------------------------- /spell_check/spellfile.vim: -------------------------------------------------------------------------------- 1 | setlocal spelllang=en_us 2 | setlocal spellfile=~/.vim/spell/en.utf-8.add 3 | setlocal spellfile+=~/books/practical_vim/jargon.utf-8.add 4 | -------------------------------------------------------------------------------- /spell_check/yoru-moustache.txt: -------------------------------------------------------------------------------- 1 | Yoru mum has a moustache. 2 | -------------------------------------------------------------------------------- /substitution/buttons.js: -------------------------------------------------------------------------------- 1 | /*** 2 | * Excerpted from "Practical Vim", 3 | * published by The Pragmatic Bookshelf. 4 | * Copyrights apply to this code. It may not be used to create training material, 5 | * courses, books, articles, and the like. Contact us if you are in doubt. 6 | * We make no guarantees that this code is fit for any purpose. 7 | * Visit http://www.pragmaticprogrammer.com/titles/dnvim for more book information. 8 | ***/ 9 | var buttons = viewport.buttons 10 | viewport.buttons.previous.show() 11 | viewport.buttons.next.show() 12 | viewport.buttons.index.hide() 13 | -------------------------------------------------------------------------------- /substitution/fudge.js: -------------------------------------------------------------------------------- 1 | /*** 2 | * Excerpted from "Practical Vim", 3 | * published by The Pragmatic Bookshelf. 4 | * Copyrights apply to this code. It may not be used to create training material, 5 | * courses, books, articles, and the like. Contact us if you are in doubt. 6 | * We make no guarantees that this code is fit for any purpose. 7 | * Visit http://www.pragmaticprogrammer.com/titles/dnvim for more book information. 8 | ***/ 9 | // Deprecated: fudge is now called tablet 10 | function fudge(ingredients) { 11 | fudge(ingredients); 12 | } 13 | -------------------------------------------------------------------------------- /substitution/get-rolling.txt: -------------------------------------------------------------------------------- 1 | When the going gets tough, the tough get going. 2 | If you are going through hell, keep going. 3 | -------------------------------------------------------------------------------- /substitution/headings.html: -------------------------------------------------------------------------------- 1 | 9 |

Heading number 1

10 |

Number 2 heading

11 |

Another heading

12 | -------------------------------------------------------------------------------- /substitution/mixin.js: -------------------------------------------------------------------------------- 1 | /*** 2 | * Excerpted from "Practical Vim", 3 | * published by The Pragmatic Bookshelf. 4 | * Copyrights apply to this code. It may not be used to create training material, 5 | * courses, books, articles, and the like. Contact us if you are in doubt. 6 | * We make no guarantees that this code is fit for any purpose. 7 | * Visit http://www.pragmaticprogrammer.com/titles/dnvim for more book information. 8 | ***/ 9 | mixin = { 10 | applyName: function(config) { 11 | return Factory(config, this.getName()); 12 | }, 13 | } 14 | -------------------------------------------------------------------------------- /substitution/qargs.vim: -------------------------------------------------------------------------------- 1 | command! -nargs=0 -bar Qargs execute 'args' QuickfixFilenames() 2 | function! QuickfixFilenames() 3 | let buffer_numbers = {} 4 | for quickfix_item in getqflist() 5 | let buffer_numbers[quickfix_item['bufnr']] = bufname(quickfix_item['bufnr']) 6 | endfor 7 | return join(map(values(buffer_numbers), 'fnameescape(v:val)')) 8 | endfunction 9 | -------------------------------------------------------------------------------- /substitution/refactor-project/about.txt: -------------------------------------------------------------------------------- 1 | Pragmatic Vim is a hands on guide to working with Vim. 2 | -------------------------------------------------------------------------------- /substitution/refactor-project/author.txt: -------------------------------------------------------------------------------- 1 | Pragmatic Vim is written by Drew Neil. 2 | -------------------------------------------------------------------------------- /substitution/refactor-project/extra/praise.txt: -------------------------------------------------------------------------------- 1 | What people are saying about Pragmatic Vim... 2 | -------------------------------------------------------------------------------- /substitution/refactor-project/extra/titles.txt: -------------------------------------------------------------------------------- 1 | Other titles from the Pragmatic Bookshelf... 2 | -------------------------------------------------------------------------------- /substitution/refactor-project/license.txt: -------------------------------------------------------------------------------- 1 | The Pragmatic Bookshelf holds the copyright for this book. 2 | -------------------------------------------------------------------------------- /substitution/subscribers.csv: -------------------------------------------------------------------------------- 1 | last name,first name,email 2 | neil,drew,drew@vimcasts.org 3 | doe,john,john@example.com 4 | -------------------------------------------------------------------------------- /substitution/who-bites.txt: -------------------------------------------------------------------------------- 1 | The dog bit the man. 2 | -------------------------------------------------------------------------------- /the_vim_way/0_mechanics.txt: -------------------------------------------------------------------------------- 1 | Line one 2 | Line two 3 | Line three 4 | Line four 5 | -------------------------------------------------------------------------------- /the_vim_way/1_copy_content.txt: -------------------------------------------------------------------------------- 1 | ...We're waiting for content before the site can go live... 2 | ...If you are content with this, let's go ahead with it... 3 | ...We'll launch as soon as we have the content... 4 | -------------------------------------------------------------------------------- /the_vim_way/2_foo_bar.js: -------------------------------------------------------------------------------- 1 | /*** 2 | * Excerpted from "Practical Vim", 3 | * published by The Pragmatic Bookshelf. 4 | * Copyrights apply to this code. It may not be used to create training material, 5 | * courses, books, articles, and the like. Contact us if you are in doubt. 6 | * We make no guarantees that this code is fit for any purpose. 7 | * Visit http://www.pragmaticprogrammer.com/titles/dnvim for more book information. 8 | ***/ 9 | var foo = 1 10 | var bar = 'a' 11 | var foobar = foo + bar 12 | -------------------------------------------------------------------------------- /the_vim_way/3_concat.js: -------------------------------------------------------------------------------- 1 | /*** 2 | * Excerpted from "Practical Vim", 3 | * published by The Pragmatic Bookshelf. 4 | * Copyrights apply to this code. It may not be used to create training material, 5 | * courses, books, articles, and the like. Contact us if you are in doubt. 6 | * We make no guarantees that this code is fit for any purpose. 7 | * Visit http://www.pragmaticprogrammer.com/titles/dnvim for more book information. 8 | ***/ 9 | var foo = "method("+argument1+","+argument2+")"; 10 | -------------------------------------------------------------------------------- /visual_mode/chapter-table.txt: -------------------------------------------------------------------------------- 1 | Chapter Page 2 | Normal mode 15 3 | Insert mode 31 4 | Visual mode 44 5 | -------------------------------------------------------------------------------- /visual_mode/fibonacci-malformed.py: -------------------------------------------------------------------------------- 1 | def fib(n): 2 | a, b = 0, 1 3 | while a < n: 4 | print a, 5 | a, b = b, a+b 6 | fib(42) 7 | -------------------------------------------------------------------------------- /visual_mode/fibonacci.py: -------------------------------------------------------------------------------- 1 | def fib(n): 2 | a, b = 0, 1 3 | while a < n: 4 | print a, 5 | a, b = b, a+b 6 | fib(42) 7 | -------------------------------------------------------------------------------- /visual_mode/indentation-fix.html: -------------------------------------------------------------------------------- 1 | 9 |
    10 |
  • 11 |

    12 | The indentation - 13 | it wants fixed. 14 |

    15 |
  • 16 |
17 | -------------------------------------------------------------------------------- /visual_mode/list-of-links.html: -------------------------------------------------------------------------------- 1 | 9 | one 10 | two 11 | three 12 | -------------------------------------------------------------------------------- /visual_mode/sprite.css: -------------------------------------------------------------------------------- 1 | li.one a{ background-image: url('/images/sprite.png'); } 2 | li.two a{ background-image: url('/images/sprite.png'); } 3 | li.three a{ background-image: url('/images/sprite.png'); } 4 | --------------------------------------------------------------------------------