% Created 2020-06-23 Tue 22:51
% Intended LaTeX compiler: pdflatex
\documentclass[presentation]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{grffile}
\usepackage{longtable}
\usepackage{wrapfig}
\usepackage{rotating}
\usepackage[normalem]{ulem}
\usepackage{amsmath}
\usepackage{textcomp}
\usepackage{amssymb}
\usepackage{capt-of}
\usepackage{hyperref}
\usepackage{microtype}
\usepackage{booktabs}
\usepackage[scale=0.9]{sourcecodepro}
\usepackage{pmboxdraw}
\usepackage[main]{embedall}
\embedfile{"Modal Editing".org}

  \usepackage{minted}
  \usepackage[many]{tcolorbox}
  \setminted{
    frame=none,
    % framesep=2mm,
    baselinestretch=1.2,
    fontsize=\footnotesize,
    highlightcolor=white!95!black!80!blue,
    linenos,
    breakanywhere=true,
    breakautoindent=true,
    breaklines=true,
    tabsize=4,
    xleftmargin=3.5em,
    autogobble=true,
    obeytabs=true,
    python3=true,
    % texcomments=true,
    framesep=2mm,
    breakbefore=\\.+,
    breakafter=\,
    style=autumn,
    breaksymbol=\color{page!60!text}\tiny\ensuremath{\hookrightarrow},
    breakanywheresymbolpre=\,\footnotesize\ensuremath{_{\color{page!60!text}\rfloor}},
    breakbeforesymbolpre=\,\footnotesize\ensuremath{_{\color{page!60!text}\rfloor}},
    breakaftersymbolpre=\,\footnotesize\ensuremath{_{\color{page!60!text}\rfloor}},
  }
  
  \BeforeBeginEnvironment{minted}{
    \begin{tcolorbox}[
      enhanced,
      overlay={\fill[white!90!black] (frame.south west) rectangle ([xshift=2.8em]frame.north west);},
      colback=white!95!black,
      colframe=white!95!black, % make frame colour same as background
      breakable,% Allow white breaks
      arc=0pt,outer arc=0pt,sharp corners, % sharp corners
      boxsep=0pt,left=0pt,right=0pt,top=0pt,bottom=0pt % no margin/paddding
    ]
  }
  \AfterEndEnvironment{minted}{\end{tcolorbox}}
  \renewcommand\theFancyVerbLine{\color{black!60!white}\arabic{FancyVerbLine}} % minted line numbering
