Vim 功能键突然改变了它们的映射
Vim function keys have suddenly changed their mappings
今天我的功能键都改变了它们的行为。
例如,F1
不再打开帮助,但等同于在正常模式下键入 OP
。也就是说,它在当前行上方打开一个新行,进入插入模式并键入 'P'。正如您在我的 .vimrc 中看到的那样,我唯一的功能键映射是 map <f2> :set rnu!<cr>
,直到今天它都运行良好。
F2
现在键入 <F2>
并进入替换模式,然后在退出替换模式之前按 <esc>
键入另一个 <F2>
。
F3
现在在上面打开一个新行,进入插入模式并输入 'P'
F5
一次改变5个连续字符的大小写
F6
到F10和F5功能类似,只是改变字符个数的大小写。
编辑:在插入模式下键入 <c-v><f1>
<c-v><f2>
... 等显示它们现在映射到 ^[OP
^[OR
^[OQ
等。 .但我仍然不知道如何或为什么
功能键在其他程序(gedit、firefox 等)中按预期工作,在不同的终端中打开 vim 也没有什么不同,这让我相信它纯粹是 vim问题。
这非常令人沮丧,因为我不知道从哪里开始解决这个问题,而且到目前为止我在网上找不到任何类似的问题。
重启电脑vim也没有效果..
"##############################################################################
"## d8b ##
"## Y8P ##
"## ##
"## 888 888 888 88888b.d88b. 888d888 .d8888b ##
"## 888 888 888 888 888 88b 888P" d88P" ##
"## Y88 88P 888 888 888 888 888 888 ##
"## d8b Y8bd8P 888 888 888 888 888 Y88b. ##
"## Y8P Y88P 888 888 888 888 888 "Y8888P ##
"## ##
"##############################################################################
"_____________________________________________________________________________
"#############################
"# General Settings
"#############################
"Disable Vi compatibility options
set nocompatible
"Set filetype detection on
filetype on
"Enable filetype plugins
filetype plugin on
"Show line numbers
set nu
"Show relative line numbers
set rnu
"Set tab character to → (unicode u2192)
"Set end of line character to ↲ (unicode u21b2)
set listchars=tab:→\ ,eol:↲
"Set tabstop, shift width, softtabstop
set ts=4 sw=4 sts=4
"Round indent (with > and < commands) to multiples of shiftwidth
set shiftround
"New split windows open on the right (vertical) and on the bottom (horizontal)
set splitbelow
set splitright
"Don't use swapfiles
set noswapfile
"No line wrapping
set nowrap
"Expand tab to spaces
set expandtab
"Set scroll offset
set scrolloff=8
"No search hilighting
set nohlsearch
"Display line and column number in the status bar
set ruler
"Fix fuzzy find:
set nocompatible "Limit search to working directory
set path+=** "Search all subdirectories recursively
set wildmenu "Shows multiple search results on one line
"Remove characters from window separators
set fillchars+=vert:\
"##############################
"# Key Mappngs
"##############################
"Set <leader> to spacebar
let mapleader=" "
"Easy escape
map <c-[> <esc>
"Easy quit/write
map <leader>q :q
map <leader>w :w
"Window split navigation
map <leader>h :wincmd h<cr>
map <leader>j :wincmd j<cr>
map <leader>k :wincmd k<cr>
map <leader>l :wincmd l<cr>
map <leader>H :wincmd H<cr>
map <leader>J :wincmd J<cr>
map <leader>K :wincmd K<cr>
map <leader>L :wincmd L<cr>
map <leader>T :wincmd T<cr>
map <leader>< :16wincmd <<cr>
map <leader>> :16wincmd ><cr>
map <leader>- :16wincmd -<cr>
map <leader>+ :16wincmd +<cr>
map <leader>= :wincmd =<cr>
"Argument navigation
map <leader>] :n<cr>
map <leader>[ :N<cr>
map <leader>a :arg<cr>
map <leader>0 :fir<cr>
map <leader>9 :las<cr>
"Tab navigation
map <leader>t :tabnew
"Set relative line numbers in netrw
let g:netrw_bufsettings = 'noma nomod rnu nobl nowrap ro'
"Window split in netrw open at 80% of window size
let g:netrw_winsize=80
"F2 toggles relative line numbers
map <f2> :set rnu!<cr>
"##############################
"# Plugins
"##############################
"vim-plug setup
call plug#begin('~/.vim/plugged')
"Plugins
Plug 'ap/vim-css-color'
Plug 'joshdick/onedark.vim'
Plug 'haishanh/night-owl.vim'
Plug 'tomasiser/vim-code-dark'
Plug 'itchyny/lightline.vim'
Plug 'itchyny/vim-gitbranch'
Plug 'jasonccox/vim-wayland-clipboard'
call plug#end()
"#############################
"# lightline settings
"#############################
"Set lightline colour theme and add git branch name to status bar
let g:lightline = {
\ 'colorscheme': 'onedark',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'gitbranch', 'readonly', 'filename', 'modified', 'buffernumber' ] ],
\ 'right': [ [ 'lineinfo' ],
\ [ 'percent' ],
\ [ 'fileformat', 'fileencoding', 'filetype', 'argumentnumber' ] ],
\ },
\ 'component_function': {
\ 'gitbranch': 'gitbranch#name'
\ },
\ 'component' : {
\ 'buffernumber': '%n',
\ 'argumentnumber': '%a'
\ },
\ }
"Fix for lightline not appearing for single windows
set laststatus=2
"Don't display mode at the bottom of the screen (not necessary due to lightline)
set noshowmode
"#############################
"# Colour settings
"#############################
"Use terminal colours
if (has ("termguicolors"))
set termguicolors
endif
"Fix for termguicolors making everything black and white
let &t_8f = "\<Esc>[38:2:%lu:%lu:%lum"
let &t_8b = "\<Esc>[48:2:%lu:%lu:%lum"
"Set syntax hilighting on
syntax on
"Set colour theme
colorscheme codedark
"Set transparent background (keep below colorscheme command)
hi Normal guibg=NONE ctermbg=NONE
hi EndOfBuffer guibg=NONE ctermbg=NONE
hi LineNr guibg=NONE ctermbg=NONE
hi Comment guibg=NONE ctermbg=NONE
"Set line numbers and comments colour to grey (keep below colorscheme command)
hi LineNr guifg=#999999 ctermfg=Grey
hi Comment guifg=#999999 ctermfg=Grey
Behviour 是由于我的 .vimrc
中的 <esc>
键映射,这似乎是不可取的。映射本身 map <c-[> <esc>
也是多余的,因为 <c-[>
默认情况下作为 <esc>
工作,至少在 US/GB 键盘上是这样。
在没有插件的情况下打开 vim 或 运行 vim -u NONE
的 .vimrc 有助于确定问题。
今天我的功能键都改变了它们的行为。
例如,F1
不再打开帮助,但等同于在正常模式下键入 OP
。也就是说,它在当前行上方打开一个新行,进入插入模式并键入 'P'。正如您在我的 .vimrc 中看到的那样,我唯一的功能键映射是 map <f2> :set rnu!<cr>
,直到今天它都运行良好。
F2
现在键入 <F2>
并进入替换模式,然后在退出替换模式之前按 <esc>
键入另一个 <F2>
。
F3
现在在上面打开一个新行,进入插入模式并输入 'P'
F5
一次改变5个连续字符的大小写
F6
到F10和F5功能类似,只是改变字符个数的大小写。
编辑:在插入模式下键入 <c-v><f1>
<c-v><f2>
... 等显示它们现在映射到 ^[OP
^[OR
^[OQ
等。 .但我仍然不知道如何或为什么
功能键在其他程序(gedit、firefox 等)中按预期工作,在不同的终端中打开 vim 也没有什么不同,这让我相信它纯粹是 vim问题。
这非常令人沮丧,因为我不知道从哪里开始解决这个问题,而且到目前为止我在网上找不到任何类似的问题。
重启电脑vim也没有效果..
"##############################################################################
"## d8b ##
"## Y8P ##
"## ##
"## 888 888 888 88888b.d88b. 888d888 .d8888b ##
"## 888 888 888 888 888 88b 888P" d88P" ##
"## Y88 88P 888 888 888 888 888 888 ##
"## d8b Y8bd8P 888 888 888 888 888 Y88b. ##
"## Y8P Y88P 888 888 888 888 888 "Y8888P ##
"## ##
"##############################################################################
"_____________________________________________________________________________
"#############################
"# General Settings
"#############################
"Disable Vi compatibility options
set nocompatible
"Set filetype detection on
filetype on
"Enable filetype plugins
filetype plugin on
"Show line numbers
set nu
"Show relative line numbers
set rnu
"Set tab character to → (unicode u2192)
"Set end of line character to ↲ (unicode u21b2)
set listchars=tab:→\ ,eol:↲
"Set tabstop, shift width, softtabstop
set ts=4 sw=4 sts=4
"Round indent (with > and < commands) to multiples of shiftwidth
set shiftround
"New split windows open on the right (vertical) and on the bottom (horizontal)
set splitbelow
set splitright
"Don't use swapfiles
set noswapfile
"No line wrapping
set nowrap
"Expand tab to spaces
set expandtab
"Set scroll offset
set scrolloff=8
"No search hilighting
set nohlsearch
"Display line and column number in the status bar
set ruler
"Fix fuzzy find:
set nocompatible "Limit search to working directory
set path+=** "Search all subdirectories recursively
set wildmenu "Shows multiple search results on one line
"Remove characters from window separators
set fillchars+=vert:\
"##############################
"# Key Mappngs
"##############################
"Set <leader> to spacebar
let mapleader=" "
"Easy escape
map <c-[> <esc>
"Easy quit/write
map <leader>q :q
map <leader>w :w
"Window split navigation
map <leader>h :wincmd h<cr>
map <leader>j :wincmd j<cr>
map <leader>k :wincmd k<cr>
map <leader>l :wincmd l<cr>
map <leader>H :wincmd H<cr>
map <leader>J :wincmd J<cr>
map <leader>K :wincmd K<cr>
map <leader>L :wincmd L<cr>
map <leader>T :wincmd T<cr>
map <leader>< :16wincmd <<cr>
map <leader>> :16wincmd ><cr>
map <leader>- :16wincmd -<cr>
map <leader>+ :16wincmd +<cr>
map <leader>= :wincmd =<cr>
"Argument navigation
map <leader>] :n<cr>
map <leader>[ :N<cr>
map <leader>a :arg<cr>
map <leader>0 :fir<cr>
map <leader>9 :las<cr>
"Tab navigation
map <leader>t :tabnew
"Set relative line numbers in netrw
let g:netrw_bufsettings = 'noma nomod rnu nobl nowrap ro'
"Window split in netrw open at 80% of window size
let g:netrw_winsize=80
"F2 toggles relative line numbers
map <f2> :set rnu!<cr>
"##############################
"# Plugins
"##############################
"vim-plug setup
call plug#begin('~/.vim/plugged')
"Plugins
Plug 'ap/vim-css-color'
Plug 'joshdick/onedark.vim'
Plug 'haishanh/night-owl.vim'
Plug 'tomasiser/vim-code-dark'
Plug 'itchyny/lightline.vim'
Plug 'itchyny/vim-gitbranch'
Plug 'jasonccox/vim-wayland-clipboard'
call plug#end()
"#############################
"# lightline settings
"#############################
"Set lightline colour theme and add git branch name to status bar
let g:lightline = {
\ 'colorscheme': 'onedark',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'gitbranch', 'readonly', 'filename', 'modified', 'buffernumber' ] ],
\ 'right': [ [ 'lineinfo' ],
\ [ 'percent' ],
\ [ 'fileformat', 'fileencoding', 'filetype', 'argumentnumber' ] ],
\ },
\ 'component_function': {
\ 'gitbranch': 'gitbranch#name'
\ },
\ 'component' : {
\ 'buffernumber': '%n',
\ 'argumentnumber': '%a'
\ },
\ }
"Fix for lightline not appearing for single windows
set laststatus=2
"Don't display mode at the bottom of the screen (not necessary due to lightline)
set noshowmode
"#############################
"# Colour settings
"#############################
"Use terminal colours
if (has ("termguicolors"))
set termguicolors
endif
"Fix for termguicolors making everything black and white
let &t_8f = "\<Esc>[38:2:%lu:%lu:%lum"
let &t_8b = "\<Esc>[48:2:%lu:%lu:%lum"
"Set syntax hilighting on
syntax on
"Set colour theme
colorscheme codedark
"Set transparent background (keep below colorscheme command)
hi Normal guibg=NONE ctermbg=NONE
hi EndOfBuffer guibg=NONE ctermbg=NONE
hi LineNr guibg=NONE ctermbg=NONE
hi Comment guibg=NONE ctermbg=NONE
"Set line numbers and comments colour to grey (keep below colorscheme command)
hi LineNr guifg=#999999 ctermfg=Grey
hi Comment guifg=#999999 ctermfg=Grey
Behviour 是由于我的 .vimrc
中的 <esc>
键映射,这似乎是不可取的。映射本身 map <c-[> <esc>
也是多余的,因为 <c-[>
默认情况下作为 <esc>
工作,至少在 US/GB 键盘上是这样。
在没有插件的情况下打开 vim 或 运行 vim -u NONE
的 .vimrc 有助于确定问题。