string1
string2
string3
string4
string5
vim test.txt
:.wq!
The file should be saved and the VIM editor should exit normally.
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 ~]#
9.0.1575
- OS: Fedora Linux 37 (Workstation Edition)
- Terminal: PuTTY Release 0.81
- value of $TERM: xterm
- shell: bash 5.2.15(1)
### 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.![]()
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.![]()
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.![]()
Actually you are right
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
Closed #14892 as completed.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
- Position the cursor on any line and type the following command:
:.wq!
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()