gpt4 book ai didi

vim - 如何在行的中间输入换行符?

转载 作者:行者123 更新时间:2023-12-02 09:00:25 25 4
gpt4 key购买 nike

在 Vim 中,如何用换行符分隔文本行?

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

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

到这里...

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

我得到的结果是,当我处于插入模式并且光标位于上面的第一个位置并按回车键时...

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

$('.edit_phone_number').ajaxForm({
success: function(response) {
$('input, select, textarea', '.edit_phone_number').removeClass('updating');
}
});

$('input, select, textarea', '.edit_phone_number').focus(function(event) {
$(event.target).removeClass('updating').addClass('focussed');
});

我根本不想进行任何重新格式化。我只想让 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>

最佳答案

您的问题是imap <C-m>映射——control-M 在逻辑上等同于在终端上输入。

关于vim - 如何在行的中间输入换行符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1652416/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com