news.volyx.in

Tell HN: Vim users, `:x` is like `:wq` but writes only when changes are made

537 points by manaskarekar · 1338 days ago · 270 comments on HN

Article summary

The article discusses the Vim command `:x`, which writes the file only when changes have been made, similar to `:wq`. This command leaves the modification time of files untouched if nothing was changed. The command is equivalent to Shift + ZZ in normal mode. The article highlights a lesser-known feature of Vim that can improve user efficiency.

Main themes

  • Vim commands
  • Keyboard shortcuts
  • User interface design
  • Efficiency and productivity
  • Discoverability and learning
  • Safety and risk mitigation

What commenters say

  • Using `:x` or Shift + ZZ can save time by only writing files when changes are made.
  • Some users prefer to remap the Esc key to a more accessible location, such as Caps Lock, to improve typing efficiency.
  • The difference between `Ctrl + [` and `Ctrl + C` in Vim is that the former finishes the input sequence, while the latter interrupts it.
  • The discoverability of Vim's features is a problem, and a more intuitive interface would help users learn about commands like ZZ.
  • RTFM is not a sufficient solution to the problem of discoverability, and a better design is needed to make Vim more user-friendly.
  • Some users value the safety of using both hands to perform irreversible actions like writing to a file.
  • The use of version control and other safety nets can mitigate the risks of irreversible actions.