Author Topic: VIM emulation questions  (Read 4930 times)

dakdikmen

  • Community Member
  • Posts: 19
  • Hero Points: 0
VIM emulation questions
« on: June 09, 2010, 06:50:58 pm »
1) How to map CTRL-TAB and CTRL-SHIFT-TAB to prev and next windows.. not sure what  vi_tab() is doing...

2) How to find what are valid/implemented command on the : command prompt (no :help )

3) Having trouble moving from buffer to buffer, tab to tab and window to window without the mouse? (VIM keys/commands I'm use to aren't mapped)

4) VIM style registry Macros I think are missing .. q and @ commands

Found CTRL-SHIFT-V to list paste registry...


Ryan

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 986
  • Hero Points: 77
Re: VIM emulation questions
« Reply #1 on: June 09, 2010, 07:50:06 pm »
Quote
1) How to map CTRL-TAB and CTRL-SHIFT-TAB to prev and next windows.. not sure what  vi_tab() is doing...

Are you trying to move from buffer to buffer?  I think the commands you want are next-buff-tab and prev-buff-tab...you can use the bind-to-key command to quickly map keys to commands.  Go to the command line, enter bind-to-key, and hit ENTER.  At the prompt, enter next-buff-tab and hit ENTER.  At the "To key:" prompt hit CTRL-TAB.  Do the same for prev-buff-tab and CTRL-SHIFT-TAB.

Quote
2) How to find what are valid/implemented command on the : command prompt (no :help )

I would recommend trying out whatever you are looking for...I don't think we currently have a full chart for the : command line options that we have implemented :(.  In the docs subdirectory of your SlickEdit installation there is a Vim_Emulation.pdf file which does have some of them listed, but I don't think it is up to date.  Feel free to request support for anything that is missing...we don't have every single command implemented, yet.

Quote
3) Having trouble moving from buffer to buffer, tab to tab and window to window without the mouse? (VIM keys/commands I'm use to aren't mapped)

Moving buffer to buffer is shown above.  To move between windows, such as those created by using :vsplit, you can use the Ctrl+W commands (which exist in normal Vim).  For example, create a split window with :vsplit, and then use the sequence Ctrl+W, w to toggle between the two windows you just created.

What commands/keys for window/buffer navigation are you used to that you aren't finding?

Quote
4) VIM style registry Macros I think are missing .. q and @ commands

We have the normal SlickEdit macro recording functionality which you might want check out: Macro > Record Macro and Macro > Stop Recording Macro.

Hope this helps.

- Ryan







dakdikmen

  • Community Member
  • Posts: 19
  • Hero Points: 0
Re: VIM emulation questions
« Reply #2 on: June 09, 2010, 11:33:20 pm »
Eek, I just tried the next-buf-tab from the : prompt and it closed all my buffers (windows) .. guess it's time to go home anyways..
I get:

-- COMMAND --, Error loading new file list. Invalid option

Tried it with CTRL-A, then typed it in, I think CTRL-A get me to the slickedit command prompt, works fine...

I can't map the CTRL-TAB, it lets me, it just doesn't work in VIM mode.  I have it working in Visual Studio emulation mode...
The only diff I can see is that TAB is mapped to vi-tab, which I don't understand slick-c....
Can I un-bind the TAB, will that cause any problems?

Don't know what TAB does in VIM, I think it's the same as CTRL-I which I already bound in slick.. and works...  I think slick can bind the two keys separately..

