-
Notifications
You must be signed in to change notification settings - Fork 0
/
vim-refpage.tex
369 lines (330 loc) · 11.4 KB
/
vim-refpage.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
\documentclass[twocolumn,a4paper]{article}
\usepackage{tgheros}
\usepackage{fourier}
\usepackage{lmodern}
\renewcommand*\familydefault{\sfdefault}
%\renewcommand*\ttdefault{lcmtt}
\usepackage[T1]{fontenc}
\usepackage{anyfontsize}
\usepackage{calc}
\usepackage{geometry}
\usepackage[table]{xcolor}
\usepackage{array}
\usepackage{multirow}
\usepackage{tabu}
\usepackage{setspace}
\geometry{margin=0pt}
\usepackage{calc}
\usepackage{adjustbox}
\usepackage{ifthen}
%%%% DEFINE \setbraceratio AND \resetbraceratio MACROS
\usepackage{etoolbox}
\usepackage{multido}
\makeatletter
% default brace filler
\def\@@bfil{\leaders \vrule \@height \ht\z@ \@depth \z@ \hfill}
% left leader filler
\def\@bLfil{\@@bfil}
% right leader filler
\def\@bRfil{\@@bfil}
% reset to default braces
\def\resetbraceratio{\gdef\@bLfil{\@@bfil}\gdef\@bRfil{\@@bfil}}
% \setbraceratio{<left>}{<right>}
\def\setbraceratio#1#2{
% clear left filler
\let\@bLfil\relax
% increase left ratio
\multido{\iA=1+1}{#1}{\gappto\@bLfil{\@@bfil}}
% clear right filler
\let\@bRfil\relax
% increase right ratio
\multido{\iA=1+1}{#2}{\gappto\@bRfil{\@@bfil}}
}
\def\upbracefill{$\m@th\setbox\z@\hbox{$\braceld$}\bracelu\@bLfil\bracerd\braceld\@bRfil\braceru$}
\def\downbracefill{$\m@th\setbox\z@\hbox{$\braceld$}\braceld\@bLfil\braceru\bracelu\@bRfil\bracerd$}
\makeatother
%%%%% END OF MACROS
\def\w#1{\textcolor{white}{#1}}
\def\r#1{\textcolor{red}{#1}}
\def\b#1{\textcolor{blue}{#1}}
\def\g#1{\textcolor{gray}{#1}}
\setlength{\extrarowheight}{2pt}
% Tabular environment with alternating row colours
% Params: (as per a normal tabular)
\newlength\smallex
\small\setlength{\smallex}{1ex}
\normalsize
\newenvironment{coltabular}[2][c]
{\rowcolors{1}{cyan!35}{white}\begin{tabular}[#1]{#2}}
{\end{tabular}\rowcolors{1}{white}{white}}
% Tabular environment for entering <cmd> <description> pairs.
% Params:
% 1 - optional (default: c) table position
% 2 - required - number of columns
% TODO: the description columns should have \descstyle set, but this makes the
% text jump down a line
% TODO: why do we need so much extrarowheight in these tables?
% TODO: the top of the first line of the description should align with the top
% of the first line of the command. At the moment the bottoms align.
\def\titlebar#1{\colorbox{gray!65}{\parbox{\linewidth}{\MakeUppercase{\bfseries #1}}}}
\newlength{\tablewidth}
\newcolumntype{C}{>{\setsize8\cmdstyle}c}
\newcolumntype{D}{>{\setsize4\setstretch{0.75}}X[1,m,l]}
\renewenvironment{table}[2][]
{\ifthenelse{\equal{#1}{}}{}{\titlebar{#1}\par}
\setlength{\tablewidth}{\linewidth+\tabcolsep}%
\begin{tabu} to \tablewidth{#2}}
{\end{tabu}}
\newenvironment{cmdtable}[2][]
{\rowcolors{1}{gray!50}{white}%
\tabulinesep=4pt%
\taburulecolor{white}%
\begin{table}[#1]{@{}*#2{|C%
@{\hspace{2\tabcolsep}\hspace{-1pt}}%
D|}@{}}%
}
{\end{table}\rowcolors{1}{white}{white}}
\parindent0pt
\def\fbbox#1{\mbox{\rlap{\fbox{\phantom{#1}}}{\kern3.5pt{#1}\kern3.5pt}}}
\def\dl#1{
\raisebox{-0.3\baselineskip}
[-0.3\baselineskip]
[-0.3\baselineskip]{#1}
}
\def\nf{\normalfont}
\def\inlinecmd#1{\colorbox{gray!65}{\kern-3pt{\ttfamily\bfseries\color{black}#1}\kern-3pt}}
\def\modehl#1{\colorbox{blue!35}{\kern-3pt{\color{red}#1}\kern-3pt}}
%\def\inlinecmd#1{{\color{black}\tt\bfseries#1}}
\def\cursorhl#1{\colorbox{black}{\kern-3pt{\color{white}#1}\kern-3pt}}
\def\titlestyle{\nf\bfseries\color{black}}
\def\parstyle{\rm\color{black}}
\def\cmdstyle{\bfseries\ttfamily\color{black}}
\def\egcmdstyle{\slshape\ttfamily\color{red}}
\def\helptagstyle{\ttfamily\color{red}}
\def\descstyle{\sf\color{black}}
\def\varstyle{\ttfamily\color{blue}}
\def\usetextobjectsbox{%
\large\tt(\fbbox{\parbox[t]{\widthof{use text-objects}+14pt}{
use
\fbbox{\parbox[t]{\widthof{text-objects}+7pt}{%
\fbbox{\parbox[t]{\widthof{text}}{
tex\cursorhl t\\[-0.3\baselineskip]
\centering\dl{\colorbox{white}{\b{iw}}}%
}}-objects\\[0.1\baselineskip]%
\centering\dl{\colorbox{white}{\b{iW}}}%
}}\\[0.1\baselineskip]%
\dl{\colorbox{white}{\b{i(}}}
}}%
)
}
%%% Tag object with help information %%%
% \taghelp{object}{help-cmd}
\newlength\helphgt
\newlength\helpdep
\settoheight{\helphgt}{\tiny\strut}
\settodepth{\helpdep}{\tiny\strut}
\def\taghelp#1#2{%
{#1}%
\llap{\raisebox{\heightof{#1}+\helpdep}{\tiny\helptagstyle{:h #2}\kern2ex}}%
}
%%%%%%%%%%
\def\infobox#1{\colorbox{gray!35}{\parbox{\linewidth}{\setsize3 #1}}}
%%%%% SIZES MACROS
\newcounter{sizecounter}
\def\setsize#1{%
\ifnum#1<1%
\global\tiny%
\else\ifcase#1%
\relax\or% 0
\setcounter{sizecounter}{#1}\global\tiny\or% 1
\setcounter{sizecounter}{#1}\global\scriptsize\or% 2
\setcounter{sizecounter}{#1}\global\footnotesize\or% 3
\setcounter{sizecounter}{#1}\global\small\or% 4
\setcounter{sizecounter}{#1}\global\normalsize\or% 5
\setcounter{sizecounter}{#1}\global\large\or% 6
\setcounter{sizecounter}{#1}\global\Large\or% 7
\setcounter{sizecounter}{#1}\global\LARGE\or% 8
\setcounter{sizecounter}{#1}\global\huge\or% 9
\setcounter{sizecounter}{#1}\global\Huge\else% 10
\global\Huge% >10
\fi\fi%
}
\makeatletter
\def\incsize{\@ifnextchar[{\@incsize}{\@incsize[1]}}
\def\decsize{\@ifnextchar[{\@decsize}{\@decsize[1]}}
\def\@incsize[#1]#2{%
\addtocounter{sizecounter}{#1}%
\setsize{\value{sizecounter}}%
#2%
\addtocounter{sizecounter}{-#1}%
\setsize{\value{sizecounter}}%
}
\def\@decsize[#1]#2{%
\addtocounter{sizecounter}{-#1}%
\setsize{\value{sizecounter}}%
#2%
\addtocounter{sizecounter}{#1}%
\setsize{\value{sizecounter}}%
}
\makeatother
%%%%%%%
\def\desccmd#1#2{\decsize[5]{%
\begin{tabular}{@{}c@{}}
\incsize[5]{\cmdstyle #1}\\
\descstyle #2
\end{tabular}%
}}
\begin{document}
{\setsize{8}\tt
\taghelp{[\r{operator}]}{operator}%
\g{[count]}\taghelp{[\b{motion}]}{navigation}}
\begin{tabular}[t]{@{}p{0.25\linewidth}
@{\hspace{0.05\linewidth}}p{0.35\linewidth}
@{\hspace{0.05\linewidth}}p{0.3\linewidth}@{}}
\downbracefill & \omit\span\omit\setbraceratio 55\downbracefill\\
\setsize7\begin{tabular}[t]{@{}p{\linewidth}@{}}
\centering\desccmd{d}{delete/cut}\\
\centering\desccmd{y}{yank/copy}\\
\centering\desccmd{c}{change}\\
\end{tabular}
& \setsize2\parstyle Any motion can follow an operator. Marks and searches count
as motions too! \inlinecmd{d/foo} will delete from the cursor to the next
instance of ``foo''. \inlinecmd{y3fi} will yank from the cursor to the 3rd
``i'' on the line after it. Counts can also come before operators:
\inlinecmd{5dd} will delete five lines.
& \setsize2\begin{coltabular}[t]{>{\cmdstyle}c>{\descstyle}l}
w & word \\
W & WORD \\
s & sentence \\\relax
[, ] & [ ] block \\
(, ) & ( ) block \\
<, > & < > block \\
t & XML/HTML tag \\
\{, \} & \{ \} block \\
", ' & quoted string
\end{coltabular} \\[-2ex]
%TODO: use tabulary for this
\setsize2\centering\begin{tabular}{@{}cc@{}}
\desccmd{gU}{make\\ upper-case} & \desccmd{Y}{swap case}\\[2ex]
\desccmd{<}{shift left} & \desccmd{=}{indent}\\
\end{tabular} &
\multicolumn{2}{c}{\raisebox{-4ex}{%
\taghelp{\usetextobjectsbox}{text-objects}
}}
\end{tabular}
\bigskip
{\taburulecolor{white}\rowcolors{1}{gray!50}{white}
\begin{table}[Searching]{|c||c||X[1,m,L]||c||c|}%\hline
{\titlestyle Forward} &
{\titlestyle Backward} &
{\hfill\titlestyle Matches\hfill} &
{\titlestyle Next}&
{\titlestyle Previous}\\%\hline
\cmdstyle /{\egcmdstyle foo} &
\cmdstyle ?{\egcmdstyle foo} &
matches \egcmdstyle foo &
\cmdstyle n & \cmdstyle N\\%\cline{1-3}
{\cmdstyle *} &
{\cmdstyle \#} &
{word under cursor} &
\cmdstyle n & \cmdstyle N\\%\cline{1-3}
\cmdstyle t{\egcmdstyle x} &
\cmdstyle T{\egcmdstyle x} &
upto {\egcmdstyle x} &
\cmdstyle ; & \cmdstyle ,\\%\cline{1-3}
{\cmdstyle f{\egcmdstyle x}} &
{\cmdstyle F{\egcmdstyle x}} &
{find {\egcmdstyle x}} &
\cmdstyle ; & \cmdstyle ,\\%\cline{1-3}
\end{table}}
%\vspace{3ex}
%{\setsize{3}\arrayrulecolor{gray!40}\tt\begin{tabular}{|*5{>{\cmdstyle}c|}}
% \hline
% \rowcolor{cyan!35}\multicolumn5{|l|}{\titlestyle Searching}\\\hline
% \titlestyle Prev & \titlestyle Next
% &\titlestyle Forward &\titlestyle Backward & \titlestyle Matches\\\hline
% \multirow 2*N & \multirow 2*n &
% /\egcmdstyle foo & ?\egcmdstyle foo & \egcmdstyle foo\\
% \cline{3-5}
% && * & \# & \decsize[1]{\descstyle word under cursor}
% \\
% \hline
% \multirow 2*; & \multirow 2*, &
% t\egcmdstyle x & T\egcmdstyle x & \decsize[1]{\descstyle upto}
% \egcmdstyle x\\
% \cline{3-5}
% && f\egcmdstyle x & F\egcmdstyle x & \decsize[1]{\descstyle find}
% \egcmdstyle x
% \\\hline
%\end{tabular}}
% marks table
% TODO: work out the best way of putting the descriptions on multiple lines.
% can we specify a width, put them in boxes and have everything calculated automatically?
%\vspace{3ex}
\bigskip
\taghelp{
\parbox{\linewidth}{\arrayrulecolor{white}
\begin{cmdtable}{3}
m\egcmdstyle{m} & create mark {\egcmdstyle m} in file &
m\egcmdstyle{M} & set mark {\egcmdstyle M} across files &
\textquotesingle[ & jump to first char of just-changed text \\
\textquotesingle\egcmdstyle{m} & jump to first char of line containing \egcmdstyle m &
\`{}\egcmdstyle m & jump to exact char of \egcmdstyle m &
\textquotesingle\textquotesingle & jump to previous jump point
\end{cmdtable}
}}{mark-motions}
\bigskip
\infobox{
Pass a directory to the \inlinecmd{:edit} command to open a
directory explorer. Instructions for usage are at the top of the
screen .
}
\bigskip
\begin{cmdtable}[Entering insert mode]{3}
i & before cursor &
a & after cursor &
s & substitute character \\
I & beginning of line &
A & end of line &
S & substitute line \\
O & previous line &
o & next line &
C & line from cursor \\
\end{cmdtable}
\bigskip
\begin{cmdtable}[Entering visual (select) mode]{3}
v &
\tt\setsize2 Use \cursorhl{Visual mode} to select
characters within a line. &
\cellcolor{white} V &
\cellcolor{white}\tt\setsize2 Use
\cursorhl{Visual Line mode} to select one or more lines. &
\^{}v &
\tt\setsize2
Visual \cursorhl{Block mode}
can \cursorhl{be used to} \cursorhl{select box}es across lines. \\
\end{cmdtable}
\begin{cmdtable}{4}
\cellcolor{white}o &
\cellcolor{white} \taghelp{\parbox{\linewidth}{switch cursor to start/end}}{v\_o} &
gv & \taghelp{\parbox{\linewidth}{reselect previous area}}{gv} &
\cellcolor{white}I & \cellcolor{white}\taghelp{\parbox{\linewidth}{prepend to each visual block
line}}{v\_b\_I} &
\textquotesingle< & \taghelp{\parbox{\linewidth}{jump to start of prior
area}}{\textquotesingle<}\\
\end{cmdtable}
\bigskip
\begin{cmdtable}[Cool insert mode stuff]{2}
\^{}w & delete word before cursor &
\^{}u & delete line before cursor\\
\^{}r{\egcmdstyle r} & insert the contents of register
{\egcmdstyle r} &
\^{}r= & use the expression register (try \inlinecmd{\^{}r=5+10})\\
\^{}t & increase line indent by {\varstyle shiftwidth} &
\^{}d & decrease line indent by {\varstyle shiftwidth}\\
\^{}x\^{}l & line completion &
\^{}n & find next completion suggestion according to {\varstyle
complete}\\
\end{cmdtable}
\bigskip
\end{document}