-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mapping <cr> #43
Comments
Rather than an option, how about if pencil declines to override an existing mapping, if one is present? I'm curious, how have you remapped CR in Insert mode? |
Sure, that would work, if it doesn't break Pencil. I didn't look into it much, but I couldn't figure out what you map I actually have more than one mapping for |
I'm trying out the change locally. If it looks good I'll post in the next few days. |
Great, thank you! |
This should have been a single, properly-labeled, commit, but was three. Nevertheless it should be working. Please give it a try and let me know if it respects your existing |
Uhm, weird… Here's what happens without pencil: A first Now if I use Pencil and do the same thing, here's what happens: I just start writing the next item and the line is joined with the previous one. Maybe my code for doing all this is less than ideal, but still it seems like Pencil is messing with something it shouldn't mess with, right? If it matters, this is my mapping that causes the problem: function! CROrUncomment()
for comment in map(split(&l:comments, ','),
\ 'substitute(v:val, "^.\\{-}:", "", "")')
if getline('.') =~ '\V' . escape(comment, '\') . ' \$'
return repeat("\<BS>", strchars(comment) + 1)
endif
endfor
return "\<cr>"
endfunction
inoremap <expr> <CR> CROrUncomment() The problem happens with any comment character, tapping |
That looks like autoformat behavior. As mentioned in the README, Pencil will typically enable Vim's autoformat when entering Insert mode. This is normally a good thing, as we want text to automatically wrap. Because autoformat isn't always desired, such as with code blocks, pencil has a blacklisting mechanism which looks at the highlight group that the cursor is in (or near). SO, with my config, the text of the I don't know offhand how You can define your own blacklist to override the default at https://github.com/reedes/vim-pencil/blob/master/plugin/pencil.vim#L74-L114 |
I'm sorry for the delay, I couldn't look into it until now. 'tex': {
\ 'black': [
\ 'tex(BeginEndName|Delimiter|DocType|InputFile|Math|RefZone|Title)',
\ 'texSection$',
\ ],
\ 'enforce-previous-line': 1,
\ } to 'tex': {
\ 'black': [
\ 'tex(BeginEndName|Delimiter|DocType|InputFile|Math|RefZone|Title)',
\ 'texSection$',
\ 'texDocZone',
\ ],
\ 'enforce-previous-line': 1,
\ } Is that what I was supposed to do? It didn't work. |
With the change you made, if you enter insert mode from a cursor position in a To determine highlight group for the blacklists, I use a function key mapping... nmap <F9> :call <SID>SynStack()<CR>
function! <SID>SynStack()
if !exists("*synstack")
return
endif
echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
endfunc Give that a try to see if |
Aha, the highlight group was |
For others, if this degrades pencil's usefulness with tex filetype, please let me know. We can dig in further to find a better solution. |
Hello,
I really want to use Pencil, but it breaks my own mapping of
<cr>
. Could add an option to change or disable the default mappings?The text was updated successfully, but these errors were encountered: