├── .gitignore ├── LICENSE ├── README.md ├── config.vim ├── doc └── demo.gif ├── katas ├── 10 │ ├── in │ ├── out │ └── tips ├── 11 │ ├── in │ ├── out │ └── tips ├── 12 │ ├── in │ ├── out │ └── tips ├── 13 │ ├── ext │ ├── in │ ├── out │ └── tips ├── 14 │ ├── ext │ ├── in │ ├── out │ └── tips ├── 15 │ ├── in │ ├── out │ └── tips ├── 16 │ ├── ext │ ├── in │ ├── out │ └── tips ├── 17 │ ├── in │ ├── out │ └── tips ├── 18 │ ├── ext │ ├── in │ ├── out │ └── tips ├── 19 │ ├── ext │ ├── in │ ├── out │ └── tips ├── 20 │ ├── in │ ├── out │ └── tips ├── 21 │ ├── ext │ ├── in │ ├── out │ └── tips ├── 22 │ ├── in │ ├── out │ └── tips ├── 23 │ ├── in │ ├── out │ └── tips ├── 24 │ ├── in │ ├── out │ └── tips ├── 25 │ ├── in │ ├── out │ └── tips ├── 26 │ ├── ext │ ├── in │ ├── out │ └── tips ├── 27 │ ├── in │ ├── out │ └── tips ├── 28 │ ├── ext │ ├── in │ ├── out │ └── tips ├── 29 │ ├── in │ ├── out │ └── tips ├── 30 │ ├── ext │ ├── in │ ├── out │ └── tips ├── 31 │ ├── ext │ ├── in │ ├── out │ └── tips ├── 32 │ ├── in │ ├── out │ └── tips ├── 33 │ ├── in │ ├── out │ └── tips ├── 34 │ ├── ext │ ├── in │ ├── out │ └── tips ├── 35 │ ├── ext │ ├── in │ ├── out │ └── tips ├── 36 │ ├── in │ ├── out │ └── tips ├── 37 │ ├── ext │ ├── in │ ├── out │ └── tips ├── 38 │ ├── ext │ ├── in │ ├── out │ └── tips ├── 39 │ ├── ext │ ├── in │ ├── out │ └── tips ├── 40 │ ├── ext │ ├── in │ ├── out │ └── tips ├── 41 │ ├── ext │ ├── in │ ├── out │ └── tips ├── 42 │ ├── ext │ ├── in │ ├── out │ └── tips ├── 43 │ ├── ext │ ├── in │ ├── out │ └── tips ├── 44 │ ├── in │ ├── out │ └── tips ├── 45 │ ├── ext │ ├── in │ ├── out │ └── tips ├── 46 │ ├── in │ ├── out │ └── tips ├── 47 │ ├── in │ ├── out │ └── tips ├── 48 │ ├── in │ ├── out │ └── tips ├── 49 │ ├── in │ ├── out │ └── tips ├── 50 │ ├── in │ ├── out │ └── tips ├── 51 │ ├── in │ ├── out │ └── tips ├── 52 │ ├── ext │ ├── in │ ├── out │ └── tips ├── 53 │ ├── ext │ ├── in │ ├── out │ └── tips ├── 54 │ ├── in │ ├── out │ └── tips ├── 01 │ ├── ext │ ├── in │ ├── out │ └── tips ├── 02 │ ├── ext │ ├── in │ ├── out │ └── tips ├── 03 │ ├── in │ ├── out │ └── tips ├── 04 │ ├── in │ ├── out │ └── tips ├── 05 │ ├── ext │ ├── in │ ├── out │ └── tips ├── 06 │ ├── in │ ├── out │ └── tips ├── 07 │ ├── in │ ├── out │ └── tips ├── 08 │ ├── in │ ├── out │ └── tips └── 09 │ ├── in │ ├── out │ └── tips ├── lib └── shuffle.vim ├── main.vim └── run.sh /.gitignore: -------------------------------------------------------------------------------- 1 | local/ 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2020 Dan Kilman. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vim-kata 2 | 3 | A vimscript to help you improve your Vim muscle memory. 4 | 5 | ## Description 6 | 7 | I wrote `vim-kata` to help me improve my Vim skills, I'm hoping it will do the same for others. 8 | 9 | It is basically a scripted version of [Vim-Katas](https://github.com/adomokos/Vim-Katas) 10 | which in turn is heavily inspired by and mostly extracted from 11 | [Practical Vim](https://pragprog.com/book/dnvim/practical-vim). 12 | 13 | In addition to taking some of the katas directly from Vim Katas, I also borrowed extensively from 14 | [VimGolf](https://www.vimgolf.com/) and added a few of my own. 15 | 16 | The katas in this repo are not meant to be hard to solve. Quite the opposite. For each, there are usually 17 | several techniques that can be employed to simplify the task greatly. I believe that going over them 18 | frequently can help build muscle memory. 19 | 20 | I intend on adding a new kata every time I run into some new trick. 21 | 22 | Contributions of new katas and fixes/improvements to the script are most welcome! 23 | 24 | ## Demo 25 | 26 | ![Screencast](https://github.com/dankilman/vim-kata/raw/master/doc/demo.gif) 27 | 28 | ## Requirements 29 | 30 | I'm using neovim on macOS but I don't think I'm using anything neovim specific or very new features. 31 | 32 | That being said, the script may need some fixes to work in different setups. 33 | 34 | Specifically, windows is not supported but I'll gladly accept PRs that add windows support. 35 | 36 | ## Usage 37 | 38 | * Clone this repo. 39 | * from terminal, `cd` into repo directory. 40 | * from terminal, run `./run.sh` 41 | 42 | After `vim-kata` is loaded, the first kata should appear (first being the first in the newly shuffled order). 43 | 44 | `vim-kata` uses the Vim diff display mode. 45 | 46 | The upper window is the input text. This is where you edit the text. 47 | 48 | The lower window is the output text. This is what your editing should look like. This buffer is `'unmodifiable'`. 49 | 50 | Once you are done with a kata: 51 | 52 | * `` to load the next kata. 53 | * `` to reload the previous kata. 54 | * `` to load a specific kata by directory name (thanks [@oflisback](https://github.com/oflisback)). 55 | * `ZQ` to quit (mapped to `qa!`). 56 | 57 | ## Tips 58 | 59 | Each kata in the `katas` dir includes an additional `tips` file. 60 | 61 | This file gives an informal description of the key sequences I tend to use when doing the kata. 62 | 63 | The tips are usually trying to strike a balance between fewer keystrokes, while remaining pragmatic and 64 | easier to reuse across different similar situations. 65 | They are not optimizing for minimal keystrokes like VimGolf does. 66 | 67 | Type `g?` to display tips for the current kata. 68 | 69 | ## Configuration 70 | 71 | The `config.vim` file contains the configuration options for `vim-kata`. 72 | 73 | ## Adding Katas 74 | 75 | All katas are stored in the `katas` directory. 76 | 77 | Each kata is a directory comprised of 4 files: `in`, `out`, `ext` and `tips`. 78 | The `in` and `out` are self explanatory. 79 | 80 | The `ext` file is optional. It contains the file extension that should be used. 81 | This is relevent when you want a certain kata to have syntax highlighting. 82 | If `ext` doesn't exist, `txt` extension is used. 83 | 84 | If `tips` exists, it will displayed when typing `g?`. 85 | 86 | To add a kata, simply create a new directory with this structure. 87 | 88 | ### Custom cursor start location 89 | 90 | To have a kata start with the cursor positioned at a custom location, 91 | add a literal `` (`^K`) to the `in` document (not the `out`!). The kata will load with the cursor 92 | at that position, and the literal `` will be removed. 93 | -------------------------------------------------------------------------------- /config.vim: -------------------------------------------------------------------------------- 1 | " let g:vim_kata_shuffle = 1 2 | " let g:vim_kata_katas_dir = 'katas' 3 | " let g:vim_kata_diff_on = 1 4 | " let g:vim_kata_split_command = 'belowright split' 5 | " let g:vim_kata_next_kata_mapping = '' 6 | " let g:vim_kata_previous_kata_mapping = '' 7 | " let g:vim_kata_goto_kata_mapping = '' 8 | -------------------------------------------------------------------------------- /doc/demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dankilman/vim-kata/b106477c22bc9b0b0b7510001f0a6d278788042f/doc/demo.gif -------------------------------------------------------------------------------- /katas/01/ext: -------------------------------------------------------------------------------- 1 | js 2 | -------------------------------------------------------------------------------- /katas/01/in: -------------------------------------------------------------------------------- 1 | var foo = 1 2 | var bar = 'a' 3 | var foobar = foo + bar 4 | -------------------------------------------------------------------------------- /katas/01/out: -------------------------------------------------------------------------------- 1 | var foo = 1; 2 | var bar = 'a'; 3 | var foobar = foo + bar; 4 | -------------------------------------------------------------------------------- /katas/01/tips: -------------------------------------------------------------------------------- 1 | - 2j 2 | - $A; 3 | -------------------------------------------------------------------------------- /katas/02/ext: -------------------------------------------------------------------------------- 1 | js 2 | -------------------------------------------------------------------------------- /katas/02/in: -------------------------------------------------------------------------------- 1 | var foo = 1 2 | var bar = 'a' 3 | var foobar = foo + bar 4 | -------------------------------------------------------------------------------- /katas/02/out: -------------------------------------------------------------------------------- 1 | ;var foo = 1 2 | ;var bar = 'a' 3 | ;var foobar = foo + bar 4 | -------------------------------------------------------------------------------- /katas/02/tips: -------------------------------------------------------------------------------- 1 | - 2j 2 | - I; 3 | -------------------------------------------------------------------------------- /katas/03/in: -------------------------------------------------------------------------------- 1 | 1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1 2 | -------------------------------------------------------------------------------- /katas/03/out: -------------------------------------------------------------------------------- 1 | 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 2 | -------------------------------------------------------------------------------- /katas/03/tips: -------------------------------------------------------------------------------- 1 | - f+s + 2 | - qq;.q 3 | - 100@q 4 | -------------------------------------------------------------------------------- /katas/04/in: -------------------------------------------------------------------------------- 1 | "...We're waiting for content before the site can go live... 2 | 3 | ...If you are content with this, let's go ahead with it... 4 | 5 | ...We'll launch as soon as we have the content...” 6 | -------------------------------------------------------------------------------- /katas/04/out: -------------------------------------------------------------------------------- 1 | "...We're waiting for copy before the site can go live... 2 | 3 | ...If you are content with this, let's go ahead with it... 4 | 5 | ...We'll launch as soon as we have the copy...” 6 | -------------------------------------------------------------------------------- /katas/04/tips: -------------------------------------------------------------------------------- 1 | - /content 2 | - ciwcopy 3 | - nn. 4 | -------------------------------------------------------------------------------- /katas/05/ext: -------------------------------------------------------------------------------- 1 | css 2 | -------------------------------------------------------------------------------- /katas/05/in: -------------------------------------------------------------------------------- 1 | .blog, .news { background-image: url(/sprite.png); } 2 | .blog { background-position: 0px 0px } 3 | -------------------------------------------------------------------------------- /katas/05/out: -------------------------------------------------------------------------------- 1 | .blog, .news { background-image: url(/sprite.png); } 2 | .blog { background-position: 0px 0px } 3 | .news { background-position: -180px 0px } 4 | -------------------------------------------------------------------------------- /katas/05/tips: -------------------------------------------------------------------------------- 1 | - jYp 2 | - wcwnews 3 | - 180 4 | -------------------------------------------------------------------------------- /katas/06/in: -------------------------------------------------------------------------------- 1 | Change two words in this sentence. 2 | Delete two words in this sentence. 3 | Yank two words in this sentence. 4 | Paste the two words yanked in the previous sentence. 5 | Apply CaSe operators on this sentENCE. 6 | Put this line to the right. 7 | Put this line to the left. 8 | Let auto indentation do the job for you in the following 2 sentences. 9 | This one is the the first. 10 | This one is the second. 11 | 12 | -------------------------------------------------------------------------------- /katas/06/out: -------------------------------------------------------------------------------- 1 | Change two from this sentence. 2 | Delete two words sentence. 3 | Yank two words in this sentence. 4 | Paste the two words yanked this sentence in the previous sentence. 5 | APPLY case operators ON this SENTence. 6 | Put this line to the right. 7 | Put this line to the left. 8 | Let auto indentation do the job for you in the following 2 sentences. 9 | This one is the the first. 10 | This one is the second. 11 | 12 | -------------------------------------------------------------------------------- /katas/06/tips: -------------------------------------------------------------------------------- 1 | - 2wc2wfrom 2 | - 3wd2w 3 | - 4wy2w 4 | - 5wi P 5 | - gUwwguwwgUwwwg~w 6 | - j>>j<< 7 | - j=G 8 | -------------------------------------------------------------------------------- /katas/07/in: -------------------------------------------------------------------------------- 1 | Delete a char in insert mode using 2 | Delete a word in insert mode usingf 3 | Delete to the start of line in insert mode using 4 | -------------------------------------------------------------------------------- /katas/07/out: -------------------------------------------------------------------------------- 1 | Delete a chr in insert mode using 2 | Delete a word in mode usingf 3 | of line in insert mode using 4 | -------------------------------------------------------------------------------- /katas/07/tips: -------------------------------------------------------------------------------- 1 | - 3ei 2 | - 5wi 3 | - 4wi 4 | -------------------------------------------------------------------------------- /katas/08/in: -------------------------------------------------------------------------------- 1 | # use register in insert mode 2 | Practical Vim, by Drew Neil 3 | Read Drew Neil's 4 | -------------------------------------------------------------------------------- /katas/08/out: -------------------------------------------------------------------------------- 1 | # use register in insert mode 2 | Practical Vim, by Drew Neil 3 | Read Drew Neil's Practical Vim. 4 | -------------------------------------------------------------------------------- /katas/08/tips: -------------------------------------------------------------------------------- 1 | - jy2w 2 | - jA 3 | - 0. 4 | -------------------------------------------------------------------------------- /katas/09/in: -------------------------------------------------------------------------------- 1 | 6 chairs, each costing $35, totals $ 2 | -------------------------------------------------------------------------------- /katas/09/out: -------------------------------------------------------------------------------- 1 | 6 chairs, each costing $35, totals $210 2 | -------------------------------------------------------------------------------- /katas/09/tips: -------------------------------------------------------------------------------- 1 | - A 2 | - = 3 | - 35*6 4 | -------------------------------------------------------------------------------- /katas/10/in: -------------------------------------------------------------------------------- 1 | `:digraphs` - Look up all the possible options 2 | `?I` - will give you ¿ 3 | `Ct` - will give you ¢ 4 | -------------------------------------------------------------------------------- /katas/10/out: -------------------------------------------------------------------------------- 1 | `:digraphs` - Look up all the possible options 2 | `?I` - will give you ¿ 3 | `Ct` - will give you ¢ 4 | ¿ - ¢ 5 | -------------------------------------------------------------------------------- /katas/10/tips: -------------------------------------------------------------------------------- 1 | - Go 2 | - ?I - Ct 3 | -------------------------------------------------------------------------------- /katas/11/in: -------------------------------------------------------------------------------- 1 | Typing in insert mode extends the line. But in replace mode 2 | the line length does not change. 3 | -------------------------------------------------------------------------------- /katas/11/out: -------------------------------------------------------------------------------- 1 | Typing in insert mode extends the line, but in replace mode 2 | the line length does not change. 3 | -------------------------------------------------------------------------------- /katas/11/tips: -------------------------------------------------------------------------------- 1 | - f.R, b 2 | -------------------------------------------------------------------------------- /katas/12/in: -------------------------------------------------------------------------------- 1 | I like March better than anything. (use visual mode) 2 | -------------------------------------------------------------------------------- /katas/12/out: -------------------------------------------------------------------------------- 1 | I like April better than anything. (use visual mode) 2 | -------------------------------------------------------------------------------- /katas/12/tips: -------------------------------------------------------------------------------- 1 | - 2wvecApril 2 | -------------------------------------------------------------------------------- /katas/13/ext: -------------------------------------------------------------------------------- 1 | py 2 | -------------------------------------------------------------------------------- /katas/13/in: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /katas/13/out: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /katas/13/tips: -------------------------------------------------------------------------------- 1 | - 3j 2 | - Vj 3 | - >. 4 | -------------------------------------------------------------------------------- /katas/14/ext: -------------------------------------------------------------------------------- 1 | html 2 | -------------------------------------------------------------------------------- /katas/14/in: -------------------------------------------------------------------------------- 1 | one 2 | two 3 | three 4 | -------------------------------------------------------------------------------- /katas/14/out: -------------------------------------------------------------------------------- 1 | ONE 2 | TWO 3 | THREE 4 | -------------------------------------------------------------------------------- /katas/14/tips: -------------------------------------------------------------------------------- 1 | - gUit 2 | - j.j. 3 | -------------------------------------------------------------------------------- /katas/15/in: -------------------------------------------------------------------------------- 1 | Chapter Page 2 | Normal Mode 15 3 | Insert Mode 31 4 | Visual Mode 44 5 | -------------------------------------------------------------------------------- /katas/15/out: -------------------------------------------------------------------------------- 1 | Chapter | Page 2 | ------------------- 3 | Normal Mode | 15 4 | Insert Mode | 31 5 | Visual Mode | 44 6 | -------------------------------------------------------------------------------- /katas/15/tips: -------------------------------------------------------------------------------- 1 | - 13l 2 | - 3j 3 | - x.... 4 | - gvr| 5 | - YpVr- 6 | -------------------------------------------------------------------------------- /katas/16/ext: -------------------------------------------------------------------------------- 1 | css 2 | -------------------------------------------------------------------------------- /katas/16/in: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /katas/16/out: -------------------------------------------------------------------------------- 1 | li.one a{ background-image: url('/components/sprite.png'); } 2 | li.two a{ background-image: url('/components/sprite.png'); } 3 | li.three a{ background-image: url('/components/sprite.png'); } 4 | -------------------------------------------------------------------------------- /katas/16/tips: -------------------------------------------------------------------------------- 1 | #1 2 | (assumes vim-targets is installed) 3 | - ci/components 4 | - j.j. 5 | 6 | #2 7 | - f/l 8 | - 2jeccomponents 9 | -------------------------------------------------------------------------------- /katas/17/in: -------------------------------------------------------------------------------- 1 | # use :t and :m 2 | 3 | Shopping list 4 | Hardware store 5 | Buy new hammer 6 | Beauty parlor 7 | Buy nail polish remover 8 | Buy nails 9 | -------------------------------------------------------------------------------- /katas/17/out: -------------------------------------------------------------------------------- 1 | # use :t and :m 2 | 3 | Shopping list 4 | Beauty parlor 5 | Buy nail polish remover 6 | Buy nails 7 | Hardware store 8 | Buy nails 9 | Buy new hammer 10 | -------------------------------------------------------------------------------- /katas/17/tips: -------------------------------------------------------------------------------- 1 | - 3j 2 | - :+4t. 3 | - k 4 | - :,+2m$ 5 | -------------------------------------------------------------------------------- /katas/18/ext: -------------------------------------------------------------------------------- 1 | js 2 | -------------------------------------------------------------------------------- /katas/18/in: -------------------------------------------------------------------------------- 1 | // use :norm 2 | var foo = 1 3 | var bar = 'a' 4 | var baz = 'z' 5 | var foobar = foo + bar 6 | var foobarbaz = foo + bar + baz 7 | -------------------------------------------------------------------------------- /katas/18/out: -------------------------------------------------------------------------------- 1 | // use :norm 2 | var foo = 1; 3 | var bar = 'a'; 4 | var baz = 'z'; 5 | var foobar = foo + bar; 6 | var foobarbaz = foo + bar + baz; 7 | -------------------------------------------------------------------------------- /katas/18/tips: -------------------------------------------------------------------------------- 1 | - jVG 2 | - :norm A; 3 | -------------------------------------------------------------------------------- /katas/19/ext: -------------------------------------------------------------------------------- 1 | js 2 | -------------------------------------------------------------------------------- /katas/19/in: -------------------------------------------------------------------------------- 1 | // do *, then cw then %s with :%s///g 2 | 3 | var tally; 4 | for (tally=1; tally <= 10; tally++) { 5 | // Do something with tally 6 | }; 7 | -------------------------------------------------------------------------------- /katas/19/out: -------------------------------------------------------------------------------- 1 | // do *, then cw then %s with :%s///g 2 | 3 | var counter; 4 | for (counter=1; counter <= 10; counter++) { 5 | // Do something with counter 6 | }; 7 | -------------------------------------------------------------------------------- /katas/19/tips: -------------------------------------------------------------------------------- 1 | - /ta 2 | - * 3 | - ciwcounter 4 | - :%s///g 5 | -------------------------------------------------------------------------------- /katas/20/in: -------------------------------------------------------------------------------- 1 | # start on takes then d/ge 2 | 3 | This phrase takes time but 4 | eventually gets to the point. 5 | -------------------------------------------------------------------------------- /katas/20/out: -------------------------------------------------------------------------------- 1 | # start on takes then d/ge 2 | 3 | This phrase gets to the point. 4 | -------------------------------------------------------------------------------- /katas/20/tips: -------------------------------------------------------------------------------- 1 | - d/ge 2 | -------------------------------------------------------------------------------- /katas/21/ext: -------------------------------------------------------------------------------- 1 | js 2 | -------------------------------------------------------------------------------- /katas/21/in: -------------------------------------------------------------------------------- 1 | var tpl = [ 2 | '{title}' 3 | ] 4 | -------------------------------------------------------------------------------- /katas/21/out: -------------------------------------------------------------------------------- 1 | var tpl = [ 2 | 'Click Here' 3 | ] 4 | -------------------------------------------------------------------------------- /katas/21/tips: -------------------------------------------------------------------------------- 1 | (assumes vim-targets is installed) 2 | - ci"# 3 | - citClick Here 4 | -------------------------------------------------------------------------------- /katas/22/in: -------------------------------------------------------------------------------- 1 | Practica lvi m 2 | 3 | 2) line two 4 | 1) line one 5 | 3) line three 6 | 7 | collection = getCollection(); 8 | process(somethingInTheWay, target); 9 | -------------------------------------------------------------------------------- /katas/22/out: -------------------------------------------------------------------------------- 1 | Practical vim 2 | 3 | 1) line one 4 | 2) line two 5 | 3) line three 6 | 7 | collection = getCollection(); 8 | process(collection, target); 9 | -------------------------------------------------------------------------------- /katas/22/tips: -------------------------------------------------------------------------------- 1 | - F xp 2 | - 2j 3 | - ddp 4 | - 3j 5 | - yiw 6 | - j 7 | - 2wvep 8 | -------------------------------------------------------------------------------- /katas/23/in: -------------------------------------------------------------------------------- 1 | I like chips and fish. 2 | -------------------------------------------------------------------------------- /katas/23/out: -------------------------------------------------------------------------------- 1 | I like fish and chips. 2 | -------------------------------------------------------------------------------- /katas/23/tips: -------------------------------------------------------------------------------- 1 | - fc 2 | - de 3 | - mm 4 | - ff 5 | - vep 6 | - `mP 7 | -------------------------------------------------------------------------------- /katas/24/in: -------------------------------------------------------------------------------- 1 | 1. one 2 | 2. two 3 | 3. three 4 | 4. four 5 | 5. five 6 | -------------------------------------------------------------------------------- /katas/24/out: -------------------------------------------------------------------------------- 1 | 1) One 2 | 2) Two 3 | 3) Three 4 | 4) Four 5 | 5) Five 6 | -------------------------------------------------------------------------------- /katas/24/tips: -------------------------------------------------------------------------------- 1 | - l4j 2 | - r) 3 | - 2l 4 | - 1U 5 | -------------------------------------------------------------------------------- /katas/25/in: -------------------------------------------------------------------------------- 1 | partridge in a pear tree 2 | turtle doves 3 | French hens 4 | calling birds 5 | golden rings 6 | -------------------------------------------------------------------------------- /katas/25/out: -------------------------------------------------------------------------------- 1 | 1) partridge in a pear tree 2 | 2) turtle doves 3 | 3) French hens 4 | 4) calling birds 5 | 5) golden rings 6 | -------------------------------------------------------------------------------- /katas/25/tips: -------------------------------------------------------------------------------- 1 | - 4j 2 | - I0) 3 | - gv 4 | - g 5 | -------------------------------------------------------------------------------- /katas/26/ext: -------------------------------------------------------------------------------- 1 | rb 2 | -------------------------------------------------------------------------------- /katas/26/in: -------------------------------------------------------------------------------- 1 | class XhtmlDocument < XmlDocument; end 2 | class XhtmlTag < XmlTag; end 3 | -------------------------------------------------------------------------------- /katas/26/out: -------------------------------------------------------------------------------- 1 | class XHTMLDocument < XMLDocument; end 2 | class XHTMLTag < XMLTag; end 3 | -------------------------------------------------------------------------------- /katas/26/tips: -------------------------------------------------------------------------------- 1 | - /Xhtml 2 | - gnUgnU 3 | - /Xml 4 | - gnUgnU 5 | -------------------------------------------------------------------------------- /katas/27/in: -------------------------------------------------------------------------------- 1 | This string contains a 'quoted' word. 2 | This string contains 'two' quoted 'words'. 3 | This 'string doesn't make things easy'. 4 | -------------------------------------------------------------------------------- /katas/27/out: -------------------------------------------------------------------------------- 1 | This string contains a "quoted" word. 2 | This string contains "two" quoted "words". 3 | This "string doesn't make things easy". 4 | -------------------------------------------------------------------------------- /katas/27/tips: -------------------------------------------------------------------------------- 1 | (assumes vim-surround is installed) 2 | - cs'" 3 | - j.. 4 | - 5 | - f'r" 6 | - ;;. 7 | -------------------------------------------------------------------------------- /katas/28/ext: -------------------------------------------------------------------------------- 1 | py 2 | -------------------------------------------------------------------------------- /katas/28/in: -------------------------------------------------------------------------------- 1 | li = ['one', 'two', 'three', 'four', 'five', 'six'] 2 | -------------------------------------------------------------------------------- /katas/28/out: -------------------------------------------------------------------------------- 1 | li = [ 2 | 'one', 3 | 'two', 4 | 'three', 5 | 'four', 6 | 'five', 7 | 'six', 8 | ] 9 | -------------------------------------------------------------------------------- /katas/28/tips: -------------------------------------------------------------------------------- 1 | - wwa 2 | - f,a 3 | - ;.;.;.;. 4 | - $i, 5 | -------------------------------------------------------------------------------- /katas/29/in: -------------------------------------------------------------------------------- 1 | package-one==0.1.23 2 | another-package==2.2.2 3 | the-third-one==0.0.1 4 | the-fourth-one==0.0.1 5 | the-last-package==0.1.0 6 | -------------------------------------------------------------------------------- /katas/29/out: -------------------------------------------------------------------------------- 1 | package-one==0.1.23 2 | another-package==2.2.2 3 | the-third-one==0.1.23 4 | the-fourth-one==0.1.23 5 | the-last-package==7.3.12 6 | -------------------------------------------------------------------------------- /katas/29/tips: -------------------------------------------------------------------------------- 1 | - f0y$ 2 | - 2 3 | - qqf0"_Dpq 4 | - @q 5 | - f0C7.3.12 6 | -------------------------------------------------------------------------------- /katas/30/ext: -------------------------------------------------------------------------------- 1 | java 2 | -------------------------------------------------------------------------------- /katas/30/in: -------------------------------------------------------------------------------- 1 | super.onCreate(savedInstanceState) 2 | setContentView(R.layout.activity_second) 3 | Intent intent = getIntent() 4 | String text = intent.getStringExtra("text") 5 | 6 | TextView view = findViewById(R.id.textView2) 7 | view.setText(text) -------------------------------------------------------------------------------- /katas/30/out: -------------------------------------------------------------------------------- 1 | super.onCreate(savedInstanceState); 2 | setContentView(R.layout.activity_second); 3 | Intent intent = getIntent(); 4 | String text = intent.getStringExtra("text"); 5 | 6 | TextView view = findViewById(R.id.textView2); 7 | view.setText(text); -------------------------------------------------------------------------------- /katas/30/tips: -------------------------------------------------------------------------------- 1 | - V3j 2 | - :norm A; 3 | - 2jVj 4 | - : 5 | -------------------------------------------------------------------------------- /katas/31/ext: -------------------------------------------------------------------------------- 1 | file -------------------------------------------------------------------------------- /katas/31/in: -------------------------------------------------------------------------------- 1 | My dream is to be in a box 2 | -------------------------------------------------------------------------------- /katas/31/out: -------------------------------------------------------------------------------- 1 | ############################### 2 | # My dream was to be in a box # 3 | ############################### 4 | -------------------------------------------------------------------------------- /katas/31/tips: -------------------------------------------------------------------------------- 1 | - i# 2 | - ficiwwasA # 3 | - YPVr#YGp 4 | -------------------------------------------------------------------------------- /katas/32/in: -------------------------------------------------------------------------------- 1 | - One number per line - 2 | ----------------------- 3 | 2,3,5,7, 4 | 11,13,17, 5 | 19,23,29, 6 | -------------------------------------------------------------------------------- /katas/32/out: -------------------------------------------------------------------------------- 1 | 2 2 | 3 3 | 5 4 | 7 5 | 11 6 | 13 7 | 17 8 | 19 9 | 23 10 | 29 11 | -------------------------------------------------------------------------------- /katas/32/tips: -------------------------------------------------------------------------------- 1 | - dj 2 | - :%s/,/\r/g 3 | - :v/./d 4 | -------------------------------------------------------------------------------- /katas/33/in: -------------------------------------------------------------------------------- 1 | ## Headers 2 | 3 | ## To 4 | 5 | ## Underline 6 | -------------------------------------------------------------------------------- /katas/33/out: -------------------------------------------------------------------------------- 1 | Headers 2 | ------- 3 | 4 | Are 5 | --- 6 | 7 | Underlined 8 | ---------- 9 | -------------------------------------------------------------------------------- /katas/33/tips: -------------------------------------------------------------------------------- 1 | - 2jfTRAre 2 | - GAd0 3 | - qqdwYpVr-q 4 | - gg@q 5 | - 2j@q 6 | -------------------------------------------------------------------------------- /katas/34/ext: -------------------------------------------------------------------------------- 1 | java 2 | -------------------------------------------------------------------------------- /katas/34/in: -------------------------------------------------------------------------------- 1 | copyRtL(source, destination); 2 | copyRtL("John Q. Public", nameVariable); 3 | -------------------------------------------------------------------------------- /katas/34/out: -------------------------------------------------------------------------------- 1 | copyRtL(destination, source); 2 | copyRtL(nameVariable, "John Q. Public"); 3 | -------------------------------------------------------------------------------- /katas/34/tips: -------------------------------------------------------------------------------- 1 | (assumes vim-targets is installed for dia) 2 | - qq 3 | - dia 4 | - mm 5 | - wvep 6 | - `mP 7 | - q 8 | - @q 9 | -------------------------------------------------------------------------------- /katas/35/ext: -------------------------------------------------------------------------------- 1 | in -------------------------------------------------------------------------------- /katas/35/in: -------------------------------------------------------------------------------- 1 | foo = a 2 | ab 3 | abc 4 | -------------------------------------------------------------------------------- /katas/35/out: -------------------------------------------------------------------------------- 1 | foo = "a" 2 | "ab" 3 | "abc" 4 | -------------------------------------------------------------------------------- /katas/35/tips: -------------------------------------------------------------------------------- 1 | #1 2 | - fa 3 | - 2jI" 4 | - gv$A" 5 | 6 | #2 7 | (assumes vim-surround is installed) 8 | - fa 9 | - ysw" 10 | - j.j. 11 | -------------------------------------------------------------------------------- /katas/36/in: -------------------------------------------------------------------------------- 1 | EMPLOYEE_NAME 2 | 3 | REVENUE_YEAR_TO_DATE 4 | 5 | SALARY -------------------------------------------------------------------------------- /katas/36/out: -------------------------------------------------------------------------------- 1 | Employee Name 2 | 3 | Revenue Year To Date 4 | 5 | Salary -------------------------------------------------------------------------------- /katas/36/tips: -------------------------------------------------------------------------------- 1 | - :%s/_/ /g 2 | - gg 3 | - qqguw~q 4 | - WQWWQWQWQWQWWQ 5 | -------------------------------------------------------------------------------- /katas/37/ext: -------------------------------------------------------------------------------- 1 | in -------------------------------------------------------------------------------- /katas/37/in: -------------------------------------------------------------------------------- 1 | one two 2 | three 3 | -------------------------------------------------------------------------------- /katas/37/out: -------------------------------------------------------------------------------- 1 | (one) (two) 2 | (three) 3 | -------------------------------------------------------------------------------- /katas/37/tips: -------------------------------------------------------------------------------- 1 | (assumes vim-surround is installed) 2 | - ysw) 3 | - W.W. 4 | -------------------------------------------------------------------------------- /katas/38/ext: -------------------------------------------------------------------------------- 1 | cs 2 | -------------------------------------------------------------------------------- /katas/38/in: -------------------------------------------------------------------------------- 1 | Assert.ThrowsAsync(() => _auction.StartSellingItem()); 2 | Assert.ThrowsAsync(() => _application.StartBiddingIn(_auction)); 3 | Assert.ThrowsAsync(() => _auction.HasReceivedJoinRequestFromSniper()); 4 | Assert.ThrowsAsync(() => _auction.AnnounceClosed()); 5 | Assert.ThrowsAsync(() => _application.ShowsSniperHasLostAuction()); -------------------------------------------------------------------------------- /katas/38/out: -------------------------------------------------------------------------------- 1 | _auction.StartSellingItem(); 2 | _application.StartBiddingIn(_auction); 3 | _auction.HasReceivedJoinRequestFromSniper(); 4 | _auction.AnnounceClosed(); 5 | _application.ShowsSniperHasLostAuction(); -------------------------------------------------------------------------------- /katas/38/tips: -------------------------------------------------------------------------------- 1 | (assumes vim-surround is installed) 2 | - t(4jd 3 | - l 4 | - t_4jd 5 | - VG:norm ds( 6 | -------------------------------------------------------------------------------- /katas/39/ext: -------------------------------------------------------------------------------- 1 | before -------------------------------------------------------------------------------- /katas/39/in: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /katas/39/out: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 3 4 | 4 5 | 5 6 | 6 7 | 7 8 | 8 9 | 9 10 | 10 11 | -------------------------------------------------------------------------------- /katas/39/tips: -------------------------------------------------------------------------------- 1 | - 10o0 2 | - ggdd 3 | - Gg 4 | -------------------------------------------------------------------------------- /katas/40/ext: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /katas/40/in: -------------------------------------------------------------------------------- 1 | The quick brown fox jumps over the lazy dog. 2 | -------------------------------------------------------------------------------- /katas/40/out: -------------------------------------------------------------------------------- 1 | The quick lazy dog jumps over the brown fox. 2 | -------------------------------------------------------------------------------- /katas/40/tips: -------------------------------------------------------------------------------- 1 | - fbd2e 2 | - mm 3 | - flv2ep 4 | - `mP 5 | -------------------------------------------------------------------------------- /katas/41/ext: -------------------------------------------------------------------------------- 1 | input -------------------------------------------------------------------------------- /katas/41/in: -------------------------------------------------------------------------------- 1 | const enum TestkitType { 2 | vanilla, 3 | unidriver, 4 | protractor, 5 | puppeteer, 6 | unknown, 7 | } 8 | -------------------------------------------------------------------------------- /katas/41/out: -------------------------------------------------------------------------------- 1 | const enum TestkitType { 2 | vanilla = 'VANILLA', 3 | unidriver = 'UNIDRIVER', 4 | protractor = 'PROTRACTOR', 5 | puppeteer = 'PUPPETEER', 6 | unknown = 'UNKNOWN', 7 | } 8 | -------------------------------------------------------------------------------- /katas/41/tips: -------------------------------------------------------------------------------- 1 | - 2 | - qqyiwwi = '0' 3 | - gUi'q 4 | - 4@q 5 | -------------------------------------------------------------------------------- /katas/42/ext: -------------------------------------------------------------------------------- 1 | file -------------------------------------------------------------------------------- /katas/42/in: -------------------------------------------------------------------------------- 1 | name=www-data, groups=developer 2 | -------------------------------------------------------------------------------- /katas/42/out: -------------------------------------------------------------------------------- 1 | name=developer, groups=www-data 2 | -------------------------------------------------------------------------------- /katas/42/tips: -------------------------------------------------------------------------------- 1 | - fwdt, 2 | - mm 3 | - fdvep 4 | - `mP 5 | -------------------------------------------------------------------------------- /katas/43/ext: -------------------------------------------------------------------------------- 1 | input -------------------------------------------------------------------------------- /katas/43/in: -------------------------------------------------------------------------------- 1 | export const playground: ( 2 | object?: Partial, 3 | ) => PlaygroundSection = config => 4 | baseSection({ 5 | type: SectionType.Playground, 6 | ...config, 7 | }); 8 | -------------------------------------------------------------------------------- /katas/43/out: -------------------------------------------------------------------------------- 1 | export const playground = ( 2 | config?: Partial, 3 | ): PlaygroundSection => 4 | baseSection({ 5 | type: SectionType.Playground, 6 | ...config, 7 | }); 8 | -------------------------------------------------------------------------------- /katas/43/tips: -------------------------------------------------------------------------------- 1 | - f:s = 2 | - ciwconfig 3 | - a: 4 | - wdw 5 | - f=dt= 6 | -------------------------------------------------------------------------------- /katas/44/in: -------------------------------------------------------------------------------- 1 | * item1 2 | * item2 3 | * item3 4 | * item4 5 | * item5 6 | -------------------------------------------------------------------------------- /katas/44/out: -------------------------------------------------------------------------------- 1 | item1,item2,item3,item4,item5 2 | -------------------------------------------------------------------------------- /katas/44/tips: -------------------------------------------------------------------------------- 1 | - 4jxgvr, 2 | - x 3 | - 5gJ 4 | -------------------------------------------------------------------------------- /katas/45/ext: -------------------------------------------------------------------------------- 1 | py 2 | -------------------------------------------------------------------------------- /katas/45/in: -------------------------------------------------------------------------------- 1 | hello(one, two, three, four, five) 2 | -------------------------------------------------------------------------------- /katas/45/out: -------------------------------------------------------------------------------- 1 | hello( 2 | one=one, 3 | two=two, 4 | three=three, 5 | four=four, 6 | five=five, 7 | ) 8 | -------------------------------------------------------------------------------- /katas/45/tips: -------------------------------------------------------------------------------- 1 | - waw 2 | - qqyiwwi=0wawq 3 | - 4@q 4 | - dd 5 | - $i, 6 | - 7 | -------------------------------------------------------------------------------- /katas/46/in: -------------------------------------------------------------------------------- 1 | 3 2 | 3 3 | 2 4 | 2 5 | 1 6 | 1 7 | 4 8 | 3 9 | 2 10 | 1 11 | -------------------------------------------------------------------------------- /katas/46/out: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 3 4 | 4 5 | -------------------------------------------------------------------------------- /katas/46/tips: -------------------------------------------------------------------------------- 1 | - :sort u 2 | -------------------------------------------------------------------------------- /katas/47/in: -------------------------------------------------------------------------------- 1 | append at the end of the word using ea 2 | -------------------------------------------------------------------------------- /katas/47/out: -------------------------------------------------------------------------------- 1 | appended at the end of the word using ea 2 | -------------------------------------------------------------------------------- /katas/47/tips: -------------------------------------------------------------------------------- 1 | - eaed 2 | -------------------------------------------------------------------------------- /katas/48/in: -------------------------------------------------------------------------------- 1 | This kata is meant to practice paragraph and sentence momements. While you could 2 | generally use j/k and similar, it is not the reason this kata exists. I am without 3 | words. The half. 4 | 5 | To practice paragraph movement, you generally want to have at least two paragrahps. 6 | That is at least what I think. Words do count. So that's it. 7 | 8 | Maybe a third paragraph will make things easier. Delete this sentence. Do not 9 | delete this sentence. 10 | -------------------------------------------------------------------------------- /katas/48/out: -------------------------------------------------------------------------------- 1 | This kata is meant to practice paragraph and sentence momements. While you could 2 | generally use j/k and similar, it is not the reason this kata exists. The half. 3 | 4 | Maybe a third paragraph will make things easier. Do not 5 | delete this sentence. 6 | -------------------------------------------------------------------------------- /katas/48/tips: -------------------------------------------------------------------------------- 1 | - 2)d)j 2 | - d} 3 | - 2)d) 4 | -------------------------------------------------------------------------------- /katas/49/in: -------------------------------------------------------------------------------- 1 | The cursor is positioned at the end. 2 | This kata targets the use of # to search word under cursor 3 | backwards for a wor d. 4 | -------------------------------------------------------------------------------- /katas/49/out: -------------------------------------------------------------------------------- 1 | The cursor is positioned at the end. 2 | This kata targets the use of # to search under cursor 3 | backwards for a word. 4 | -------------------------------------------------------------------------------- /katas/49/tips: -------------------------------------------------------------------------------- 1 | - #dw 2 | -------------------------------------------------------------------------------- /katas/50/in: -------------------------------------------------------------------------------- 1 | " / 2 | One, Two, Three, Four, Five 3 | abc, def, ghhij, klmn, opqr 4 | -------------------------------------------------------------------------------- /katas/50/out: -------------------------------------------------------------------------------- 1 | " / 2 | One, def, Three, Four, Five 3 | abc, def, ghhij, Four, opqr 4 | -------------------------------------------------------------------------------- /katas/50/tips: -------------------------------------------------------------------------------- 1 | - j 2 | - 2wciw 3 | - j2Wciw 4 | -------------------------------------------------------------------------------- /katas/51/in: -------------------------------------------------------------------------------- 1 | ( 2 | one, 3 | two, 4 | ) 5 | ( 6 | three, 7 | four, 8 | ) 9 | ( 10 | five, 11 | six, 12 | ) 13 | -------------------------------------------------------------------------------- /katas/51/out: -------------------------------------------------------------------------------- 1 | ( 2 | one, 3 | two, 4 | ) 5 | 0 6 | ( 7 | three, 8 | four, 9 | ) 10 | 1 11 | ( 12 | five, 13 | six, 14 | ) 15 | -------------------------------------------------------------------------------- /katas/51/tips: -------------------------------------------------------------------------------- 1 | - %o0 2 | - j%o1 3 | -------------------------------------------------------------------------------- /katas/52/ext: -------------------------------------------------------------------------------- 1 | py 2 | -------------------------------------------------------------------------------- /katas/52/in: -------------------------------------------------------------------------------- 1 | def hello(): 2 | """consider using S""" 3 | print('Hello') 4 | -------------------------------------------------------------------------------- /katas/52/out: -------------------------------------------------------------------------------- 1 | def hello(): 2 | """consider using S""" 3 | return 'Goodbye' 4 | -------------------------------------------------------------------------------- /katas/52/tips: -------------------------------------------------------------------------------- 1 | - Sreturn 'Goodbye' 2 | -------------------------------------------------------------------------------- /katas/53/ext: -------------------------------------------------------------------------------- 1 | py 2 | -------------------------------------------------------------------------------- /katas/53/in: -------------------------------------------------------------------------------- 1 | def hello(self): 2 | """consider using I""" 3 | some_method('Hello') 4 | -------------------------------------------------------------------------------- /katas/53/out: -------------------------------------------------------------------------------- 1 | def hello(self): 2 | """consider using I""" 3 | self.some_method('Hello') 4 | -------------------------------------------------------------------------------- /katas/53/tips: -------------------------------------------------------------------------------- 1 | - Iself. 2 | -------------------------------------------------------------------------------- /katas/54/in: -------------------------------------------------------------------------------- 1 | This is the first point: 2 | * The first point 3 | 4 | -- 5 | 6 | This is the second one: 7 | * The second one 8 | 9 | === 10 | 11 | And as expected, the third: 12 | * The third and last point 13 | 14 | ____ 15 | 16 | Put them here: 17 | 18 | ///// 19 | -------------------------------------------------------------------------------- /katas/54/out: -------------------------------------------------------------------------------- 1 | This is the first point: 2 | 3 | -- 4 | 5 | This is the second one: 6 | 7 | === 8 | 9 | And as expected, the third: 10 | 11 | ____ 12 | 13 | Put them here: 14 | * The first point 15 | * The second one 16 | * The third and last point 17 | 18 | ///// 19 | -------------------------------------------------------------------------------- /katas/54/tips: -------------------------------------------------------------------------------- 1 | - g/*/m16 2 | -------------------------------------------------------------------------------- /lib/shuffle.vim: -------------------------------------------------------------------------------- 1 | function! Shuffle(list) 2 | let n = len(a:list) 3 | for i in range(0, n-2) 4 | let j = Random(0, n-i-1) 5 | let e = a:list[i] 6 | let a:list[i] = a:list[i+j] 7 | let a:list[i+j] = e 8 | endfor 9 | return a:list 10 | endfunction 11 | 12 | function! Random(min, max) 13 | let i = system('echo $RANDOM') 14 | return i * (a:max - a:min + 1) / 32768 + a:min 15 | endfunction 16 | -------------------------------------------------------------------------------- /main.vim: -------------------------------------------------------------------------------- 1 | source lib/shuffle.vim 2 | 3 | let s:current_kata = 0 4 | let s:kata_pairs = [] 5 | 6 | let s:next_kata_mapping = '' 7 | let s:previous_kata_mapping = '' 8 | let s:goto_kata_mapping = '' 9 | if exists('g:vim_kata_next_kata_mapping') 10 | let s:next_kata_mapping = g:vim_kata_next_kata_mapping 11 | endif 12 | if exists('g:vim_kata_previous_kata_mapping') 13 | let s:previous_kata_mapping = g:vim_kata_previous_kata_mapping 14 | endif 15 | if exists('g:vim_kata_goto_kata_mapping') 16 | let s:goto_kata_mapping = g:vim_kata_goto_kata_mapping 17 | endif 18 | execute 'nnoremap '.s:next_kata_mapping.' :call KataNext()' 19 | execute 'nnoremap '.s:previous_kata_mapping.' :call KataPrevious()' 20 | execute 'nnoremap '.s:goto_kata_mapping.' :call KataGoto()' 21 | 22 | nnoremap ZQ :qa! 23 | execute 'nnoremap g? :call CurrentKataTip()' 24 | 25 | function! CurrentKataTip() 26 | let current_conf = s:kata_pairs[s:current_kata] 27 | let tips = '' 28 | let tips_path = current_conf.tips 29 | if filereadable(tips_path) 30 | let tips = join(readfile(tips_path), "\n") 31 | endif 32 | echo tips 33 | endfunction 34 | 35 | function! LoadKatas() 36 | let result = [] 37 | let katas_dir = 'katas' 38 | if exists('g:vim_kata_katas_dir') 39 | let katas_dir = g:vim_kata_katas_dir 40 | endif 41 | let dirs = systemlist('ls '. katas_dir) 42 | for dir in dirs 43 | let ext = 'txt' 44 | let ext_path = katas_dir.'/'.dir.'/ext' 45 | if filereadable(ext_path) 46 | let ext = readfile(ext_path)[0] 47 | endif 48 | let in = katas_dir.'/'.dir.'/in' 49 | let out = katas_dir.'/'.dir.'/out' 50 | let tips = katas_dir.'/'.dir.'/tips' 51 | call add(result, {'in': in, 'out': out, 'ext': ext, 'dir': dir, 'tips': tips}) 52 | endfor 53 | if !exists('g:vim_kata_shuffle') || g:vim_kata_shuffle 54 | call Shuffle(result) 55 | endif 56 | let s:kata_pairs = result 57 | endfunction 58 | 59 | function! KataNext() 60 | if s:current_kata >= len(s:kata_pairs) - 1 61 | echo 'Already at last kata' 62 | return 63 | endif 64 | let s:current_kata += 1 65 | call LoadCurrentKata() 66 | endfunction 67 | 68 | function! KataPrevious() 69 | if s:current_kata <= 0 70 | echo 'Already at first kata' 71 | return 72 | endif 73 | let s:current_kata -= 1 74 | call LoadCurrentKata() 75 | endfunction 76 | 77 | function! KataGoto() 78 | call inputsave() 79 | let dir = input('Enter kata directory: ') 80 | call inputrestore() 81 | let kata_dirs = map(copy(s:kata_pairs), 'v:val.dir') 82 | let i = index(kata_dirs, dir) 83 | if i == -1 84 | redraw 85 | echo 'Kata directory not found: ' . dir 86 | return 87 | endif 88 | let s:current_kata = i 89 | call LoadCurrentKata() 90 | endfunction 91 | 92 | function! LoadCurrentKata() 93 | let diff_on = 1 94 | if exists('g:vim_kata_diff_on') 95 | let diff_on = g:vim_kata_diff_on 96 | endif 97 | let current_conf = s:kata_pairs[s:current_kata] 98 | let pair = CreateWorkKata(current_conf) 99 | let item_in = pair[0] 100 | let item_out = pair[1] 101 | if diff_on 102 | windo diffoff 103 | endif 104 | silent only 105 | execute 'edit '.item_in 106 | " place a literal ^K somewhere in the 'in' document to specify 107 | " a custom cursor start location 108 | let line_number = search('\%x0b') 109 | if line_number 110 | " remove ^K and clear undo history 111 | normal dl 112 | let old_undolevels = &undolevels 113 | set undolevels=-1 114 | execute "normal a \\" 115 | let &undolevels = old_undolevels 116 | endif 117 | let split_command = 'belowright split' 118 | if exists('g:vim_kata_split_command') 119 | let split_command = g:vim_kata_split_command 120 | endif 121 | execute split_command.' '.item_out 122 | setlocal nomodifiable 123 | if diff_on 124 | windo diffthis 125 | endif 126 | wincmd t 127 | endfunction 128 | 129 | function! CreateWorkKata(conf) 130 | let file_in_content = readfile(a:conf.in) 131 | let file_out_content = readfile(a:conf.out) 132 | let file_in = tempname() . '.' . a:conf.dir . '.in.' . a:conf.ext 133 | let file_out = tempname() . '.' . a:conf.dir .'.out.' . a:conf.ext 134 | call writefile(file_in_content, file_in) 135 | call writefile(file_out_content, file_out) 136 | return [file_in, file_out] 137 | endfunction 138 | 139 | call LoadKatas() 140 | -------------------------------------------------------------------------------- /run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | vim -S config.vim -S main.vim -c 'call LoadCurrentKata()' 3 | --------------------------------------------------------------------------------