\usetheme[progressbar=foot]{metropolis}
\author{Timothy}
\date{2020-06-25}
\title{Modal Editing}
\subtitle{One mode just isn't enough}
\let\textsc\MakeUppercase
\definecolor{verbatim}{HTML}{50a14f}
\makeatletter \def\verbatim@font{\color{verbatim}\normalfont\ttfamily} \makeatother

\colorlet{greenyblue}{blue!70!green}
\colorlet{blueygreen}{blue!40!green}
\providecolor{link}{named}{greenyblue}
\providecolor{cite}{named}{blueygreen}
\hypersetup{
  pdfauthor={Timothy},
  pdftitle={Modal Editing},
  pdfkeywords={},
  pdfsubject={},
  pdfcreator={Emacs 26.3 (Org mode 9.4)},
  pdflang={English},
  breaklinks=true,
  colorlinks=true,
  linkcolor=,
  urlcolor=link,
  citecolor=cite
}
\urlstyle{same}
\begin{document}

\maketitle

\section{'Normal' editing}
\label{sec:normal-editing}
\begin{frame}[label={sec:standard-keybindings},fragile]{Standard keybindings}
 You'll likely be used to some common shortcuts
\begin{center}
\begin{tabular}{ll}
\toprule
Shortcut & Action\\
\midrule
\verb~Ctrl + a~ & Select all\\
\verb~Ctrl + f~ & Find\\
\verb~Ctrl + c~ & Copy\\
\verb~Ctrl + v~ & Paste\\
\verb~Ctrl + o~ & Open\\
\verb~Ctrl + s~ & Save\\
\ldots{} & \\
\bottomrule
\end{tabular}
\end{center}
\end{frame}
\begin{frame}[label={sec:application-specific-keybindings},fragile]{Application-specific keybindings}
 \begin{block}{Word}
\begin{center}
\begin{tabular}{ll}
\toprule
Shortcut & Action\\
\midrule
\verb~Ctrl + Shift + <right>~ & Select word to the right\\
\verb~Ctrl + Alt + z~ & Cycle through previous (4) changes\\
\bottomrule
\end{tabular}
\end{center}
\end{block}
\begin{block}{\textls*[70]{\textsc{vs}} Code}
\begin{center}
\begin{tabular}{ll}
\toprule
Shortcut & Action\\
\midrule
\verb~Ctrl + r~ & Open recent\\
\verb~Alt + Shift + a~ & Block comment\\
\verb~Ctrl + Alt + Shift + c~ & Copy relative path of file\\
\verb~Ctrl + K, Ctrl + Alt + s~ & Git, stage selected region\\
\bottomrule
\end{tabular}
\end{center}
\end{block}
\end{frame}
\section{The problem with normal editing}
\label{sec:-problem-with}
\begin{frame}[label={sec:problem-with-normal}]{The problem with normal editing}
Shortcut overloading.
\end{frame}
\begin{frame}[label={sec:mathematical-shortcut-limit},fragile]{Mathematical shortcut limit}
 \begin{itemize}
\item 26 letters + 10 numbers + 12 (not-on-number) symbol keys + 12 function keys
\item \verb~Ctrl~, \verb~Alt~, \verb~Shift~ modifiers, 4 possible combinations
\item How many possible shortcuts? \pause
\end{itemize}
\[
  4 \times (26+10+12) + 3 \times 12 = 228
\]

That's \ldots{} a lot? \pause Actually, once you consider all the different categories of
things, it's not that many --- hence clunky shortcuts like \verb~Ctrl + Alt + Shift + c~.
\end{frame}
\begin{frame}[label={sec:solution-add-prefix},fragile]{Solution? Add a prefix key (\textls*[70]{\textsc{vs}} Code style)}
 \begin{itemize}
\item \textls*[70]{\textsc{vs}} Code reserves \verb~Ctrl + K~ to be used as a prefix for a second shortcut
\item This increases the number of shortcuts to
\verb~452~
\item More flexibility is good! \pause \ldots{}but it's also even more clunky :(
\item \verb~Ctrl + K, Ctrl + Alt + s~
\end{itemize}
\end{frame}
\begin{frame}[label={sec:solution-modal-editing}]{Solution! Modal editing}
\begin{center}
\includegraphics[height=0.7\linewidth]{lord-saviour-vim.jpg}
\end{center}
\end{frame}
\section{Modal Editing}
\label{sec:modal-editing}
\begin{frame}[label={sec:observation-there-are},fragile]{Observation: There are \emph{way} more keys than modifiers}
 \begin{itemize}
\item 3 modifier keys (\verb~Ctrl~, \verb~Alt~, \verb~Shift~)
\item 48 \textls*[70]{\textsc{ascii}} character keys
\item If only there was some way we could use them\ldots{}
\end{itemize}
\pause
\emph{Think of how much time you spend editing}
\end{frame}
\begin{frame}[label={sec:use-them-keys}]{Use them keys}
\begin{itemize}
\item Turn 'normal' typing text into a special case
\item The opens up the possibility to use every single key for an action
\end{itemize}
\end{frame}
\begin{frame}[label={sec:modal-editing-use},fragile]{Use them keys --- how?}
 \begin{itemize}
\item Define different \alert{modes}
\item Start off in a default mode
\item From the default mode, move to other modes using any key
\item Leave a mode with \verb~Esc~
\item This opens up \emph{every single key} for use in actions
\end{itemize}
\end{frame}
\begin{frame}[label={sec:-modal-editing},fragile]{Use them keys --- an example}
 \begin{itemize}
\item Let's call the default mode \alert{normal}
\item Let's call the you-see-what-you-type behaviour (that you're used to) \alert{insert} mode
\item Type \verb~i~ to enter \alert{insert} mode, type like you're in any other app
\item Press \verb~Esc~ and you go back to \alert{normal} mode
\end{itemize}
\end{frame}
\begin{frame}[label={sec:mathematical-advantage}]{The mathematical advantage}
\begin{itemize}
\item Use up to three keys in a row
\item Each key can be any letter, number, symbol + usual modifiers
\item \((26 + 10 + 12) \times 4 = 192\) options
\item How many possible keybindings can we use now? \pause
\end{itemize}
\[
  192^3 = 7\,077\,888
\]

This is a \emph{huge} increase from the 192 possibilities 'normally', in fact this is a
factor of 36-thousand more!
\end{frame}
\begin{frame}[label={sec:mnemonic-advantage},fragile]{The mnemonic advantage}
 You are no longer forced to use weird keybindings.

With so many options, one can design mnemonic categories of keybindings. E.g.
put actions to do with deletion under \verb~d~, etc.
\end{frame}
\begin{frame}[label={sec:ergonomic-advantage}]{The ergonomic advantage}
I no longer feel like I have to be part-human, part-spider to use uncommon shortcuts.
\end{frame}
\begin{frame}[label={sec:capability-curve}]{The capability curve}
\begin{center}
\includegraphics[width=0.7\linewidth]{learning-curve.pdf}
\end{center}
Phases:
\vspace{-3mm}
\begin{enumerate}
\item \textls*[70]{\textsc{wtf}}?
\item Clunky
\item Eh, it's alright
\item I like this
\item \textls*[70]{\textsc{omg}}!
\end{enumerate}
\end{frame}
\section{Vim}
\label{sec:vim}
\begin{frame}[label={sec:what-it}]{What is it?}
\begin{itemize}
\item An old text editor
\item An old \alert{modal} text editor
\item Despite being \raisebox{0.5ex}{\texttildelow}30 years old,
people still use it \pause
\item Clearly it did something right (modal editing)
\end{itemize}
\end{frame}
\begin{frame}[label={sec:quick-history},fragile]{A quick history}
 \begin{itemize}
\item Rewrite of the \texttt{vi} editor (which Bill Joy created in 1976)
\item Motivation for creation:
\begin{itemize}
\item George Coulouris worked at \textls*[70]{\textsc{at}}\&T
\item The 'default' editor at the time was nasty and clunky
\item George had an idea for a better way (\texttt{em})
\item Bill Joy is impressed, re-implements favourite ideas (\texttt{vi})
\end{itemize}
\item The hardware back then looked a bit different
\end{itemize}
\begin{center}
\includegraphics[height=0.2\linewidth]{adm-3a terminal keyboard.png}
\end{center}

\alert{There is no mouse and you cannot click!}
\end{frame}

\begin{frame}[label={sec:main-vim-modes}]{The (main) vim modes}
\begin{itemize}
\item \alert{Normal} mode --- the \ldots{} normal mode (default)
\item \alert{Insert} mode --- type text normally
\item \alert{Visual} Mode --- select text
\end{itemize}
\end{frame}
\begin{frame}[label={sec:simple-diagram}]{A simple diagram}
\begin{center}
\includegraphics[width=.9\linewidth]{simple-mode-flow.pdf}
\end{center}
\end{frame}
\begin{frame}[label={sec:modal-madness}]{Modal madness}
\begin{center}
\includegraphics[width=\linewidth]{vimModeStateDiagram.pdf}
\end{center}
\end{frame}
\section{Let's learn Vim}
\label{sec:lets-learn-vim}
\begin{frame}[label={sec:basics},fragile]{The Basics}
 Vim is the name of the terminal command, \texttt{vim}.
Please don't be scared of terminals, they're really quite simple.
To open \texttt{file.txt} in vim, just run \texttt{vim file.txt}. \pause

From there you can edit text just knowing this
\begin{itemize}
\item Press \verb~i~ to enter \alert{insert} mode, and type some text
\item Press \verb~Esc~ to stop writing text (go to \alert{normal} mode)
\item Type \verb~:wq~ to save your file and exit.
\end{itemize}
\end{frame}
\begin{frame}[label={sec:basics-exiting-vim},fragile]{The Basics --- exiting Vim}
 \begin{center}
\includegraphics[width=.9\linewidth]{cant-exit-vim-tweet-alpha.png}
\end{center}
\begin{itemize}
\item Type \verb~:wq~ to save your file and \alert{exit}.
\end{itemize}
\end{frame}
\begin{frame}[label={sec:little-bit-more},fragile]{A little bit more}
 For going through your edits
\begin{itemize}
\item \verb~u~ undoes the last change
\item \verb~Ctrl + r~ re-does the last change
\end{itemize}

For making and using text selections
\begin{itemize}
\item \verb~v~ to start a selection
\item \verb~y~ to yank (copy) the text to the clipboard
\item \verb~p~ to paste
\item \verb~d~ to delete
\end{itemize}

\href{../Demos/1-basics.txt}{Demo}
\end{frame}
\section{More Vim}
\label{sec:more-vim}
\begin{frame}[label={sec:aside-shortened-shortcut},fragile]{Aside --- shortened shortcut notation}
 \begin{itemize}
\item We can do better than typing \verb~Ctrl + a~, or \verb~Shift + i~ each time.
\item So, we perform the following contractions
\begin{itemize}
\item \verb~Shift   + a~ becomes \verb~A~
\item \verb~Control + a~ becomes \verb~C-a~
\item \verb~Alt     + a~ becomes \verb~M-a~\footnote{\verb~M~ not \verb~A~ because \verb~Alt~ used to be called \verb~Meta~}
\item \verb~Control + Alt + Shift + a~ becomes \verb~C-M-A~ \\
\emph{isn't that easier?}
\end{itemize}
\end{itemize}
\end{frame}
\begin{frame}[label={sec:insert-mode},fragile]{Insert Mode}
 \begin{itemize}
\item Enter using one of \verb~i I a A o O gi~
\begin{itemize}
\item \verb~i~ insert at point
\item \verb~I~ insert at start of line
\item \verb~a~ insert after point
\item \verb~A~ insert at end of line
\item \verb~o~ insert on new line above
\item \verb~O~ insert on new line below
\item \verb~gi~ insert at last edit
\pause
\end{itemize}
\item \verb~C-w~ to delete the last word
\item \verb~C-u~ to delete the last line (this is the same as \verb~dd~ in normal mode)
\end{itemize}

\emph{Think about the mnemonics in your head.}

\href{../Demos/2-insert.txt}{Demo}
\end{frame}
\begin{frame}[label={sec:visual-mode},fragile]{Visual mode}
 \begin{itemize}
\item Make a selection using on of \verb~v V C-v gv~
\begin{itemize}
\item \verb~v~ visual \alert{character} mode
\item \verb~V~ visual \alert{line} mode
\item \verb~C-v~ visual \alert{block} mode (rectangle)
\item \verb~gv~ last visual selection
\pause
\end{itemize}
\item \verb~o~ switch between start/end of selection
\item grow/shrink selection with normal cursor movement
\end{itemize}

\href{../Demos/3-visual.txt}{Demo}
\end{frame}
\begin{frame}[label={sec:quick-actions},fragile]{'Quick' actions}
 \begin{itemize}
\item Some action don't need a selection to act on
\item If you press the key twice, they'll simply act on the current line
\pause
\item This works for
\begin{itemize}
\item \verb~dd~ delete line
\item \verb~yy~ yank (copy) line
\item \verb~cc~ change line
\item \verb~==~ re-indent line
\item \verb~>>~ shift line right
\item \verb~<<~ shift line left
\pause
\end{itemize}
\item You can also use \verb~x~ to delete the character under the cursor, or the active
selection, and \verb~r~ to replace the character.
\end{itemize}
\end{frame}
\begin{frame}[label={sec:actions-selection},fragile]{Actions on a selection}
 \begin{itemize}
\item \verb~d~ delete
\item \verb~c~ change content (delete and enter insert mode)
\item \verb~y~ (yank) copy selection to clipboard
\pause
\item \verb,~, swap case
\item \verb~u~ make lowercase
\item \verb~U~ make uppercase
\end{itemize}

\href{../Demos/4-simple-actions.txt}{Demo}
\end{frame}
\begin{frame}[label={sec:-more-actions},fragile]{\emph{More} actions on a selection}
 \begin{itemize}
\item \verb~!~ run selection though an external program
\item \verb~=~ re-indent
\item \verb~>~ shift right
\item \verb~<~ shift left
\end{itemize}

\href{../Demos/5-simple-code-actions.py}{Demo}
\end{frame}
\begin{frame}[label={sec:text-objects},fragile]{Text objects}
 \begin{itemize}
\item Used while in visual mode, or after an action (e.g. \verb~d~ for delete)
\item Performed from the current cursor
\item Can be prefixed with \verb~i~ or \verb~a~
\begin{itemize}
\item \verb~i~ selects the 'inner' object
\item \verb~a~ selects the 'outer' object
\end{itemize}
\end{itemize}
\end{frame}
\begin{frame}[label={sec:text-objects-list},fragile]{Text objects --- a list}
 \begin{itemize}
\item \verb~w~ word
\item \verb~p~ paragraph
\item \verb~b~ brackets, or \verb~()~ , \verb~[]~, \verb~{}~, \verb~<>~ if you want to be specific
\item \verb~'~ or \verb~"~ for quoted text
\end{itemize}
\end{frame}
\begin{frame}[label={sec:text-objects-an},fragile]{Text objects --- an example}
 \begin{verbatim}
                                  as
                     ┌───────────────────────────┐
   Here is some text. Isn't that nice (yes it is).
   └────┘  └──┘             └───┘     └─────────┘
     w      iw               aw           ab
    
                  is
   ┌───────────────────────────────────┐
  ┌Often one likes to "manipulate" text. Applications
ip├often make text easy to write, clunky to edit.
ap└

   That's why modal editing is nice.
\end{verbatim}

\href{../Demos/6-simple-objects.txt}{Demo}
\end{frame}
\begin{frame}[label={sec:movements},fragile]{Movements}
 Has the same effect as arrow keys, \verb~Home~, and \verb~End~.

Used for moving the current cursor, and shrinking/growing a selection.
\end{frame}
\begin{frame}[label={sec:movements-overview}]{Movements --- overview}
\begin{center}
\includegraphics[width=1\linewidth]{vim-movements.png}
\end{center}
\end{frame}
\begin{frame}[label={sec:movements-put-another},fragile]{Movements --- put another way}
 \begin{block}{Micro}
\vspace{-4mm}
\begin{center}
\begin{tabular}{lllll}
\toprule
target & forwards & forward upto & backwards & back upto\\
\midrule
word & \verb~w~ & \verb~e~ & \verb~b~ & \verb~ge~\\
\emph{x} & \verb~f~ \emph{x} & \verb~t~ \emph{x} & \verb~F~ \emph{x} & \verb~T~ \emph{x}\\
\bottomrule
\end{tabular}
\end{center}
\vspace{-4mm}
\end{block}
\begin{block}{Macro}
\vspace{-4mm}
\begin{center}
\begin{tabular}{lll}
\toprule
target & start & end\\
\midrule
line & \verb~0~ & \\
line content & \verb~^~ & \verb~$~\\
sentence & \verb~(~ & \verb~)~\\
paragraph & \verb~{~ & \verb~}~\\
document & \verb~gg~ & \verb~G~\\
page & \verb~C-b~ & \verb~C-f~\\
\bottomrule
\end{tabular}
\end{center}
\end{block}
\end{frame}
\begin{frame}[label={sec:movements-an-example},fragile]{Movements --- an example}
 \begin{verbatim}
gg
{     w            fc                         tl   $
↓     ↓            ↓                          ↓    ↓
Pretend there is a cursor at the start of this line,
then look around at the various movements.
                                         ↑
0 ^            Tc                Fd      )    }
↓ ↓            ↓                 ↓            ↓
  Pretend the cursor is at the end of this now.
                                              ↑
                                              G
\end{verbatim}

\href{../Demos/7-movements-prose.txt}{Demo (Prose)}
\qquad
\href{../Demos/8-movements-objects-code.py}{Demo (Code)}
\end{frame}
\begin{frame}[label={sec:count-prefix},fragile]{Count prefix}
 Want to do something multiple times, for example not just delete the next word (\verb~dw~),
but the next three words?

It's easy! Just type the number of times you want to do it \emph{before} or \emph{during} the action.

In this example, 3-delete-word (\verb~3dw~) or delete-3-words (\verb~d3w~) does the trick.

This works for everything though, not just words :)
\end{frame}
\begin{frame}[label={sec:structure-vim-operation}]{Structure of a vim operation}
\begin{center}
\includegraphics[width=1\linewidth]{vim-command-structure.pdf}
\end{center}
\end{frame}
\begin{frame}[label={sec:command-mode},fragile]{Command mode}
 \begin{itemize}
