5 no warnings 'qw'; # you know what you doing
6 no warnings 'uninitialized'; # save some useless checks for more legible code
11 if (exists $get{ascii}) {
12 $ascii = $get{ascii} ne '0'; # manual override
13 } elsif (defined $ENV{HTTP_ACCEPT_CHARSET}) {
15 for (split q{,}, $ENV{HTTP_ACCEPT_CHARSET}) {
16 $ascii = 0, last if $_ eq '*' or m{utf-?8}i;
20 my $charset = $ascii ? 'us-ascii' : 'utf-8';
21 my $ctype = "text/html; charset=$charset";
22 $header{content_type} = $ctype;
24 :><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
25 "http://www.w3.org/TR/html4/loose.dtd">
29 <title>vi cheat sheet</title>
30 <meta http-equiv="content-type" content="<:= $ctype :>">
31 <link rel="stylesheet" type="text/css" media="all" href="base.css">
32 <!--[if lte IE 6]><style> .help dl.legend dt {margin:0 0 1px} </style><![endif]-->
33 <!--[if lte IE 7]><style> .help dl.legend dd {float:none} </style><![endif]--><:
34 my %styles = map {$_ => $_} qw(dark circus mono terse);
35 our $style = exists $get{style} && $styles{$get{style}} || 'light';
36 printf(qq{\n<link rel="%s" type="text/css" media="all" href="%s" title="%s">},
37 $_ eq $style ? 'stylesheet' : 'alternate stylesheet', "$_.css", $_
40 our $showkeys = exists $get{keys} && $get{keys} ne '0';
41 print "\n<style> .no {visibility:hidden} </style>" unless $showkeys;
42 print "\n<style> .no, .alias {opacity:.5} </style>"
43 if $showkeys and $get{keys} eq 'ghost';
47 function setmode(classname) {
48 // set style for each #rows>li>ul>li to display:none unless it matches classname
49 var showclass = classname ? ' '+classname+'(?!\\w)' : '^$';
50 var parentskip = /^keys/;
51 var row = document.getElementById('rows').firstChild;
53 if (row.tagName == 'LI' && row.firstChild.tagName == 'UL'
54 && !row.firstChild.className.match(parentskip)) {
55 var el = row.firstChild.firstChild;
57 if (el.tagName == 'LI') {
58 el.style.display = el.className.match(showclass) ? 'block' : 'none';
60 } while (el = el.nextSibling);
62 } while (row = row.nextSibling);
64 // update H2 to reflect the first part of a currently active (but hidden) H3
65 var h3s = document.getElementsByTagName('H3');
66 for (var i = 0; i < h3s.length; i++) {
67 if (h3s[i].parentNode.style.display != 'block') continue;
68 document.getElementsByTagName('H2')[0].innerHTML = h3s[i].firstChild.data;
75 <h1>vi/vim cheat sheet</h1>
77 <h2>normal mode (default)</h2>
82 <ul class="keys omni">
83 <li class="mo" onclick="setmode()"><b>Esc</b> normal mode
84 <!-- not as static anymore, but never bothered; just see ^[ -->
90 arg => $ascii ? '.' : '·', # described as 'dot'
91 motion => $ascii ? '|' : '↕',
92 alias => $ascii ? 'see: ' : '»',
93 up => $ascii ? 'up' : '▲',
94 right => $ascii ? 'right' : '▶',
95 down => $ascii ? 'down' : '▼',
96 left => $ascii ? 'left' : '◀',
97 sep => $ascii ? '*' : '•',
98 _ => exists $get{ascii} && !$ascii ? "\x{200b}" : '<wbr>',
99 # use the correct ZWNJ only when unicode is forced on
100 # default to use unofficial html for best support
103 use Shiar_Sheet::Keyboard;
104 my $keys = Shiar_Sheet::Keyboard->new({do 'vim.inc.pl'});
105 $keys->map($get{map}) or undef $get{map};
106 $keys->print_rows($get{static});
114 <dl class="legend legend-types">
116 <dd>Info command: shows/does something without altering anything.
117 <dt class="pm">motion
118 <dd>Moves the cursor, or defines the range for an operator (<:= $sign{motion} :>).
119 <dt class="po">positioning
120 <dd>Other movement (jumps, window (re)positioning).
121 <dt class="co">command
122 <dd>Direct action command.
123 <dt class="mi">ins mode
124 <dd>Enters Insert or Replace mode.
126 <dd>Enters a different mode.
127 <dt class="mv">vis mode
128 <dd>Enters Visual or Select mode.
129 <dt class="me">key cmd
130 <dd>Additional key commands (click for overview).
135 <dl class="legend legend-options">
136 <dt>key<:= $sign{arg} :>
137 <dd>Commands with a dot need a char argument afterwards.
138 <dt>key<:= $sign{motion} :>
139 <dd>Requires a motion afterwards, operates between cursor and destination.
141 <dd>Not in original Vi (assessment incomplete).
142 <dt class="vim7">vim7
143 <dd>New in vim version 7.x.
146 <ul class="legend legend-set">
147 <li>keyboard <strong>map</strong> is
148 <:= $get{map} ? 'set to ' : '' :><em><:= $keys->{map} :></em>
149 <li><strong>ascii</strong> mode is
150 <:= exists $get{ascii} && 'forced ' :><em><:=
151 $ascii ? 'on' : 'off' :></em>
152 <li><strong>keys</strong> are
153 <em><:= $showkeys ? 'always shown' : 'hidden if unassigned' :></em><:=
154 !exists $get{keys} && ' by default' :>
155 <li>default <strong>style</strong> is
156 <:= defined $get{style} && 'set to ' :><em><:= $style :></em>
162 <a href="http://sheet.shiar.nl/vim">sheet.shiar.nl<strong>/vim</strong></a>
163 <a href="git://dev.shiar.net/vi-cheat"><:= "v$VERSION" :></a>
164 created by Shiar <:= $sign{sep} :>
165 <a title="Licensed under the GNU Affero General Public License, version 3"
166 href="http://www.fsf.org/licensing/licenses/agpl-3.0.html">AGPLv3</a> <:= $sign{sep} :>
168 use Time::Format qw(time_format);
169 print time_format('yyyy-mm-dd', (stat 'vim.inc.pl')[9]);