\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{ghodt} \pdfinfo{ /Title (vim.pdf) /Creator (Cheatography) /Author (ghodt) /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}{9368C4} \definecolor{LightBackground}{HTML}{F8F5FB} \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}{ghodt} via \textcolor{DarkBackground}{\uline{cheatography.com/171239/cs/35911/}}} \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}ghodt \\ \uline{cheatography.com/ghodt} \\ \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 December, 2022.\\ 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*}{2} \begin{tabularx}{8.4cm}{x{1.76 cm} x{6.24 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Working with files}} \tn % Row 0 \SetRowColor{LightBackground} :e \seqsplit{filename} & Open a new file. You can use the Tab key for automatic file name completion, just like at the shell command prompt. \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} :w \seqsplit{filename} & Save changes to a file. If you don't specify a file name, Vim saves as the file name you were editing. For saving the file under a different name, specify the file name. \tn % Row Count 10 (+ 6) % Row 2 \SetRowColor{LightBackground} :q & Quit Vim. If you have unsaved changes, Vim refuses to exit. \tn % Row Count 12 (+ 2) % Row 3 \SetRowColor{white} :q! & Exit Vim without saving changes. \tn % Row Count 14 (+ 2) % Row 4 \SetRowColor{LightBackground} :wq & Write the file and exit. \tn % Row Count 15 (+ 1) % Row 5 \SetRowColor{white} :x & Almost the same as :wq, write the file and exit if you've made changes to the file. If you haven't made any changes to the file, Vim exits without writing the file. \tn % Row Count 21 (+ 6) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{1.6 cm} x{6.4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Moving around in the file}} \tn % Row 0 \SetRowColor{LightBackground} j or Up & Move the cursor up one line. \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} k or Down & Down one line. \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} h or Left & Left one character. \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} l or Right & Right one character. \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} e & To the end of a word. \tn % Row Count 8 (+ 1) % Row 5 \SetRowColor{white} E & To the end of a whitespace-delimited word. \tn % Row Count 10 (+ 2) % Row 6 \SetRowColor{LightBackground} b & To the beginning of a word. \tn % Row Count 11 (+ 1) % Row 7 \SetRowColor{white} B & To the beginning of a whitespace-delimited word. \tn % Row Count 13 (+ 2) % Row 8 \SetRowColor{LightBackground} 0 & To the beginning of a line. \tn % Row Count 14 (+ 1) % Row 9 \SetRowColor{white} \textasciicircum{} & To the first non-whitespace character of a line. \tn % Row Count 16 (+ 2) % Row 10 \SetRowColor{LightBackground} \$ & To the end of a line. \tn % Row Count 17 (+ 1) % Row 11 \SetRowColor{white} H & To the first line of the screen. \tn % Row Count 18 (+ 1) % Row 12 \SetRowColor{LightBackground} M & To the middle line of the screen. \tn % Row Count 20 (+ 2) % Row 13 \SetRowColor{white} L & To the the last line of the screen. \tn % Row Count 22 (+ 2) % Row 14 \SetRowColor{LightBackground} :n & Jump to line number n. For example, to jump to line 42, you'd type :42 \tn % Row Count 25 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{p{0.8 cm} x{7.2 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Inserting and overwriting text}} \tn % Row 0 \SetRowColor{LightBackground} i & Insert before cursor. \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} I & Insert to the start of the current line. \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} a & Append after cursor. \tn % Row Count 4 (+ 1) % Row 3 \SetRowColor{white} A & Append to the end of the current line. \tn % Row Count 6 (+ 2) % Row 4 \SetRowColor{LightBackground} o & Open a new line below and insert. \tn % Row Count 7 (+ 1) % Row 5 \SetRowColor{white} O & Open a new line above and insert. \tn % Row Count 8 (+ 1) % Row 6 \SetRowColor{LightBackground} C & Change the rest of the current line. \tn % Row Count 9 (+ 1) % Row 7 \SetRowColor{white} r & Overwrite one character. After overwriting the single character, go back to command mode. \tn % Row Count 12 (+ 3) % Row 8 \SetRowColor{LightBackground} R & Enter insert mode but replace characters rather than inserting. \tn % Row Count 14 (+ 2) % Row 9 \SetRowColor{white} ESC & Exit insert/overwrite mode and go back to command mode. \tn % Row Count 16 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2 cm} x{6 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Editing blocks of text}} \tn % Row 0 \SetRowColor{LightBackground} \textasciitilde{} & Change the case of characters. This works both in visual and command mode. In visual mode, change the case of highlighted characters. In command mode, change the case of the character under cursor. \tn % Row Count 7 (+ 7) % Row 1 \SetRowColor{white} \textgreater{} (V) & Shift right (indent). \tn % Row Count 8 (+ 1) % Row 2 \SetRowColor{LightBackground} \textless{} (V) & Shift left (de-indent). \tn % Row Count 9 (+ 1) % Row 3 \SetRowColor{white} c (V) & Change the highlighted text. \tn % Row Count 10 (+ 1) % Row 4 \SetRowColor{LightBackground} y (V) & Yank the highlighted text. In Windows terms, "copy the selected text to clipboard." \tn % Row Count 13 (+ 3) % Row 5 \SetRowColor{white} d (V) & Delete the highlighted text. In Windows terms, "cut the selected text to clipboard." \tn % Row Count 16 (+ 3) % Row 6 \SetRowColor{LightBackground} yy or :y or Y & Yank the current line. You don't need to highlight it first. \tn % Row Count 18 (+ 2) % Row 7 \SetRowColor{white} dd or :d & Delete the current line. Again, you don't need to highlight it first. \tn % Row Count 21 (+ 3) % Row 8 \SetRowColor{LightBackground} p & Put the text you yanked or deleted. In Windows terms, "paste the contents of the clipboard". Put characters after the cursor. Put lines below the current line. \tn % Row Count 27 (+ 6) % Row 9 \SetRowColor{white} P & Put characters before the cursor. Put lines above the current line. \tn % Row Count 30 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{Note: the Vim commands marked with (V) work in visual mode, when you've selected some text. The other commands work in the command mode, when you haven't selected any text.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{1.44 cm} x{6.56 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Deleting text}} \tn % Row 0 \SetRowColor{LightBackground} x & Delete characters under the cursor. \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} X & Delete characters before the cursor. \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} dd or :d & Delete the current line. \tn % Row Count 6 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{1.36 cm} x{6.64 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Search}} \tn % Row 0 \SetRowColor{LightBackground} \seqsplit{/pattern} & Search the file for pattern. \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} n & Scan for next search match in the same direction. \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} N & Scan for next search match but opposite direction. \tn % Row Count 6 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Delimiter}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{} \tn % Row Count 0 (+ 0) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{p{1.04 cm} x{6.96 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Undo and redo}} \tn % Row 0 \SetRowColor{LightBackground} u & Undo the last action. \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} U & Undo all the latest changes that were made to the current line. \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} \seqsplit{Ctrl+r} & Redo. \tn % Row Count 5 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{p{0.8 cm} x{7.2 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Visual mode}} \tn % Row 0 \SetRowColor{LightBackground} v & Start highlighting characters. Use the normal movement keys and commands to select text for highlighting. \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} V & Start highlighting lines. \tn % Row Count 5 (+ 1) % Row 2 \SetRowColor{LightBackground} ESC & Exit visual mode and return to command mode. \tn % Row Count 7 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}