Vim netrw asking to "Press ENTER or type command to continue" - vim

I have noticed that when I start the day and open vim, then use :Exp, I get the "Press ENTER or type command to continue" prompt. Usually this is shown when an external command is executed. I don't remember :Exp doing this in the past(?). Further, the prompt is only displayed upon the first use of netrw?!
Although trivial, I find this annoying. Does anyone have an idea why netrw is doing this? I have been removing various things in my .vimrc to see if they change anything, but I could be here a long time...
Steps to reproduce:
Open vim or gvim
:Exp (followed by enter)
Prompt appears.

The contents of v:scrollstart can be used to get a clue of why this is happening.
There are some options that may be related to the problem.
From vim-faq:
Vim will prompt you with the "hit enter to continue" prompt, if there are
some messages on the screen for you to read and the screen is about to be
redrawn. You can add the 'T' flag to the 'shortmess' option to truncate
all messages. This will help in avoiding the hit-enter prompt:
:set shortmess+=T
You can also increase the command height by setting the 'cmdheight' option:
:set cmdheight=2
For more information, read
hit-enter
avoid-hit-enter
'shortmess'
'cmdheight'
Edit:
From :h netrw-problems:
P10. I'm being pestered with "[something] is a directory" and
"Press ENTER or type command to continue" prompts...
The "[something] is a directory" prompt is issued by Vim,
not by netrw, and there appears to be no way to work around
it. Coupled with the default cmdheight of 1, this message
causes the "Press ENTER..." prompt. So: read |hit-enter|;
I also suggest that you set your |'cmdheight'| to 2 (or more) in
your <.vimrc> file.
You should also check if you are using the latest plugin version, as there is a bug fix on version 71 that is related to your problem:
v71: * bugfix -- made some "set nomodifiable"s into
:
:
* When ch=1, on the second and subsequent uses of
browsing Netrw would issue a blank line to clear
the echo'd messages. This caused an annoying
"Hit-Enter" prompt; now a blank line message
is echo'd only if &ch>1.

Adding this line to ~/.vimrc seems to resolve the issue for me:
let g:netrw_silent = 1

I usually just do :e . to browse in current directory. Also, to get rid of prompts you can do :silent Exp.

Related

How to issue Vim commands in command mode (`Enter` not working)

I installed neovim with pkg install neovim. I then downloaded the latest version of Nvim-R with curl -L "https://www.vim.org/scripts/download_script.php?src_id=26482" > NvimR.vmb. Finally, I opened the file with nvim NvimR.vmb.
Now I'm in the editor and I launch the command mode by pressing the : key on my keyboard. I then proceed to type packadd vimball into the command console. Finally I try to issue the packadd vimball command by hitting Enter on my keyboard and nothing happens. I look up in the editor panel and notice each time I hit Enter the cursor is just being moved around in the editor.
I don't want the cursor to move around in the editor. I want to issue my :packadd vimball command. How do I do this?
Everything I see in that gif is precisely what I would expect to see given what you typed.
You run :packadd vimballEnter—this does vim’s native packadd command (assuming nvim has that), and then returns you to the editing portion of the screen.
Subsequent Enter presses are equivalent to j—move down a line.
All of that said, I dont know of any packages named vimball, but I don’t really work with that format. Perhaps you’ve misunderstood a plugin’s usage or vimball usage? Ask about that stuff on vi.stackexchange.com: we probably have better vi/m experts there.

p4 change not working with gvim

I use perforce as source code repository. p4 change command is used to create a changelist of opened files. If I set setenv EDITOR gvim and then run this command then gvim opens and I add some description and then save and quit. I get below error. Same error does not come if EDITOR is not set, I mean in that case vim opens. Any idea to fix this issue?
sachina#inn-sachina-vm[285] p4 change
Error in change specification.
Error detected at line 29.
Change description missing. You must enter one.
Hit return to continue...
Applications that invoke EDITOR assume that the command blocks until editing is done and the editor was closed. While true for vim, the GUI version gvim launches in the background; i.e. the command returns immediately.
You can avoid this via the :help -f command-line option:
setenv EDITOR 'gvim -f'

editing file through vi editor in shell script show error

