set cursor position in v6

I wonder what is the command to set cursor position in v6.

editor.dispatch({selection: {anchor: N, head: N}})

1 Like

I did this in two steps

  1. Figure out current cursor position


  1. Set cursor to the line I want
const newPosition = viewUpdate.view.state.selection.ranges[0].from - 2;

    selection: {
      anchor: newPosition,
      head: newPosition,

not sure if you think this is a decent solution also @marijn

hello, marijn. I pass the following code, the editor does not set the cursor。The highlighting of the focused row is normal, but the cursor display is not normal

  selection: { anchor: pos, head: pos },
  effects: EditorView.scrollIntoView(targetLine.from, {
    y: 'center',

The style of the focused cursor through the click event。The above code lacks automatic new animation-name.

Could it be that the editor is simply not focused? The cursor won’t be visible then.