Author Topic: Vim plugin?  (Read 36382 times)

Offline kilgore

  • Single posting newcomer
  • *
  • Posts: 3
Vim plugin?
« on: June 19, 2007, 07:09:33 pm »
Greetings all,


I am seriously addicted to vim -- has anyone created a vim plugin for code blocks?  Is it possible?
Thanks!

-kt.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9508
Re: Vim plugin?
« Reply #1 on: June 19, 2007, 08:02:42 pm »
I am seriously addicted to vim -- has anyone created a vim plugin for code blocks?
Addicted to vim and working with C::B - how is that possible...?! :lol: ;-)
Anyways - It's not quite clear what you mean. If you mean the key shortcuts than have a look at the keybinder plugin - you can re-assign the shortcuts there easily. If you mean the macros / "additional functionality" with vim then have a look at the KeyMacs plugin - you can create macros and assign them a(nother) shortcut to emulate more complex behaviour.
With regards, Morten.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline David Perfors

  • Developer
  • Lives here!
  • *****
  • Posts: 560
Re: Vim plugin?
« Reply #2 on: June 19, 2007, 08:09:01 pm »
it is not done yet. and of course it is possible. (I suppose you mean to embed vi in C::B as an editor) But keep in mind that most of the plugins only work with the build in editor (like code completion...)
OS: winXP
Compiler: mingw
IDE: Code::Blocks SVN WX: 2.8.4 Wish list: faster code completion, easier debugging, refactoring

Offline kilgore

  • Single posting newcomer
  • *
  • Posts: 3
Re: Vim plugin?
« Reply #3 on: June 19, 2007, 08:14:45 pm »
Yes, I meant primarily the key mappings.  Thanks for the reply!  I'm not yet a serious c::b user, just exploring  -- I like what I see, but _really_ want what I already know (and I detest having to use that <expletive> mouse when I could do it with a keystroke or two).

Thanks -- and maybe when I get some time, I'll contribute one... ahem...

-kt.


Offline Andrej08

  • Single posting newcomer
  • *
  • Posts: 7
Re: Vim plugin?
« Reply #4 on: August 12, 2010, 01:46:12 am »
*El bumpo*

I recently found an autohotkey script which has some very basic VIM key-bindings that can be used in some editors (e.g. scintilla, which is what codeblocks uses).

I started modifying it 2 days ago and I've added a bunch of handy close-to-homerow key shortcuts. I'm not making them 100% vim compatible because emulating everything that VIM has is way too hard + a lot of those key shortcuts depend on VIM features. I'm quite inexperienced with VIM, but I do like some of it's features. I've customized the script to my own style, although anyone is free to modify it to their own style and add/edit/remove features.

The script is here: http://www.autohotkey.com/forum/viewtopic.php?p=375239#375239

You'll need to copy-paste it to a filename.ahk file and download and install AutoHotkey_L, a custom version of AHK from this website:
http://www.autohotkey.net/~Lexikos/AutoHotkey_L/

Then just run the script with AHK_L (double-click should do it). You can use caps-lock to toggle between usual editing and vim-mode (you can change the toggle key as well).

If you need to set a quick exit key, add this on any line:
^!home::ExitApp

That's Ctrl+alt+home to exit the script. Check the documentation of AHK_L. Btw if you're new to AHK, the syntax takes some time getting used to. If you have any ideas for some features then if I'm in a good mood I might try to implement them. I've used AHK for almost a year now, so I'd probably find my way around.

Anyway, hope you have a use for it..

Edit: One more thing, I've only extensively tested the script with Scite, but I've only tried it with CB for a few minutes. Most of the features seem to work fine.
« Last Edit: August 12, 2010, 01:48:30 am by Andrej08 »

ayheos

  • Guest
Re: Vim plugin?
« Reply #5 on: January 06, 2012, 12:36:49 pm »
 :) Recently, I do some jobs to make codeblocks internal editor works like vim.
 
Try it, any feedback is welcome.

https://code.google.com/p/cbvike/

Thanks to codeblocks group.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5241
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Vim plugin?
« Reply #6 on: September 21, 2013, 08:26:17 am »
:) Recently, I do some jobs to make codeblocks internal editor works like vim.
 
Try it, any feedback is welcome.

