Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

providing common command to compliment ex-mode. #52

Closed
t9md opened this issue Dec 10, 2015 · 30 comments
Closed

providing common command to compliment ex-mode. #52

t9md opened this issue Dec 10, 2015 · 30 comments

Comments

@t9md
Copy link
Owner

t9md commented Dec 10, 2015

Use ex-mode. It's work well from ex-mode@0.15.0.


  • I created yet another vim-mode-plus-ex-mode before ex-mode support vim-mode-plus.
  • But I have no motivation to improve this my vim-mode-plus-ex-mode package, my thought is explained here #52.

Updated at 2017.05.25, since this is still very frequently accessed






Original issue comment

Many of former vim-mode user seem to use ex-mode.
But I'm not motivated to use different command prompt in one editor(Atom already have native command-palette feature as explained in #32).

Instead of providing independent command-mode( ex-mode ) to mimic pure Vim,
I want to gather information from ex-mode user for "what operation you are using frequently in ex-mode?".

Based on that information I can make those command via command-palette.
For example I locally using custom user command which toggle line-wrap.
I can include it as xxxxx to be able to toggle wrap from command-palette.
What other commands you guys make it available as command, put this discussion.

@bronson
Copy link
Contributor

bronson commented Dec 10, 2015

All I want is :w, :W (typo), and :wq. I think... I'll keep an eye out.

