Add ex commands, including save #50

Open
rgbkrk opened this Issue Feb 27, 2014 · 48 comments

Projects

None yet
@rgbkrk
rgbkrk commented Feb 27, 2014

Many of the ex commands are critical to true vi heritage, including :w. From wikipedia's article on ex:

ex was eventually given a screen oriented visual interface (adding to its command line oriented operation), thereby becoming the vi text editor.

We've got a lot of our movement commands, but it would be great to have our :w, :%s, :g.

Most of the movement commands are there, so I'm generally having a good time. Thanks for this package!

@aseba
aseba commented Feb 27, 2014

👍 ! I was thinking that quickfix to this is mapping : to cmd+shift+p and w work as save

@rgbkrk
rgbkrk commented Feb 27, 2014

Oh that's a decent idea @aseba.

@mcolyer
Contributor
mcolyer commented Feb 28, 2014

I'm hesitant to add this as I think we want to carefully craft the mix of atomisms (cmd+shift+p and find-and-replace) and vimisms (:). I think there's a lot of great stuff in atom and we should try to leverage that as much as possible.

@zenhob
Contributor
zenhob commented Feb 28, 2014

@mcolyer I agree that vim-mode should attempt to be as light a layer over Atom as practical, but I assume that respecting existing muscle memory is a log-term goal of vim-mode, correct? I can't tell if you're hesitant about the workaround, or the idea of completely supporting traditional ex commands along with the command palette.

Personally I'd prefer the keep the workarounds out of master (although I will probably be using some locally) and also support ex commands with : in the long term.

@mcolyer
Contributor
mcolyer commented Feb 28, 2014

@zenhob both to some degree 😬. I definitely want to ease the transition to Atom but not at the cost of possible long term wins. It's a fine line and something that's going to evolve over time.

For me the power of vim is the ability to quickly move around files and replace things in a succinct way and I definitely want to keep that part (so all of the awesome commands people have been asking for in command mode). However I'm not sure that I want to perpetuate :w over cmd-s. Instead I think a better approach would be for people to add : to cmd+shift+p and w to their local configuration and then peel that back (or not) as they become more comfortable with Atom.

I've been thinking about @rogeriopvl's #89 as a possible middle road, the muscle memory being : but the Atomism being the command palette rather than ex. What do you think about that?

@mcolyer mcolyer added the question label Feb 28, 2014
@zenhob
Contributor
zenhob commented Feb 28, 2014

I think the rest of Atom itself already covers the "Atom features" side of things pretty well, while vim-mode is supposed to act like Vim. I do have to disagree that the only relevant Vim features worth porting are movement and editing commands. ex commands are an incredibly powerful Vim feature with a lot of collective memory behind them. It's not just so we can :w. Frankly I already use cmd-s because I've been on macvim for years, but I'm not the only user here.

vim-mode is by far the single most popular plugin for Atom so far. There are clearly a large number of potential users, probably very few of whom use the same subset of Vim commands. In the README this is acknowledged, with the hope that enough users can fill in their preferred Vim functionality as needed. However, just 2 days after release, the tune appears to be shifting to allowing users to add their preferred Vim functionality as long as it isn't something Atom already does? I am impressed by Atom's functionality, but that seems like an unnecessarily narrow interpretation.

Vim has a vast command set, and it's discouraging to see push back on implementing a core part of it just 2 days after the announcement.

@ciarand
Contributor
ciarand commented Feb 28, 2014

While some commands (esp. plugin commands like :Test, :Gstatus, etc.) can be mapped to cmd+shift+p, there are others that aren't as easily mapped. Substitutions are the first that come to mind, but there are others.

Could a set of ex commands that populate the command palette be available prefixed with :? Then : could open the command palette prefilled with :. :w could be alias'd to save, and that gives us a framework to make the other commands work as well.

What do you think?

@bhuga
Contributor
bhuga commented Feb 28, 2014

What about a second plugin, ex? It would be easy to make entering it be as simple as : in command mode. That could be as full-featured as one likes while letting vim-mode remain pretty simple; vim mode wouldn't even be required.

@ciarand
Contributor
ciarand commented Feb 28, 2014

That actually sounds like a nicer split. How do registers and other shared code get handled if the two are separate?

@bhuga
Contributor
bhuga commented Feb 28, 2014

I think I'm going to take a stab at some shared state between editors here soon. It would be referenceable from other plugins. Javascript!

@ciarand
Contributor
ciarand commented Feb 28, 2014

You're my hero

@mcolyer
Contributor
mcolyer commented Feb 28, 2014

I'm 👍 on splitting ex related goodies into a separate package. I think we can find clever ways to integrate without requiring one or the other.

@zenhob
Contributor
zenhob commented Feb 28, 2014

I love the idea of an ex plugin, great thinking.