script in which I open a file in vi editor , after that user will write any thing in it then save or quite by :wq!
When I try this then it give an error message as below
e138 can't write viminfo file $home/.viminfo!
and ask for,
Press Enter or command to continue
Now when I press enter then file save. But why that error message shows.
If I open same file direct with vi editor or vim editor and do changes then it does not give any error.
also if I install vim editor then it works fine and no error shows
Please tell me what may be the issue.
my best guess is that $home is not defined properly. try running: !echo $home on both editors. If it's not defined during the script run, define it before running vim.
I came here with mostly the same error, but this answer did not work for me. I had to create more space within my $HOME directory by deleting a few files, and then vim worked normally again.

how to refresh entire screen in putty

I have a redhat machine which I use remotely using putty and this is what have been bugging me a lot now...
Each time I open and close a file with any editor, my prompt shows up on the bottom line without the content of the screen being refreshed. This is really problematic because then I can't see previous outputs that were on the screen just before I opened that file which is still showing up after closing.
Is there a way to fix this. I want it to behave like the gnome-terminal. I don't think this use to happen when I was using an ubuntu server.
I understand that this is the traditional tty behavior, but I don't want it...
Thanks in advance.
If your terminal supports an alternate screen buffer, it should have rmcup and smcup define in its terminfo entry
% infocmp | grep -e rmcup -e smcup
ri=\EM, rmacs=^O, rmcup=\E[2J\E[?47l\E8, rmir=\E[4l,
smcup=\E7\E[?47h, smir=\E[4h, smkx=\E[?1h\E=, smso=\E[7m,
If enabling altscreen in your .screenrc doesn't fix it, try adding these 2 lines to your .vimrc:
set t_ti=^[[?47h
set t_te=^[[?47l
(note that ^[ is escape, I typed ctrl-v esc)
Vim will echo ti to the terminal on startup and te on exit, instructing the shell/xterm/screen to switch screen buffers.

How do I deal with vim's swap file system?

When using vim in ubuntu, I accidentally pressed ctrl-z which suspended my session of vim. I was editing a file (I'll call it test) which was not saved.
When I opened the file again in vim, I got the swap file error:
E325: ATTENTION
Found a swap file by the name ".test.swp"
Swap file ".test.swp" already exists!
According to Found a swap file by the name question, I have two options:
Find the session and finish it (preferable).
Delete the .swp file (if you're sure the other git session has gone away).
How would I do either of those things? If I perform rm test.swp it doesn't see the file:
rm: cannot remove `test.swp': No such file or directory
What am I doing wrong in the deletion of the swap file and how can I finish the session?
EDIT: I forgot the period in test.swp
So the correct way to remove the swp file is rm .test.swp.
My remaining question is how to resume/finish a suspended session of vim.
This is not related to Ubuntu alone, since what happens is a base mechanism of
nearly every Unix OS.
By pressin ^Z you ave suspended (not ended) the currently running vim session. The vim
session is still there and waiting for a signal to put it to foreground again.
To reactivate the session:
If vim was started directly from the commandline -- use the command "fg" (which is for "ForeGroung") and vim will appear again. This works on all ksh/bourne-like shells. For t/csh I dont know. This only works when the command "fg" was given on the console of the same terminal session as from which vim was started (which is the "controlling terminal" related to the vim session).
If vim was started (mostly under the name gvim) from a menu of a windowmanager you are a little bit out of luck here, since (g)vim gets detached from its controling terminal.
Your options to recover:
Use "fg" if the condition is valid described above. This is the cleanest way.
If the (g)vim session is detached from the controling terminal, which can be checked by doing a "ps -ef | grep vim". If the column for the TTY (see header of the output) shows
a "?" there is no controling terminal anymore, I would recommend to send the process
a SIGHUB (see manpage for the commmand "kill"/"killall") and then a SIGKILL if it is still there.
Killing vim (or any other task) will probably result in inconsistent data though, cause there was no "save" command to vim before it is killed.
After that, start a new vim with the same file, do a "recover" first (as offered by vim, which sees the according swp-file) , save the file, end vim and start it again with that file and do a "delete swap file". This is the savest way possible after killing vim.
To avoid accidentically putting vim into background if not wanted, map ^Z to another, more
"complicated" keysequence, which is hard to press accidentically. You can deactivate the
^Z command by adding the following line to your .vimrc:
map <C-z> ;
Addition: Your rm-command misses the dot in front of .test.swp causing rm not to
find the file...or deleting another file, which is named test.swp instead of ".test.swp". By deleting swp-files via vim, you are sure to delete the correct file.
Swp-files always start with a dot (hidden file) on UNIX like systems.
the file is going to be " .test.swp ", not " test.swp "
So you'll want to:
rm .test.swp

Resources