Giter VIP home page Giter VIP logo

vim-surround's People

Contributors

adriaanzon avatar agguser avatar apcomplete avatar aster89 avatar catlee avatar chrisjohnsen avatar daniellesucher avatar hayatogh avatar itspriddle avatar jwhitley avatar pvdb avatar shanesmith avatar sunaku avatar tommcdo avatar toqoz avatar tpope avatar unclechu avatar yuex avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vim-surround's Issues

dsB command breaks line order

Suppose I have the following code (ft=c):

//calculate sum
for (size_t idx = 0; idx < size; ++idx)
{
   sum += array[idx];
}
//use sum for calculations
do_something(sum);

I want to remove the block braces, so I put the cursor inside them and say "dsB". This works fine for the braces, but incorrectly moves the comment up above the loop body, like this:

//calculate sum
for (size_t idx = 0; idx < size; ++idx)
//use sum for calculations
   sum += array[idx];
do_something(sum);

The same behavior occurs if the loop body spans multiple lines.

surround broke my macros

when i just recordet macros q0 some actions 'q'

then im trying to sorround some selected text wish 's

' and since my macro is broken.

how to solve ?

Can't surround with newlines

I want to get

<p>donkey</p>

to

<p>
donkey
</p>

by going to d, veS<enter>. The current result:

<p>^Mdonkey^M</p>

(perhaps I've got something badly confed.) Cheers

Delete surround tag with ERB injection

Try the following line in your erb file:

<a href="<%= profile_path %>"><%= current_user.name %></a>

Put cursor on current_user and press dst.
My result:

"><%= current_user.name %>

Expected result:

<%= current_user.name %>

Allow multiple characters surround

Hi,

I'd like to use your plugin for editing Trac wiki pages. In this language sections have more than one = level, for instance:

= Section1 =

== Section2 ==

=== Section3 ===

would it be possible to specify a number before the character to wrap? For instance if I want to convert a text into Section3 header it will be something like cs<text_selection>3=

Thank you

Doesn't seem to work with repeat.vim

I am getting started with surround.vim and I installed the corresponding repeat.vim, but when I do "." to invoke the repeat operation, it does not "repeat" the prior surround.vim operation. I am sure that I installed repeat.vim correctly. I notice that repeat.vim was last changed in 2008. Is there a newer version that I should be using?

I am using vim 7.2 on a Windows XP machine.

Thanks in advance

Repeat addition of surrounding braces

Not sure if this is a feature request or a bug, but it would be very nice to be able to repeat operations like:

viws)

I have the most up-to-date surround and repeat from git installed. Operations like:

cs)]

do repeat properly for me, so I believe I have installed the files correctly.

Thanks and I love your plugins!

[Feature]: Surround 'if' statement

An idea to have the 'sif' command that surrounds selected text with if conditional statement like

Ruby example.
Before:
article.publish!

After:
if
article.publish!
end

The problem is that it depends on the current buffer file type e.g. Ruby, ERB, JavaScrit etc.
Is that possible to implement with surround.vim?

Switch to get LaTeX command instead of environment functionality for \ similar to < for XML tag

If I need to put something into a LaTeX environment
it's usually a longer piece -- one or more paragraphs --,
and it's anyway most convenient to just open a line,
type in the \begin{} line, move down, open another
line and type in the \end{} line.

For me a far more common use case is that I'm marking
up an existing text and want to surround a smaller text
object -- a word/WORD/sentence -- with a command,
making the text object the argument of the command.
To handle the cases beyond the most common commands
I've put the following in my .vimrc:

autocmd FileType tex let b:surround_{char2nr("\\")} = "\\\1\\\1{\r}"

I would like to have a switch to change between the
environment and command argument behavior of the \
target and back. Even if that can't be I hope you put
the above customization as an example in the
documentation, since I believe very many who regularly
mark up text written by others for LaTeX would find it
very useful.

A cosmetic and hence not very important wish would be for the
prompt to appear just as \ similar to < with an XML tag.

Request: support exotic quotes «» ‹›

As of now, surrounding (by addition or change of surroundings) with «, », ‹ or › inserts the same character twice (resulting in things like «sometext«).

« and » are opening and closing double angle (AKA "French") quotation marks: https://en.wikipedia.org/wiki/%C2%AB
‹ and › are opening and closing simple angle quotation marks (same article)

