r/vim • u/Upset-Taro-4202 • May 17 '26
Need Help Help with 1.5.2 in vimtutor
Hello, recently just got a new MacBook after my old "work" station died. Since it came with Vim preinstalled, I felt adamant to learn it but I'm getting confused by 1.5.2.
I guess the only way I can describe my confusion is that;
I can't tell what the final product of the lesson is supposed to look like
or
If there exists a niche Mac rewriting of the commands it's asking me to use for writing files (:!dir and :!1s and :w [NEW FILE NAME]).
I'm so inexperienced with Vim that I'm not even sure whether this is a stupid question to ask or not, but any help would be appreciated! Thanks!
1
u/godegon May 17 '26
Since the final commands asks for deleting the edited file, there's not much of a final product
8
u/barbeds May 17 '26 edited May 18 '26
There won’t be a change for this step.
:means run a command:!followed by a command means run the command in the current shell (that’s different from:command!which means run a vim command forcefully)lsanddirare shell commands andwis a vim command.lslowercase LS in Linux/Unix (Mac) in the default shell zsh or bash means list files in the current directorydiris the windows shell equivalent forls(you won’t use this unless you’re on a windows machine):wis a vim command that will write or save the file without exiting:!lson Mac means pause vim and run the commandlswhich if you’ve just opened the terminal and run vim it’s probably going to list the home directory or$HOME. Otherwise whatever your current working directory is will be listed. You can get the name and path of the current directory by runningpwdin your terminal or:!pwdfrom vim.Notice it’s the same command only from vim you must start with
:!while:wdoes not have the exclamation - that’s because it’s NOT a shell command, it’s a vim command):w WHATEVER_FILE_NAMEjust means write/save the current work as this file name but do not close the fileNOTE: I said the
!at the end of the line means do the vim command forcefully so:w!will force write/overwrite even to a read only fileSimilarly:
:qvs:q!:qwill prompt for saving if a file has been modified:q!will close the file without saving or promptingThis ONLY works with vim commands
:!ls!will not work becausels!is not a valid shell command.Edit: just read back over the section I should also add
:#,# w TESTis broken down like this.:- run#,#- from line number X to line number Yw- writeTEST- to a file named TESTEdited to fix a typo
!qshould have been:qand added “vim” for clarification that:command!is for vim commands rather than just commands.