https://code.google.com/p/cbvike/

Thanks to codeblocks group.
I just build and test this plugin, at least it can switch between vim's normal mode and insert mode, and then I can move caret around by "h,j,k,l" key. I'm just a vim beginner, so I think this plugin is useful, at least it can move caret without the help of mouse. ;)
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline arthurzmj

  • Multiple posting newcomer
  • *
  • Posts: 13
Re: Vim plugin?
« Reply #7 on: October 07, 2013, 04:59:51 pm »
:) Recently, I do some jobs to make codeblocks internal editor works like vim.
 
Try it, any feedback is welcome.

https://code.google.com/p/cbvike/

Thanks to codeblocks group.

I've made some improvement of this code.
https://github.com/zmj64351508/cbvike
Thanks to ayheos

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: Vim plugin?
« Reply #8 on: October 07, 2013, 11:10:39 pm »
:) Recently, I do some jobs to make codeblocks internal editor works like vim.
 
Try it, any feedback is welcome.

https://code.google.com/p/cbvike/

Thanks to codeblocks group.
I just build and test this plugin, at least it can switch between vim's normal mode and insert mode, and then I can move caret around by "h,j,k,l" key. I'm just a vim beginner, so I think this plugin is useful, at least it can move caret without the help of mouse. ;)

If you want to move caret without the mouse or arrow keys (which are not practical while typing), you can use autohotkey software to define macros for key combinations, for example I use Right Alt+E,S,D,F to move the caret in corresponding directions.
http://www.autohotkey.com/

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5241
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Vim plugin?
« Reply #9 on: October 08, 2013, 01:33:20 am »
:) Recently, I do some jobs to make codeblocks internal editor works like vim.
 
Try it, any feedback is welcome.

https://code.google.com/p/cbvike/

Thanks to codeblocks group.

I've made some improvement of this code.
https://github.com/zmj64351508/cbvike
Thanks to ayheos
I suggest not using absolute paths in cbp, instead, you can try my patch:
Code: [Select]
vike.cbp | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/vike.cbp b/vike.cbp
index a4e498d..868fd11 100644
--- a/vike.cbp
+++ b/vike.cbp
@@ -7,12 +7,13 @@
  <Option compiler="gcc" />
  <Build>
  <Target title="default">
- <Option output="..\..\..\devel\share\CodeBlocks\plugins\vike.dll" prefix_auto="0" extension_auto="0" />
- <Option object_output="..\..\..\.objs\plugins\contrib\vike" />
+ <Option output="$(#cb_sdk)/devel/share/CodeBlocks/plugins/vike.dll" prefix_auto="0" extension_auto="0" />
+ <Option object_output="$(#cb_sdk)/.objs/plugins/contrib/vike" />
  <Option type="3" />
  <Option compiler="gcc" />
- <Option parameters="--debug-log -na -ns -nd" />
- <Option host_application="..\..\..\devel\codeblocks.exe" />
+ <Option parameters="--debug-log -na -ns -nd -p debug" />
+ <Option host_application="$(#cb_sdk)/devel/codeblocks.exe" />
+ <Option run_host_application_in_terminal="0" />
  <Compiler>
  <Add option="-Winvalid-pch" />
  <Add option="-pipe" />
@@ -33,8 +34,8 @@
  </Linker>
  </Target>
  <Environment>
- <Variable name="WX_SUFFIX" value="u" />
  <Variable name="WX_CFG" value="" />
+ <Variable name="WX_SUFFIX" value="u" />
  </Environment>
  </Build>
  <VirtualTargets>
@@ -43,23 +44,22 @@
  <Compiler>
  <Add option="-Wall" />
  <Add option="-g" />
- <Add directory="..\..\..\include" />
- <Add directory="..\..\..\sdk\wxscintilla\include" />
+ <Add directory="$(#cb_sdk)/include" />
+ <Add directory="$(#cb_sdk)/sdk/wxscintilla/include" />
  <Add directory="$(#WX.include)" />
- <Add directory="$(#WX.lib)\gcc_dll$(WX_CFG)\msw$(WX_SUFFIX)" />
- <Add directory="$(#WX)\contrib\include" />
+ <Add directory="$(#WX.lib)/gcc_dll$(WX_CFG)/msw$(WX_SUFFIX)" />
+ <Add directory="$(#WX)/contrib/include" />
  </Compiler>
  <Linker>
  <Add library="codeblocks" />
  <Add library="wxmsw28$(WX_SUFFIX)" />
