ctrlpvim / ctrlp.vim

Active fork of kien/ctrlp.vim—Fuzzy file, buffer, mru, tag, etc finder.
ctrlpvim.github.com/ctrlp.vim
Other
5.57k stars 261 forks source link

Read-only mode for file open? #397

Open Roy-Orbison opened 7 years ago

Roy-Orbison commented 7 years ago

I normally do view <somefile> or (vert|tab) sv <somefile> when looking at library code, or anything else I don't want to make changes to. I don't see a way to do that in CtrlP. Perhaps a MarkToOpenRO() function that is toggled by another ctrl sequence (are there any left?) such that it applies to opening both single files, and multiple files (implying MarkToOpen() in that case).

mattn commented 7 years ago

MarkToOpen and MarkToOpenRO are possibly mixed. It is hard to implement another sign or marker which mean read-only. How about simply add modifier r for e on AcceptSelection like below?

'AcceptSelection("re")'
Roy-Orbison commented 7 years ago

I'm not good at vim scripts, but it looks like it could be easier to set a flag (perhaps by commandeering the <c-g> mapping) that invokes alternate commands in ctrlp#acceptfile(), and gets reset after any open action or the CtrlP window is closed. Looks like s:AcceptSelection() is fairly involved and already looks for an r char in the action parameter.