Vim 我怎么才能在一条直线中间输入一条直线?

Vim 我怎么才能在一条直线中间输入一条直线?,vim,Vim,在Vim中,如何用换行符打断文本行 例如,我处于INSERT模式,我想从这里开始 $('#toggle_contact_search_mode').click([CURSOR IS HERE]); 到这里 $('#toggle_contact_search_mode').click( [CURSOR IS HERE] ); 我得到的结果是,当我在插入模式,我有光标在上面的第一个位置,我点击返回 Vim进入正常模式 带有光标的行滚动到屏幕底部 整个文件中的代码重新格式化不正确。例如,在文

在Vim中,如何用换行符打断文本行

例如,我处于
INSERT
模式,我想从这里开始

$('#toggle_contact_search_mode').click([CURSOR IS HERE]);
到这里

$('#toggle_contact_search_mode').click(
  [CURSOR IS HERE]
);
我得到的结果是,当我在插入模式,我有光标在上面的第一个位置,我点击返回

  • Vim进入正常模式
  • 带有光标的行滚动到屏幕底部
  • 整个文件中的代码重新格式化不正确。例如,在文件的另一部分中,代码的格式如下所示:

我根本不想重新格式化。我只希望Vim只输入一个换行符并保持插入模式


更新

当我临时删除
.vimrc
文件时,Vim的行为与预期一致。我的
.vimrc

" ==================================================================================
" Global stuff
" ==================================================================================

" Prevent Vim from emulating vi bugs and limitations
:set nocompatible

" Custom status line based on one from here:
" http://www.linux.com/archive/feature/120126
:set statusline=\ \ %f\ \ [FORMAT=%{&ff}]\ \ [TYPE=%Y]\ \ [POS=%04l,%04v][%p%%]\ \ [LEN=%L]

" Set status line colors
highlight StatusLine term=reverse ctermfg=DarkBlue ctermbg=Grey

" Set status line to be shown above the command buffer.
:set laststatus=2

" Enable syntax highlighting
:syntax on

" Enable line numbering, taking up 6 spaces
:set number

" Allow <BkSpc> to delete line breaks, beyond the start of the current
" insertion, and over indentations
" set backspace=eol,start,indent

" ==================================================================================
" Searching
" ==================================================================================

" Highlight matches as you type in the search string
:set incsearch
:set showmatch

" When searching ignore case (except explicit caps)
:set ignorecase
:set smartcase

" ==================================================================================
" Indenting
" ==================================================================================

" Copy indent from current line when starting a new line
" :set autoindent
"
" :set smartindent

" :filetype plugin on

" indent depends on filetype
" :filetype indent on

:set tabstop=2
:set softtabstop=2
:set shiftwidth=2
:set expandtab

" ==================================================================================
" Mappings
" ==================================================================================

" ESC
imap <C-k> <ESC>

" Go to the next tab
nmap <C-j> gt
imap <C-j> <ESC>gt

" Auto indent entire file.
" Sets a mark ("mt""), moves across the whole file to indent it ("gg=G"), 
" then returns to the mark ("'t").
nmap <C-m> mtgg=G't
imap <C-m> <ESC><C-m>
”==================================================================================
“全球的东西
" ==================================================================================
“防止Vim模拟vi缺陷和限制
:设置不兼容
“基于此处的自定义状态行:
" http://www.linux.com/archive/feature/120126
:set statusline=\\%f\\[FORMAT=%{&ff}]\\[TYPE=%Y]\\[POS=%04l,%04v][%p%%]\\[LEN=%L]
“设置状态行颜色
高亮显示状态行项=反向字符MFG=暗蓝色字符MBG=灰色
“将状态行设置为显示在命令缓冲区上方。
:set laststatus=2
“启用语法突出显示
:语法打开
“启用行编号,占用6个空格
:设定号码
“允许删除当前文件开头以外的换行符
“插入和超缩进
“设置退格=下线、开始、缩进
" ==================================================================================
“搜索
" ==================================================================================
“键入搜索字符串时突出显示匹配项
:在搜索中设置
:设置showmatch
“搜索时忽略大小写(明确大写除外)
:设置ignorecase
:设置smartcase
" ==================================================================================
“缩进
" ==================================================================================
“开始新行时从当前行复制缩进
“:设置自动缩进
"
“:设置智能缩进
“:上的文件类型插件
“缩进取决于文件类型
“:上的文件类型缩进
:设置tabstop=2
:设置softtabstop=2
:设置shiftwidth=2
:设置展开选项卡
" ==================================================================================
“映射
" ==================================================================================
“ESC
imap
“转到下一个选项卡
nmap燃气轮机
imap燃气轮机
“自动缩进整个文件。
设置标记(“mt”),在整个文件中移动以缩进它(“gg=G”),
然后返回到标记('t')。
nmap mtgg=G't
imap

看起来你的.vimrc中的imap行把你搞砸了。在插入模式下进行映射只是为了让它像正常模式映射那样工作似乎很奇怪。你确定你真的想这样吗?我建议考虑删除最后两条imap行(c-j和c-m),看看你是否注意到它们消失了。

你的问题是
imap
映射——control-M在逻辑上等同于进入终端。

我不知道VIM,但Ctrl+M在记事本中工作——你可以试试。

我根本看不到这种行为。当我在描述的位置按return键时,我得到一条带有“;”的新行在它上面,仍然处于插入模式。另外,你能移动你的.vimrc并用纯默认设置再试一次吗?如果这解决了问题,你能发布你的.vimrc的内容吗?如果不能,你能列出你的系统、vim的版本等吗?输入^J也相当于在终端上按enter键。通常,映射其中任何一个都不是gre在idea。哈哈,这回答了我经历的一个古老的怪诞。我已经将C-m映射为“make”,并且想知道为什么有时候当我按enter键时会出现make。
" ==================================================================================
" Global stuff
" ==================================================================================

" Prevent Vim from emulating vi bugs and limitations
:set nocompatible

" Custom status line based on one from here:
" http://www.linux.com/archive/feature/120126
:set statusline=\ \ %f\ \ [FORMAT=%{&ff}]\ \ [TYPE=%Y]\ \ [POS=%04l,%04v][%p%%]\ \ [LEN=%L]

" Set status line colors
highlight StatusLine term=reverse ctermfg=DarkBlue ctermbg=Grey

" Set status line to be shown above the command buffer.
:set laststatus=2

" Enable syntax highlighting
:syntax on

" Enable line numbering, taking up 6 spaces
:set number

" Allow <BkSpc> to delete line breaks, beyond the start of the current
" insertion, and over indentations
" set backspace=eol,start,indent

" ==================================================================================
" Searching
" ==================================================================================

" Highlight matches as you type in the search string
:set incsearch
:set showmatch

" When searching ignore case (except explicit caps)
:set ignorecase
:set smartcase

" ==================================================================================
" Indenting
" ==================================================================================

" Copy indent from current line when starting a new line
" :set autoindent
"
" :set smartindent

" :filetype plugin on

" indent depends on filetype
" :filetype indent on

:set tabstop=2
:set softtabstop=2
:set shiftwidth=2
:set expandtab

" ==================================================================================
" Mappings
" ==================================================================================

" ESC
imap <C-k> <ESC>

" Go to the next tab
nmap <C-j> gt
imap <C-j> <ESC>gt

" Auto indent entire file.
" Sets a mark ("mt""), moves across the whole file to indent it ("gg=G"), 
" then returns to the mark ("'t").
nmap <C-m> mtgg=G't
imap <C-m> <ESC><C-m>