-
-
Notifications
You must be signed in to change notification settings - Fork 448
Update README to clarify some points for Vim beginners. #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,57 +1,91 @@ | ||
| surround.vim | ||
| ============ | ||
|
|
||
| Surround.vim is all about "surroundings": parentheses, brackets, quotes, | ||
| XML tags, and more. The plugin provides mappings to easily delete, | ||
| change and add such surroundings in pairs. | ||
| Surround.vim is a Vim plugin that is all about "surroundings": parentheses, | ||
| brackets, quotes, XML tags, and more. The plugin provides mappings to easily | ||
| delete, change and add such surroundings in pairs. | ||
|
|
||
| It's easiest to explain with examples. Press `cs"'` inside | ||
| How to Use | ||
| ---------- | ||
|
|
||
| "Hello world!" | ||
|
|
||
| to change it to | ||
|
|
||
| 'Hello world!' | ||
|
|
||
| Now press `cs'<q>` to change it to | ||
| Surround.vim may be easiest to explain by taking a look at a few examples. | ||
|
|
||
| <q>Hello world!</q> | ||
| ### Single character surroundings | ||
|
|
||
| To go full circle, press `cst"` to get | ||
| Lets change a set of double quotes to single quotes. Surround.vim makes this | ||
| simple with four key strokes. Start with this bit of text: | ||
|
|
||
| "Hello world!" | ||
|
|
||
| To remove the delimiters entirely, press `ds"`. | ||
| Move your cursor so that it is within the double quotes. Now type the letter | ||
| `c` (change), the letter `s` (surround), the double quote `"`, and then the | ||
| single qoute `'`. The double quotes instantly become single quotes. | ||
|
|
||
| 'Hello world!' | ||
|
|
||
| To remove the delimiters entirely, type `d` (delete), `s` (surround), and the | ||
| single quote `'`, all together like this: `ds'`. | ||
|
|
||
| Hello world! | ||
|
|
||
| Now with the cursor on "Hello", press `ysiw]` (`iw` is a text object). | ||
| #### Surround a text object | ||
|
|
||
| Now with the cursor on the word "Hello", select the word and surround | ||
| it brackets by typing: `ysiw]`. (`iw` or "inner word" is one of Vim's | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this needs a “with” between “it” and “brackets” so that it reads
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right you are, sir. :-) |
||
| [text objects](http://vimdoc.sourceforge.net/htmldoc/motion.html#object-select), | ||
| `y` is copy or "yank", but in this case is being used to select the text object | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The documentation suggests “you surround” as a mnemonic for
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see. Yes, actually that one second timeout was tripping me up for a while before I figured out what was happening. Thanks for the clarification here. I also changed the wording in a few places to read more like that mnemonic. |
||
| without changing it.) | ||
|
|
||
| [Hello] world! | ||
|
|
||
| This works with other text objects like sentences `is` and paragraphs `ip`. | ||
|
|
||
| #### Space or no space | ||
|
|
||
| Let's make that braces and add some space (use `}` instead of `{` for no | ||
| space): `cs]{` | ||
| For pairs of surrounds, use the beginning character `[` to surround | ||
| with some space. Use the ending `]` to surround tightly without space. | ||
|
|
||
| Let's change the brackets to braces and add some space. Type: `cs]{`. | ||
|
|
||
| { Hello } world! | ||
|
|
||
| Now wrap the entire line in parentheses with `yssb` or `yss)`. | ||
| Now wrap the entire line in parentheses without space. Type: `yss)`. | ||
|
|
||
| ({ Hello } world!) | ||
|
|
||
| Revert to the original text: `ds{ds)` | ||
| Revert to the original text with quotes: `ds{ds)yss"` | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You may want to use Or, advise the user to first move the cursor back onto (or inside) the curly braces before doing the sequence starting with
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, it makes sense to do the brackets before the parentheses. I also separated the three commands so it looks less like gibberish to a beginner. |
||
|
|
||
| Hello world! | ||
| "Hello world!" | ||
|
|
||
| ### Tag surroundings | ||
|
|
||
| HTML and XML tag surroundings are triggered with the `<` character, after | ||
| which you can type the whole tag and attributes. | ||
|
|
||
| Lets change the quotes to the html `<q>` tag. Type `cs'<q`, hit enter, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. “Lets” should have an apostrophe.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. Also, I just realized I had |
||
| and the text instantly becomes: | ||
|
|
||
| <q>Hello world!</q> | ||
|
|
||
| When dealing with existing HTML or XML tags, we don't have to type | ||
| out the whole tag, just use the `t` (till). So, to go full circle, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Maybe something like this:
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see, yes, that is better. Updated. |
||
| press `cst"` to change the `<q>` tags to quotation marks `"`: | ||
|
|
||
| "Hello world!" | ||
|
|
||
| Emphasize hello: `ysiw<em>` | ||
| Emphasize hello: `ysiw<em` | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After the previous Also, the double quotes have disappeared in the following examples. Did you intend to keep them in there, or do you want to add a
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right. I fixed this by changing the |
||
|
|
||
| <em>Hello</em> world! | ||
|
|
||
| Finally, let's try out visual mode. Press a capital V (for linewise | ||
| visual mode) followed by `S<p class="important">`. | ||
| visual mode) followed by `S<p class="important"`. | ||
|
|
||
| <p class="important"> | ||
| <em>Hello</em> world! | ||
| </p> | ||
|
|
||
| Notes | ||
| ----- | ||
|
|
||
| This plugin is very powerful for HTML and XML editing, a niche which | ||
| currently seems underfilled in Vim land. (As opposed to HTML/XML | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may be better to avoid saying “select” here since that might make the user think of Vim’s visual or select modes.
Maybe just delete the phrase “select the word and”.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed.