codelite icon indicating copy to clipboard operation
codelite copied to clipboard

vim mode

Open slycelote opened this issue 11 years ago • 13 comments

Many editors/IDEs have vim editing mode, it would be great to see it in Codelite too.

slycelote avatar Jun 06 '15 05:06 slycelote

This is unlikely to happen .. (Pull Request are most welcomed)

eranif avatar Jun 09 '15 07:06 eranif

I would like to implement this feature. Any clue where I can start this? Any existing plugin who's could I can refer for this?

hemantmits avatar May 30 '16 09:05 hemantmits

Create new plugin, capture the event wxEVT_ACTIVE_EDITOR_CHANGED (which is sent when CodeLite sets the focus to a new editor)

In the 'ActiveEditorChanged' event handler, bind the active editor's wxEVT_KEY_DOWN event handler from there you can handle all the user key events

Resources: Create new plugin List of all CodeLite events

eranif avatar May 30 '16 11:05 eranif

I would not mind joining in on getting this plugin up and going. I am new to C++ and want to use CodeLite as my IDE but am lost without VIM bindings. Anyone else working on this?

J2112O avatar Feb 24 '17 16:02 J2112O

Hallo, I have forked codelite and started implementing a rudimentary vim-like bindings for codelite https://github.com/StefanoBelloni/codelite It is still in an unripe phase. Actual Issues: - If I close an editor ( typing :q ) via the IManager, no wxEVT_ACTIVE_EDITOR_CHANGED is sent and codelite crashes.

StefanoBelloni avatar May 17 '17 03:05 StefanoBelloni

@StefanoBelloni how do you close the editor?

eranif avatar May 18 '17 08:05 eranif

@StefanoBelloni I found this method:

bool VimCommand::OnReturnDown(IEditor **editor, IManager *manager)

which in turn calls for IManager::CloseEditor (which should work), however, I am lacking context here: can you confirm that *editor is not NULL? can you confirm that manager is not NULL? (BTW, you can use this code):

IManager* manager = clGetManager();
IEditor* editor = clGetManager()->GetActiveEditor();

eranif avatar May 18 '17 08:05 eranif

Hallo,

Thanks for the quick replay. I do not understand, why it is crashing. If I have two editors-tab open,and a close one with the IManager::CloseEditor method, I get the editor to be closed, but no wxEVT_ACTIVE_EDITOR_CHANGED is sent, and consequentially in the method void VimManager::OnEditorChanged(wxCommandEvent &event) the text controller of the new editor is not connected to the events wxEVT_CHAR and wxEVT_KEY_DOWN. when the other editor is displayed and I press ESCAPE, it crashes in the method bool QuickFindBar::DoShow(bool s, const wxString& findWhat, bool replaceBar) 676├───────> m_sci->SetFocus(); I guess because the ESCAPE try to hide the quickfindbar, but its editor has been deleted.

For now as a workaround, when the user pressed :q, I simulate the Ctrl + W with the help of wxUIActionSimulator. ( I do the same to get the quickfindbar, when pressing '/', since I could not find a why to have a pointer to it).

Till now for now this plug-in, I am still working on

  • The repetition of the command when pressing '.'
  • copy/paste.
  • a setting dialog to make it active/inactive.

StefanoBelloni avatar May 18 '17 19:05 StefanoBelloni

why don't you just debug CodeLite? You should also have log in ~/.codelite/crash.log

eranif avatar May 18 '17 19:05 eranif

Hi, I think there is a bug in the function:

bool MainBook::ClosePage(IEditor* editor, bool prompt)

The boolean variable is not used and the call m_book->DeletePage(pos, false) does not leave the event to be propagated. I guess it has never been found, since the editor is always closed directly with the method bool Notebook::DeletePage(size_t page, bool notify) The following should fix it file: mainbook.cpp:1429

bool MainBook::ClosePage(IEditor* editor, bool prompt)
{
    wxWindow* page = dynamic_cast<wxWindow*>(editor->GetCtrl());
    if(!page) return false;
    int pos = m_book->GetPageIndex(page);
    return (pos != wxNOT_FOUND) && (m_book->DeletePage(pos, prompt));
}

I would not close the issue yet, since if someone wants to contribute to this vim-mode implementation might find the actual fork quicker.

StefanoBelloni avatar May 19 '17 19:05 StefanoBelloni

This is now merged into CodeLite (mostly works, still needs to be improved, I am working on it)

eranif avatar May 24 '17 08:05 eranif

better if it can support .vimrc as vscode does, so I can use my custom keybindings

laoshaw avatar Aug 13 '23 03:08 laoshaw

This is now merged into CodeLite (mostly works, still needs to be improved, I am working on it)

can I define some keybinding for vim, imap and nmap. thanks.

laoshaw avatar Sep 21 '23 01:09 laoshaw