Vim: insertion issue: reassignments (imap) and abbreviations (ab) in .vimrc do not work

I have a problem in vim: If I modify the .vimrc file and add the following lines:

map ;bb A78

It only works in normal mode. If I received it, it should also work in insert mode, right? During editing, I checked that everything was read correctly (command ": map"):

i  ;bb           A78

If I do the same with "imap", I have the same problem: the command ": imap" shows that it is configured, but if I go into insert mode and type "; bb" or "; bb" or "bb" ,; bb "nothing has changed, I don't get A78

What am I missing? (And the wonderful codeSnippet plugin only works in normal mode, which is a big problem for me)

If you forgot exactly: I only have the Tabularize plugin, it is vim version 7.3 under cygwin, but I get the same problem in SSH / Linux Debian / vim version 7.0

If I try to do exactly what is written here (to give another attempt, if this can help), this also does not work: "To use the abbreviation, switch to Insert mode and enter th followed by any spaces above (space, tab or carriage return). " not working at all. It drives me crazy.

Here is my .vimrc file, maybe something is wrong, I have not seen:

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$"))

Thank you so much!

+3
source share
2 answers

You need to make sure that vim is not in insert mode.

Try

:set nopaste
+7
source

map : map!. . :help :map! .

imap , , , "". , ( , 1 ), , , . , :

:map! ;bb A78

:

;<pause>bb

( <pause> - , , )

;bb, :

;bb

, A78.

-, :

:help 'timeout'
:help 'ttimeout'
:help 'timeoutlen'
:help 'ttimeoutlen'

'paste' : . :set paste?, , :set nopaste, .

:

:help 'paste'
+2

Source: https://habr.com/ru/post/1788490/


All Articles