vi mode - experimental build

edited November 2017
I've just uploaded an experimental build with basic vi emulation:



Go to Edit | Preferences > General UI to enable.

Let me know if anything important is missing - or if anything is behaving badly.




  • Joe, thanks!

    We've asked for the basic vi commands and so far very cool!

    As we start using it, we'll encounter commands that aren't implemented. how should we report these so that you can aggregate popularity?

    Thanks again,
  • Thanks, Howard. If you have any requests or find any bugs, report them on this thread.
  • This is awesome, Joe! Thank you! I was just trying it out and I found a small issue. If you open a new query and add a few characters of text, then hit ESC and "yyp" to copy the line, the line is concatenated to the current line instead of beginning on a new line. It seems like this may be happening because the current line itself in this case does not end in a '\n'
  • I've just uploaded a build that fixes this (and a few other issues).
  • Hi Joe, thanks for fixing this! I'm not sure where to draw the line on which commands to implement, but one I use very frequently is '>' and '<' to indent / outdent lines. Would it be possible to add these, or at least add them to a list of future candidate commands.

    Thanks again, this has already been a huge help to me.
  • Thank you, Joe! LINQPad + vi mode is really awesome!

    Some suggestions:

    * it would be great to be able to move from the editor panel to the grid with CTRL-W j and back with CTRL-W k
    * maybe inoremap or something like that so that we could map jj or kj or jk to exit insert mode
    * enable moving around when at the grid using the same j k l h keys

    Thanks again.
  • I've uploaded a new build that lets you scroll the results with Alt+Shift+(H|L|J|K|U|D|B|E). You can do this while keeping focus in the editor.

    I can't remap J and K to scroll the results when focused because you can dump things such as textboxes that need to respond to keypresses.

    I like using kj to exit insert mode. There's now an option for this.

  • Thank you! kj is great, and also the scroll.
  • I forgot to mention, < and > now work for indenting in command mode.
  • Very cool. I've been wanting a vi editor in LINQPad since I started using it ~5yrs ago.

    Ran into an issue moving around with the '-' character: It won't move up over vertical white space. Within a dense block of code it navigates fine but stops at a blank line. Navigating down with '+' (something I rarely do because is easier) works fine but seems to jump over the white space to the next section.

    Maybe related I also noticed that moving to the last line in the file, navigating up one line with 'k' to a blank line, then hitting '-' moves down, not up.
  • Indentation with < and > are indenting a single line immediately. In vi, indenting a single line is done with << or >> because the second character can be a navigation command instead. For example, marking a location ("ma"), moving to another line and indenting the whole block with ">'a".
  • These problems should now be fixed in 5.26.07 Let me know if you experience any further issues.
  • Both are working great. Thanks! -Vic
  • Submitted an error report with this but just in case that's lost in the fog, here's a repeatable crash:

    Click "+" to open a new tab
    Click the DB name in the upper right corner
    Click in the window and type "Time"

    Get a System ArgumentException: The indicator is not allowed to be zero-length. This also may have occurred if you specified a TextRange that is outside the bounds of the document.

    Since the window is empty, I almost certainly specified a range outside the bounds.

    I'm going to have to retrain my brain to hit "a" before I start typing queries...

  • This is pretty great!
    I do run into one issue though. when an auto-completion popup is open during insert mode, escape will first close that popup, and only the second escape will leave insert mode.

    Could you maybe provide an option to make escape leave insert mode right away?
  • Originally it worked like that, but it was very annoying when you wanted to close the popup without leaving insert mode.

    Note that you can also use Ctrl+Enter or Shift+Enter to exit insert mode - this will work even when a popup is active.
  • While editing, instead of "cw" I will often use "cf," to change to the next comma. This works fine in the vi emulation with commas (original line followed by results of the commands in comments):

    muggle, buggle, snuggle, fuggle (a hop variety)
    buggle, snuggle, fuggle (a hop variety) // cf,
    snuggle, fuggle (a hop variety) // c2f,
    fuggle (a hop variety) // c3f

    When I try using "+" characters, things get weird: it "takes" more than I expected

    Monkey++, Froggie++, j++
    +, Froggie++, j++ // c1f+
    +, j++ // c2f+
    // c3f+ [took the whole line including the comment

    Not a really big deal since it seems isolated to "+".

    Thanks again. Still enjoying the heck out of vi in LINQPad.

  • Not vi related but are there controls on reformatting? I'm a K&R C guy from the dark ages. I respect other people's opinions on code format but get annoyed when mine gets automatically reformatted. I'd be really happy with a switch to turn it off - I don't need ReSharper level formatting rules that require a masters degree to set correctly.
  • The change/repeat/find sequence is not working as expected because it repeats the action rather than the find. I'll fix this for the next build.

    Regarding disabling auto-formatting, you can do this in Edit | Preferences | Advanced > Code Formatting. Turn off 'Auto format on closing brace or end block', and 'Auto format on paste'.
  • Hi Joe, thanks for the best feature ever.

    I've found an issue when yanking/putting substrings. When selecting a substring
    in visual mode and pressing 'yp' to duplicate the content, the yanked string is
    inserted on a new line below, instead of at the current cursor position.

    Also, is it possible to use the windows clipboard as the yank buffer? That
    would simplify copy-pasting to/from other applications.
  • Hi Joe, loving vim emulation!

    a couple of vi sequence I use a lot and would love to see implemented:

    * "[[" to move to the top and "]]" to move to the bottom or ":0" and ":$"
    * "ma" then move somewhere else "mb" then "'a,'bt." to copy from marker a to b to current location and also "'a,'bm." to move the block.

    Thanks Joe and Merry Christmas!


  • Hi Joe,

    Another obscure bug but something I use often:

    Cap1 = r.MonthlySum1YCap1 * 100, Targ1 = r.MonthlySum1YTarget1 * 100, Val1 = r.MonthlySum1YValue1 * 100,

    Editing this line I want to change most of the "1" to "2" so I type:

    "f1r2;;.;;.;;." or translated to English: find "1" in Cap1, replace with "2", find next "1" (twice to skip the 1Y) using ";", replace with 2 using "." to repeat prior command, etc.

    What happens is the first one works correctly but the second and subsequent "." replaces two characters with "2" giving me the following:

    Cap2 = r.MonthlySum1YCap22* 100, Targ22= r.MonthlySum1YTarget22* 100, Val22= r.MonthlySum1YValue22* 100

    Thanks again. I'm loving vi in LINQPad.

  • Thanks for the repro. I've fixed this for the next build, and have also added support for [[ and ]].
  • Please consider adding support for text objects so commands like ci', ci{, ci[, di', di{, di[, etc all work.

    I had some text between []s, [App-Vlan-IP], I was trying to change. My cursor was located between the two p's. In Vim 5ciw would allow me to change the five words between the [...]. Issuing the command in LinqPad eats way too much yet 5dw works if the cursor is located at the A.
  • ci{ and di{ should already work. I'll add ' and [ to the next build.
  • I'm using v5.28.00 and ci{, di{ don't do anything. ci}, di} change/delete to the end of the paragraph which still isn't correct.
  • Try now. The {, [, (, ' and " ranges should all now work with ci and ca.
  • Better, but... ;-)

    { and ( seem to be no-op at this point. Also, closing }, ), ] should behave just like the opening partner...
  • What query language are you using? And when the cursor is over the { or ( symbol, does it highlight the matching brace in green?
  • Hi Joe,

    I'm having issues with the behavior of selected text. For example if I double click on Bob below, your vi emulation is already in edit/change mode.

    void Main()
    string bob = "Bob";

    Console.WriteLine("{0}", bob);

    So if I then type "y" to yank the string "Bob" I end up editing it to "y" instead. In gVim, double click selecting something does just that: selects it. To edit, you still have to type "s" or "c" and as illustrated above, other commands like yank are available. To me this is is a more natural or expected behavior, though admittedly it's hard to argue what "natural" means with mouse inputs and an editor designed in the 1970s.

    Can you consider adopting the gVim behavior?

Sign In or Register to comment.