Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Vim keymaps #427

Merged
merged 3 commits into from

2 participants

@benarmston

Add vim key maps for g* and g#. Also, add an abbreviation of the only ex command.

I have tried to run the self-checks, but they don't seem to do anything.
make test complains about a UI not having been configured and exists so
quickly that I suspect that it is not running any tests. dist/build/yi/yi
--self-check
opens up the editor and nothing appears to happen. Would you
explain where I'm going wrong in trying to run these?

Thanks
Ben Armston

Ben Armston added some commits
Ben Armston g* and g# keymaps 4a9d5ab
Ben Armston Add :on command as an abbreviation of :only
In Vim, :onl also works. From reading the Vim help pages, I'm not sure if this
is guarenteed. I guess that the majority of uses of this command will be in
either the form :on or :only.
c9e8edc
Ben Armston Remove compilation warning 48ff948
@ethercrow
Owner

Thanks!

You might be interested in my vim2 branch, where I'm reimplementing vim bindings, but with tests this time.

As for --self-check - sadly it doesn't really test anything, it launches tests from yi/src/tests/TestSuite.hs and there are none.

@ethercrow ethercrow merged commit d7b5465 into yi-editor:master

1 check passed

Details default The Travis build passed
@benarmston

I've taken a look at your vim2 branch. It looks very impressive.

I had done some work on getting the ';' and ',' normal mode keys working, but it seems that you've already done those in vim2. I'll see what else there is that I can pick up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 5, 2012
  1. g* and g# keymaps

    Ben Armston authored
  2. Add :on command as an abbreviation of :only

    Ben Armston authored
    In Vim, :onl also works. From reading the Vim help pages, I'm not sure if this
    is guarenteed. I guess that the majority of uses of this command will be in
    either the form :on or :only.
  3. Remove compilation warning

    Ben Armston authored
This page is out of date. Refresh to see the latest.
Showing with 14 additions and 7 deletions.
  1. +14 −7 yi/src/library/Yi/Keymap/Vim.hs
View
21 yi/src/library/Yi/Keymap/Vim.hs
@@ -178,6 +178,8 @@ data VimExCmd = VimExCmd { cmdNames :: [String]
type VimExCmdMap = [VimExCmd] -- very simple implementation yet
+data SearchVariety = Bounded | Unbounded
+
$(nameDeriveAccessors ''VimOpts $ Just.(++ "A"))
-- | The Vim keymap is divided into several parts, roughly corresponding
@@ -672,12 +674,14 @@ defKeymap = Proto template
,char 'm' ?>> setMark
,char '.' ?>>! applyViCmd cnt =<< withEditor (getA lastViCommandA)]
-
- searchCurrentWord :: Direction -> EditorM ()
- searchCurrentWord dir = do
+ searchCurrentWord :: SearchVariety -> Direction -> EditorM ()
+ searchCurrentWord bounded dir = do
w <- withBuffer0' $ readRegionB =<< regionOfNonEmptyB unitViWord
- viSearch (boundedPattern w) [] dir
+ viSearch (pattern bounded w) [] dir
where
+ pattern bounded' w = case bounded' of
+ Bounded -> boundedPattern w
+ Unbounded -> w
boundedPattern x = "\\<" ++ (regexEscapeString x) ++ "\\>"
gotoPrevTagMark :: Int -> YiM ()
@@ -743,12 +747,14 @@ defKeymap = Proto template
,([ctrlW, char 'W'], prevWinE')
,([ctrlW, char 'p'], prevWinE')
- -- these 4 commands should go to moveKeymap
+ -- these 6 commands should go to moveKeymap
-- however moveKeymap is currently confined to BufferM
,([char 'n'], const $ continueSearching id)
,([char 'N'], const $ continueSearching reverseDir)
- ,([char '*'], const $ searchCurrentWord Forward)
- ,([char '#'], const $ searchCurrentWord Backward)
+ ,([char '*'], const $ searchCurrentWord Bounded Forward)
+ ,([char '#'], const $ searchCurrentWord Bounded Backward)
+ ,(map char "g*", const $ searchCurrentWord Unbounded Forward)
+ ,(map char "g#", const $ searchCurrentWord Unbounded Backward)
-- since we don't have vertical splitting,
-- these moving can be done using next/prev.
@@ -1506,6 +1512,7 @@ exEval self cmd =
fn "u" = withBuffer' undoB
fn "undo" = withBuffer' undoB
+ fn "on" = withEditor closeOtherE
fn "only" = withEditor closeOtherE
fn "red" = withBuffer' redoB
fn "redo" = withBuffer' redoB
Something went wrong with that request. Please try again.