我在vim中遇到问题:如果我修改.vimrc文件并添加以下行:
map ;bb A78
Run Code Online (Sandbox Code Playgroud)
它只是在正常模式下工作.如果我得到它,它也应该在插入模式下工作,不应该吗?编辑时,我已经确认所有内容都已正确读取(命令":map"):
i ;bb A78
Run Code Online (Sandbox Code Playgroud)
如果我用"imap"执行相同的操作,我遇到了同样的问题:命令":imap"显示它已配置,但如果我进入插入模式,并键入"; bb"或"; bb"或"; bb"什么都没有改变,我没有得到A78
我错过了什么?(而且奇妙的codeSnippet插件也只能在正常模式下工作,这对我来说是个大问题)
如果忘了精确:我只有插件Tabularize,它是cygwin下的vim版本7.3,但我在SSH/Linux Debian/vim 7.0版中遇到同样的问题
如果我尝试完全按照这里所写的内容(如果它可能会有帮助的话再次尝试),那也不起作用:"要使用缩写,切换到插入模式并输入th,然后输入上面的任何空格(空格,标签或回车)." 不工作在所有.这让我疯狂.
这是我的.vimrc文件,也许这里有什么问题我没看到:
set nocompatible
filetype plugin on
syntax enable
set ignorecase
set paste
set ruler
set modeline
set showcmd
set expandtab
set tabstop=2
set autoindent
set smartindent
set number
colorscheme desert
set vb t_vb=
set backup
set backupdir=~/.vim/backup
set directory=~/.vim/tmp
set fileencodings=utf-8,ucs-bom,default,latin1
set scrolloff=5
set undolevels=1000
nmap ;bw :. w! ~/.vimxfer<CR>
nmap ;br :r ~/.vimxfer<CR>
nmap ;ba :. w! >>~/.vimxfer<CR>
" Tell vim to remember certain things when we exit
" '10 : marks will be remembered for up to 10 previously edited files
" "100 : will save up to 100 lines for each register
" :20 : up to 20 lines of command-line history will be remembered
" % : saves and restores the buffer list
" n... : where to save the viminfo files
set viminfo='10,\"100,:20,%,n~/.viminfo
" when we reload, tell vim to restore the cursor to the saved position
augroup JumpCursorOnEdit
au!
autocmd BufReadPost *
\ if expand("<afile>:p:h") !=? $TEMP |
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ let JumpCursorOnEdit_foo = line("'\"") |
\ let b:doopenfold = 1 |
\ if (foldlevel(JumpCursorOnEdit_foo) > foldlevel(JumpCursorOnEdit_foo - 1)) |
\ let JumpCursorOnEdit_foo = JumpCursorOnEdit_foo - 1 |
\ let b:doopenfold = 2 |
\ endif |
\ exe JumpCursorOnEdit_foo |
\ endif |
\ endif
" Need to postpone using "zv" until after reading the modelines.
autocmd BufWinEnter *
\ if exists("b:doopenfold") |
\ exe "normal zv" |
\ if(b:doopenfold > 1) |
\ exe "+".1 |
\ endif |
\ unlet b:doopenfold |
\ endif
augroup END
set backspace=2
inoremap <silent> <Bar> <Bar><Esc>:call <SID>align()<CR>a
function! s:align()
let p = '^\s*|\s.*\s|\s*$'
if exists(':Tabularize') && getline('.') =~# '^\s*|' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p)
let column = strlen(substitute(getline('.')[0:col('.')],'[^|]','','g'))
let position = strlen(matchstr(getline('.')[0:col('.')],'.*|\s*\zs.*'))
Tabularize/|/l1
normal! 0
call search(repeat('[^|]*|',column).'\s\{-\}'.repeat('.',position),'ce',line('.'))
endif
endfunction
:autocmd BufNewFile * silent! 0r ~/.vim/templates/%:e.tpl
:autocmd BufNewFile *.php call search('w', '', line("w$"))
Run Code Online (Sandbox Code Playgroud)
非常感谢!
您需要确保vim不处于"粘贴"模式.
尝试
:set nopaste
Run Code Online (Sandbox Code Playgroud)