- <Add library="wxscintilla" />
- <Add directory="D:\Prog\CodeBlocks_bak" />
- <Add directory="$(#WX.lib)\gcc_dll$(WX_CFG)" />
- <Add directory="..\..\..\devel" />
+ <Add library="wxscintilla_cb" />
+ <Add directory="$(#WX.lib)/gcc_dll$(WX_CFG)" />
+ <Add directory="$(#cb_sdk)/devel" />
  </Linker>
  <ExtraCommands>
- <Add after="zip -j9 ..\..\..\devel\share\CodeBlocks\vike.zip manifest.xml" />
- <Add after="zip -j9 vike.cbplugin ..\..\..\devel\share\CodeBlocks\plugins\vike.dll ..\..\..\devel\share\CodeBlocks\vike.zip" />
+ <Add after="zip -j9 $(#cb_sdk)\devel\share\CodeBlocks\vike.zip manifest.xml" />
+ <Add after="zip -j9 vike.cbplugin $(#cb_sdk)\devel\share\CodeBlocks\plugins\vike.dll $(#cb_sdk)\devel\share\CodeBlocks\vike.zip" />
  <Mode after="always" />
  </ExtraCommands>
  <Unit filename="cbvike.cpp" />


Note: you can define cb_sdk in C::B's settings->global variables to the root folder of C::B source.

BTW: I have contacted ayheos weeks ago, he said his cbvilike development freezes currently.

@scarphin: thanks, I finally think mouse is still necessary when editing under C::B.  ;)

If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline arthurzmj

  • Multiple posting newcomer
  • *
  • Posts: 13
Re: Vim plugin?
« Reply #10 on: October 08, 2013, 12:24:04 pm »
I suggest not using absolute paths in cbp, instead, you can try my patch:
Code: [Select]
vike.cbp | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/vike.cbp b/vike.cbp
index a4e498d..868fd11 100644
--- a/vike.cbp
+++ b/vike.cbp
@@ -7,12 +7,13 @@
  <Option compiler="gcc" />
  <Build>
  <Target title="default">
- <Option output="..\..\..\devel\share\CodeBlocks\plugins\vike.dll" prefix_auto="0" extension_auto="0" />
- <Option object_output="..\..\..\.objs\plugins\contrib\vike" />
+ <Option output="$(#cb_sdk)/devel/share/CodeBlocks/plugins/vike.dll" prefix_auto="0" extension_auto="0" />
+ <Option object_output="$(#cb_sdk)/.objs/plugins/contrib/vike" />
  <Option type="3" />
  <Option compiler="gcc" />
- <Option parameters="--debug-log -na -ns -nd" />
- <Option host_application="..\..\..\devel\codeblocks.exe" />
+ <Option parameters="--debug-log -na -ns -nd -p debug" />
+ <Option host_application="$(#cb_sdk)/devel/codeblocks.exe" />
+ <Option run_host_application_in_terminal="0" />
  <Compiler>
  <Add option="-Winvalid-pch" />
  <Add option="-pipe" />
@@ -33,8 +34,8 @@
  </Linker>
  </Target>
  <Environment>
- <Variable name="WX_SUFFIX" value="u" />
  <Variable name="WX_CFG" value="" />
+ <Variable name="WX_SUFFIX" value="u" />
  </Environment>
  </Build>
  <VirtualTargets>
@@ -43,23 +44,22 @@
  <Compiler>
  <Add option="-Wall" />
  <Add option="-g" />
- <Add directory="..\..\..\include" />
- <Add directory="..\..\..\sdk\wxscintilla\include" />
+ <Add directory="$(#cb_sdk)/include" />
+ <Add directory="$(#cb_sdk)/sdk/wxscintilla/include" />
  <Add directory="$(#WX.include)" />
- <Add directory="$(#WX.lib)\gcc_dll$(WX_CFG)\msw$(WX_SUFFIX)" />
- <Add directory="$(#WX)\contrib\include" />
+ <Add directory="$(#WX.lib)/gcc_dll$(WX_CFG)/msw$(WX_SUFFIX)" />
+ <Add directory="$(#WX)/contrib/include" />
  </Compiler>
  <Linker>
  <Add library="codeblocks" />
  <Add library="wxmsw28$(WX_SUFFIX)" />
