Size: 623
Comment:
|
Size: 2998
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 1: | Line 1: |
= Vim Tricks = | = Vim = '''`vim(1)`''' is a terminal text editor. It is closely related to a family of editors stretching from `ed(1)` to `nvim(1)`, but `vim(1)` is both the most commonly available and most visible. |
Line 9: | Line 11: |
== Quoting Words | == History == '''`ed(1)`''' is a line editor. Originally created by Bell Labs for Unix, GNU ed is a POSIX-compliant implementation. '''`ex(1)`''' is the '''ex'''tended line editor written for the first Berkeley Software Distribution. It is POSIX-compliant implementation of `ed(1)`. '''`vi(1)`''' is a '''visual''' text editor built on `ex(1)`. Type a colon (`:`) to enter ex mode. '''`vim(1)`''' is '''v'''i '''im'''proved. '''`nvim(1)`''' is a fork of `vim(1)` with a significantly refactored codebase, including... * The UI and editor processes are separate, enabling the creation of other (often non-terminal) UIs. * Directory scanning follows modern standards (i.e. XDG on *nix, !AppData on Windows). * Features moved from third-party plugins were incorporated to the project, generally making user configurations more portable across platforms. ---- == Installation == All *nix distributions will have a POSIX-compliant implementation of `ed(1)` and `vi(1)` pre-installed. Many distributions will also have `vim(1)` pre-installed. Most will at least offer `vim` and `neovim` packages. For Windows users, while GVim is an option, Neovim is strongly recommended. Chocolatey offers a `neovim` package. ---- == Configuration == See [[Vim/Configuration|here]] for details on configuring this family of programs. ---- == Tips == === Regular Expressions === For help with writing regular expressions in `vim(1)`, look [[Vim/RegularExpressions|here]]. === Searching for Non-ASCII Characters === Vim regular expressions can use hexadecimal to represent non-ASCII code points, but the syntax differs for literal characters and character classes. Try... * `/\%x30` to search for the number 0 * `/[^\x00-\x7F]` to search for any non-ASCII code point * '''Note the omitted percent sign''' Similar syntax is available for Unicode code points, especially multibyte characters. Try... * `/\%u201c` to search for left curly quotes * `/[\u201c-\u201d]` to search for left or right curly quotes * '''Note the omitted percent sign''' * `/\%u00a0` to search for non-breaking spaces === Quoting Words === |
Line 22: | Line 90: |
Vim
vim(1) is a terminal text editor. It is closely related to a family of editors stretching from ed(1) to nvim(1), but vim(1) is both the most commonly available and most visible.
Contents
History
ed(1) is a line editor. Originally created by Bell Labs for Unix, GNU ed is a POSIX-compliant implementation.
ex(1) is the extended line editor written for the first Berkeley Software Distribution. It is POSIX-compliant implementation of ed(1).
vi(1) is a visual text editor built on ex(1). Type a colon (:) to enter ex mode.
vim(1) is vi improved.
nvim(1) is a fork of vim(1) with a significantly refactored codebase, including...
- The UI and editor processes are separate, enabling the creation of other (often non-terminal) UIs.
Directory scanning follows modern standards (i.e. XDG on *nix, !AppData on Windows).
- Features moved from third-party plugins were incorporated to the project, generally making user configurations more portable across platforms.
Installation
All *nix distributions will have a POSIX-compliant implementation of ed(1) and vi(1) pre-installed.
Many distributions will also have vim(1) pre-installed. Most will at least offer vim and neovim packages.
For Windows users, while GVim is an option, Neovim is strongly recommended. Chocolatey offers a neovim package.
Configuration
See here for details on configuring this family of programs.
Tips
Regular Expressions
For help with writing regular expressions in vim(1), look here.
Searching for Non-ASCII Characters
Vim regular expressions can use hexadecimal to represent non-ASCII code points, but the syntax differs for literal characters and character classes. Try...
/\%x30 to search for the number 0
/[^\x00-\x7F] to search for any non-ASCII code point
Note the omitted percent sign
Similar syntax is available for Unicode code points, especially multibyte characters. Try...
/\%u201c to search for left curly quotes
/[\u201c-\u201d] to search for left or right curly quotes
Note the omitted percent sign
/\%u00a0 to search for non-breaking spaces
Quoting Words
Affixes can be applied programmatically using word deletion and registers. For example, to quote the currently selected word, use ciw'Ctrl+r"'.
ciw - delete selected word and enter insert mode
' - insert the leading quote mark
Ctrl+r" - insert the contents of the " register, a.k.a. the deleted word
' - insert the trailing quote mark
This method can be used to apply any affixes. To surround an SPSS string variable name with the trimming functions, use ciwrtrim(ltrim(Ctrl+r")).