Giter Club home page Giter Club logo

Comments (8)

alerque avatar alerque commented on September 25, 2024 2

Thanks for the report. I've actually run into this myself but never managed to track down what is causing it even as far as you have. I don't have the bandwidth to sit and mess with it right now, but if anybody does have ideas and finds this a PR would be welcome!

I don't typically turn Pencil on or off except once based on the file type on open so this is rare, but I have noted that g prefixed motions are occasionally getting screwed up.

from vim-pencil.

evantravers avatar evantravers commented on September 25, 2024 1

I have always had this problem as well. The only nuance I have:

If you enter pencil mode :PencilSoft and then leave :PencilOff… if you enter it again :PencilSoft the mappings are broken… if you leave the second time and re-enter a third time… the mappings are restored!

It's always alternate… the solution has been for me to quickly "restart" it, but I've never been able to track down why the mappings break the second time.

from vim-pencil.

pooriajr avatar pooriajr commented on September 25, 2024

No worries!

For me, the use case is that I want to have a "Prose Mode" in vim that is tied to when I enter/leave the Goyo mode from goyo.vim

And when using Goyo, there are a lot of reasons to switch in and out, so Pencil was getting toggled a lot.

For anyone else who might be wanting to do the same, my solution was to drop pencil and manually set up/tear down the mappings and settings I want, like so:

function! StartProse()
  setlocal linebreak
  setlocal wrap
  nnoremap <buffer> j gj
  nnoremap <buffer> k gk
  inoremap <buffer> . .<c-g>u
  inoremap <buffer> ! !<c-g>u
  inoremap <buffer> ? ?<c-g>u
  inoremap <buffer> , ,<c-g>u
  inoremap <buffer> ; ;<c-g>u
  inoremap <buffer> : :<c-g>u
endfunction

function! StopProse()
  setlocal nolinebreak
  setlocal nowrap
  unmap <buffer> j
  unmap <buffer> k
  iunmap <buffer> .
  iunmap <buffer> !
  iunmap <buffer> ?
  iunmap <buffer> ,
  iunmap <buffer> ;
  iunmap <buffer> :
endfunction

autocmd! User GoyoEnter nested call StartProse()
autocmd! User GoyoLeave nested call StopProse()

from vim-pencil.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.