I'll miss :%s/re/repl/g but I sure don't advocate porting that to Atom. (and :'<,'>s/re/repl/g that appears when you're using visual mode)

@t9md
Copy link
Owner Author

t9md commented Dec 10, 2015

I'm experimenting the way to use command-palette to complement those commands.
What I'm trying to do is invoke command-palette by : with inserting some prefix text like ex mode: to narrow candidate list. after that user simply w invoke core:save which command is defined like bllow

getEditor = ->
  atom.workspace.getActiveTextEditor()

dispatch = (command) ->
  el = atom.views.getView(getEditor())
  atom.commands.dispatch(el, command)

atom.commands.add 'atom-workspace',
  'ex-command:w': -> dispatch 'core:save'

Currently I'm trying to find paste prefixed text to command-palette mini editor when I invoke it via :

@t9md
Copy link
Owner Author

t9md commented Dec 10, 2015

here is the prototype for ex-mode complement feature which user copy&paste to init.coffee
Although, I noticed wq throw some error when linter is enabled which is not actually this code's problem.
The evaluation result was good, but a bit slow(inserting text to command-palette fire narrowing process), maybe I can provide independent select-list view for this particular purpose.

dispatch = (commands...) ->
  editor = atom.workspace.getActiveTextEditor()
  editorElement = atom.views.getView(editor)
  for command in commands
    atom.commands.dispatch(editorElement, command)

getCommandPaletteView = () ->
  for {item} in atom.workspace.getModalPanels()
    return item if item.constructor.name is 'CommandPaletteView'

getCommandPaletteEditor = () ->
  getCommandPaletteView().filterEditorView.getModel()

insertToCommandPaletteEditor = (text) ->
  editor = getCommandPaletteEditor()
  editor.insertText(text)
  editor.moveToEndOfLine()

atom.commands.add 'atom-workspace',
  'ex-command:w': -> dispatch 'core:save'
  'ex-command:wq': -> dispatch 'core:save', 'core:close'

exCommandsPrefix = 'Ex Command:'
atom.commands.add 'atom-workspace',
  'user-ex-command-open': ->
    dispatch 'command-palette:toggle'
    insertToCommandPaletteEditor(exCommandsPrefix)

@jordwalke
Copy link

I like any and all features that aim to implement faithful vim experiences, but I have to weigh in and say that everything else should be secondary to recreating perfect replication of core vim editing/cursor movement. Of course I want great ex mode support - but everything else is secondary to cursor movement and editing.

@jordwalke
Copy link

The number one issue I see with other attempts to create a vim plugin is focusing on the long tail of vim features while neglecting the core editing experience which is what really makes vim vim. Differences in the core editing experience, no matter how subtle, is what makes people stop using Vim emulators.

@t9md
Copy link
Owner Author

t9md commented Dec 10, 2015

@jordwalke At least for my vim-mode-plus package, I'm not trying to create Vim emulator .
I just borrowing part of Vim features.
I already not so faithfull like including lots of not core feature like surround, text-obj-function, indent etc. And i already breaks many of default keymap like gc is mapped to CamelCase operator(Althogh i need to reconsider reasonable keymap)

I strongly agree for editing feature is most important.
So I'm adding lots of operator/text-object even if its not provided as pure Vim.
But I'm not aiming to recreate all the vim editing feature.

@bronson
Copy link
Contributor

bronson commented Dec 10, 2015

@t9md looks great as long as I add this keymap of course:

'atom-text-editor.vim-mode-plus:not(.insert-mode)':
  ':': 'user-ex-command-open'

Love it in fact. This feels much better to me than ex-mode.

I also added a space after Ex Command:, looks better to me but not important.

exCommandsPrefix = 'Ex Command: '

@jordwalke duplicating all of Vim's editing features would be nice but I think not realistic, even with a big development team. That would be a never-ending grind of a project.

However, if everybody pitches in and implements what they personally want to see, I think we can get close enough. (Since t9md implemented gv, I think my next gruntle is that the normal mode cursor can go past the last line in the file... Fixing that will automatically fix the dd-on-the-last-line problem. I'll get to that if nobody else does it first)

@bronson
Copy link
Contributor

bronson commented Dec 10, 2015

and I updated all my other keybindings to vim-mode-plus... No going back now!

@bronson
Copy link
Contributor

bronson commented Dec 10, 2015

Another one I use a lot: :vs. So here's my change:

  'ex-command:s': -> dispatch 'pane:split-down'
  'ex-command:v': -> dispatch 'pane:split-right'    # (not in vim)
  'ex-command:vs': -> dispatch 'pane:split-right'

@bronson
Copy link
Contributor

bronson commented Dec 10, 2015

Hm... Turns out I type :vspl a lot. I had no idea.

How hard would it be to do a unique trigger like Vim? That way :vs, :vsp, :vspl, :vsplit etc would all work without having to define each variation. (I'm guessing it would be pretty hard so not worth it. That's fine)

@jordwalke just curious, what do you think is the biggest hole in vim-mode-plus's basic editing?

@bronson
Copy link
Contributor

bronson commented Dec 10, 2015

ahahahaaa, why didn't I try it before commenting? The command palette does it for you. It even completes :wq into Ex Command: Write Quit

So here are my new completions. All common abbreviations work. And they look right at home in the command palette.

atom.commands.add 'atom-workspace',
  'ex-command:write': -> dispatch 'core:save'
  'ex-command:write-quit': -> dispatch 'core:save', 'core:close'
  'ex-command:split': -> dispatch 'pane:split-down'
  'ex-command:vertical-split': -> dispatch 'pane:split-right'

screen shot 2015-12-10 at 2 04 56 pm

One day the command palette's case-insensitivity might be an issue... Hope not, we'll see.

@t9md
Copy link
Owner Author

t9md commented Dec 11, 2015

Changed my mind, I started to experiment to bundle ex-mode like fuzzy select-list palette to vim-mode-plus.
Through this ex-palette, we can w, wq, 15 to move row 15, 50% to move to 50% row of buffer.

pros: we can frees up valuable keymapping and brain resource to remember keymap .
cons: need to maintain separate command-palette independently.

t9md added a commit that referenced this issue Dec 11, 2015
t9md added a commit that referenced this issue Dec 12, 2015
@t9md
Copy link
Owner Author

t9md commented Dec 12, 2015

I removed ex-mode part from vim-mode-plus master.
Since I'm still not sure the requirement of ex-mode(since I don't want to introduce unnecessary complexity into main code).

I cleaned up and separate it as independent package.
I'm not in mood to publish this for now.

https://github.com/t9md/atom-vim-mode-plus-ex-mode

@bronson
Copy link
Contributor

bronson commented Dec 19, 2015

Agree 100% with keeping ex mode out of vim.

I'm still using your snippet and liking it a lot. Now that the fuzzy completion works, it fills all my needs. I don't like ex mode much, maybe it shows. :)

@oknixus
Copy link

oknixus commented Dec 31, 2015

Please publish it,thanks very much😊

@t9md
Copy link
Owner Author

t9md commented Dec 31, 2015

@NixusCN You can manual install by following Readme.md of vim-mode-plus-ex-mode.

I won't publish until I find reasonable reason to support ex-mode.

@oknixus
Copy link

oknixus commented Dec 31, 2015

👍OK,thanks. You are great!

@oknixus
Copy link

oknixus commented Dec 31, 2015

@t9md Please, how to use ? enter : ? But it does not seem to work.
I have restarted the Atom.

Happy New Year !

@t9md
Copy link
Owner Author

t9md commented Jan 1, 2016

@NixusCN

I put keymap section in Readme.md of vim-mode-plus-ex-mode.
But why I won't publish this is I don't want to spend my time for the feature I don't thinks its necessary.

