diff --git a/README.markdown b/README.markdown index fef61a8..9ea1f8a 100644 --- a/README.markdown +++ b/README.markdown @@ -1,48 +1,78 @@ 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 +Surround.vim may be easiest to explain by taking a look at a few examples. - 'Hello world!' +### Single character surroundings -Now press `cs'` to change it to - - Hello world! - -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", you surround it with brackets +by typing: `ysiw]`. (`iw` or "inner word" is one of Vim's +[text objects](http://vimdoc.sourceforge.net/htmldoc/motion.html#object-select), +you might think, "_you surround inner word_".) [Hello] world! + +This works with other text objects like sentences `is` and paragraphs `ip`. -Let's make that braces and add some space (use `}` instead of `{` for no -space): `cs]{` +#### Space or no space + +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"` + + "Hello world!" + +### Tag surroundings + +HTML and XML tag surroundings are triggered with the `<` character, after +which you can type the whole tag and attributes. + +Let's change the quotes to the html `` tag. Type `cs"`, and the +text instantly becomes: + + Hello world! + +When dealing with existing HTML or XML tags, you don't have to type +out the whole tag, just use `t` to refer to the immediately surrounding tag +pair. So, to _delete surrounding tags_ type: `dst` Hello world! -Emphasize hello: `ysiw` +_You surround_ an _inner word_ with the emphasis tag like this: `ysiw` Hello world! @@ -52,6 +82,9 @@ visual mode) followed by `S

`.

Hello world!

+ +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