\item A way to tell vim to do non-text-editing stuff
\item Enter command mode with \verb~:~
\item This is how you:
\begin{itemize}
\item \verb~:w~ write a file
\item \verb~:q~ quit vim
\item \verb~:wq~ write a file, and quit
\item and more
\end{itemize}
\end{itemize}
\end{frame}
\section{Even more Vim}
\label{sec:-even-more}
\begin{frame}[label={sec:oh-yes-theres}]{Oh yes, there's more}
You've just seen how to perform 'basic' operations in vim.

Don't worry, while it may look intimidating, if you try this out you'll find
yourself picking it up quickly --- the mnemonic-ness helps a lot.

Vim does a bit more though, so we'll go over that for fun (and profit).
\end{frame}
\begin{frame}[label={sec:marks-saving},fragile]{Marks --- saving}
 \begin{itemize}
\item A way to save a position
\item Save the current location with \verb~m?~ where \verb~?~ is a letter (a-z) which serves as a
unique identifier
\begin{itemize}
\item Lower case letters are local to the file
\item Upper case letters work globally
\end{itemize}
\end{itemize}
\end{frame}
\begin{frame}[label={sec:marks-accessing},fragile]{Marks --- accessing}
 \begin{itemize}
\item \verb~'a~ goes to the \alert{line} of mark \verb~a~
\item \verb~`a~ goes to the \alert{position} of \verb~a~
\item \verb~''~ and \verb~``~ go to your last line/position respectively
\item \verb~'.~ / \verb~`.~ goes to the line/position of the last edit
\end{itemize}

\href{../Demos/9-marks.txt}{Demo}
\end{frame}
\begin{frame}[label={sec:search},fragile]{Search}
 \begin{itemize}
\item \verb~/~ search forwards
\item \verb~?~ search backwards
\item \verb~n~ next result
\item \verb~N~ previous result
\pause
\item \verb~*~ search forwards, for word under cursor
\item \verb~#~ search backwards, for word under cursor
\end{itemize}

\href{../Demos/10-search.txt}{Demo}
\end{frame}
\begin{frame}[label={sec:replace},fragile]{Replace}
 \begin{itemize}
\item \verb~:s/pattern/replacement~ \\
acts on the current \alert{line}
\item \verb~:%s/pattern/replacement~ \\
acts on the current \alert{file}
\item \verb~:'<,'>s/pattern/replacement~ \\
acts on the current \alert{selection}
\pause
\item You can use regex: \texttt{\textbackslash{}(...\textbackslash{})} to match, \texttt{\textbackslash{}1} to reference
\pause
\item The general syntax is \verb~:[range]s/{pattern}/{replacement}/[flags] [count]~
\begin{itemize}
\item 3 of the flags are: \texttt{c} to confirm each substitution, \texttt{g} to replace all
occurrences on a line, and \texttt{i} to ignore case
\end{itemize}
\end{itemize}

\href{../Demos/11-replace.txt}{Demo}
\end{frame}
\begin{frame}[label={sec:registers},fragile]{Registers}
 \begin{itemize}
\item Like marks, just for your text.
\item You can basically save text to a named spot.
\item \verb~"a~ to \verb~"z~ \alert{save} the selected text set a register.
\item \verb~"A~ to \verb~"Z~ \alert{add} the selection to the register
\pause
\item You need to add an action, e.g.
\begin{itemize}
\item \verb~"ay~ yanks (copies) an \emph{active selection} to register \verb~a~
\item \verb~"ayvap~ yanks (copies) the \emph{current paragraph} to register \verb~a~
\item \verb~"ap~ pastes the content of register \verb~a~
\item \verb~"Ayiw~ adds the \emph{current word} to register \verb~a~
\end{itemize}
\end{itemize}

\href{../Demos/12-registers.txt}{Demo}
\end{frame}
\begin{frame}[label={sec:macros-mini},fragile]{Macros (mini)}
 \begin{center}
\verb~.~ repeats the last action \\
\href{../Demos/13-dot-macro.txt}{Demo}
\end{center}
\end{frame}

\begin{frame}[label={sec:recording-named-macro},fragile]{Recording a named macro}
 \begin{itemize}
\item \verb~qa~ starts recording a macro saved to \verb~a~
\item \emph{do the things\textsuperscript{\textls*[70]{\textsc{tm}}}}
\item \verb~q~ to stop recording
\end{itemize}
\end{frame}
\begin{frame}[label={sec:using-named-macro},fragile]{Using a named macro}
 \begin{itemize}
\item \verb~@a~ to execute macro \verb~a~
\item \verb~@@~ to execute the last macro
\item \verb~22@a~ to execute \verb~a~ 22 times\ldots{}
\end{itemize}
\end{frame}
\begin{frame}[label={sec:editing-an-existing},fragile]{Editing an existing macro}
 \begin{itemize}
\item You can just use the register functionality
\item \verb~"ap~ pastes the content of macro \verb~a~
\item Edit, select new macro content
\item \verb~"ay~ writes to the macro \verb~a~
\end{itemize}
\end{frame}
\begin{frame}[label={sec:named-macro-example},fragile]{A named macro --- example}
 \begin{verbatim}
qs $ S ) Ret "ayib dab x ^ "aP a : Spc Esc ^ <down> q
\end{verbatim}
\pause
\vspace{-2mm}
\begin{block}{What does that do!?}
\vspace{-2mm}
\begin{itemize}
\item \verb~$~ go to end of line
\item \verb~S )~ search backwards for \verb~)~
\item \verb~Ret~ go to the first match
\item \verb~"ayib~ copy the content of the parenthesis to register \verb~a~
\item \verb~dab~ delete the parenthesised content
\item \verb~x~ delete the current character
\item \verb~^~ go to the start of the content
\item \verb~"aP~ paste content of register \verb~a~
\item \verb~a : Spc Esc~ enter insert mode after the content, and add ``: '' before
returning to normal mode
\item \verb~^~ go to the start of the content
\item \verb~<down>~ move the cursor down one line
\end{itemize}
\end{block}
\end{frame}
\begin{frame}[label={sec:even-more-vim},fragile]{A named macro --- example explained}
 Ok, what does that \emph{really} do?

