anchor.diff:          | ForwardToEndOfWORD -> editor.CaretOffset, findWordEnd editor isWORDChar
           | HalfPageUp -> 
               let visibleLineCount = getVisibleLineCount editor
  -            let halfwayUp = Math.Max(1, editor.CaretLine - visibleLineCount / 2)
  +            let halfwayUp = max 1 (editor.CaretLine - visibleLineCount / 2)
               editor.CaretOffset, editor.GetLine(halfwayUp).Offset
           | HalfPageDown -> 
               let visibleLineCount = getVisibleLineCount editor
  -            let halfwayDown = Math.Min(editor.LineCount, editor.CaretLine + visibleLineCount / 2)
  +            let halfwayDown = min editor.LineCount (editor.CaretLine + visibleLineCount / 2)
               editor.CaretOffset, editor.GetLine(halfwayDown).Offset
           | PageUp ->
               let visibleLineCount = getVisibleLineCount editor
  -            let pageUp = Math.Max(1, editor.CaretLine - visibleLineCount)
  +            let pageUp = max 1 (editor.CaretLine - visibleLineCount)
               editor.CaretOffset, editor.GetLine(pageUp).Offset
           | PageDown ->
               let visibleLineCount = getVisibleLineCount editor
  -            let pageDown = Math.Min(editor.LineCount, editor.CaretLine + visibleLineCount)
  +            let pageDown = min editor.LineCount (editor.CaretLine + visibleLineCount)
               editor.CaretOffset, editor.GetLine(pageDown).Offset
           | CurrentLocation -> editor.CaretOffset, editor.CaretOffset+1
           | SelectedText ->
               let selection = editor.Selections |> Seq.head
               let lead = editor.LocationToOffset selection.Lead
               let anchor = editor.LocationToOffset selection.Anchor
  -            Math.Min(lead, anchor), Math.Max(lead, anchor)
  +            Math.Min(lead, anchor), max lead anchor
           | SelectionStart -> editor.CaretOffset, vimState.visualStartOffset
           | MatchingBrace ->
               match findNextBraceForwardsOnLine editor line with
  
positive.code:             match state.mode, keyList with
              | VisualBlockMode, [ Escape ] -> [ switchMode NormalMode; run Move SelectionStart ]
              | NormalMode, [ Escape ] -> resetKeys
              | VisualModes, [ Escape ] -> [ run (SwitchMode NormalMode) Nothing ]
              | _, [ Escape ] -> [ run (SwitchMode NormalMode) Nothing; run Move Left ]
              | NotInsertMode, [ "G" ] ->
                  match numericArgument with
                  | Some lineNumber -> [ runOnce Move (StartOfLineNumber lineNumber) ]
                  | None -> [ runOnce Move LastLine ]
              | NormalMode, [ "V" ] ->
                  match numericArgument with
                  | Some lines -> [ run (SwitchMode VisualLineMode) Nothing; getCommand (lines-1 |> Some) Move Down ]
                  | None -> [ run (SwitchMode VisualLineMode) Nothing ]
              | NormalMode, [ "v" ] ->
                  match numericArgument with
                  | Some chars -> [ runOnce (SwitchMode VisualMode) Nothing; getCommand (chars-1 |> Some) Move Right ]
                  | None -> [ run (SwitchMode VisualMode) Nothing ]
              | NormalMode, [ "d"; "G" ] -> [ runOnce DeleteWholeLines LastLine]
              | NormalMode, [ "d"; "g" ] -> wait
              | NormalMode, [ "d"; "g"; "g" ] -> [ runOnce DeleteWholeLines StartOfDocument]
  
negative.code:     let runOnce = getCommand (Some 1)
      let typeChar c = runOnce (InsertChar c) Nothing
  
      let getSelectedText vimState (editor: TextEditor) (command:VimAction) =
          let linewise =
              match vimState.mode with
              | VisualLineMode -> true
              | _ ->
                  match command.textObject with
                  | LineWise -> true
                  | _ -> false
  
  