gepoch / vim-surround Goto Github PK
View Code? Open in Web Editor NEWSurround for the Atom editor.
License: MIT License
Surround for the Atom editor.
License: MIT License
Surrounding selected text with S
key is useful feature of original surround.vim!
After executing a surround, the editor remains in visual mode.
Great little plugin! Works great with vim-mode
. But vim-mode-plus
does so many things better than vim-mode
, so I want to use it! But I can't because I'm so reliant on vim-surround
, and vim-surround
doesn't currently work with vim-mode-plus
.
Note: this issue is the root cause of #35, noted in this comment.
Thank you so much for this package!
When I do a surround action, it would be great to be able to repeat that command by hitting .
.
c s " '
(change double quotes to single quotes) and related commands are not implemented yet.
I am running into issues when running the cs
command when the delimiter pair does not have whitespace on the outside, like with a ruby method definition:
def some_method(parens_to_be_changed)
# some code
end
When running cs(
, so before I can type the character to replace the (
, it removes all text on that line before the cursor, so if the cursor was after the word parens
, the result would look like this (and it is put in insert mode):
_to_be_changed)
# some code
end
A similar thing happens with square brackets: array[0]
-> 0]
This doesn't seem to happen with ds
.
Additionally, after several unsuccessful attempts, when trying to cs
again Atom becomes unresponsive, even in a situation where it should work.
i'm guessing it has to do with the fact that on the german keyboard you have to use the following shortcuts to write brackets:
[ = alt + 5
] = alt + 6
| = alt + 7
{ = alt + 8
} = alt + 9
\ = alt + shift + 7
is the alt-key the problem?
you can probably test this by switching your keyboard layout to german via system preferences
Surround: Activate must be manually selected from the command pallet before use.
Hey everyone!
We have a lot of vim-mode-next plugins commenting on tickets lately. Currently, it's API is really close to vim-mode. There are no guarantees of this remaining the case, however.
Still, I would love to support it, as long it is within my means to do so! v0.8.0 takes a crack at it. Previously, you could only use vim-surround with vim-mode-next if you had vim-mode installed and disabled.
Now, you don't need the old vim-mode at all.
If the vim-mode-plus API should significantly diverge from vim-mode, and it becomes too much work to maintain API bindings to both, I'll be falling back to vim-mode.
Hopefully, that never happens :)
[Enter steps to reproduce below:]
Atom Version: 1.3.2
System: Unknown Windows Version
Thrown From: vim-surround package, v0.8.1
Failed to load the vim-surround package
At Cannot find module 'undefined/lib/text-objects'
Error: Cannot find module 'undefined/lib/text-objects'
at Module._resolveFilename (module.js:336:15)
at Function.Module._resolveFilename (C:\Users\Administrator\AppData\Local\atom\app-1.3.2\resources\app.asar\src\module-cache.js:383:52)
at Function.Module._load (module.js:286:25)
at Module.require (module.js:365:17)
at require (C:\Users\Administrator\AppData\Local\atom\app-1.3.2\resources\app.asar\src\native-compile-cache.js:50:27)
at Object.<anonymous> (file:///C:/Users/Administrator/.atom/packages/vim-surround/lib/command/selector.coffee:4:46)
at Object.<anonymous> (file:///C:/Users/Administrator/.atom/packages/vim-surround/lib/command/selector.coffee:1:1)
at Module._compile (C:\Users\Administrator\AppData\Local\atom\app-1.3.2\resources\app.asar\src\native-compile-cache.js:103:30)
at Object.defineProperty.value [as .coffee] (C:\Users\Administrator\AppData\Local\atom\app-1.3.2\resources\app.asar\src\compile-cache.js:208:21)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (C:\Users\Administrator\AppData\Local\atom\app-1.3.2\resources\app.asar\src\native-compile-cache.js:50:27)
at Object.<anonymous> (file:///C:/Users/Administrator/.atom/packages/vim-surround/lib/command/delete.coffee:4:12)
at Object.<anonymous> (file:///C:/Users/Administrator/.atom/packages/vim-surround/lib/command/delete.coffee:1:1)
at Module._compile (C:\Users\Administrator\AppData\Local\atom\app-1.3.2\resources\app.asar\src\native-compile-cache.js:103:30)
at Object.defineProperty.value [as .coffee] (C:\Users\Administrator\AppData\Local\atom\app-1.3.2\resources\app.asar\src\compile-cache.js:208:21)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (C:\Users\Administrator\AppData\Local\atom\app-1.3.2\resources\app.asar\src\native-compile-cache.js:50:27)
at Object.<anonymous> (file:///C:/Users/Administrator/.atom/packages/vim-surround/lib/vim-surround.coffee:4:10)
at Object.<anonymous> (file:///C:/Users/Administrator/.atom/packages/vim-surround/lib/vim-surround.coffee:1:1)
at Module._compile (C:\Users\Administrator\AppData\Local\atom\app-1.3.2\resources\app.asar\src\native-compile-cache.js:103:30)
at Object.defineProperty.value [as .coffee] (C:\Users\Administrator\AppData\Local\atom\app-1.3.2\resources\app.asar\src\compile-cache.js:208:21)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (C:\Users\Administrator\AppData\Local\atom\app-1.3.2\resources\app.asar\src\native-compile-cache.js:50:27)
at Package.module.exports.Package.requireMainModule (C:\Users\Administrator\AppData\Local\atom\app-1.3.2\resources\app.asar\src\package.js:663:34)
{
"core": {}
}
# User
javascript-snippets, v1.0.0
vim-surround, v0.8.1
# Dev
No dev packages
cs'"
It just copies the thing at the first cursor and puts it (along with the change) in the last cursor.
It must have broken since #8
atom.workspaceView is no longer available.
In most cases you will not need the view. See the Workspace docs for
alternatives: https://atom.io/docs/api/latest/Workspace.
If you do need the view, please use atom.views.getView(atom.workspace)
,
which returns an HTMLElement.
Atom.Object.defineProperty.get (/usr/local/share/atom/resources/app/src/atom.js:55:11)
Surround.activate (/home/gmarchin/.nomadconf/atom/packages/vim-surround/lib/surround.coffee:8:26)
For some reason when Vim mode is active, s deletes the first character before surround is invoked to surround the text object.
To allow multiple surrounding characters.
While your package is new you might want to change your package to vim-surround or vim-surround-brackets or something.
Why:
Currently the apm search has no ability to search package.json keywords, description, readme, etc.
It ONLY searches the title you can find this confirmed here:
https://discuss.atom.io/t/apm-search-results/11054
[Enter steps to reproduce below:]
Atom Version: 1.0.0
System: Ubuntu 14.04.2
Thrown From: vim-surround package, v0.7.2
Failed to load the vim-surround package
At Cannot find module 'undefined/lib/text-objects'
Error: Cannot find module 'undefined/lib/text-objects'
at Module._resolveFilename (module.js:328:15)
at Function.Module._resolveFilename (/usr/share/atom/resources/app.asar/src/module-cache.js:383:52)
at Function.Module._load (module.js:270:25)
at Module.require (module.js:357:17)
at require (module.js:376:17)
at Object.<anonymous> (/home/maverick/.dotfiles/atom.symlink/packages/vim-surround/lib/command/selector.coffee:2:46)
at Object.<anonymous> (/home/maverick/.dotfiles/atom.symlink/packages/vim-surround/lib/command/selector.coffee:1:1)
at Module._compile (module.js:452:26)
at Object.requireCoffeeScript (/usr/share/atom/resources/app.asar/node_modules/coffee-cash/lib/coffee-cash.js:85:19)
at Module.load (module.js:347:32)
at Function.Module._load (module.js:302:12)
at Module.require (module.js:357:17)
at require (module.js:376:17)
at Object.<anonymous> (/home/maverick/.dotfiles/atom.symlink/packages/vim-surround/lib/command/delete.coffee:4:12)
at Object.<anonymous> (/home/maverick/.dotfiles/atom.symlink/packages/vim-surround/lib/command/delete.coffee:1:1)
at Module._compile (module.js:452:26)
at Object.requireCoffeeScript (/usr/share/atom/resources/app.asar/node_modules/coffee-cash/lib/coffee-cash.js:85:19)
at Module.load (module.js:347:32)
at Function.Module._load (module.js:302:12)
at Module.require (module.js:357:17)
at require (module.js:376:17)
at Object.<anonymous> (/home/maverick/.dotfiles/atom.symlink/packages/vim-surround/lib/vim-surround.coffee:4:10)
at Object.<anonymous> (/home/maverick/.dotfiles/atom.symlink/packages/vim-surround/lib/vim-surround.coffee:1:1)
at Module._compile (module.js:452:26)
at Object.requireCoffeeScript (/usr/share/atom/resources/app.asar/node_modules/coffee-cash/lib/coffee-cash.js:85:19)
at Module.load (module.js:347:32)
at Function.Module._load (module.js:302:12)
at Module.require (module.js:357:17)
at require (module.js:376:17)
at Package.module.exports.Package.requireMainModule (/usr/share/atom/resources/app.asar/src/package.js:709:34)
at /usr/share/atom/resources/app.asar/src/package.js:188:28
at Package.module.exports.Package.measure (/usr/share/atom/resources/app.asar/src/package.js:165:15)
at Package.module.exports.Package.load (/usr/share/atom/resources/app.asar/src/package.js:179:12)
at PackageManager.module.exports.PackageManager.loadPackage (/usr/share/atom/resources/app.asar/src/package-manager.js:372:14)
at PackageManager.module.exports.PackageManager.activatePackage (/usr/share/atom/resources/app.asar/src/package-manager.js:451:30)
at /usr/share/atom/resources/app.asar/node_modules/settings-view/lib/package-manager.js:362:29
at exit (/usr/share/atom/resources/app.asar/node_modules/settings-view/lib/package-manager.js:53:16)
at triggerExitCallback (/usr/share/atom/resources/app.asar/src/buffered-process.js:213:47)
at /usr/share/atom/resources/app.asar/src/buffered-process.js:220:18
at Socket.<anonymous> (/usr/share/atom/resources/app.asar/src/buffered-process.js:98:18)
at emitOne (events.js:82:20)
at Socket.emit (events.js:166:7)
at Pipe.close (net.js:464:12)
11x -2:05.4.0 core:backspace (atom-text-editor.editor.mini.is-focused)
-2:00.8.0 editor:consolidate-selections (atom-text-editor.editor.mini.is-focused)
-2:00.8.0 core:cancel (atom-text-editor.editor.mini.is-focused)
-1:40.1.0 command-palette:toggle (atom-text-editor.editor.is-focused)
2x -1:35.3.0 core:move-down (atom-text-editor.editor.mini.is-focused)
-1:33.8.0 core:confirm (atom-text-editor.editor.mini.is-focused)
-1:33.8.0 settings-view:install-packages-and-themes (atom-text-editor.editor)
3x -1:24 core:backspace (atom-text-editor.editor.mini.is-focused)
-1:23.3.0 editor:consolidate-selections (atom-text-editor.editor.mini.is-focused)
-1:23.3.0 core:cancel (atom-text-editor.editor.mini.is-focused)
-1:18.4.0 command-palette:toggle (atom-text-editor.editor.is-focused)
-1:14.1.0 core:confirm (atom-text-editor.editor.mini.is-focused)
-1:14.1.0 open-on-github:file (atom-text-editor.editor)
-1:04.6.0 command-palette:toggle (atom-text-editor.editor.is-focused)
-0:42.5.0 core:backspace (atom-text-editor.editor.mini.is-focused)
-0:42.1.0 core:confirm (atom-text-editor.editor.mini.is-focused)
{
"core": {
"ignoredNames": [
".bundle",
".git",
"log",
"repositories",
"tmp",
"vendor"
],
"themes": [
"atom-dark-ui",
"atom-dark-syntax"
],
"hideGitIgnoredFiles": true,
"disabledPackages": [
"background-tips",
"exception-reporting",
"metrics"
]
}
}
# User
pigments, v0.8.0
vim-surround, v0.7.2
# Dev
No dev packages
Test
I can add {{}}
to the vim-surround config to enable double character surrounding, but it's not working correctly!
The system is creating a mapping for s }}
which is useless. It needs to be s } }
in order for vim-mode to interpret my keypresses correctly.
Use a config schema instead. See the configuration section
of https://atom.io/docs/latest/hacking-atom-package-word-count and
https://atom.io/docs/api/latest/Config for more details
Package.activateConfig (/Applications/Atom.app/Contents/Resources/app.asar/src/package.js:247:11)
Package.activateNow (/Applications/Atom.app/Contents/Resources/app.asar/src/package.js:218:14)
<unknown> (/Applications/Atom.app/Contents/Resources/app.asar/src/package.js:203:30)
Package.measure (/Applications/Atom.app/Contents/Resources/app.asar/src/package.js:147:15)
I can't get "", (), or {} to work anymore.
It seems that vim-mode isn't parsing these keystrokes correctly.
I believe this is related to vim-mode #389 which has been fixed in the gg case, but not for shifted characters.
I often want to change $(this)
to $( this )
, but running cs)(
does not add the spaces around the word. Would it be possible to add this feature?
Cheers and thanks for the great package!
vim-mode
now publishes its editor state via a service. It may be fruitful to create an object representing the command and interact in a composable way with pushOperations
. This will help make the surround
adjective composable with many verbs and objects as well as be repeatable with .
, recordable in macros...
Thanks for bringing the incredible vim-surround to Atom!
The original supports surrounding a text object with the normal-mode command ys
. From the README:
Now with the cursor on "Hello", press ysiw] (iw is a text object).
[Hello] world!
This is how I usually use the plugin in Vim, rather than selecting with visual mode and then surrounding.
It would be awesome to be able to use it that way in Atom too. Of course, that would mean interacting with vim-mode's API to get a handle on an arbitrary text object; I don't know how easy that is given how it's currently implemented and how their API works.
[Enter steps to reproduce below:]
Atom Version: 0.210.0
System: Mac OS X 10.10.3
Thrown From: vim-surround package, v0.7.2
Failed to load the vim-surround package
At Cannot find module 'undefined/lib/text-objects'
Error: Cannot find module 'undefined/lib/text-objects'
at Module._resolveFilename (module.js:328:15)
at Function.Module._resolveFilename (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/src/module-cache.js:383:52)
at Function.Module._load (module.js:270:25)
at Module.require (module.js:357:17)
at require (module.js:376:17)
at Object.<anonymous> (/Users/daryl/.atom/packages/vim-surround/lib/command/selector.coffee:2:46)
at Object.<anonymous> (/Users/daryl/.atom/packages/vim-surround/lib/command/selector.coffee:1:1)
at Module._compile (module.js:452:26)
at Object.requireCoffeeScript (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/node_modules/coffee-cash/lib/coffee-cash.js:85:19)
at Module.load (module.js:347:32)
at Function.Module._load (module.js:302:12)
at Module.require (module.js:357:17)
at require (module.js:376:17)
at Object.<anonymous> (/Users/daryl/.atom/packages/vim-surround/lib/command/delete.coffee:4:12)
at Object.<anonymous> (/Users/daryl/.atom/packages/vim-surround/lib/command/delete.coffee:1:1)
at Module._compile (module.js:452:26)
at Object.requireCoffeeScript (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/node_modules/coffee-cash/lib/coffee-cash.js:85:19)
at Module.load (module.js:347:32)
at Function.Module._load (module.js:302:12)
at Module.require (module.js:357:17)
at require (module.js:376:17)
at Object.<anonymous> (/Users/daryl/.atom/packages/vim-surround/lib/vim-surround.coffee:4:10)
at Object.<anonymous> (/Users/daryl/.atom/packages/vim-surround/lib/vim-surround.coffee:1:1)
at Module._compile (module.js:452:26)
at Object.requireCoffeeScript (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/node_modules/coffee-cash/lib/coffee-cash.js:85:19)
at Module.load (module.js:347:32)
at Function.Module._load (module.js:302:12)
at Module.require (module.js:357:17)
at require (module.js:376:17)
at Package.module.exports.Package.requireMainModule (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/src/package.js:709:34)
at /opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/src/package.js:188:28
at Package.module.exports.Package.measure (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/src/package.js:165:15)
at Package.module.exports.Package.load (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/src/package.js:179:12)
at PackageManager.module.exports.PackageManager.loadPackage (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/src/package-manager.js:372:14)
at PackageManager.module.exports.PackageManager.activatePackage (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/src/package-manager.js:451:30)
at /opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/node_modules/settings-view/lib/package-manager.js:362:29
at exit (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/node_modules/settings-view/lib/package-manager.js:53:16)
at triggerExitCallback (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/src/buffered-process.js:213:47)
at /opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/src/buffered-process.js:220:18
at Socket.<anonymous> (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/src/buffered-process.js:98:18)
at emitOne (events.js:82:20)
at Socket.emit (events.js:166:7)
at Pipe.close (net.js:464:12)
-0:25.9.0 settings-view:open (atom-text-editor.editor.is-focused)
-0:19.5.0 core:confirm (atom-text-editor.editor.mini.is-focused)
{
"core": {
"themes": [
"one-light-ui",
"github-2014"
]
}
}
# User
file-icons, v1.5.7
github-2014, v3.6.0
language-docker, v1.1.3
language-haml, v0.21.0
vim-surround, v0.7.2
# Dev
No dev packages
Whenever a surround is made, this error is raised.
This is due to vim-mode's API having changed. This needs to be corrected.
vim-surround/lib/surround.coffee:59
Since updating to vim-mode
0.57.0 surround no longer seems to be working.
My Surround Key setting (capital S) doesn't seem to be respected any more. It was working pre-0.6.0 release. Using the default key (lowercase s) binding does work.
[Enter steps to reproduce below:]
Atom Version: 0.190.0
System: Mac OS X 10.10.3
Thrown From: vim-surround package, v0.5.0
Failed to activate the vim-surround package
At Cannot read property 'length' of undefined
TypeError: Cannot read property 'length' of undefined
at /Users/suresh.iyer/.atom/packages/vim-surround/lib/surround.coffee:27:14
at Surround.registerPairs (/Users/suresh.iyer/.atom/packages/vim-surround/lib/surround.coffee:52:9)
at /Users/suresh.iyer/.atom/packages/vim-surround/lib/surround.coffee:1:1
at Config.module.exports.Config.observeKeyPath (/Applications/Atom.app/Contents/Resources/app/src/config.js:544:7)
at Config.module.exports.Config.observe (/Applications/Atom.app/Contents/Resources/app/src/config.js:126:21)
at Surround.activate (/Users/suresh.iyer/.atom/packages/vim-surround/lib/surround.coffee:16:17)
at Package.module.exports.Package.activateNow (/Applications/Atom.app/Contents/Resources/app/src/package.js:225:19)
at /Applications/Atom.app/Contents/Resources/app/src/package.js:206:30
at Package.module.exports.Package.measure (/Applications/Atom.app/Contents/Resources/app/src/package.js:152:15)
at Package.module.exports.Package.activate (/Applications/Atom.app/Contents/Resources/app/src/package.js:199:14)
at PackageManager.module.exports.PackageManager.activatePackage (/Applications/Atom.app/Contents/Resources/app/src/package-manager.js:435:21)
at /Applications/Atom.app/Contents/Resources/app/node_modules/settings-view/lib/package-manager.js:268:29
at exit (/Applications/Atom.app/Contents/Resources/app/node_modules/settings-view/lib/package-manager.js:43:16)
at BufferedProcess.triggerExitCallback (/Applications/Atom.app/Contents/Resources/app/src/buffered-process.js:63:47)
at /Applications/Atom.app/Contents/Resources/app/src/buffered-process.js:70:18
at Socket.<anonymous> (/Applications/Atom.app/Contents/Resources/app/src/buffered-process.js:150:18)
at emitOne (events.js:82:20)
at Socket.emit (events.js:166:7)
at Pipe.close (net.js:464:12)
-30:48.7 settings-view:open (atom-text-editor.editor)
{
"core": {
"themes": [
"atom-dark-ui",
"atom-dark-syntax"
]
}
}
# User
vim-surround, v0.5.0
# Dev
No dev packages
Hi there! Thanks for making this package!
When I add custom characters to the plugin settings, and then try to use the plugin, I get a bunch of extra wrappings inserted into my editor. After refreshing the editor, the extra wrappings go away.
I'm guessing that probably the keybinding to trigger a wrapping is getting re-bound every time that settings box is edited, instead of the binding getting replaced.
That's all!
Atom 1.10.0
vim-mode-plus 0.56.0
Does not working at all =(
Here I am putting my cursor inside the string s = "hello"
and pressing c s " '
.
I can't track this down to a package or anything in particular, though I assume it's related to the way atom will give you matching character pairs by default as you type (apparently regardless of language/grammar.)
Note that this behaviour is the same for quotes and brackets etc.
Sorry if I'm missing something obvious, that seems like a distinct possibility given noone else seems to have reported it yet.
Vim mode now supports multiple cursors! Surround should too!
Hi, I'm really new to vim and atom in general so excuse my lack of knowledge. I added the following custom surrounds:
<xmp>,
</xmp>And now when I press 's' after selecting some text in visual mode, the text is simply deleted. No html tags are added. And other surrounds don't work anymore (quotes, brackets, etc). When I remove these custom html tags, everything works again.
Is it not possible to have these html tags in surround? Or am I just doing it wrong?
Thanks for the great package!
We need to be able to delete surrounding pairs with d s "
etc!
d s
doesn't work for me as immediately upon pressing d
it just deletes the text selected. I've tried pressing them as fast as possible, there's just no way that I'm Doing It Wrong™.
I've tried setting it to Z s
and doing Z s (
just does the surround mapping. I've tried just doing Z
and thus Z (
and that does nothing.
I should add that I was making these changes via the provided settings not via a keymapping
What are the differences between these two settings? Actually why are there two settings? The default is the same (d s
) command.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.