New answers tagged

2

Without the yr mapping (or any other mapping that starts with y), the code does not work. Why? That's because you're calling feedkeys() with the 'x' option, which will also process the typeahead buffer. So you need the next keypress to be in that buffer in order to execute the full command. For example, if you type yG, you need the G to be on the buffer at ...


1

I have this since 2002 it seems It also handles <end> key inoremap <silent> <Home> <c-o>@=<SID>HomeLikeVCpp()<cr> nnoremap <silent> <Home> @=<SID>HomeLikeVCpp()<cr> vnoremap <silent> <Home> @=<SID>HomeLikeVCpp()<cr> inoremap <silent> <End> <c-\><c-n>...


0

This is what I came up with. It is not as short as other options, but seems to do the job: func F_home() let n_ind = indent(line('.')) let n_col = col('.') - 1 if n_col > n_ind normal ^ else normal 0 endif return '' endfunc nmap <Home> :call F_home()<CR> imap <Home> <C-R>=F_home()<CR>


1

Yes, it is possible to create a mapping for that. For example, a mapping that will go to the indent if you're elsewhere in the line, but go to the first character if you're on the indent: noremap <expr> <Home> col('.') == match(getline('.'), '\S') + 1 ? "\<Home>" : "^" inoremap <expr> <Home> col('.') == match(getline('.'), '\...


2

I feel like this is all overly complicated, you can realize this with just a few lines of regex: s/<\(\w\+\)>\%#/&<\/\1>/g This expression will allow you to add a closing tag after the cursor: - < matches the start of the opening tag - \w\+ matches the tag content, we include it in braces so that we can use it in the replacement - > ...


Top 50 recent answers are included