blob: 6e7a75a88b9d50483a5a8c3eebe3e471bfa4025f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
###Easy Method###
Use surround.vim plugin
###Native Vim methods###
__Quote a word using single quotes__
`ciw'Ctrl+r"'`
* `ciw` - Delete the word the cursor is on, and end up in insert mode
* `'` - Add the first quote
* `Ctrl+r"` - Insert the contents of the `"` register, aka the last yank/delete.
* `'` - Add the closing quote
_Unquote a word that's enclosed in single quotes_
`di'hPl2x`
* `di'` - Delete the word enclosed by single quotes.
* `hP` - Move the cursor left one place (on top of the opening quote) and put the just deleted text before the quote.
* `l` - Move the cursor right one place (on top of the opening quote).
* `2x` - Delete the two quotes.
_Change single quotes to double quotes_
`va':s/\%V'\%V/"/g`
* `va'` - Visually select the quoted word and the quotes.
* ``:s/`` - Start a replacement.
* ``\%V'\%V` - Only match single quotes that are within the visually selected region.
* ``/"/g` - Replace them all with double quotes.
See [Stack Overflow Ref:](https://stackoverflow.com/questions/2147875/what-vim-commands-can-be-used-to-quote-unquote-words)
|