[vim/vim] .wq! Deletes All data except the line where the cursor is located. (Issue #14892)

21 views
Skip to first unread message

Ivan Brykin

unread,
Jun 1, 2024, 5:58:08 AM6/1/24
to vim/vim, Subscribed

Steps to reproduce

  1. Create any file with the following content (for example):
    string1
    string2
    string3
    string4
    string5
    
  2. Open the file with VIM:
    vim test.txt
  3. Position the cursor on any line and type the following command:
    :.wq!
    

Expected behaviour

Expected Behavior:

The file should be saved and the VIM editor should exit normally.

Actual Behavior:

All lines in the file are deleted except the string where the cursor is located. The content of the file after the command is:

[root@fedora ~]# cat test.txt
string3
[root@fedora ~]#

Version of Vim

9.0.1575

Environment

- OS: Fedora Linux 37 (Workstation Edition)
- Terminal: PuTTY Release 0.81
- value of $TERM: xterm
- shell: bash 5.2.15(1)

Logs and stack traces

### Full Command Sequence

# Create the test file
echo -e "string1\nstring2\nstring3\nstring4\nstring5" > test.txt

# Open the file in VIM with verbose logging
vim -V9vimlog.txt test.txt

# Inside VIM, execute the command to reproduce the issue
# :.wq!

# Exit VIM and check the log file
cat vimlog.txt


```bash
chdir(/etc)
fchdir() to previous dir
sourcing "/etc/vimrc"
chdir(/usr/share/vim/vim90/syntax)
fchdir() to previous dir
line 90: sourcing "/usr/share/vim/vim90/syntax/syntax.vim"
chdir(/usr/share/vim/vim90/syntax)
fchdir() to previous dir
line 19: sourcing "/usr/share/vim/vim90/syntax/synload.vim"
chdir(/usr/share/vim/vim90/syntax)
fchdir() to previous dir
line 21: sourcing "/usr/share/vim/vim90/syntax/syncolor.vim"
chdir(/usr/share/vim/vim90/colors/lists)
fchdir() to previous dir
line 53: sourcing "/usr/share/vim/vim90/colors/lists/default.vim"
finished sourcing /usr/share/vim/vim90/colors/lists/default.vim
continuing in /usr/share/vim/vim90/syntax/syncolor.vim
finished sourcing /usr/share/vim/vim90/syntax/syncolor.vim
continuing in /usr/share/vim/vim90/syntax/synload.vim
finished sourcing /usr/share/vim/vim90/syntax/synload.vim
continuing in /usr/share/vim/vim90/syntax/syntax.vim
chdir(/usr/share/vim/vim90)
fchdir() to previous dir
line 25: sourcing "/usr/share/vim/vim90/filetype.vim"
not found in 'runtimepath': "ftdetect/*.vim"
finished sourcing /usr/share/vim/vim90/filetype.vim
continuing in /usr/share/vim/vim90/syntax/syntax.vim
Executing FileType Autocommands for "*"
autocommand 0verbose exe "set syntax=" . expand("<amatch>")

Executing BufRead Autocommands for "*"
autocommand if !did_filetype() && expand("<amatch>") !~ g:ft_ignore_pat | runtim                                                                                                                                                             e! scripts.vim | endif

chdir(/usr/share/vim/vim90)
fchdir() to previous dir
line 0: sourcing "/usr/share/vim/vim90/scripts.vim"
chdir(/usr/share/vim/vim90/autoload/dist)
fchdir() to previous dir
line 30: sourcing "/usr/share/vim/vim90/autoload/dist/script.vim"
finished sourcing /usr/share/vim/vim90/autoload/dist/script.vim
continuing in /usr/share/vim/vim90/scripts.vim
finished sourcing /usr/share/vim/vim90/scripts.vim
continuing in BufRead Autocommands for "*"
Executing BufRead Autocommands for "*.txt"
autocommand if getline('$') !~ 'vim:.*ft=help'|   setf text| endif

Executing FileType Autocommands for "*"
autocommand 0verbose exe "set syntax=" . expand("<amatch>")

Executing BufRead Autocommands for "*"
autocommand if !did_filetype() && expand("<amatch>") !~ g:ft_ignore_pat    && (g                                                                                                                                                             etline(1) =~ '^#' || getline(2) =~ '^#' || getline(3) =~ '^#'^I|| getline(4) =~                                                                                                                                                              '^#' || getline(5) =~ '^#') |   setf FALLBACK conf | endif

finished sourcing /usr/share/vim/vim90/syntax/syntax.vim
continuing in /etc/vimrc
chdir(/usr/share/vim/vim90)
fchdir() to previous dir
line 98: sourcing "/usr/share/vim/vim90/filetype.vim"
finished sourcing /usr/share/vim/vim90/filetype.vim
continuing in /etc/vimrc
chdir(/usr/share/vim/vim90)
fchdir() to previous dir
line 98: sourcing "/usr/share/vim/vim90/ftplugin.vim"
finished sourcing /usr/share/vim/vim90/ftplugin.vim
continuing in /etc/vimrc
finished sourcing /etc/vimrc
chdir(/root)
fchdir() to previous dir
could not source "$HOME/.vimrc"
chdir(/root/.vim)
fchdir() to previous dir
could not source "~/.vim/vimrc"
chdir(/root)
fchdir() to previous dir
could not source "$HOME/.exrc"
chdir(/usr/share/vim/vim90)
fchdir() to previous dir
sourcing "$VIMRUNTIME/defaults.vim"
chdir(/usr/share/vim/vim90)
fchdir() to previous dir
line 85: sourcing "/usr/share/vim/vim90/filetype.vim"
finished sourcing /usr/share/vim/vim90/filetype.vim
continuing in /usr/share/vim/vim90/defaults.vim
chdir(/usr/share/vim/vim90)
fchdir() to previous dir
line 85: sourcing "/usr/share/vim/vim90/ftplugin.vim"
finished sourcing /usr/share/vim/vim90/ftplugin.vim
continuing in /usr/share/vim/vim90/defaults.vim
chdir(/usr/share/vim/vim90)
fchdir() to previous dir
line 85: sourcing "/usr/share/vim/vim90/indent.vim"
finished sourcing /usr/share/vim/vim90/indent.vim
continuing in /usr/share/vim/vim90/defaults.vim
chdir(/usr/share/vim/vim90/syntax)
fchdir() to previous dir
line 121: sourcing "/usr/share/vim/vim90/syntax/syntax.vim"
chdir(/usr/share/vim/vim90/syntax)
fchdir() to previous dir
line 15: sourcing "/usr/share/vim/vim90/syntax/nosyntax.vim"
Executing BufEnter Autocommands for "*"
autocommand syn clear

autocommand if exists("b:current_syntax") | unlet b:current_syntax | endif

finished sourcing /usr/share/vim/vim90/syntax/nosyntax.vim
continuing in /usr/share/vim/vim90/syntax/syntax.vim
chdir(/usr/share/vim/vim90/syntax)
fchdir() to previous dir
line 19: sourcing "/usr/share/vim/vim90/syntax/synload.vim"
chdir(/usr/share/vim/vim90/syntax)
fchdir() to previous dir
line 21: sourcing "/usr/share/vim/vim90/syntax/syncolor.vim"
finished sourcing /usr/share/vim/vim90/syntax/syncolor.vim
continuing in /usr/share/vim/vim90/syntax/synload.vim
finished sourcing /usr/share/vim/vim90/syntax/synload.vim
continuing in /usr/share/vim/vim90/syntax/syntax.vim
Executing FileType Autocommands for "*"
autocommand 0verbose exe "set syntax=" . expand("<amatch>")

finished sourcing /usr/share/vim/vim90/syntax/syntax.vim
continuing in /usr/share/vim/vim90/defaults.vim
finished sourcing $VIMRUNTIME/defaults.vim
not found in 'packpath': "pack/*/start/*"
chdir(/usr/share/vim/vim90/plugin)
fchdir() to previous dir
sourcing "/usr/share/vim/vim90/plugin/getscriptPlugin.vim"
finished sourcing /usr/share/vim/vim90/plugin/getscriptPlugin.vim
chdir(/usr/share/vim/vim90/plugin)
fchdir() to previous dir
sourcing "/usr/share/vim/vim90/plugin/gzip.vim"
finished sourcing /usr/share/vim/vim90/plugin/gzip.vim
chdir(/usr/share/vim/vim90/plugin)
fchdir() to previous dir
sourcing "/usr/share/vim/vim90/plugin/logiPat.vim"
finished sourcing /usr/share/vim/vim90/plugin/logiPat.vim
chdir(/usr/share/vim/vim90/plugin)
fchdir() to previous dir
sourcing "/usr/share/vim/vim90/plugin/manpager.vim"
finished sourcing /usr/share/vim/vim90/plugin/manpager.vim
chdir(/usr/share/vim/vim90/plugin)
fchdir() to previous dir
sourcing "/usr/share/vim/vim90/plugin/matchparen.vim"
finished sourcing /usr/share/vim/vim90/plugin/matchparen.vim
chdir(/usr/share/vim/vim90/plugin)
fchdir() to previous dir
sourcing "/usr/share/vim/vim90/plugin/netrwPlugin.vim"
finished sourcing /usr/share/vim/vim90/plugin/netrwPlugin.vim
chdir(/usr/share/vim/vim90/plugin)
fchdir() to previous dir
sourcing "/usr/share/vim/vim90/plugin/rrhelper.vim"
finished sourcing /usr/share/vim/vim90/plugin/rrhelper.vim
chdir(/usr/share/vim/vim90/plugin)
fchdir() to previous dir
sourcing "/usr/share/vim/vim90/plugin/spellfile.vim"
finished sourcing /usr/share/vim/vim90/plugin/spellfile.vim
chdir(/usr/share/vim/vim90/plugin)
fchdir() to previous dir
sourcing "/usr/share/vim/vim90/plugin/tarPlugin.vim"
finished sourcing /usr/share/vim/vim90/plugin/tarPlugin.vim
chdir(/usr/share/vim/vim90/plugin)
fchdir() to previous dir
sourcing "/usr/share/vim/vim90/plugin/tohtml.vim"
finished sourcing /usr/share/vim/vim90/plugin/tohtml.vim
chdir(/usr/share/vim/vim90/plugin)
fchdir() to previous dir
sourcing "/usr/share/vim/vim90/plugin/vimballPlugin.vim"
finished sourcing /usr/share/vim/vim90/plugin/vimballPlugin.vim
chdir(/usr/share/vim/vim90/plugin)
fchdir() to previous dir
sourcing "/usr/share/vim/vim90/plugin/zipPlugin.vim"
finished sourcing /usr/share/vim/vim90/plugin/zipPlugin.vim
not found in 'packpath': "pack/*/start/*"
not found in 'runtimepath': "plugin/**/*.vim"
Reading viminfo file "/root/.viminfo" info oldfiles
"test.txt"
"test.txt" 5L, 40B
Reading viminfo file "/root/.viminfo" marks
Executing BufRead Autocommands for "*"
autocommand if line("'\"") > 0 && line ("'\"") <= line("$") |   exe "normal! g'\                                                                                                                                                             "" | endif

Executing BufRead Autocommands for "*"
autocommand if !did_filetype() && expand("<amatch>") !~ g:ft_ignore_pat | runtim                                                                                                                                                             e! scripts.vim | endif

chdir(/usr/share/vim/vim90)
fchdir() to previous dir
line 0: sourcing "/usr/share/vim/vim90/scripts.vim"
finished sourcing /usr/share/vim/vim90/scripts.vim
continuing in BufRead Autocommands for "*"
Executing BufRead Autocommands for "*.txt"
autocommand if getline('$') !~ 'vim:.*ft=help'|   setf text| endif

Executing FileType Autocommands for "*"
autocommand call LoadFTPlugin()

chdir(/usr/share/vim/vim90/ftplugin)
fchdir() to previous dir
line 18: sourcing "/usr/share/vim/vim90/ftplugin/text.vim"
finished sourcing /usr/share/vim/vim90/ftplugin/text.vim
continuing in <SNR>9_LoadFTPlugin
Executing FileType Autocommands for "*"
autocommand call s:LoadIndent()

not found in 'runtimepath': "indent/text.vim"
Executing FileType Autocommands for "*"
autocommand 0verbose exe "set syntax=" . expand("<amatch>")

Executing BufRead Autocommands for "*"
autocommand if !did_filetype() && expand("<amatch>") !~ g:ft_ignore_pat    && (g                                                                                                                                                             etline(1) =~ '^#' || getline(2) =~ '^#' || getline(3) =~ '^#'^I|| getline(4) =~                                                                                                                                                              '^#' || getline(5) =~ '^#') |   setf FALLBACK conf | endif

Executing BufRead Autocommands for "*"
autocommand if line("'\"") >= 1 && line("'\"") <= line("$") && &ft !~# 'commit'                                                                                                                                                              |   exe "normal! g`\"" | endif

Executing BufWinEnter Autocommands for "*"
autocommand call s:Highlight_Matching_Pair()

Executing BufEnter Autocommands for "*"
autocommand sil call s:LocalBrowse(expand("<amatch>"))

Executing VimEnter Autocommands for "*"
autocommand sil call s:VimEnter(expand("<amatch>"))

Executing CursorMoved Autocommands for "*"
autocommand call s:Highlight_Matching_Pair()

Executing CursorMoved Autocommands for "*"
autocommand call s:Highlight_Matching_Pair()

Executing CursorMoved Autocommands for "*"
autocommand call s:Highlight_Matching_Pair()


"test.txt"
"test.txt" 1L, 8B written


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/14892@github.com>

Ivan Brykin

unread,
Jun 1, 2024, 6:06:53 AM6/1/24
to vim/vim, Subscribed

Also works with many other rpm-based distributions and older versions of VIM.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/14892/2143389643@github.com>

zeertzjq

unread,
Jun 1, 2024, 6:09:06 AM6/1/24
to vim/vim, Subscribed

Isn't this behavior correct?

:[range]wq[!] [++opt] [file]
			Same as above, but only write the lines in [range].


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/14892/2143390385@github.com>

Ivan Brykin

unread,
Jun 1, 2024, 6:23:51 AM6/1/24
to vim/vim, Subscribed

Actually you are right


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/14892/2143395817@github.com>

Ivan Brykin

unread,
Jun 1, 2024, 6:23:59 AM6/1/24
to vim/vim, Subscribed

Closed #14892 as completed.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issue/14892/issue_event/13008828191@github.com>

Christ van Willegen

unread,
Jun 1, 2024, 7:40:53 AM6/1/24
to vim...@googlegroups.com, reply+ACY5DGEE5KDFLKTFUX...@reply.github.com, vim/vim, Subscribed


Op za 1 jun. 2024 11:58:
  1. Position the cursor on any line and type the following command:
    :.wq!

I guess that the . indicates the range of lines to write, the current one...

Christ van Willegen

vim-dev ML

unread,
Jun 1, 2024, 7:41:22 AM6/1/24
to vim/vim, vim-dev ML, Your activity

Op za 1 jun. 2024 11:58:

>
> 1. Position the cursor on any line and type the following command:
>
> :.wq!
>
>
>

I guess that the . indicates the range of lines to write, the current one...

Christ van Willegen

>


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/14892/2143417592@github.com>

Reply all
Reply to author
Forward
0 new messages