So use command-palette, most case command-palette is sufficient alternative to ex-mode.
If not, put note, background here.
For vim-mode-plus-ex-mode specific problem, put issue to that repository. Not to here.

Happy New Year!

@t9md t9md closed this as completed Jan 11, 2016
@luisdavim
Copy link

I created a keymap to open th ecommand palette with ':' and I use https://atom.io/packages/alias-command to create my alias like :w :q etc...

@mussel
Copy link

mussel commented Aug 9, 2016

@t9md I've been using your configs for a week now and they work great. However, I found a slight "bug". If you type ':w' and press enter really fast, the command palette will be toggled but there wont be enough time for the function insertToCommandPaletteEditor(exCommandsPrefix) to be executed. As a result, when trying to save a file, Atom kept executing the default first option of the command palette, which is opening the View Release Notes.

So, to solve this minor issue, what I did was reverse the order of the commands in the config, so that the content of the palette is changed before it is toggled:

atom.commands.add 'atom-workspace',
  'user-ex-command-open': ->
    insertToCommandPaletteEditor(exCommandsPrefix)
    dispatch 'command-palette:toggle'    

I just wanted to post this solution here in case anyone else was having the same issue.

@t9md
Copy link
Owner Author

t9md commented Aug 9, 2016

This discussion was had before I decided to release vim-mode-plus-ex-mode, and this package have fix you described above.

@msaine
Copy link

msaine commented Oct 4, 2016

First of all an apology: I am new to atom and platformIO so it may just be my ignorance of the environment that creates the following questions. In the VIM mode is there a way to jump to a specific line number? ( :23 moves cursor to line 23). Also is there an equivalent to beautify? The auto indent doesn't seem to handle braces correctly when inserting a linefeed. I come from a C standards environment that doesn't allow "{" on the same line as a control word (if, do while etc). Each "{" must be on the next line and if I go through and "fix" braces to this standard they don't end up where expected.
ie.
if (something){do something (else);}

has to be

if (something)
{
dosomething (else);
}

It really makes visually checking indentation/scope of "{" much easier for the "next" person to edit a file. I know about "%" and it is not the same as scanning a page for correct indentation.

@intijk
Copy link

intijk commented Feb 28, 2017

I still don't see the ex-mode works, the author give up atom and no longer use/develop it anymore.

ex-mode is dead.

Hi t9md, I think all the changes you've made to vim-mode-plus are great, but the personal reference should not set limitations for customization. When old vim user want to keep their habit, they don't have option now.

@luisdavim
Copy link

@intijk I understand your position but I also understand @t9md point. For me, the ideal solution is one that allows us to have vim's commands in atom's command pallet and you can map : to trigger it if you like. There are some options out there like https://github.com/takkjoga/atom-vim-colon-command-on-command-pallete, https://github.com/hurrymaplelad/atom-alias-command and https://github.com/luisdavim/atom-alias-command but they are limited to commands that don't take arguments and I don't know if that's a limitation on atom's command pallet side.

@ferrao
Copy link

ferrao commented Mar 28, 2017

Find & Replace using vim ex-mode is hardcoded into my DNA.. losing this in Atom makes me rethink using it at all.

Please, Please, Please... support things like :1,$s/text/replacement/g

@bronson
Copy link
Contributor

bronson commented Mar 28, 2017

Many people want it, but it appears nobody wants it bad enough to actually step up and to it. Alas.

@bronson
Copy link
Contributor

bronson commented Mar 28, 2017

(by "it" I mean :s search. Simple to moderate ex comands work pretty well with vim-mode-plus-ex-mode)

@mikeylemmon
Copy link
Contributor

The latest version of the ex-mode package appears to be working without any issues with vim-mode-plus (@ferrao :1,$s/text/replacement/g included!)

I created PR #789 to update the readme with a reference to the ex-mode package.

@ferrao
Copy link

ferrao commented May 25, 2017

My day just got better @fritzherald :)

mlncn added a commit to mlncn/atom-vim-mode-plus that referenced this issue Jul 23, 2018
No need to mention vim-mode-plus-ex-mode, it's deprecated in favor of ex-mode.

And if we want to link somewhere explaining the motivation behind keeping the packages separate / not making ex-mode a dependency when vim-mode-plus is installed, it should probably go in a concise wiki page; issue t9md#52 is informative but a bit more than needs to be linked from the README.

Anyhow, a frequently asked question like this would have helped me a lot!  Probably this person - t9md#328 - and many similar issues from the old vim-mode queue, too, such as atom/vim-mode#50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants