\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{nwilde} \pdfinfo{ /Title (vim.pdf) /Creator (Cheatography) /Author (nwilde) /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}{70C1FF} \definecolor{LightBackground}{HTML}{EDF7FF} \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}{nwilde} via \textcolor{DarkBackground}{\uline{cheatography.com/68037/cs/17135/}}} \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}nwilde \\ \uline{cheatography.com/nwilde} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 1st November, 2018.\\ Updated 19th September, 2018.\\ 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{3.38436 cm} x{1.59264 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Moving \{\{fa-plane\}\}}} \tn % Row 0 \SetRowColor{LightBackground} \{\{fa-arrow-up\}\} & k \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \{\{fa-arrow-down\}\} & j \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \{\{fa-arrow-left\}\} & h \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} \{\{fa-arrow-right\}\}\{\{bb\}\} & l\{\{bb\}\} \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} Move Forward One "Word"\{\{nl\}\}Forward to Whitespace & w \{\{nl\}\} W \tn % Row Count 6 (+ 2) % Row 5 \SetRowColor{white} \{\{nobreak\}\}Move Forward to End of "Word" \{\{nl\}\} Same but to Whitespace & e \{\{nl\}\} E \tn % Row Count 9 (+ 3) % Row 6 \SetRowColor{LightBackground} \{\{nobreak\}\}Move Backward one word (start)\{\{nl\}\}Move Backward to whitespace & b\{\{nl\}\}B \tn % Row Count 12 (+ 3) % Row 7 \SetRowColor{white} Page Down One Page & \{\{nobreak\}\}\textless{}Ctrl-f\textgreater{} \tn % Row Count 14 (+ 2) % Row 8 \SetRowColor{LightBackground} Page Up One Page & \{\{nobreak\}\}\textless{}Ctrl-b\textgreater{} \tn % Row Count 16 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{These can be used with text objects and repeat modifiers ie 2j will move down 2 lines instead of one, 3w will move 3 "words" forward, etc.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.68758 cm} x{2.28942 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Moving Advanced \{\{fa-graduation-cap\}\}}} \tn % Row 0 \SetRowColor{LightBackground} Move to End of Line & {\bf{\$}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \{\{nobreak\}\}Move to beginning of Line (first character) & {\bf{\textasciicircum{}}} \tn % Row Count 4 (+ 3) % Row 2 \SetRowColor{LightBackground} Move to beginning of line & 0 \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} Move to top of file & {\bf{gg}} \tn % Row Count 7 (+ 1) % Row 4 \SetRowColor{LightBackground} Move to bottom of file & {\bf{G}} \tn % Row Count 9 (+ 2) % Row 5 \SetRowColor{white} Move to line \textless{}num\textgreater{}\{\{bb\}\} & \{\{nobreak\}\}\textless{}num\textgreater{}G\{\{bb\}\} {\emph{6G}} \tn % Row Count 11 (+ 2) % Row 6 \SetRowColor{LightBackground} \{\{nobreak\}\}Find next occurrence of \textless{}char\textgreater{}\{\{nl\}\}Find previous occurrence of \textless{}char\textgreater{} & f\textless{}char\textgreater{}\{\{nl\}\}F\textless{}char\textgreater{} \tn % Row Count 15 (+ 4) % Row 7 \SetRowColor{white} \{\{nobreak\}\}'Till the next occurence of \textless{}char\textgreater{}\{\{nl\}\}'Till the previous occurrence of \textless{}char\textgreater{}\{\{bb\}\} & {\bf{t\textless{}char\textgreater{}}}\{\{nl\}\}{\bf{T\textless{}char\textgreater{}}}\{\{bb\}\} \tn % Row Count 20 (+ 5) % Row 8 \SetRowColor{LightBackground} Move cursor to matching pair () \{\} {[}{]}\{\{bb\}\} & \%\{\{bb\}\} \tn % Row Count 23 (+ 3) % Row 9 \SetRowColor{white} Move cursor to top of screen & H (Home) \tn % Row Count 25 (+ 2) % Row 10 \SetRowColor{LightBackground} Move cursor to middle of screen & M \tn % Row Count 27 (+ 2) % Row 11 \SetRowColor{white} Move cursor to bottom of screen & L (Last) \tn % Row Count 29 (+ 2) % Row 12 \SetRowColor{LightBackground} Re-position cursor to the top & zt \tn % Row Count 31 (+ 2) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.68758 cm} x{2.28942 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Moving Advanced \{\{fa-graduation-cap\}\} (cont)}} \tn % Row 13 \SetRowColor{LightBackground} Re-position cursor to the middle & zz \tn % Row Count 2 (+ 2) % Row 14 \SetRowColor{white} Re-position cursor to bottom & zb \tn % Row Count 4 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{You can repeat the commands with f and t using ; for forward repeat and , for backwards repeat} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.9862 cm} x{1.9908 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Marks \{\{fa-bookmark\}\}}} \tn % Row 0 \SetRowColor{LightBackground} Make mark & {\bf{m{[}a-zA-Z{]}}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} Go to line with mark & {\bf{'{[}a-zA-Z{]}}} \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} Go to actual column mark & `{[}a-zA-Z{]} \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} :marks\{\{bt\}\} & Show marks\{\{bt\}\} \tn % Row Count 4 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{The marks A-Z are stored between files. the marks a-z are only in that single file. So two files can have different marks a but there can only be one A mark.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{3.68298 cm} x{1.29402 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Inserting Text \{\{fa-font\}\}}} \tn % Row 0 \SetRowColor{LightBackground} Insert before current position \{\{nl\}\}Insert at beginning of line (first char) & i\{\{nl\}\}I \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} Insert after current position\{\{nl\}\}Insert at the end of line & a\{\{nl\}\}A \tn % Row Count 6 (+ 3) % Row 2 \SetRowColor{LightBackground} \{\{nobreak\}\}Insert new line below current line\{\{nl\}\}Insert new line above current line\{\{bb\}\} & o\{\{nl\}\}O\{\{bb\}\} \tn % Row Count 10 (+ 4) % Row 3 \SetRowColor{white} Read Text from \textless{}source\textgreater{} (source can be a file or command) & :r file.txt \tn % Row Count 12 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{3.43413 cm} x{1.54287 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Modifying Text \{\{fa-font\}\}}} \tn % Row 0 \SetRowColor{LightBackground} \{\{nobreak\}\}Delete one char\{\{nl\}\}Delete one char to left & {\bf{x}} \{\{nl\}\} {\bf{X}} \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} Delete text to motion & {\bf{d\textless{}motion\textgreater{}}} \tn % Row Count 5 (+ 2) % Row 2 \SetRowColor{LightBackground} Change text to motion & {\bf{c\textless{}motion\textgreater{}}} \tn % Row Count 7 (+ 2) % Row 3 \SetRowColor{white} Delete single line & {\bf{dd}} \tn % Row Count 8 (+ 1) % Row 4 \SetRowColor{LightBackground} Change entire line & cc | S \tn % Row Count 9 (+ 1) % Row 5 \SetRowColor{white} Delete to end of line & {\bf{D}} \tn % Row Count 10 (+ 1) % Row 6 \SetRowColor{LightBackground} Change to the end of line & {\bf{C}} \tn % Row Count 11 (+ 1) % Row 7 \SetRowColor{white} Replace single character at cursor & {\bf{r\textless{}char\textgreater{}}} \tn % Row Count 13 (+ 2) % Row 8 \SetRowColor{LightBackground} Enter insert mode but replace text & R \tn % Row Count 15 (+ 2) % Row 9 \SetRowColor{white} Copy text to motion & y\textless{}motion\textgreater{} \tn % Row Count 16 (+ 1) % Row 10 \SetRowColor{LightBackground} Copy line & {\bf{yy}} \tn % Row Count 17 (+ 1) % Row 11 \SetRowColor{white} \{\{nobreak\}\}Paste text after cursor\{\{nl\}\}Paste text before cursor & {\bf{p}}\{\{nl\}\}{\bf{P}} \tn % Row Count 20 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{If you copy an entire line, p will paste the whole line below the current line and P will do the same above.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{3.08574 cm} x{1.89126 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Text Objects \{\{fa-font\}\}}} \tn % Row 0 \SetRowColor{LightBackground} \{\{nobreak\}\}A word (arround something) & \{\{nobreak\}\}a\textless{}motion/char\textgreater{} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \{\{nobreak\}\}Inner word (inside something) & \{\{nobreak\}\}i\textless{}motion/char\textgreater{} \tn % Row Count 4 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{The text objects can be used with text modifying commands, like d, c, y, and p. ciw will change the inner word (keep whitespace) and wait for text in insert mode. \newline For more information see :help text-objects} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{3.18528 cm} x{1.79172 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Visual Mode \{\{fa-eye\}\}}} \tn % Row 0 \SetRowColor{LightBackground} Enter Visual Mode & v \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} Enter Visual Block Mode & \textless{}Ctrl-v\textgreater{} \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} Enter Visual Line Mode & {\bf{\textless{}Shift-v\textgreater{}}} \tn % Row Count 3 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Visual mode accepts commands like d, c, y, and p after text has been selected.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{3.38436 cm} x{1.59264 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Searching \{\{fa-search\}\}}} \tn % Row 0 \SetRowColor{LightBackground} Search forward & {\bf{/}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} Search backward & ? \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \{\{nobreak\}\}Move to next search result\{\{nl\}\}Move to previous search & {\bf{n}}\{\{nl\}\}{\bf{N}} \tn % Row Count 5 (+ 3) % Row 3 \SetRowColor{white} Match whole word & \{\{nobreak\}\}\textbackslash{}\textless{}text\textbackslash{}\textgreater{} \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} Regex searching & \textasciicircum{}\$. \tn % Row Count 8 (+ 1) % Row 5 \SetRowColor{white} Search forward the word under the cursor & * \tn % Row Count 10 (+ 2) % Row 6 \SetRowColor{LightBackground} Search backward the word under the cursor & \# \tn % Row Count 12 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Escape regex chars with \textbackslash{}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{3.73275 cm} p{1.24425 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Registers \{\{fa-registered\}\}}} \tn % Row 0 \SetRowColor{LightBackground} Access register & "{[}a-z{]} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} Append to register & "{[}A-Z{]} \tn % Row Count 2 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{3.93183 cm} p{1.04517 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Macros \{\{fa-microphone\}\}}} \tn % Row 0 \SetRowColor{LightBackground} Start recording macro & q{[}a-z{]} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} Execute recorded macro & @{[}a-z{]} \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} Execute last used macro & @@ \tn % Row Count 3 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.43873 cm} x{2.53827 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Files \{\{fa-folder\}\}}} \tn % Row 0 \SetRowColor{LightBackground} Save file & :w \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} Save and Quit & :wq \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} Edit a new file & :e filename \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} Save copy of file & \{\{nobreak\}\}:w filename.copy \tn % Row Count 5 (+ 2) % Row 4 \SetRowColor{LightBackground} Save copy and edit copy of file & \{\{nobreak\}\}:saveas filename.copy \tn % Row Count 7 (+ 2) % Row 5 \SetRowColor{white} Change name of the current file & :file filename \tn % Row Count 9 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Use ! to override warnings about saving files. Like if you type :q without saving changes Vim will warn you about this. But if you really want to discard your changes use :q!} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{3.28482 cm} x{1.69218 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Files Advanced \{\{fa-folder\}\} \{\{fa-graduation-cap\}\}}} \tn % Row 0 \SetRowColor{LightBackground} Open file in a split window & :split filename \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} Open file in a vertically split window & :vsplit filename \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} Open file in a new tab & :tabedit filename \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} Move to window & \textless{}Ctrl-w\textgreater{}\textless{}motion\textgreater{} \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} Move to next tab & gt \tn % Row Count 9 (+ 1) % Row 5 \SetRowColor{white} Move to previous tab & gT \tn % Row Count 10 (+ 1) % Row 6 \SetRowColor{LightBackground} Move current window to tab & \{\{nobreak\}\}\textless{}Ctrl-W\textgreater{}T \tn % Row Count 12 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}