@@ -7,6 +7,7 @@ python << endpython
7
7
import vim
8
8
import re
9
9
10
+ reg_to_use = ' z' #' +'
10
11
11
12
def run_visual_code ():
12
13
" ""
@@ -36,7 +37,7 @@ def run_visual_code():
36
37
lines += " \n "
37
38
38
39
# register might need to be set as * instead of +
39
- vim .command (" :let @*='%s' " % ( lines .replace (" '" , " ''" )))
40
+ vim .command (" :let @{0}='{1}' " . format (reg_to_use, lines .replace (" '" , " ''" )))
40
41
vim .command (' :call VimuxRunCommand("%paste\n", 0)' )
41
42
42
43
elif use_cpaste:
@@ -61,7 +62,7 @@ def run_visual_code():
61
62
# Shift the whole text by nindent spaces (so the first line has 0 indent )
62
63
if nindent > 0 :
63
64
pat = ' \s' * nindent
64
- lines = " \n " .join ([re .sub (' ^%s ' % pat, ' ' , l ) for l in lines ])
65
+ lines = " \n " .join ([re .sub (' ^{0} ' . format ( pat) , ' ' , l ) for l in lines ])
65
66
#print ' -----------------'
66
67
#print lines
67
68
else :
@@ -72,15 +73,15 @@ def run_visual_code():
72
73
lines += " \n "
73
74
74
75
vim .command (' :call VimuxRunCommand("%cpaste\n", 0)' )
75
- vim .command (' :call VimuxRunCommand("%s ", 0)' % lines )
76
+ vim .command (' :call VimuxRunCommand("{0} ", 0)' . format ( lines ) )
76
77
vim .command (' :call VimuxRunCommand("\n--\n", 0)' )
77
78
78
79
elif use_raw:
79
80
# NOTE doesn't work well
80
81
lines = " \n " .join (lines )
81
82
lines += " \n "
82
- vim .command (" let @+='%s' " % ( lines .replace (" '" , " ''" )))
83
- vim .command (' :call VimuxSendText(@+) ' )
83
+ vim .command (" let @{0}='{1}' " . format (reg_to_use, lines .replace (" '" , " ''" )))
84
+ vim .command (' :call VimuxSendText(@{0}) ' . format (reg_to_use) )
84
85
85
86
elif use_register_with_cpaste:
86
87
# works
@@ -96,16 +97,16 @@ def run_visual_code():
96
97
# Shift the whole text by nindent spaces (so the first line has 0 indent )
97
98
if nindent > 0 :
98
99
pat = ' \s' * nindent
99
- lines = " \n " .join ([re .sub (' ^%s ' % pat, ' ' , l ) for l in lines ])
100
+ lines = " \n " .join ([re .sub (' ^{0} ' . format ( pat) , ' ' , l ) for l in lines ])
100
101
else :
101
102
lines = " \n " .join (lines )
102
103
103
104
104
105
# Add empty newline at the end
105
106
lines += " \n "
106
- vim .command (" let @+='%s' " % ( lines .replace (" '" , " ''" ))) #doesn't work w /o this
107
+ vim .command (" let @{0}='{1}' " . format (reg_to_use, lines .replace (" '" , " ''" ))) #doesn't work w /o this
107
108
vim .command (' :call VimuxRunCommand("%cpaste\n", 0)' )
108
- vim .command (' :call VimuxSendText(@+) ' )
109
+ vim .command (' :call VimuxSendText(@{0}) ' . format (reg_to_use) )
109
110
vim .command (' :call VimuxRunCommand("\n--\n", 0)' )
110
111
111
112
# Move cursor to the end of the selection
@@ -120,27 +121,27 @@ def run_cell(save_position=False, cell_delim='####'):
120
121
121
122
The cell_delim arg can be set such that it is the same as what the
122
123
iPython notebook uses to delimit its code cells (cell_delim= ' # <codecell>' )
123
- Thus, if cells are seperated with this, then the script can be uploaded &
124
- opened as an iPython notebook, and the iPython NB environment will
125
- recognize the delimited cell blocks. NOTE, in order for this to work,
124
+ Thus, if cells are seperated with this, then the script can be opened
125
+ as an iPython notebook and the iPython NB environment will recognize
126
+ the delimited cell blocks. NOTE, in order for this to work,
126
127
the first thing at the top of the script needs to be:
127
128
# <nbformat> 3 </nbformat>
128
129
129
130
(http:// ipython.org/ipython-doc/ stable/interactive/ htmlnotebook.html#the- notebook- format)
130
131
131
- The :?% s ?;/%s / part creates a range by:
132
- ?% s ? searches backwards for the cell_delim,
132
+ The :?{ 0 } ?;/{0} / part creates a range by:
133
+ ?{ 0 } ? searches backwards for the cell_delim,
133
134
then the ' ;' starts the range from the result of the
134
135
previous search (cell_delim) to the end of the
135
- range at /%s / (the next cell_delim).
136
+ range at /{0} / (the next cell_delim).
136
137
" ""
137
138
138
139
if save_position:
139
140
# Save cursor position
140
141
(row, col ) = vim .current.window .cursor
141
142
142
143
# Run chunk on cell range
143
- vim .command (' :?%s ?;/%s / :python run_visual_code()' % (cell_delim, cell_delim))
144
+ vim .command (' :?{0} ?;/{0} / :python run_visual_code()' . format ( cell_delim))
144
145
145
146
# this clears the highlighting from the delim search
146
147
vim .command (' :noh' )
@@ -173,6 +174,10 @@ function! VimuxIpy(...)
173
174
" Interrupt any command running in the runner pane
174
175
map <Leader> vq :VimuxInterruptRunner<CR>
175
176
177
+ " Zoom the tmux runner page
178
+ " also, need to use tmux bind-key + z to restore the runner pane.
179
+ " map <Leader>vz :VimuxZoomRunner<CR>
180
+
176
181
" Change pane height
177
182
let g: VimuxHeight = " 35"
178
183
0 commit comments