- <Add library="wxscintilla" />
- <Add directory="D:\Prog\CodeBlocks_bak" />
- <Add directory="$(#WX.lib)\gcc_dll$(WX_CFG)" />
- <Add directory="..\..\..\devel" />
+ <Add library="wxscintilla_cb" />
+ <Add directory="$(#WX.lib)/gcc_dll$(WX_CFG)" />
+ <Add directory="$(#cb_sdk)/devel" />
  </Linker>
  <ExtraCommands>
- <Add after="zip -j9 ..\..\..\devel\share\CodeBlocks\vike.zip manifest.xml" />
- <Add after="zip -j9 vike.cbplugin ..\..\..\devel\share\CodeBlocks\plugins\vike.dll ..\..\..\devel\share\CodeBlocks\vike.zip" />
+ <Add after="zip -j9 $(#cb_sdk)\devel\share\CodeBlocks\vike.zip manifest.xml" />
+ <Add after="zip -j9 vike.cbplugin $(#cb_sdk)\devel\share\CodeBlocks\plugins\vike.dll $(#cb_sdk)\devel\share\CodeBlocks\vike.zip" />
  <Mode after="always" />
  </ExtraCommands>
  <Unit filename="cbvike.cpp" />


Note: you can define cb_sdk in C::B's settings->global variables to the root folder of C::B source.

BTW: I have contacted ayheos weeks ago, he said his cbvilike development freezes currently.

@scarphin: thanks, I finally think mouse is still necessary when editing under C::B.  ;)



Thanks for your advise. I'll patch it later.

I'm going to complete this plugin graually. I'm happy if you can try it and give more suggestion to me.
« Last Edit: October 08, 2013, 03:22:39 pm by arthurzmj »

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5241
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Vim plugin?
« Reply #11 on: October 10, 2013, 04:17:25 pm »
@arthurzmj, I see you have some commits, good work.

Suggestion:
1, vike.layout should not be put in git, because this is a user preference file.
2, I see you have a "bin" folder which contains some generated dlls, I also think this should be removed, because users can have different compilers, and all the binaries files can be build on their local computer.
3, I'm a very beginner of Vim, I still mainly use mouse, so if you can write a document about what functionality this plugin supplies, that will be better. ;D

Thanks.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5241
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Vim plugin?
« Reply #12 on: October 10, 2013, 05:03:50 pm »
Is it Ok to change the license?

I see you said in https://github.com/zmj64351508/cbvike

Quote
cbvike

VIM plugin for Code::Blocks.

It's based on https://code.google.com/p/cbvike/ and improved in my own way. So It still retains the name of cbvike but I change the license file.

The original license is GPLv3 (see https://code.google.com/p/cbvike/), you changed to GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 (see https://github.com/zmj64351508/cbvike/blob/master/LICENSE)
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline arthurzmj

  • Multiple posting newcomer
  • *
  • Posts: 13
Re: Vim plugin?
« Reply #13 on: December 16, 2013, 09:09:43 am »
@arthurzmj, I see you have some commits, good work.

Suggestion:
1, vike.layout should not be put in git, because this is a user preference file.
2, I see you have a "bin" folder which contains some generated dlls, I also think this should be removed, because users can have different compilers, and all the binaries files can be build on their local computer.
3, I'm a very beginner of Vim, I still mainly use mouse, so if you can write a document about what functionality this plugin supplies, that will be better. ;D

Thanks.

I'm sorry to be late for the reply. Good suggestions. But I'm now busy with some other work, so I'll improve it when I'm free. As the license problem you mentioned, I made a mistake. Thank you for pointing it out.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5241
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Vim plugin?
« Reply #14 on: December 16, 2013, 09:18:00 am »
I'm sorry to be late for the reply. Good suggestions. But I'm now busy with some other work, so I'll improve it when I'm free. As the license problem you mentioned, I made a mistake. Thank you for pointing it out.
Ok, once you make a step in your project, you can add a reply here(I will receive an email notification), so I can test it, thanks for your contribution. :D
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.