6 Commits

Author SHA1 Message Date
Tim Pope 3d188ed211 Call out opening bracket behavior in FAQ
Apparently mentioning in the both the README intro and the help file
isn't enough.  I give up.

Resolves: https://github.com/tpope/vim-surround/issues/366
Resolves: https://github.com/tpope/vim-surround/issues/363
Resolves: https://github.com/tpope/vim-surround/issues/314
Resolves: https://github.com/tpope/vim-surround/issues/303
Resolves: https://github.com/tpope/vim-surround/issues/240
Resolves: https://github.com/tpope/vim-surround/issues/205
Resolves: https://github.com/tpope/vim-surround/issues/108
Resolves: https://github.com/tpope/vim-surround/issues/27
2022-10-25 16:41:16 -04:00
Tim Pope bf3480dc9a Remove issues section from help file
I haven't even looked at this in over a decade.
2022-04-22 19:25:12 -04:00
Tim Pope 81fc0ec460 Fix insert mode maps after "\r" change
Resolves: https://github.com/tpope/vim-surround/issues/349
2022-04-09 22:21:13 -04:00
Tim Pope 427f80f254 Avoid "\r" as a cursor stand-in
This confuses Neovim's LSP.  I'd be surprised if there are LSPs it
*doesn't* confuse.

References: https://github.com/neovim/neovim/issues/15532
2022-04-09 16:04:28 -04:00
Enrico Maria De Angelis 9857a87463 Save, set, and restore startofline
Consider this code:
```javascript
_.map(
  (
    mapObjOnK
  )
);
```
If the cursor is on the 3rd line and you press <kbd>d</kbd><kbd>s</kbd><kbd>b</kbd>, the code will become
```javascript
_.map(
);
mapObjOnK
```

The problem occurs if `startofline` is off.

With this change, I set it before processing the the call to
`dosurround`, and then, after the call, I'm unsetting it if
it was unset.
2022-03-25 16:13:16 -04:00
Tim Pope baf89ad264 Only reindent when enabled by Vim option
References: https://github.com/tpope/vim-markdown/pull/187
2022-01-29 21:05:37 -05:00
3 changed files with 22 additions and 16 deletions
+7
View File
@@ -70,6 +70,13 @@ support:
git clone https://tpope.io/vim/surround.git
vim -u NONE -c "helptags surround/doc" -c q
## FAQ
> How do I surround without adding a space?
Only the opening brackets—`[`, `{`, and `(`—add a space. Use a closing
bracket, or the `b` (`(`) and `B` (`{`) aliases.
## Contributing
See the contribution guidelines for
-12
View File
@@ -202,16 +202,4 @@ that allow you to jump to such markings.
>
let g:surround_insert_tail = "<++>"
<
ISSUES *surround-issues*
Vim could potentially get confused when deleting/changing occurs at the very
end of the line. Please report any repeatable instances of this.
Do we need to use |inputsave()|/|inputrestore()| with the tag replacement?
Indenting is handled haphazardly. Need to decide the most appropriate
behavior and implement it. Right now one can do :let b:surround_indent = 1
(or the global equivalent) to enable automatic re-indenting by Vim via |=|;
should this be the default?
vim:tw=78:ts=8:ft=help:norl:
+15 -4
View File
@@ -323,7 +323,7 @@ function! s:insert(...) " {{{1
let cb_save = &clipboard
set clipboard-=unnamed clipboard-=unnamedplus
let reg_save = @@
call setreg('"',"\r",'v')
call setreg('"',"\032",'v')
call s:wrapreg('"',char,"",linemode)
" If line mode is used and the surrounding consists solely of a suffix,
" remove the initial newline. This fits a use case of mine but is a
@@ -354,19 +354,21 @@ function! s:insert(...) " {{{1
call s:reindent()
endif
norm! `]
call search('\r','bW')
call search("\032",'bW')
let @@ = reg_save
let &clipboard = cb_save
return "\<Del>"
endfunction " }}}1
function! s:reindent() " {{{1
if exists("b:surround_indent") ? b:surround_indent : (!exists("g:surround_indent") || g:surround_indent)
function! s:reindent() abort " {{{1
if get(b:, 'surround_indent', get(g:, 'surround_indent', 1)) && (!empty(&equalprg) || !empty(&indentexpr) || &cindent || &smartindent || &lisp)
silent norm! '[=']
endif
endfunction " }}}1
function! s:dosurround(...) " {{{1
let sol_save = &startofline
set startofline
let scount = v:count1
let char = (a:0 ? a:1 : s:inputtarget())
let spc = ""
@@ -388,6 +390,9 @@ function! s:dosurround(...) " {{{1
if a:0 > 1
let newchar = a:2
if newchar == "\<Esc>" || newchar == "\<C-C>" || newchar == ""
if !sol_save
set nostartofline
endif
return s:beep()
endif
endif
@@ -414,6 +419,9 @@ function! s:dosurround(...) " {{{1
if keeper == ""
call setreg('"',original,otype)
let &clipboard = cb_save
if !sol_save
set nostartofline
endif
return ""
endif
let oldline = getline('.')
@@ -478,6 +486,9 @@ function! s:dosurround(...) " {{{1
else
silent! call repeat#set("\<Plug>C".(a:0 > 2 && a:3 ? "S" : "s")."urround".char.newchar.s:input,scount)
endif
if !sol_save
set nostartofline
endif
endfunction " }}}1
function! s:changesurround(...) " {{{1