\begin{itemize}
\item Find the last parenthesised content in a line, take it out and bring it to the front
\end{itemize}

If one called it on the following line for example
\begin{verbatim}
I need to make some slides (Due Thursday) on vim
\end{verbatim}
becomes
\begin{verbatim}
Due Thursday: I need to make some slides on vim
\end{verbatim}

\href{../Demos/14-named-macro.txt}{Demo}
\end{frame}
\begin{frame}[label={sec:this-seems-like}]{This seems like a lot of work}
It is, but it's easy to gradually build your skill. We spend so much time
editing text that I think it's worth using a method which improves the
experience, even if it takes a bit of time to learn.

\begin{figure}[!htb]
  \centering
  \includegraphics[scale=0.4]{/home/tec/.emacs.d/xkcd/1205.png}
  \caption*{\label{xkcd:1205} \textbf{Is It Worth the Time?} Don't forget the time you spend finding the chart to look up what you save. And the time spent reading this reminder about the time spent. And the time trying to figure out if either of those actually make sense. Remember, every second counts toward your life total, including these right now.}
\end{figure}
\end{frame}
\begin{frame}[label={sec:resources},fragile]{Resources}
 \begin{itemize}
\item A nice big \href{https://vim.rtorr.com/}{Vim Cheat Sheet}
\item \href{https://www.glump.net/\_media/howto/desktop/vim-graphical-cheat-sheet-and-tutorial/vi-vim-cheat-sheet-and-tutorial.pdf}{Vim functions overlayed on a keyboard}
\item Interactive Vim tutorial: \url{https://www.openvim.com/}
\item Vim navigation in Firefox: \href{https://github.com/tridactyl/tridactyl}{tridactyl} (\href{https://addons.mozilla.org/en-us/firefox/addon/tridactyl-vim/}{add-on page})
\item Vim navigation in Chrome: \url{https://vimium.github.io/}
\item Blog post: \href{https://yehudakatz.com/2010/07/29/everyone-who-tried-to-convince-me-to-use-vim-was-wrong/}{Everyone Who Tried to Convince Me to use Vim was Wrong}
\item \texttt{vimtutor} is a little tool that comes bundled with vim
\end{itemize}
\end{frame}

\section{Q\&A}
\label{sec:qa}
\end{document}
