\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{PeterCeeAU} \pdfinfo{ /Title (vim-editor-yet-another.pdf) /Creator (Cheatography) /Author (PeterCeeAU) /Subject (Vim Editor {[}Yet Another{]} 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}{282836} \definecolor{LightBackground}{HTML}{F8F8F8} \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 Editor {[}Yet Another{]} Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{PeterCeeAU} via \textcolor{DarkBackground}{\uline{cheatography.com/58333/cs/15442/}}} \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}PeterCeeAU \\ \uline{cheatography.com/peterceeau} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 11th April, 2018.\\ Updated 18th May, 2021.\\ 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} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Modes}} \tn \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{Vim offers multiple modes, including Normal, Insert, Command and Visual. \newline % Row Count 2 (+ 2) {\bf{Normal mode}} is the mode Vim starts in and which is used for navigation and text manipulation. You can return to normal mode by pressing ESC. \newline % Row Count 5 (+ 3) {\bf{Insert mode}} is used for inserting text and can be accessed several ways, the most common being "i" to Insert, "a" to Append, "c" to change. \newline % Row Count 8 (+ 3) {\bf{Command mode}} is to enter commands such as searching, reading files, saving and exiting. It is accessed by ":" key. \newline % Row Count 11 (+ 3) {\bf{Visual mode}} like normal mode is used for navigation and text manipulation, there are additional sub-modes - visual, visual-line and visual-block modes. Visual mode is accessed by pressing a variety of "v" key combinations. \newline % Row Count 16 (+ 5) In the various modes most commands execute immediately, the exception to this is Command mode where you need to press the Enter key to execute.% Row Count 19 (+ 3) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{p{0.88 cm} x{7.12 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Insert Mode}} \tn % Row 0 \SetRowColor{LightBackground} Key & Action \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} `i` & insert at cursor \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} `I` & insert at the beginning of the line \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} `a` & append after the cursor \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} `A` & append at the end of the line \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} `o` & open blank line below current line (no need to press return) \tn % Row Count 7 (+ 2) % Row 6 \SetRowColor{LightBackground} `O` & open blank line above current line \tn % Row Count 8 (+ 1) % Row 7 \SetRowColor{white} `ESC` & to exit insert mode (and return to normal mode) \tn % Row Count 10 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{Cursor movements can be combined with insert mode commands \newline {\emph{ `Bi` - insert at the start of the current word \newline }} `ea` - append at the end of the current word \newline {\emph{ `Wi` - insert at the start of next word \newline }} `jI` - insert at the start of next line \newline * `jA` - append at the end of next line} \tn \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}{Command Mode}} \tn % Row 0 \SetRowColor{LightBackground} Key & Action \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} `:` & enter command mode \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \seqsplit{`Enter`} & to action command \tn % Row Count 4 (+ 2) % Row 3 \SetRowColor{white} `Esc` x2 & to exit command mode (and return to normal mode) \tn % Row Count 6 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{The command is only executed after pressing the `Enter` key.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.56 cm} x{5.44 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Visual Mode}} \tn % Row 0 \SetRowColor{LightBackground} Key & Action \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} `v` & enter visual mode \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} `V` & enter visual-line mode \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} \{\{nobreak\}\}`Ctrl-v` & enter visual-block mode \tn % Row Count 5 (+ 2) % Row 4 \SetRowColor{LightBackground} \{\{nobreak\}\}`Esc` x2 & to exit visual mode (and return to normal mode) \tn % Row Count 7 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{Examples of usage, after making visual selection perform the following actions: \newline visual-line mode \newline {\emph{ delete complete lines - `d` \newline }} yank (copy) - `y` \newline visual-block mode \newline {\emph{ Insert text to start of multiple lines - `I`, \textless{}text,whitespace\textgreater{}, `Esc`, `Esc` \newline }} Delete characters from the start of multiple lines - `d`} \tn \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}{Cursor Movement}} \tn % Row 0 \SetRowColor{LightBackground} Key & Action \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} `h` & move left (also left cursor) \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} `j` & move down (also down cursor) \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} `k` & move up (also up cursor) \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} `l` & move right (also right cursor) \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} `w` & jump forward to start of words (punctuation considered words) \tn % Row Count 7 (+ 2) % Row 6 \SetRowColor{LightBackground} `W` & jump forward to start of words (spaces separate words) \tn % Row Count 9 (+ 2) % Row 7 \SetRowColor{white} `e` & jump forward to end of words (punctuation considered words) \tn % Row Count 11 (+ 2) % Row 8 \SetRowColor{LightBackground} `E` & jump forward to end of words (spaces separate words) \tn % Row Count 13 (+ 2) % Row 9 \SetRowColor{white} `b` & jump backward to start of words (punctuation considered words) \tn % Row Count 15 (+ 2) % Row 10 \SetRowColor{LightBackground} `B` & jump backward to start of words (spaces separate words) \tn % Row Count 17 (+ 2) % Row 11 \SetRowColor{white} `0` & jump to start of line (zero) \tn % Row Count 18 (+ 1) % Row 12 \SetRowColor{LightBackground} `\textasciicircum{}` & jump to first non-blank character of line \tn % Row Count 20 (+ 2) % Row 13 \SetRowColor{white} `\$` & jump to end of line \tn % Row Count 21 (+ 1) % Row 14 \SetRowColor{LightBackground} `G` & go to end of file \tn % Row Count 22 (+ 1) % Row 15 \SetRowColor{white} `gg` & go to start of file \tn % Row Count 23 (+ 1) % Row 16 \SetRowColor{LightBackground} `H` & move to top of screen (no screen movement) \tn % Row Count 25 (+ 2) % Row 17 \SetRowColor{white} `M` & move to middle of screen (no screen movement) \tn % Row Count 27 (+ 2) % Row 18 \SetRowColor{LightBackground} `L` & move to bottom of screen (no screen movement) \tn % Row Count 29 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{Prefix a movement command with a number to repeat the move that number of times.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.56 cm} x{5.44 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Editing}} \tn % Row 0 \SetRowColor{LightBackground} Key & Action \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} `x` & delete character from right \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} `X` & delete character to left \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} `r` & replace a single character (does not use insert mode) \tn % Row Count 5 (+ 2) % Row 4 \SetRowColor{LightBackground} `R` & replace multiple characters \tn % Row Count 6 (+ 1) % Row 5 \SetRowColor{white} {\bf{change}} c+option & start change command (will enter Insert mode) \tn % Row Count 8 (+ 2) % Row 6 \SetRowColor{LightBackground} `cw` & change to the end of word \tn % Row Count 9 (+ 1) % Row 7 \SetRowColor{white} `cc` & change an entire line \tn % Row Count 10 (+ 1) % Row 8 \SetRowColor{LightBackground} `c\$` or `C` & change to the end of line \tn % Row Count 11 (+ 1) % Row 9 \SetRowColor{white} `cG` & change to end of file \tn % Row Count 12 (+ 1) % Row 10 \SetRowColor{LightBackground} {\bf{delete}} d+option & start delete command (will stay in Normal mode) \tn % Row Count 14 (+ 2) % Row 11 \SetRowColor{white} `dw` & delete word \tn % Row Count 15 (+ 1) % Row 12 \SetRowColor{LightBackground} `dd` & delete entire line \tn % Row Count 16 (+ 1) % Row 13 \SetRowColor{white} `d\$` or `D` & delete to the end of the line \tn % Row Count 18 (+ 2) % Row 14 \SetRowColor{LightBackground} `dG` & delete to the end of the file \tn % Row Count 20 (+ 2) % Row 15 \SetRowColor{white} `s` & delete character at cursor and substitute text (enters Insert mode) \tn % Row Count 23 (+ 3) % Row 16 \SetRowColor{LightBackground} `S` & delete line at cursor and substitute text (same as cc) \tn % Row Count 25 (+ 2) % Row 17 \SetRowColor{white} `xp` & transpose two letters (technically a combo to delete and paste) \tn % Row Count 28 (+ 3) % Row 18 \SetRowColor{LightBackground} `u` & undo \tn % Row Count 29 (+ 1) % Row 19 \SetRowColor{white} `Crtl-r` & redo \tn % Row Count 30 (+ 1) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{x{2.56 cm} x{5.44 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Editing (cont)}} \tn % Row 20 \SetRowColor{LightBackground} `.` & repeat last command \tn % Row Count 1 (+ 1) % Row 21 \SetRowColor{white} `J` & join current line with line below \tn % Row Count 3 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{Commands seem similar but there are slight differences. Some command will execute and can be repeated by pressing the same key. Other commands will perform the action and then automatically switch to Insert mode. Also, a command can be performed in multiple modes with slightly different keystrokes. \newline Commands are combined with cursor movement commands, so it is possible to: \newline {\emph{ `dgg` - delete to beginning for file \newline }} `c5w` - change 5 words \newline * `4dj` - delete current and 4 other lines} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.8 cm} x{5.2 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Cut, Copy, Paste}} \tn % Row 0 \SetRowColor{LightBackground} Key & Action \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} {\bf{delete}} & delete, i.e. cut (see previous) \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} {\bf{yank}} (y+option) & yank, i.e. copy \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} `yw` & yank word \tn % Row Count 6 (+ 1) % Row 4 \SetRowColor{LightBackground} `yy` & yank line \tn % Row Count 7 (+ 1) % Row 5 \SetRowColor{white} `2yy` & yank 2 lines \tn % Row Count 8 (+ 1) % Row 6 \SetRowColor{LightBackground} `yj` & yank current and next line \tn % Row Count 9 (+ 1) % Row 7 \SetRowColor{white} {\bf{put}} (p+option) & put, i.e. paste \tn % Row Count 11 (+ 2) % Row 8 \SetRowColor{LightBackground} `p` & put clipboard contents after cursor \tn % Row Count 13 (+ 2) % Row 9 \SetRowColor{white} `P` & put clipboard contents before cursor \tn % Row Count 15 (+ 2) % Row 10 \SetRowColor{LightBackground} `2p` & paste 2 copies \tn % Row Count 16 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.6 cm} x{4.4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Search and Replace}} \tn % Row 0 \SetRowColor{LightBackground} Key & Action \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \{\{noshy\}\}`/{\emph{pattern}}` & search for {\emph{pattern}} forward from cursor \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} \{\{noshy\}\}`?{\emph{pattern}}` & search for {\emph{pattern}} backward from cursor \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} `n` & repeat search in same direction \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} `N` & repeat search in opposite direction \tn % Row Count 9 (+ 2) % Row 5 \SetRowColor{white} \{\{nobreak\}\}`:\%s/{\emph{old}}/{\emph{new}}/g` & replace all {\emph{old}} with {\emph{new}} throughout file \tn % Row Count 11 (+ 2) % Row 6 \SetRowColor{LightBackground} \{\{nobreak\}\}`:\%s/{\emph{old}}/{\emph{new}}/gc` & replace all {\emph{old}} with {\emph{new}} throughout file with confirmations \tn % Row Count 14 (+ 3) % Row 7 \SetRowColor{white} \{\{nobreak\}\}`:1,.\%s/{\emph{old}}/{\emph{new}}/g` & search from start of file to current cursor position, replace all {\emph{old}} with {\emph{new}} \tn % Row Count 18 (+ 4) % Row 8 \SetRowColor{LightBackground} \{\{nobreak\}\}`:.,\$\%s/{\emph{old}}/{\emph{new}}/g` & search from current cursor position to end of file, replace all {\emph{old}} with {\emph{new}} \tn % Row Count 22 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.52 cm} x{4.48 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Open, Save and Exit}} \tn % Row 0 \SetRowColor{LightBackground} Key & Action \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} `:w` & write (save) the file, but don't exit \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} \{\{nobreak\}\}`:w {\emph{file}}` & write to new {\emph{file}} \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} \{\{nobreak\}\}`:1,5w {\emph{file}}` & write lines 1-5 to new {\emph{file}} \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} `:wq` or `ZZ` & write (save) and quit \tn % Row Count 8 (+ 1) % Row 5 \SetRowColor{white} `:q` & quit (fails if anything has changed) \tn % Row Count 10 (+ 2) % Row 6 \SetRowColor{LightBackground} `:q!` & quit and discard changes \tn % Row Count 12 (+ 2) % Row 7 \SetRowColor{white} \{\{nobreak\}\}`:r~{\emph{file}}` & read in {\emph{file}} to current cursor position \tn % Row Count 14 (+ 2) % Row 8 \SetRowColor{LightBackground} \{\{nobreak\}\}`:r !head -n5 {\emph{file}}` & read in the first 5 lines of {\emph{file}} to current cursor position \tn % Row Count 17 (+ 3) % Row 9 \SetRowColor{white} \{\{nobreak\}\}`:e {\emph{file}}` & edit {\emph{file}} in new buffer \tn % Row Count 19 (+ 2) % Row 10 \SetRowColor{LightBackground} \{\{nobreak\}\}`:sp {\emph{file}}` & edit {\emph{file}} in new buffer and split window \tn % Row Count 21 (+ 2) % Row 11 \SetRowColor{white} `ctrl-ww` & switch between windows \tn % Row Count 22 (+ 1) % Row 12 \SetRowColor{LightBackground} \{\{nobreak\}\}`!! {\emph{command}}` & perform shell command, output will overwrite current line \tn % Row Count 25 (+ 3) \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}{Marks}} \tn % Row 0 \SetRowColor{LightBackground} \seqsplit{`:marks`} & list of marks - includes mark name, line, column and text \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} `ma` & set current position for mark 'a' \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} `'a` & jump to position of mark 'a' \tn % Row Count 4 (+ 1) % Row 3 \SetRowColor{white} `\textbackslash{}`a` & jump start of line of mark 'a' \tn % Row Count 5 (+ 1) % Row 4 \SetRowColor{LightBackground} `y'a` & yank from current position to mark 'a' \tn % Row Count 7 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{Can use a variety of commands from current position to position of mark 'a'. Most often use this command to copy and paste multiple lines of text. Similar results can be achieved in Visual mode.} \tn \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}{Ranges}} \tn % Row 0 \SetRowColor{LightBackground} `:.` & perform action on current line \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} `:1` & perform action on line 1 \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} `:1,5` & perform action on lines 1-5 \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} `:\$` & perform action on last line \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} `:\%` & perform action on all lines \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} `:5,\$` & perform action on lines 5 to last \tn % Row Count 7 (+ 2) % Row 6 \SetRowColor{LightBackground} `:.,\$` & perform action on current to last line \tn % Row Count 9 (+ 2) % Row 7 \SetRowColor{white} `:.+1,\$` & perform action on line below current to last \tn % Row Count 11 (+ 2) % Row 8 \SetRowColor{LightBackground} `:.+1,.+5` & perform action on line below to 5 lines below current line \tn % Row Count 13 (+ 2) % Row 9 \SetRowColor{white} `:'a,'b` & peform action from mark `a` to mark `b` \tn % Row Count 15 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{Ranges are combined on the Command line to perform a task on the lines specified. The default range, for most commands, is the current line. While for other commands the default range is all lines. \newline `:1,5d` - delete lines 1-5 \newline `:5,.y` - yank lines 5 to current \newline `:.,\$s/{\emph{old}}/{\emph{new}}/g` - replace {\emph{old}} with {\emph{new}} from current line to end of file \newline `'a,'by` - yank from 'a' to 'b'} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Miscellaneous}} \tn % Row 0 \SetRowColor{LightBackground} `:set number` & display line numbers \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} `:set number!` or\{\{nl\}\}`:set nonumber` & turn off line numbers \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} \{\{noshy\}\}`:colorscheme \textless{}colorscheme\textgreater{}` & change colorscheme \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} `:version` & show version and other information \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} `:set list` & show hidden characters \tn % Row Count 9 (+ 2) % Row 5 \SetRowColor{white} `:set nolist` & do not show hidden characters \tn % Row Count 11 (+ 2) % Row 6 \SetRowColor{LightBackground} `Ctrl-V`, cursor highlight, `I`, `\#`, `Esc`, `Esc` & multi-line comment \tn % Row Count 14 (+ 3) % Row 7 \SetRowColor{white} `Ctrl-V`, cursor highlight, `x` & delete multi-line comment \tn % Row Count 16 (+ 2) % Row 8 \SetRowColor{LightBackground} `:nohl` & remove search highlight \tn % Row Count 18 (+ 2) % Row 9 \SetRowColor{white} `:\%s/\textasciicircum{}M//g` & replace DOS carriage returns (if `dos2unix` is not installed) \tn % Row Count 22 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{Commands can be abbreviated, e.g. `:nohl` is shorthand for `:nohlsearch`} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Configuration}} \tn \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{Global defaults can be configured in `/etc/vimrc` but setting personal defaults is preferred. \newline % Row Count 2 (+ 2) Shared colour scheme files are located in \{\{nl\}\}`/usr/share/vim/vim{\emph{XX}}/colors` \newline % Row Count 4 (+ 2) Personal defaults can be configured in `\textasciitilde{}/.vimrc` \newline % Row Count 5 (+ 1) Personal colour scheme files added to \{\{nl\}\}`\textasciitilde{}/.vim/colors` \newline % Row Count 7 (+ 2) Specifiy default colour scheme in \{\{nl\}\}`\textasciitilde{}/.vimrc` \newline % Row Count 9 (+ 2) `colorscheme \textless{}colorscheme\textgreater{}`% Row Count 10 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Useful Links}} \tn \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{\seqsplit{https://en.wikibooks.org/wiki/Learning\_the\_vi\_Editor/Vim/Modes} \newline % Row Count 2 (+ 2) \seqsplit{http://vim.wikia.com/wiki/Vim\_Tips\_Wiki} \newline % Row Count 3 (+ 1) \seqsplit{http://vim.wikia.com/wiki/Search\_and\_replace} \newline % Row Count 4 (+ 1) http://vimcolors.com/ \newline % Row Count 5 (+ 1) \seqsplit{https://www.howtoforge.com/vim-basics}% Row Count 6 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}