vim fugitive installation
vim surround
Delete surroundings
To delete we use ds, the next character determines the target to delete. Some examples:
Objective | Original text | Command | Edited text |
---|---|---|---|
Delete quotes surrounding a sentence | “Hello world!” | ||
[] <— cursor | ds” | Hello world! | |
[] <— cursor now | |||
Delete surrounding tags | <p>Start here</p> | ||
[] <— cursor | dst | Start here | |
[] <— cursor now | |||
Delete surrounding parentheses in some code | (var1, var2) | ds( | var1, var2 |
Objective | Original text | Command | Edited text |
---|---|---|---|
Delete quotes surrounding a sentence | |||
Delete surrounding tags | |||
Delete surrounding parentheses in some code | var1, var2 |
The cursor can be anywhere within the surrounding text object we’re operating on, when the command is complete the cursor moves to the start of the object we operated on. Also, unlike other text objects there’s no i or a option for changing how it selects the area.
Change surrounding
To change a surrounding we use cs, this deletes the supplied text-object and replaces it with the second argument. When used in this way the cursor does not enter Insert mode at the end of the command. There are two ways to use it:
Change one surround to another: cs
| Objective | Original text | Command | Edited text | | ———————————————————– | —————————————————- | ——- | ————————————————– | | Change surrounding quotes from double to single quote marks | “My kingdom for a horse” [] <— cursor here | cs”’ | ‘My kingdom for a horse’ [] <— cursor here now | | Change to HTML paragraph with tags on separate lines | ‘Look, to the East’ | cS’<p> | <p> Look, to the East </p> |
Objective | Original text | Command | Edited text |
---|---|---|---|
Change surrounding quotes from double to single quote marks | |||
Change to HTML paragraph with tags on separate lines | <p> Look, to the East </p> |
Add surrounding
Often, rather than altering some existing mark-up or brackets, we want to add some additional surroundings. Add a surrounding uses ys, the following item is the additional mark-up, brackets or text that will placed either side. The ways it can be used are:
Wrap the vim motion or text object in the second argument: ys<motion|text-object>
| Objective | Original text | Command | Edited text | | ———————————————————————————————————————– | ————————————————- | ——- | —————————————————- | | Put some quotes around some text at the end of a line. | he said, Boo! scary huh [] <— cursor | ys$” | he said, “Boo! scary huh” | | Put some square brackets around some variables. Note use of repetition in the motion. | print var1, var2 [] <— cursor | ys3w) | print (var1, var2) [] <— cursor | | Put some squiggly brackets around some code. This acts on the whole line with the cursor anywhere on the line | 34, 21, 7 [] <– cursor | yssB | { 34, 21, 7 } [] <– cursor moves | | Convert some speech into a HTML blockquote. Uses Vims search motion and surrounds ability to then put tags around that. | Jack said, “Done it!” [] <— cursor | ySf”t | Jack said, <blockquote> “Done it!” </blockquote> | | Put some brackets around a procedure and indent the text | defn -proc1 [] <— cursor | ySSb | ( defn -proc1 ) |
Objective | Original text | Command | Edited text |
---|---|---|---|
Put some quotes around some text at the end of a line. | |||
Put some square brackets around some variables. Note use of repetition in the motion. | |||
Put some squiggly brackets around some code. This acts on the whole line with the cursor anywhere on the line | |||
Convert some speech into a HTML blockquote. Uses Vims search motion and surrounds ability to then put tags around that. | |||
Put some brackets around a procedure and indent the text | ( defn -proc1 ) |
Visual surround
In visual mode, the surround object is called with S, and then an argument that wraps the visual selection. The keyboard usage is something like this:
v # Enter visual mode
<visually select> # Use the keyboard to select the section of text
S # Press upper case S
" # Specify what you want to surround the visual selection with
In linewise visual mode the surrounding are placed on separate lines and indented: vS
Objective | Original text | Command | Edited text |
---|---|---|---|
Select a word and put rST italic marks around it | Add two eggs | ||
[] <— cursor | viwS* | Add *two* eggs | |
[] <— cursor now | |||
Put HTML paragraph around some lines. |
Uses linewise visual mode | Consider this, when we create an object we take more memory. | Shift-v,
|
Consider this, when we create an object we take more memory.
| | Put HTML list item on each line to create a list. Uses block wise visual mode | 6 eggs 4 apples 2 pints of milk | Ctrl-vObjective | Original text | Command | Edited text |
---|---|---|---|
Select a word and put rST italic marks around it | |||
Put HTML paragraph around some lines. Uses linewise visual mode | |||
Put HTML list item on each line to create a list. Uses block wise visual mode |
The following wiki, pages and posts are tagged with
Title | Type | Excerpt |
---|---|---|
using git with vim | post | shortcut keys and application |
2021-10-11-vim-ycm-python3.md | post | python2 좀 그만 쓰자 |
Vim-Category.md | post | 카테고리 문서 1단계 |
Vimrc-Category.md | post | 카테고리 2단계 (끝) |
Web-Category.md | post | 카테고리 2단계 (끝) |
Wiki-Setting-Category.md | post | 카테고리 1단계 (끝) |
Practical Vim | post | 손이 먼저 반응하는 |
vim howtos | page | vim fugitive emmets shortcut keys and howtos |
template.md | post | python2 좀 그만 쓰자 |
term-string-interpolation.md | post | 플릿 문자열, 백틱 문자열, f문자열 |
test.md | post | python2 좀 그만 쓰자 |
vim-basic.md | post | keep them by heart, fugitive |
vim-folding.md | post | vimrc가 점점 커진다면 폴딩을 적용해보자. |
vscode-configurations.md | post | vscode settings for theme and vim |
wiki-inWindows.md | post | on using Jekyll on windows, with ruby |
wiki-troubleshooting.md | post | 위키 운영하면서 생기는 문제 정리 |
Vim Ycm Python3 | post | python2 좀 그만 쓰자 |