On Feb 28, 2014, at 13:36, Ben Lavender notifications@github.com wrote:

What about a second plugin, ex? It would be easy to make entering it be as simple as : in command mode. That could be as full-featured as one likes while letting vim-mode remain pretty simple; vim mode wouldn't even be required.


Reply to this email directly or view it on GitHub.

@rgbkrk
rgbkrk commented Feb 28, 2014

👍 on having an ex package. I'll change this issue to be about ex.

@blinks
blinks commented Mar 7, 2014

Does that ex package exist somewhere yet? Even in a small form? (Also, it seems like some of this discussion led to agreement that : would open the command-palette in prep for such a package; where did that end up?)

@dougblack
Contributor

@blinks I believe the plan is that : will open up a vim-style command window at the bottom. I don't know if the package exists yet.

@mcolyer
Contributor
mcolyer commented Mar 7, 2014

@blinks it doesn't exist yet, would you be interested in getting it started? I know @zenhob was pretty interested in it.

@bhuga
Contributor
bhuga commented Mar 7, 2014

I've got an idea of how to start this: probably just something that talks correctly to vim mode and implements w. I'm hoping to have an embryonic ex package 🔜.

@blinks
blinks commented Mar 7, 2014

Ah, not planning on piggy-backing on top of the command panel? That's what I gleaned from ciarand's comment (a package that added a bunch of ex commands that could be run from cmd-shift-p).

@ciarand
Contributor
ciarand commented Mar 7, 2014

Afaik the decision was made to create an ex package instead. That reduces the complexity of this package and allows people to make the decision regarding whether they'd like to use the command palette or the more traditionally vim-esque ex palette.

@lloeki
Contributor
lloeki commented Apr 1, 2014

I made a few suggestions regarding ex-mode in #185 that seem to trigger enjoyment.

@lloeki
Contributor
lloeki commented Apr 1, 2014

To sum it up:

don't open the command palette at all and instead open a vim-only command palette, giving access to "ex mode" CoffeeScript (thus extendable) functions and get the best of vim and atom.

@thousand
thousand commented Sep 2, 2014

Has there been any motion on this? I'd be more than happy to test or contribute if there's a need.

@ffiw
ffiw commented Sep 15, 2014

Wow, this is the only issue that's preventing me from using atom. I have no idea how to add the ex-command support otherwise I would have added it myself. Without implementing ex-command at least save it's hard to use atom as it breaks the flow.

@bibodha
bibodha commented Sep 18, 2014

I would also love to have this feature. I'm a pure vim user and am giving atom a shot. This is literally the only thing keeping me from using atom full time. I'd rather user Sublime because it has some support for ex commands. There are few weirdness that I don't like about vim in ST3 and vim for Atom is very incomplete for me. Reason I use vim is because I don't want to do ctrl (cmd) - S. It breaks the work flow completely. Please consider making this part of Vim Mode.

@veturi
veturi commented Nov 9, 2014

I'll bump this feature request, too. As bibodha said those missing ex commands are the one and only missing feature that prevents me from going Atom full time.

@verdywid
verdywid commented Dec 4, 2014

I would definitely change from sublime to atom if it supports this essential feature

@fentas
fentas commented Jan 22, 2015

I would like to see this enhancement realized in some way. Seperate package would work for me also.
+1

@kristoiv
kristoiv commented Feb 4, 2015

+1 I def. want this! I keep hitting :w, and was sad not to be able to goto line using :.

@ffiw
ffiw commented Feb 4, 2015

You guys are trying to reinvent how vim emulation should work ?. The whole point of vim emulation is to make it easy for vim users to work on atom. If there is no way to save a file using :w then it's not vim emulation. Why not just go ahead invent a novel alternative to pressing Escape ?.

Mean while I was waiting on this issue I went back to vim and have been playing around with spacemacs and tried other editors that have basic vim keybindings. Unsubscribing from this issue, I no longer want to get these +1 mails.

@nnjpp
nnjpp commented Feb 4, 2015

If it's in a different package, fine, but +1 on this being essential. This is muscle memory, and it's a misconception to think that many long-term vim users are interested in 'transitioning' their muscle memory to the atom way.

@joelmo
joelmo commented Feb 4, 2015

Maybe the easiest would be to use the vim binary for this feature, just
send the command to it, let it execute and save. That way people can use
custom commands and use vimscripts.

On Wed, Feb 4, 2015 at 5:09 PM, Nick Perez notifications@github.com wrote:

If it's in a different package, fine, but +1 on this being essential. This
is muscle memory, and it's a misconception to think that many long-term vim
users are interested in 'transitioning' their muscle memory to the atom
way.


Reply to this email directly or view it on GitHub
#50 (comment).

@jeffschwartz