[sorry, please ignore]

This was me being stupid; there doesn't seem to be a way for me to delete the issue entirely.

removing what its inside the surround...

maybe I missed it and I'm also a vim noob but is there a way to easily change whats inside of a surrounding tag? e.g. if I yank a string "hello" and want to change just hello with something else; is there a way for surround to figure out what surrounds the word and delete everything around it besides the "surrounding" tag,quote,whatever, so I can replace whats inside. Hope that makes sense. Love this plugin.

indentation-dependant multiple-line surround

Would it be possible to combine what VS does with indentation-recognition (as in http://www.ibm.com/developerworks/linux/library/l-vim-script-2/index.html#A%20function%20to%20help%20you%20code )?

As it is, VS has 1 line as its default scope. It would be nice if some command like ViS would take indentation into account.

<example1 />
<example2>
    <example3 />
    <example4 />
</example2>
<example5>
    <example6 />
</example5>

↓ with the cursor on <example3 /> or <example4 />: ↓

<example1 />
<example2>
    <surround>
        <example3 />
        <example4 />
    </surround>
</example2>
<example5>
    <example6 />
</example5>



Or even better would be to also encompass all further indentation:

<example1 />
<example2>
    <example3>
        <example4 />
    </example3>
</example2>
<example5>
    <example6 />
</example5>

↓ with cursor on <example 3> or </example3>: ↓

<example1 />
<example2>
    <surround>
        <example3>
            <example4 />
        </example3>
    </surround>
</example2>
<example5>
    <example6 />
</example5>

add #ifdef ... #endif support

It would be convenient for C and C++ programmers to have #ifdef VALUE\r...\r#endif preprocessor directive support. It is very commonly used for both commenting code #ifdef 0 and checking for platform features to make the code portable.

z for folding for any &ft

I try add this to my vimrc

    let g:commentChar = {
        \ 'vim': '"',
        \ 'c': '//',
        ...
        \ 'cpp': '//',                                                                                                                  
        \ 'sh': '#',
        \ 'python': '#'
        \}
    let comChar = g:commentChar[&ft]
    let g:surround_{char2nr('z')}=comChar."{{{ \r ".comChar."}}}"
    let g:surround_{char2nr('Z')}="\" \<++\> {{{ \r \"}}}"

but I get this error message

Error detected while processing ~/.vimrc:
line 290:
E713: Cannot use empty key for Dictionary
E15: Invalid expression: g:commentChar[&ft]
line 291:
E121: Undefined variable: comChar
E15: Invalid expression: comChar."{{{ \r ".comChar."}}}"

Can't delete/change semicolon

I just download this vim script and find it great!

But, while I can use 'ysiw;' to surround text with semicolon,
I can't use 'ds;' to delete it, and so does 'cs;'

Is that this script intentionally does this?

//sorry for my poor English

; is not recognised

If I enter

;Ti*le;

(star* being current cursor position) and then try to change via say typing

cs;'

nothing happens.

Deletion also does not work - typing

ds; 

does nothing.

Deletion also does not work for $ character:

when standing on

source $$VIM*RUNTIME$/vimrc_example.vim

and typing

ds$

Visual mode no longer works

Recently, whenever I select something and try to use surround in visual mode (either s" or gs"), the s key causes the selected text to be deleted. I am using the latest revision from the master branch (c912039) and have verified there is no conflict with vimrc or other plugins. The latest version from vim.org (1.90) works as expected.

yss(

Not sure about it

Have a line
"Exclaim"
Type
yss(
Result
( "Exclaim" )
Type
yss)
or
yssb
Result
("Exclaim")
From documentation
Eight punctuation marks, (, ), {, }, [, ], <, and >, represent themselves
and their counterparts. If the opening mark is used, contained whitespace is
also trimmed. The targets b, B, r, and a are aliases for ), }, ], and >
(the first two mirror Vim; the second two are completely arbitrary and
subject to change).

trimmed caused a question for me when i finally figured out how to add braces without extra space

These lines may refer to change and delete use cases and not adding surrounding, but not very clear.

Space change in multi-line surround change

Perhaps this is related to #19

cs{( on this text is off

{
  line 1
  line 2
}

becomes (line re-ordering happens, too, but I'm not showing it here #19)

(
line 1
  line 2
)

and another example

something {
  line 1
  line 2
}

becomes

something ( line 1
  line 2
 )

LaTeX $ surround

Hi,

it would be awesome if the $ sign (as used in LaTeX to show equations) could be a surrounding environment, like <>, (), etc.

Thanks for an awesome package.

Adding surrounding in visual mode

Here are 2 examples for somewhat strange behavior

First line is what we had before

Second - surrounding used

Third - result

The main issue is that ',' gets into surrounding, which isn't very obvious.

    IN VISUAL - selection is between | |
        reply to |"me"|, urgent
            S}
        reply to {"me",} urgent

        reply to |"me|", urgent
            S}
        reply to {"me|"}, urgent


Gitignore tags

Please add doc/tags to gitignore to enable this plugin to be used as a pathogen bundle through git submodules

line 561: xnoremap <silent> s :<C-U>echoerr 'surround.vim: Visual mode s has been removed in favor of S'<CR>

Hi,

I don't exactly understand what the above line does. It messes up my usual editing behaviour though. I usually visually select an element of text with 'v', then press 's' and type whatever I want the selected text to be replaced with. However, loading the vim-surround plugin results in the error message above.

I understand that I can simply do an 'unmap s' to restore the normal behaviour but I wonder why the remap is actually in place?

Thanks,

Jochen

Can't delete $,%,&,* etc. surrounds

It doesn't delete matching character surrounds. Works fine on () {} [] etc.

start with:

*f|oo*

where | is the cursor and type ds* it does nothing. I'm using win32 gvim.
I'm only saying this because I can insert *,&,%,etc. surrounds with the tool so I would expect it to be able to get rid of them as well.

Thanks for the awesome plugin!

2 space indentation

When I add a surrounding in visual mode the line is indented with a tab.

Is there a way to add a 2 space indentation instead?

don't add whitespace

i've just discovered vim-surround and this is a godsend for editing lisp code in vim.

however, i find that when adding parens the additional whitespace forces me to delete said space on the closing parens.

is there any way to change this? i am not so well learned in reading vim scripting code.

maybe a pointer in the docs on how to disable this manually would be just fine.

thank you for this very handy script.

`cs` and `ds`doesn't work with '#' character

It seems that cs and ds doesn't work inside a string like ## Configuration ##. Considering that cursor is on 'g' character, issuing cs#" or ds# has no effect, despite it does work if # is replaced by ' on the string and commands.

Thanks for sharing this awesome plugin!

request for new surround type: LaTeX command

There is already "ys..l" for surrounding something in a LaTeX environment, e.g. type (from normal mode)

ysiwl
center<CR>

for the effect

foobar -> \begin{center}foobar\end{center}

Similar to "l", I added to my local copy the letter "c" which wraps not in a LaTeX environment, but in a LaTeX command, e.g.

ysiwc
textbf<CR>

has the effect

foobar -> \textbf{foobar}

Here's what I added to s:wrap in my surround.vim, near the code that creates the environments. My code is based on the behavior of "f" as in "function".

  elseif newchar ==# 'c' || newchar ==# 'C'
    " LaTeX command
    let cmd = input('command: ')
    if cmd != ""
      let before = substitute(cmd,'{$','','').'{'
      let before = '\'.substitute(before,'^\','','')
      let after  = '}'
      if newchar ==# 'C'
        let before .= ' '
        let after = ' ' . after
      endif
    endif

repeat and yss

After reading the docs and closed issues here, I understand repeat.vim can't fully repeat yss, so I'm wondering: Is there another super fast way to build a list?

Let's say I have plain text:
Item one
Item two
Item three

I can navigate to Item one, hit yss<li> to surround it, but can't repeat it properly on the next 2 items.

I was trying to find a way to use cs instead since the docs say it can repeat, but how would you use cs to do what I'm trying with yss<li>? Perhaps there's a better way? Tried macros but couldn't get it to work right.

surround blocks s command in visual mode

Commit f6c9d3b prevents me from selecting text and using s to start replacing it. It displays an error.

Maybe something like this would be more appropriate:

xnoremap <silent> <Plug>Vsurround :<C-U>echoerr 'surround.vim: Visual mode s has been removed in favor of S'<CR>

Remove useless 'vs' error that mask normal Vim behaviour

The surround.vim plugin masks the 's' command in visual mode, replacing it not by an awesome feature (like many other key combos), but with a useless ;echoerr stating that I should use 'S' instead. I definitely did not want to press 'S' instead, since pressing 's' in visual mode is a standard Vim command (see ':help v_s'). I know it's the same as 'c' (see ':help v_c'), but it's hard to change many years of muscle memory training. :)

Anyway, I hope you agree masking normal Vim behaviour with just an error message (and not with added features) is not intended behaviour, so please remove the :echoerr. Thanks!

restore cursor position after surround-change operation

Hello,

I use the surround-change operation (not sure if that is the official name) to switch between single and double quotes for strings in my Ruby program.

While trying to make shortcuts for the aforementioned operation, I noticed that the cursor moves to the beginning of the operand text after the operation. I tried to solve this by restoring Vim's default "position before the latest jump" marker (see :help '') as suggested by a person named "elik" in the #vim IRC channel:

nmap <leader>' cs"' ``
nmap <leader>" cs'" ``

But this did not work. Instead, I had to use an explicit temporary (I hope) marker:

" switch between single and double quotes (surround plugin)
"
" NOTE: we explictly set a temporary marker (z) and restore it after
"       the surround operation because the surround plugin does not
"       restore the cursor position after the surround operation; it
"       leaves the cursor at the opening quote of the operand instead!
"
nmap <leader>' mz cs"' `z
nmap <leader>" mz cs'" `z

Perhaps surround.vim is interfering with this default Vim marker?

Thanks for your consideration.

Why isn't the whole command repeated?

This has been bothering me for ages, but maybe I'm just doing something wrong.

I have vim-repeat installed and it dutifully repeats commands, but it doesn't repeat the entire command. Say I do ysiw" to surround a single word with double quotes, and now I move the cursor to a different word and hit ., I would just expect that word to be surrounded with double quotes. Instead, I need to strike " again.

So usually this goes ysiw"j."j."j."j."j."j."j.", etc... It would be so much faster if I could just do ysiw"j.j.j.j.j.j.j.. And in my opinion that's more inline with how vim's other commands behave (e.g. ciw).

Am I doing something wrong, or is this intentional? If so, why?

delay on remapped cursor up

Using the latest vim-surround, installed via pathogen, I get a strange ~1second delay with my remapped cursor up key. Below is a pared-down version of my .vimrc, with my minimally useful set of remappings. During testing, the only thing in my .vim/bundle directory is vim-surround, cloned from this repo.

call pathogen#infect() 

" enter command-line window
noremap qs q:

" command-line history
cnoremap <C-p> <Up>
cnoremap <C-n> <Down>

" up-arrow
noremap c k
" down-arrow
noremap t j
" right-arrow
noremap n l

" find-prev
noremap C N
" find-next
noremap T n

" 'til
noremap l t
" back 'til
noremap L T

" help
noremap J K
" join-lines
noremap j J

" change-to-eol
noremap K C
" change
noremap k c

" subst-line
noremap : S
" subst
noremap ; s

" ex cmd line
noremap S ;
" repeat t/T/f/F
noremap s :

Strangely, my regular cursor keys work fine, no delay. And if I use the normal 'k' cursor-up key, it also works fine. It's only when I use my mapping of 'c' to 'k' that I experience the delay.

Removing vim-surround rectifies the problem.

Feature request: ability to paste a yanked surround

This seems so obvious that I apologize if it's been addressed elsewhere, but: it would be great, once I've deleted a complicated HTML tag surround using dst, to be able to then put it around some other text, with a command like perhaps yswp.

Is this way more difficult than I realize?

Feature Request: cS

It would be handy to have a cS command that acts like yS by putting the resulting text on its own line.

For example:

results = Entry.objects.filter(title='foo', author='bob').count()
                                  ^
                                  |
                                  Cursor

Press cSbb and get:

results = Entry.objects.filter(
    title='foo', author='bob'
).count()

`cs` doesn't work for quotes on foreign keyboards

some languages have many accented chars like áàãçéêíôöú so it requires 2 keystrokes to insert single and double quotes which breaks the cs'" and cs"' commands.

to test it just change your keyboard layout to U.S. International and try to insert a quote - the quote is only placed if the following char can't have an accent or if you press space.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.