\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{Bob1212} \pdfinfo{ /Title (vim.pdf) /Creator (Cheatography) /Author (Bob1212) /Subject (Vim Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{1C52A3} \definecolor{LightBackground}{HTML}{F0F4F9} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{Vim Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Bob1212} via \textcolor{DarkBackground}{\uline{cheatography.com/123144/cs/23110/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}Bob1212 \\ \uline{cheatography.com/bob1212} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Not Yet Published.\\ Updated 6th June, 2020.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{3} \begin{tabularx}{5.377cm}{x{1.44333 cm} x{3.53367 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Motions}} \tn % Row 0 \SetRowColor{LightBackground} h & move cursor left \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} j & move cursor down \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} k & move cursor up \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} l & move cursor right \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} w & move to the start of the next word \tn % Row Count 6 (+ 2) % Row 5 \SetRowColor{white} 3w & move forward 3 words (not counting the word under the cursor) and place cursor at the start of that word \tn % Row Count 10 (+ 4) % Row 6 \SetRowColor{LightBackground} e & (a) if cursor at end of current word, then move to the end of the next word \{\{nl\}\}(b) otherwise, move to the end of the current word \tn % Row Count 15 (+ 5) % Row 7 \SetRowColor{white} 3e & move forward 3 words (not counting the word under the cursor) and place cursor at the start of that word \tn % Row Count 19 (+ 4) % Row 8 \SetRowColor{LightBackground} 0 & move to the start of the line \tn % Row Count 21 (+ 2) % Row 9 \SetRowColor{white} \$ & move to the end of the line \tn % Row Count 22 (+ 1) % Row 10 \SetRowColor{LightBackground} G & move cursor to the last line of the document \tn % Row Count 24 (+ 2) % Row 11 \SetRowColor{white} 5G & move cursor to the 5th line of the document \tn % Row Count 26 (+ 2) % Row 12 \SetRowColor{LightBackground} gg & move cursor to the first line of the document \tn % Row Count 28 (+ 2) % Row 13 \SetRowColor{white} \% & find next item (, {[}, or \{ in this line after or under the cursor and jump to matching item ), {]}, or \}. Type \% again to jump back to the matching item (, {[}, or \{. \tn % Row Count 34 (+ 6) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{1.44333 cm} x{3.53367 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Motions (cont)}} \tn % Row 14 \SetRowColor{LightBackground} \textless{}C-o\textgreater{}\{\{nobreak\}\} & go to older cursor position in jump list (note that a "jump" is a command that normally moves the cursor several lines away, e.g., gg) \tn % Row Count 5 (+ 5) % Row 15 \SetRowColor{white} \textless{}C-i\textgreater{} & go to newer cursor position in jump list (note that a "jump" is a command that normally moves the cursor several lines away, e.g., gg) \tn % Row Count 10 (+ 5) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.44333 cm} x{3.53367 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Insert Mode}} \tn % Row 0 \SetRowColor{LightBackground} i & insert text before the cursor \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} a & insert text after the cursor \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} A & insert text after the end of the line \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} o & open a line below the cursor and start Insert mode \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} O & open a line above the cursor and start Insert mode \tn % Row Count 9 (+ 2) % Row 5 \SetRowColor{white} \textless{}Esc\textgreater{}\{\{nobreak\}\} & exit insert mode \tn % Row Count 11 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.64241 cm} x{3.33459 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Open, Save, \& Exit}} \tn % Row 0 \SetRowColor{LightBackground} :q! & exits the editor, discarding any changes you have made \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} :wq & save file and exit \tn % Row Count 4 (+ 1) % Row 2 \SetRowColor{LightBackground} :w {\emph{file}} & writes the current Vim file to disk named {\emph{file}} \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} :r {\emph{file}} & insert the contents of the {\emph{file}} below cursor line \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} :r !{\emph{cmd}}\{\{nobreak\}\} & insert output of external command {\emph{cmd}} below cursor line \tn % Row Count 11 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.4977 cm} x{4.4793 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Cut/Copy \& Past}} \tn % Row 0 \SetRowColor{LightBackground} x & delete (cut) character under cursor (does the same as dl, and acts the same as \textless{}Del\textgreater{} key) \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} X & delete (cut) character before cursor (acts the same as \textless{}Bksp\textgreater{} key) \tn % Row Count 5 (+ 2) % Row 2 \SetRowColor{LightBackground} dw & delete (cut) from the cursor postion to the start of the next word (excluding its first character) \tn % Row Count 8 (+ 3) % Row 3 \SetRowColor{white} 3wd & delete (cut) the characters of the word from the cursor postion to the start of the 3rd word foreward (not counting the word under the cursor and excluding the first character of kth word) \tn % Row Count 14 (+ 6) % Row 4 \SetRowColor{LightBackground} de & (a) if cursor at end of current word, then delete (cut) from the cursor position to the end of the next word (including the last character). \{\{nl\}\}(b) Otherwise, delete (cut) from the cursor postion to the end of the word (including the last character). \tn % Row Count 22 (+ 8) % Row 5 \SetRowColor{white} d\$ & delete (cut) from cursor to the end of the line (including the last character) \tn % Row Count 25 (+ 3) % Row 6 \SetRowColor{LightBackground} dd & delete (cut) whole line \tn % Row Count 26 (+ 1) % Row 7 \SetRowColor{white} 3dd & delete (cut) 3 lines (on and below cursor) \tn % Row Count 28 (+ 2) % Row 8 \SetRowColor{LightBackground} y & yanks (copies) text (p puts (pastes) it) \tn % Row Count 30 (+ 2) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{p{0.4977 cm} x{4.4793 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Cut/Copy \& Past (cont)}} \tn % Row 9 \SetRowColor{LightBackground} p & put previously deleted text after the cursor. If a line was deleted it will go on the line below the cursor. \tn % Row Count 3 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.44333 cm} x{3.53367 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Editing Text}} \tn % Row 0 \SetRowColor{LightBackground} rx & replace the character at the cursor with x \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} R & enters Replace mode until \textless{}Esc\textgreater{} is pressed. Replace mode is like Insert mode, but every typed character deletes an existing character \tn % Row Count 7 (+ 5) % Row 2 \SetRowColor{LightBackground} cw & deletes until the start of the next word (excluding its first character) and switches to Insert mode \tn % Row Count 11 (+ 4) % Row 3 \SetRowColor{white} ce & (a) if cursor at end of current word, then delete until the end of the next word (including its last character) and switches to Insert mode. \{\{nl\}\}(b) otherwise, delete until the end of a word (including its last character) and switches to Insert mode. \tn % Row Count 20 (+ 9) % Row 4 \SetRowColor{LightBackground} c\$ & deletes to the end of the line and switches to Insert mode \tn % Row Count 23 (+ 3) % Row 5 \SetRowColor{white} u & undo the last command \tn % Row Count 24 (+ 1) % Row 6 \SetRowColor{LightBackground} U & undo all changes on a line \tn % Row Count 25 (+ 1) % Row 7 \SetRowColor{white} \textless{}C-p\textgreater{}\{\{nobreak\}\} & undo the undo (redo) \tn % Row Count 27 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.94103 cm} x{3.03597 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Search \& Replace}} \tn % Row 0 \SetRowColor{LightBackground} /pattern & searches forward for the pattern in the document \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} ?pattern & searchs backward for pattern in document \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} n & repeat search in same direction \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} N & repeat search in opposite direction \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} :s/old/new & substitute 'new' for the first 'old' in the current line \tn % Row Count 11 (+ 3) % Row 5 \SetRowColor{white} :s/old/new/g & substitute 'new' for 'old' (all occurrences) in the current line \tn % Row Count 14 (+ 3) % Row 6 \SetRowColor{LightBackground} :\#,\#s/old/new/g\{\{nobreak\}\} & substitute 'new' for 'old' in the range of line numbers of \#,\# \tn % Row Count 17 (+ 3) % Row 7 \SetRowColor{white} :\%s/old/new/g & substitute 'new' for 'old' in the entire document \tn % Row Count 20 (+ 3) % Row 8 \SetRowColor{LightBackground} :\%s/old/new/gc & substitute 'new' for 'old' in the entire document, with a prompt whether to substiute or not \tn % Row Count 24 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.33919 cm} x{2.63781 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Visual Mode}} \tn % Row 0 \SetRowColor{LightBackground} v & Start visual mode. Use the normal movement keys and commands to select text for highlighting. \tn % Row Count 5 (+ 5) % Row 1 \SetRowColor{white} v {\emph{motion}}\{\{nl\}\}:w {\emph{file}}\{\{nobreak\}\} & writes the Visually selected text (via {\emph{motion}}) to {\emph{file}} \tn % Row Count 8 (+ 3) % Row 2 \SetRowColor{LightBackground} \textless{}Esc\textgreater{} & exit visual mode \tn % Row Count 9 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.89126 cm} x{3.08574 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Miscellaneous}} \tn % Row 0 \SetRowColor{LightBackground} \textless{}C-g\textgreater{} & show your location in the file and the file status \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} :!{\emph{cmd}} & allows you to execute any external shell command {\emph{cmd}} (e.g., :!ls -al) \tn % Row Count 6 (+ 3) % Row 2 \SetRowColor{LightBackground} :h & open help window (\textless{}C-w\textgreater{} to jump from one window to another, and :q \textless{}CR\textgreater{} to close help window) \tn % Row Count 11 (+ 5) % Row 3 \SetRowColor{white} :h {\emph{cmd}} & open help for command {\emph{cmd}} \tn % Row Count 13 (+ 2) % Row 4 \SetRowColor{LightBackground} :e \textless{}C-d\textgreater{} & Vim will show list of all commands that start with "e" \tn % Row Count 16 (+ 3) % Row 5 \SetRowColor{white} :e \textless{}C-d)\textgreater{}\textless{}Tab\textgreater{}\{\{nobreak\}\} & Vim will complete the name that starts with "e" \tn % Row Count 18 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.69218 cm} x{3.28482 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Optional Settings}} \tn % Row 0 \SetRowColor{LightBackground} :set {\emph{xxx}}\{\{nobreak\}\} & sets the option {\emph{xxx}} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} :set ic & ignore upper/lower case when searching \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} :set is & show partial matches for a search phrase \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} :set hls & highlight all matching phrases \tn % Row Count 8 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{prepend "no" to argument option to switch option off} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}