VSCodeVim / Vim

:star: Vim for Visual Studio Code
http://aka.ms/vscodevim
MIT License
13.86k stars 1.31k forks source link

`<Home>` and `<End>` don't work the same in normal and insert mode #7168

Open aaa45190 opened 2 years ago

aaa45190 commented 2 years ago
1 abcdefgthijklmn
2 012345678912345
  1. suppose one line have 15 letter as above
  2. With Insert Mode, my cursor at col 10.(current cursor pointer to number 9)
  3. I Press Home, cursor go col 0. (cursor Point to mnumber 0)
  4. I Press arrow right, cursor go col 11, not col 1.

My question is: In step 4, why cursor not go to col 1? By the way, with normal mode, Home work as expected.(in step4, cursor with go to col 1 with step 2 is Normal mode)

J-Fields commented 2 years ago

Can you please provide your settings? I'm unable to reproduce

aaa45190 commented 2 years ago

I am not sure which setting do you need. I Work with remote ssh, below is all of setting on remote server. I attached three setting, include vscode setting, keyboard shortcut$Home/.vimrc. If these three are not enough, please let me know. vscode setting:

{
    "[go]": {
        "editor.insertSpaces": false,
        "editor.formatOnSave": true,
        "editor.codeActionsOnSave": {
            "source.organizeImports": true
        },
        "editor.wordWrap": "wordWrapColumn",
        "editor.wordWrapColumn": 120,
    },
    "go.testFlags": [
        "-gcflags=all=-N -l",
        "-v"
    ],
    "go.gopath": "/root/.local/go",
    "editor.formatOnSave": true,
    "editor.quickSuggestions": true,
    "editor.rulers": [],
    "[markdown]": {
        "editor.wordWrap": "on",
        "editor.quickSuggestions": false
    },
    "[proto3]": {},
    "clang-format.language.proto.style": "{BasedOnStyle: LLVM, AlignTrailingComments: true, AllowShortFunctionsOnASingleLine: Empty, AllowShortLambdasOnASingleLine: Empty, AllowShortBlocksOnASingleLine: Never, ColumnLimit: 1000, BraceWrapping: {AfterEnum: true}}",
    "clang-format.language.proto.fallbackStyle": "none",
    "protoc": {
        "editor.wordWrap": "off",
        "editor.wordWrapColumn": 10
    },
    "clang-format.style": "{BasedOnStyle: LLVM, AlignTrailingComments: true, AllowShortFunctionsOnASingleLine: Empty, AllowShortLambdasOnASingleLine: Empty, AllowShortBlocksOnASingleLine: Never, ColumnLimit: 120, BraceWrapping: {AfterEnum: true}}, AlignAfterOpenBracket: AlwaysBreak",
    "clang-format.executable": "/usr/bin/clang-format",
    "clang-format.language.typescript.fallbackStyle": "LLVM",
    "maven.executable.preferMavenWrapper": false,
    "maven.executable.path": "/usr/local/apache-maven-3.6.3/bin/mvn",
    "go.formatTool": "gofmt",
    "go.formatFlags": [],
    "clang-format.fallbackStyle": "none",
    "clang-format.language.proto.enable": true,
    "go.toolsEnvVars": {
        "GO111MODULE": "on"
    },
    "better-comments.highlightPlainText": true,
    "remote.autoForwardPortsSource": "output"
}

Keyboard ShortCuts Setting image image

// Place your key bindings in this file to override the defaultsauto[]
[
    {
        "key": "shift+home",
        "command": "cursorHomeSelect",
        "when": "textInputFocus"
    },
    {
        "key": "shift+home",
        "command": "-cursorHomeSelect",
        "when": "textInputFocus"
    },
    {
        "key": "home",
        "command": "extension.vim_home",
        "when": "editorTextFocus && vim.active && !inDebugRepl && vim.mode != 'Insert'"
    },
    {
        "key": "home",
        "command": "-extension.vim_home",
        "when": "editorTextFocus && vim.active && !inDebugRepl && vim.mode != 'Insert'"
    }
]

$Home/.vimrc file

" Specify a directory for plugins
" - For Neovim: stdpath('data') . '/plugged'
" - Avoid using standard Vim directory names like 'plugin'
call plug#begin('~/.vim/plugged')

" Make sure you use single quotes

" Shorthand notation; fetches https://github.com/junegunn/vim-easy-align
Plug 'junegunn/vim-easy-align'

" Any valid git URL is allowed
Plug 'https://github.com/junegunn/vim-github-dashboard.git'
" Plug 'https://github.com/jiangmiao/auto-pairs.git'
" Plug 'https://github.com/tmsvg/pear-tree.git'
" Multiple Plug commands can be written in a single line using | separators
" Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'

" On-demand loading
Plug 'scrooloose/nerdtree', { 'on':  'NERDTreeToggle' }
Plug 'tpope/vim-fireplace', { 'for': 'clojure' }

" Using a non-default branch
Plug 'rdnetto/YCM-Generator', { 'branch': 'stable' }

"" Using a tagged release; wildcard allowed (requires git 1.9.2 or above)
"Plug 'fatih/vim-go', { 'tag': '*' }

" Plugin options
Plug 'nsf/gocode', { 'tag': 'v.20150303', 'rtp': 'vim' }

" Plugin outside ~/.vim/plugged with post-update hook
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }

" Unmanaged plugin (manually installed and updated)
Plug '~/my-prototype-plugin'

" Initialize plugin system
call plug#end()

set number
"set paste
set autoindent
set expandtab
set tabstop=4
set shiftwidth=4
set formatoptions-=cro

inoremap ( ()<ESC>i
inoremap [ []<ESC>i
inoremap { {}<ESC>i
inoremap < <><ESC>i
inoremap ' ''<ESC>i
inoremap " ""<ESC>i
gjherbiet commented 2 years ago

Same bug here.

settings.json:

{
    "editor.fontSize": 14,
    "editor.renderWhitespace": "boundary",
    "editor.cursorBlinking": "solid",
    "terminal.integrated.defaultLocation": "editor",
    "terminal.integrated.fontSize": 14,
    "terminal.integrated.lineHeight": 1.1,
    "ansible.ansible.path": "/opt/homebrew/bin/ansible",
    "ansible.ansibleLint.path": "/opt/homebrew/bin/ansible-lint",
    "ansibleVault.executable": "/opt/homebrew/bin/ansible-vault",
    "errorLens.onSave": true,
    "errorLens.gutterIconsEnabled": true,
    "errorLens.gutterIconSet": "defaultOutline",
    "errorLens.gutterIconSize": "auto",
    "errorLens.statusBarMessageEnabled": true,
    "errorLens.statusBarMessageType": "closestSeverity",
    "errorLens.statusBarMessageTemplate": "[$source] $severity: $message ($code)",
    "python.linting.flake8Enabled": true,
    "python.linting.mypyEnabled": true,
    "python.linting.pycodestyleEnabled": true,
    "python.linting.pydocstyleEnabled": true,
    "python.linting.pylintEnabled": true,
    "python.linting.banditEnabled": true,
    "python.linting.pydocstylePath": "/opt/homebrew/bin/pydocstyle",
    "python.linting.mypyPath": "/opt/homebrew/bin/mypy",
    "python.linting.pylintPath": "/opt/homebrew/bin/pylint",
    "python.linting.flake8Path": "/opt/homebrew/bin/flake8",
    "python.linting.banditPath": "/opt/homebrew/bin/bandit",
    "python.linting.pycodestylePath": "/opt/homebrew/bin/pycodestyle",
    "shellcheck.run": "onSave",
    "vim.showMarksInGutter": true,
    "vim.smartRelativeLine": true,
    "vim.statusBarColorControl": true,
    "vim.statusBarColors.normal": "#2470c7",
    "vim.statusBarColors.insert": "#005f5f",
    "vim.statusBarColors.visual": "#87592e",
    "vim.statusBarColors.visualblock": "#87592e",
    "vim.statusBarColors.visualline": "#87592e",
    "vim.statusBarColors.replace": "#cd3131",
    "vim.statusBarColors.commandlineinprogress": "#10a5cc",
    "vim.whichwrap": "b,s,<,>,[,]",
    "workbench.colorCustomizations": {
        "statusBar.background": "#87592e",
        "statusBar.noFolderBackground": "#87592e",
        "statusBar.debuggingBackground": "#87592e"
    },
}

keybindings.json:

[
    {
        "key":     "ctrl+`",
        "command": "workbench.action.terminal.focus"
    },
    {
        "key":     "ctrl+`",
        "command": "workbench.action.focusActiveEditorGroup",
        "when":    "terminalFocus"
    }
]

No .vimrc enabled.

gjherbiet commented 2 years ago

I have the impression that the following setting solves it:

"vim.startofline": false
mrdunk commented 1 year ago

@gjherbiet 's solution works for me. It works around the issue for both Home and End. I believe this should be the default behavior.

chrisjaquet commented 11 months ago

As an extra data point. I also experienced the issue but only on Linux not on Windows. My settings are synced across machines and setting "vim.startofline ": false does not appear to have an effect.

After disabling all extensions and commenting out all my settings the one that seemed to cause the strange behaviour was "vim.foldfix": true. Setting this to false seems to have fixed the issue in my case.

Extension Name: vscodevim
Extension Version: 1.26.1

VS Code Version: 1.83.1
Commit: f1b07bd25dfad64b0167beb15359ae573aecd2cc
Date: 2023-10-10T23:45:31.402Z
Electron: 25.8.4
ElectronBuildId: 24154031
Chromium: 114.0.5735.289
Node.js: 18.15.0
V8: 11.4.183.29-electron.0
OS: Linux x64 6.1.0-13-amd64
pboettch commented 10 months ago

In my environment, neither value foldfix nor startofline have an impact on this behavior.

Using home/end/page-down/up in insert-mode and then going back to visual moves the cursor back to where it was just before.

EDIT: it has an effect, but I had to restart vscode.

woldaker commented 4 months ago

This has been driving me crazy for weeks. Adding

"vim.startofline": false, "vim.foldfix": true

to my .vscode/settings.json file fixed it. No restart required. Thank you!