Questions tagged [surround]

91 questions
117
votes
2 answers

Vim Surround inserts extra space around the word

When I select the word and use the surround plugin with S: foobar It becomes ( foobar ) How do I remove the extra spaces, so that it becomes (foobar) What should I place in my settings?
Kit
  • 30,365
  • 39
  • 105
  • 149
56
votes
5 answers

Change HTML tag in vim, but keeping the attributes (surround)

Let's say I have a tag (and cursor at *):

H*ello!

I want to change it to: *

Hello

i.e. Change the type of tag, but keep all the elements. Using surround.vim, I could do: cst

but…

cazgp
  • 1,538
  • 1
  • 12
  • 26
32
votes
9 answers

Replacing quote marks around strings in Vim?

I have something akin to and need to change the single quotation marks to double quotation marks. I tried :s/\'.*\'/\"\0\" but it ended up producing . Replacing the \0 with \1 only produced…
ravuya
  • 8,586
  • 4
  • 30
  • 33
28
votes
7 answers

Is there an extension or mode in Emacs similar to surround.vim?

Surround.vim is a nifty vim extension that allows you to surround blocks of text with , brackets, braces, and pretty much any arbitrary "surround" character. It supports paragraph and word surround, but I frequently use it in visual mode. I'm…
Chow
  • 465
  • 1
  • 5
  • 6
21
votes
5 answers

How do I match a pattern with optional surrounding quotes?

How would one write a regex that matches a pattern that can contain quotes, but if it does, must have matching quotes at the beginning and end? "?(pattern)"? Will not work because it will allow patterns that begin with a quote but don't end with…
Jake
  • 2,925
  • 5
  • 22
  • 21
20
votes
3 answers

Surround two words with quotes in Vim

I am working with vim-surround and the following text. (* is the place of the cursor) This is a lo*ng line and I want to highlight two words I want to surround both the words long and line within quotes, so that it becomes This is a "long line" and…
Sudar
  • 18,954
  • 30
  • 85
  • 131
17
votes
2 answers

Repeating surround with "." command in VIM

Did anybody get surround.vim to work with repeat.vim? This should enable you to repeat any command provided by the surround plugin with the "." command. I think surround.vim should already have builtin support for the repeat plugin, so it should…
frank
16
votes
2 answers

How to surround a line with parentheses in IntelliJ IdeaVim?

IntelliJ IdeaVim supports vim-surround features now. But how can I quickly surround a line with parentheses in IntelliJ using IdeaVim? I can do this using yss) or yssb in Vim using the surround plugin. Currently I have to use ^ to go the beginning…
Benjamin Du
  • 1,391
  • 1
  • 17
  • 25
15
votes
3 answers

vim - surround text with function call

I want to wrap some code : myObj.text; with a function call where the code is passed as an argument. console.log(myObj.text); I've thought about using surround.vim to do that but didn't manage to do it. Any idea if it's possible ? I
Florian F
  • 8,822
  • 4
  • 37
  • 50
14
votes
4 answers

MySQL select before after row

This is the example table: Column | 1st record | 2nd record | 3rd record | 4th record | etc
id (primary) | 1 | 5 | 8 | 12 | etc
name | name 1 | name 2 | name 3 …
bosniamaj
  • 838
  • 4
  • 10
  • 17
12
votes
2 answers

How to select a whole line for as a motion in Vim?

I recently started to use the "surround" plugin. I realized I don't know how to surround the current line. I mean, ysap

surrounds a paragraph and ysaw

surrounds a word. Apparently dw deletes a word and das deletes a sentence. dd deletes a…

huoenter
  • 512
  • 3
  • 16
10
votes
4 answers

How do I surround two words with tag in vim, such that I can repeat the operation with a dot operator?

I'm working with the vim-surround plugin and this HTML (where the * is my cursor):
  • *#005462
  • I'd like to surround the #005462 with so it looks like this, #005462. I can do…
    Mark B
    • 2,870
    • 3
    • 20
    • 18
    8
    votes
    4 answers

    How to surround multiple lines individually with surround.vim

    I have these three (or more) lines that I want to surround with li (or any other) tag : Bananas Citrus Orange I can do it this way: qaysstli>jq then 2@a. Is there a way to do this faster and without a macro ?
    woodspock
    • 93
    • 1
    • 5
    5
    votes
    2 answers

    Change enclosing quotes in Vim

    In Vim, it's a quick 3-character command to change what's inside the current quoted string (e.g., ci"), but is there a simple way to change what type of quotes are currently surrounding the cursor? Sometimes I need to go from "blah" to """blah"""…
    Mzzzzzz
    • 4,770
    • 7
    • 30
    • 47
    4
    votes
    6 answers

    Vim Surround: Create new tag but don't indent/new line

    I would like to mimic Textmates CTRL+ALT+w, which creates a new pair of opening and closing HTML tags on the same line. In VIM Surround I'm using CTRL+st in Edit mode for this, but it always indents and creates a new line after setting the tag, so…
    user627542
    1
    2 3 4 5 6 7