pabo
pabo

Reputation: 635

How to -enable- vim's "Press ENTER or type command to continue"

There are lots of questions on here about how to disable the "Press ENTER or type command to continue" text when running an external command from vim. But I want to know how to enable it. As you can see below, I'm not using silent or any other means to disable it.

Here is the relevant portion of my .vimrc:

nmap <leader>r :call NoFrills()<CR>     "(r)eveal hidden chars
nmap <leader>i :set paste!<CR>          "(i)ndenting on/off
nmap <leader>h :set nohlsearch!<CR>     "(h)ighlighting of search terms on/off
nmap <leader>w :call SudoWrite()<CR>    "(w)rite file, sudoing first
nmap <leader>a :! sudo service httpd restart<CR>"(a)pache restart
nmap <leader>p :! perl -c %<CR>         "(p)erl -c

When I execute a command that should have output, like with the key sequence \ p, the command executes but any output is quickly dismissed from the screen without pausing or prompting me to continue. Why is that?

If I execute :! perl -c % from vim's command mode, it shows me the output and prompts me to continue, as expected.

:version
VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Feb 17 2012 10:23:31)

:set
--- Options ---
  background=dark     filetype=perl       incsearch           scrolloff=3         ttyfast
  comments=:#         helplang=en         list                shiftwidth=4        ttymouse=xterm
  commentstring=#%s   history=50          number              syntax=perl         viminfo='20,"50
  define=[^A-Za-z_]   hlsearch            ruler               tabstop=4           wildmenu
  backspace=indent,eol,start
  complete=.,w,b,u,t,i,k
  fileencoding=utf-8
  fileencodings=ucs-bom,utf-8,latin1
  formatoptions=tcrq
  guicursor=n-v-c:block,o:hor50,i-ci:hor15,r-cr:hor30,sm:block,a:blinkon0
  include=\<\(use\|require\)\>
  includeexpr=substitute(substitute(v:fname,'::','/','g'),'$','.pm','')
  indentexpr=GetPerlIndent()
  indentkeys=0{,0},:,0#,!^F,o,O,e,0=,0),0=or,0=and
  isfname=@,48-57,/,.,-,_,+,,,#,$,%,~,=,:
  keywordprg=perldoc -f
  listchars=tab:>-,trail:o
  path=/usr/local/lib64/perl5,/usr/local/share/perl5,/usr/lib64/perl5/vendor_perl,/usr/share/perl5/vendor_perl,/usr/lib64/perl
5,/usr/share/perl5,,
  wildmode=longest,list,full

Upvotes: 1

Views: 1618

Answers (1)

Ingo Karkat
Ingo Karkat

Reputation: 172570

As @romainl has already indicated in the comments, the appended comments are part of the mappings, and one of those characters (e.g. the <Space>) dismisses the hit-enter prompt. You could include a trailing comment by separating with | (which must be escaped or written as <Bar>) inside a mapping):

nnoremap <leader>p :! perl -c %<CR>| "(p)erl -c

But I'd recommend to put the comments on a separate line:

" (p)erl -c
nnoremap <leader>p :! perl -c %<CR>

PS: You should use :noremap; it makes the mapping immune to remapping and recursion.

Upvotes: 1

Related Questions