Skip to content

Commit

Permalink
Merge pull request yi-editor#427 from benarmston/vim-keymaps
Browse files Browse the repository at this point in the history
g*, g# and :on
  • Loading branch information
ethercrow committed Dec 6, 2012
2 parents c187da0 + 48ff948 commit d7b5465
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions yi/src/library/Yi/Keymap/Vim.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 ()
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d7b5465

Please sign in to comment.