It would be nice to have a way to make alias to slick commands (like:
 ':bn' maps to 'CTRL-A , next-buf-tab'
 ':bnext' maps to 'CTRL-A , next-buf-tab'
 ':sb <buffer>'   maps to 'macro that splits window and edit the buffer <buffer>'
etc...

Anyways, for now, I'll just remember to use the CTRL-A and the slick commands..

-David

Ryan

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 986
  • Hero Points: 77
Re: VIM emulation questions
« Reply #3 on: June 10, 2010, 02:46:17 pm »
Quote
Eek, I just tried the next-buf-tab from the : prompt and it closed all my buffers (windows) .. guess it's time to go home anyways..
I get:

-- COMMAND --, Error loading new file list. Invalid option

Tried it with CTRL-A, then typed it in, I think CTRL-A get me to the slickedit command prompt, works fine...

Yea, that's because next-buff-tab and prev-buff-tab aren't Vim : command line commands...they are just SlickEdit commands.

Quote
I can't map the CTRL-TAB, it lets me, it just doesn't work in VIM mode.

Mapping key bindings in Vim can be a little tricky because of the different modes, so let me show you have to use the Key Bindings dialog (Tools > Options > Keyboard and Mouse > Key Bindings) which should help to see what's going on.  I have Vim emulation turned on and set to default key bindings, using SlickEdit 15.0.0.6.  If you want to reset to the default key bindings just go to Tools > Options > Keyboard and Mouse > Emulation, make sure your emulation is set to Vim, and click "Restore to default key bindings".

On Key Bindings, if you enter next-buff-tab in the "Search by command" box it shows me that next-buff-tab is not bound to anything.  So select this item in the list,  click the "Add..." button, and press CTRL-TAB in the "Key Sequence" field.  It's going to tell you that CTRL-TAB is currently bound to next-window, but clicking "Bind" will get rid of that and set up the new key binding for you.  So if you do that, and then click "OK" to exit out of the Options dialog, CTRL-TAB will be performing next-buff-tab.  You can do the same for prev-buff-tab.

This is probably how you should be binding commands in the future, I just like using bind-to-key from the command line because it is a bit faster.

Quote
It would be nice to have a way to make alias to slick commands (like:
':bn' maps to 'CTRL-A , next-buf-tab'
':bnext' maps to 'CTRL-A , next-buf-tab'
':sb <buffer>'   maps to 'macro that splits window and edit the buffer <buffer>'
etc...

I will file a feature request for implementing these commands...I think sb <buffer> would be a good feature, and it shouldn't be difficult to add the :bn etc. commands b/c we already have the functionality.

- Ryan

dakdikmen

  • Community Member
  • Posts: 19
  • Hero Points: 0
Re: VIM emulation questions
« Reply #4 on: June 10, 2010, 05:54:52 pm »
Thanks the CTRL-TAB and SHIFT-CTRL-TAB is now working.... :)

There is a bunch of buffer/windows/tab commands. They all have matching on partial commands (b[uffer] matches b, bu, buf, buff, buffe, buffer)..
and the numbering/ name access of buffers. Buffer 1 might have file.txt and you can access it as ':buf 1' or by ':buffer file.txt'. Not having numbered buffers is fine, just state so, so we know not to use it.

I guess I use the :bn  go to next bufffer and :bmod n to get to the nth modified buffer frequently.

I found EX_CMDS in the ex.sh macro file and has this list:
" ! = < > & ABBREVIATE COPY CD DELETE EDIT FILE GLOBAL JOIN K LIST":+\
                " MOVE NEXT NUMBER PRINT PUT QUIT QALL READ REWIND SUBSTITUTE":+\
                " SET SG SHELL SPLIT T TAG UNDO UNABBREVIATE V VERSION VSPLIT WRITE WQ WQALL WALL X YANK Z BUFDO "

First thing I would do it implement :h[elp]  and pop up that list of commands... there is just too many VIM commands... I get frustrated and switch back.

Oh, before doing help command, the partial matching [] of command is important.

Popular [for me ;D] command your missing:

':vie[w] [++opt] [+cmd] file' use to edit a file in read-only mode.
':fin[d][!] [++opt] [+cmd] {file} Find {file} in 'path' and then |:edit| it.

I'm using ^O to get to the GUI open, but have not figured out a way to do ":find batch.bat" to edit a file in the PATH quickly..

From the VIM help files... guess this post is getting big... should just point you to the help files.

Install VIM 7.2 in default directory...
Tabs described here:
"C:\Program Files\Vim\vim72\doc\tabpage.txt"
Windows & buffers here:
"C:\Program Files\Vim\vim72\doc\windows.txt"
Editing commands here:
"C:\Program Files\Vim\vim72\doc\editing.txt"

(argument stuff I don't think is that popular?)
---- buffers ----
7. Argument and buffer list commands         *buffer-list*

      args list             buffer list      meaning ~
1. :[N]argument [N]   11. :[N]buffer [N]   to arg/buf N
2. :[N]next [file ..]   12. :[N]bnext [N]   to Nth next arg/buf
3. :[N]Next [N]      13. :[N]bNext [N]   to Nth previous arg/buf
4. :[N]previous   [N]   14. :[N]bprevious [N]   to Nth previous arg/buf
5. :rewind / :first   15. :brewind / :bfirst   to first arg/buf
6. :last      16. :blast      to last arg/buf
7. :all         17. :ball      edit all args/buffers
         18. :unhide      edit all loaded buffers
         19. :[N]bmod [N]   to Nth modified buf

  split & args list     split & buffer list      meaning ~
21. :[N]sargument [N]   31. :[N]sbuffer [N]   split + to arg/buf N
22. :[N]snext [file ..] 32. :[N]sbnext [N]      split + to Nth next arg/buf
23. :[N]sNext [N]       33. :[N]sbNext [N]      split + to Nth previous arg/buf
24. :[N]sprevious [N]   34. :[N]sbprevious [N]  split + to Nth previous arg/buf
25. :srewind / :sfirst   35. :sbrewind / :sbfirst split + to first arg/buf
26. :slast      36. :sblast      split + to last arg/buf
27. :sall      37. :sball      edit all args/buffers
         38. :sunhide      edit all loaded buffers
         39. :[N]sbmod [N]   split + to Nth modified buf

40. :args      list of arguments
41. :buffers      list of buffers

-David

Ryan

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 986
  • Hero Points: 77
Re: VIM emulation questions
« Reply #5 on: June 10, 2010, 06:16:13 pm »
Thanks for the great info and suggestions.

One thing that you might want to look at, which I use all the time, is the e command for quickly opening files.  If you want to quickly open a file in your workspace and you know the file name, all you have to do is go to the command line and type e FILENAME.  The full path to the file will complete and you can hit TAB to select the complete file name, and then hit ENTER to open it.

- Ryan