Skip to content

Commit 5cfb2db

Browse files
committed
Add map to %run with -n flag
1 parent 26f4ca6 commit 5cfb2db

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

ftplugin/python/ipy.vim

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ augroup END
147147

148148
" Setup plugin mappings for the most common ways to interact with ipython.
149149
noremap <Plug>(IPython-RunFile) :update<CR>:Python2or3 run_this_file()<CR>
150+
noremap <Plug>(IPython-ImportFile) :update<CR>:Python2or3 run_this_file('-n')<CR>
150151
noremap <Plug>(IPython-RunLine) :Python2or3 run_this_line()<CR>
151152
noremap <Plug>(IPython-RunLines) :Python2or3 run_these_lines()<CR>
152153
noremap <Plug>(IPython-OpenPyDoc) :Python2or3 get_doc_buffer()<CR>
@@ -168,6 +169,7 @@ function! s:DoMappings()
168169
if g:ipy_perform_mappings != 0
169170
if &buftype == ''
170171
map <buffer> <silent> <F5> <Plug>(IPython-RunFile)
172+
map <buffer> <silent> g<F5> <Plug>(IPython-ImportFile)
171173
endif
172174
" map <buffer> <silent> <S-F5> <Plug>(IPython-RunLine)
173175
map <buffer> <silent> <F9> <Plug>(IPython-RunLines)

ftplugin/python/vim_ipython.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -621,15 +621,15 @@ def f_with_update(*args, **kwargs):
621621
return f_with_update
622622

623623
@with_subchannel
624-
def run_this_file():
624+
def run_this_file(flags=''):
625625
ext = os.path.splitext(vim.current.buffer.name)[-1][1:]
626626
if ext in ('pxd', 'pxi', 'pyx', 'pyxbld'):
627627
cmd = ' '.join(filter(None, (
628628
'%run_cython',
629629
vim_vars.get('cython_run_flags', ''),
630630
repr(vim.current.buffer.name))))
631631
else:
632-
cmd = '%%run %s %s' % (vim_vars['ipython_run_flags'],
632+
cmd = '%%run %s %s' % (flags or vim_vars['ipython_run_flags'],
633633
repr(vim.current.buffer.name))
634634
msg_id = send(cmd)
635635
print_prompt(cmd, msg_id)

0 commit comments

Comments
 (0)