preservim / vimux

easily interact with tmux from vim
MIT License
2.2k stars 160 forks source link

Remember autoreturn setting #37

Closed abstiles closed 12 years ago

abstiles commented 12 years ago

Create a new variable "_VimTmuxCmdAutoreturn" which remembers the value of the autoreturn parameter used by the last invocation of VimuxRunCommand or RunVimTmuxCommand. Use this parameter in the VimuxRunLastCommand function.

benmills commented 12 years ago

Thanks for the pull request. Could you explain a more detailed use case for this feature?

abstiles commented 12 years ago

I find myself using Vimux to send snippets of python code to an IPython session. If I highlight a block of code using line-wise visual selection, then send it to the runner pane with a mapping to the function VimuxRunCommand, I get an extra "return" sent to IPython (one from the newline at the end of the selection, and another from the autoreturn). The extra blank line can be significant to IPython (it denotes the end of a block of code). My mapping is set to pass 0 to VimuxRunCommand to avoid this extra return, and therefore not include any additional blank lines that I may not want.

The problem is that when I use a mapping to run the VimuxRunLastCommand function, it always adds the autoreturn, since the setting is not remembered from the last call to VimuxRunCommand. The fact that VimuxRunLastCommand does not exactly reproduce the last command (by adding the autoreturn) was unexpected behavior to me as a user. By saving the autoreturn setting, VimuxRunLastCommand will always have the exact same behavior as specified by the last call to VimuxRunCommand.