@joelmo the problem seems to be that the vim module currently doesn't support external commands (someone please correct me if I am mistaken about this). So acting as a delegate and calling into the vim module won't work.

@joelmo
joelmo commented Feb 4, 2015

On Wed, Feb 4, 2015 at 5:20 PM, Jeff Schwartz notifications@github.com
wrote:

@joelmo https://github.com/joelmo the problem seems to be that the vim
module currently doesn't support all the commands (someone please correct
me if I am mistaken about this). So acting as a delegate and calling into
the vim module won't work.

The commands that vim-mode supports doesn't have to be delegated.


Reply to this email directly or view it on GitHub
#50 (comment).

@jeffschwartz

@joelmo so how can you save a file now just using vim emulation? I don't see a "save" option in the command palette. I'd guess if "save" were implemented then it would be exposed as would other ex commands and would show in the command palette, right?

@joelmo
joelmo commented Feb 4, 2015

I don't understand what you mean. If atom supports opening external processes, then it could just execute /usr/bin/vim /path/to/file +CustomCmd +w +qa!, CustomCmd could be %substitute or anything. If those commands have to show up in the command palette there probably is a way to query them, ':command' in vim will list all user commands.

@jeffschwartz

@joelmo that's my point, this isn't vim and currently vim emulation doesn't implement what the actions that external commands would need, like saving a file in response to :w - it doesn't do that now. I'm not saying it wouldn't be nice if it did. Either a separate ex command module will have to implement :w or the current vim module will have to implement it. Personally, I sort of like the idea of a separate ex command module but I'd be happy in either case. The bottom line for me is that I don't expect vim emulation to emulate every facet of Vim. If I wanted that then I'd just use Vim (and I do at times). Perhaps when Neovim is ready, then some enterprising UI person will craft a sweet GUI around it. Until then for me there's Atom with decent (but could be better) emulation and the real deal when I want it.

@gepoch
gepoch commented Feb 4, 2015

FWIW, the key resolver is very awesome, and vim mode is quite happy to work with it.

This could be a good workaround for ya'll, if you weren't doing this already:

In your keymap.cson

'.editor.vim-mode:not(.insert-mode)':
  ': w enter': 'core:save'

And that's :w taken care of.

Some of the other commands may require more creativity, however. Not sure what to do for :%s You could launch atom's native find and replace though, as a productive step:

'.editor.vim-mode:not(.insert-mode)':
  ': w enter': 'core:save'
  ': % s enter': 'find-and-replace:show'

Again, not truly vim emulation, but it might be helpful to some for the time being.

@joelmo
joelmo commented Feb 4, 2015

I agree that not everything have to be emulated, but I believe the core commands people are asking for is substitute, global, sort, bufdo. All those, except last accept a regex, and also supports operating on ranges. I think it would be hard work to implement an emulation for these. This feature was suggested one year ago, but I don't feel like doing that work so I'm just using vim and follow some progress on neovim.

@jameydeorio

This is the only issue keeping me from using Atom

@lloeki
Contributor
lloeki commented Feb 19, 2015

No one was stepping up so, ex-mode here. While there's only w and write, groundwork is done, so adding new commands is easy.

@Tsarpf
Tsarpf commented May 4, 2015

+1 This is the main thing that makes me not want to use Atom. I want :commands.

...But cool that finally someone has started working on the ex-mode.

EDIT: ok this means finding with /this doesn't work either. Also the ctrl+f thingy is bugged when used with vim. This works really horribly :(

EDIT2: okay, this page https://github.com/atom/vim-mode/blob/master/docs/motions.md says / should work. Nothing happens for me from it though.

EDIT3: okay even $ doesn't work for me (for moving to the end of a line). Maybe it's a keyboard layout issue. Dunno. I guess I'll just stop trying to use vim with this.

@webduvet
webduvet commented May 5, 2015

: commands are essential.
Simply life is not possible without them.
Atom is nice, fancy, great, has a lot of potential and I'm sure I could love it. (with :)

@flyingfisch
Contributor

ex-mode now supports :s as well. Could we add a link to ex-mode in the readme?

@bronson
Contributor
bronson commented May 21, 2015

@flyingfisch you're too modest (: 40e7f3d

Does it make sense to close this in favor of opening bugs on ex-mode? Or is there anything that still needs to be tracked here?

@rgbkrk
rgbkrk commented May 21, 2015

I'm happy to close the issue now that I know about ex-mode.

@flyingfisch
Contributor

@bronson yeah after i posted here i thought i would just do it the github way ;)

@rgbkrk
rgbkrk commented Jan 4, 2016

Heh, I never closed this. I'll keep it open now that ex-mode is looking for maintainers: lloeki/ex-mode#116

Perhaps there are contributors here that would like to help there (or bring over some of it?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment