Hot answers tagged vim
There are several options to do so: You can use a terminal multiplexer like screen or tmux. In screen, for example, the shortcut Ctrl+a - a, has the same functiononality as Alt+Tab in graphical environments: switch to the last screen. Or you use vim's internal function. Type :!command in vim's command mode. For example: :!ls -l. After the command ...
Without a count, ^ and _ are indeed equivalent, but the latter supports a count: _ <underscore> [count] - 1 lines downward, on the first non-blank character |linewise|. The linewise explains your second observation: when used as a motion, it not just covers the text between the previous position and the new ...
You can use \0 or & in the replacement as in :%s/2009.a/ \0 /gc :%s/2009.a/ & /gc
You can press Ctrl-z to stop vim and go to CLI, do whatever you need to (edit another vim file perhaps), then press fg on command line to return back into vim at the same place you left off at. If you didn't see the command fg being typed, then it's very likely that screen was being used.
I don't know about the "suddenly returned ..." part, but the first bit is fairly trivial. The :shell command opens your shell. For me, it opens at wherever I was when I opened vim, so it is inheriting settings from vim, as G-Man notes. That gives you the CLI mode. You can also open another vim from it. Quitting this shell returns you to wherever you where in ...
Yes there is a way to automate this. And it starts with selecting the right tool, for the job. In this case you should be using e.g sed and not try to bend vi which was designed for interactive use (and not for automation). The replacement syntax for sed is largely the same as the one for vi. sed -i.backup 's/boy/Boy/g' file-name-1 file-name-2 ...
Why not use sed ? With sed you could easily loop over the files in the directory: for f in *.txt do sed 's/boy/Boy/g;s/girl/Girl/g;/^\s*$/d' $f > tmp mv tmp $f done Above example would change boy->Boy, girl->Girl and delete empty the lines.
sed is the tool for you. Most of the commands that you will use in vi will be available in sed and so, there is not much learning curve. The commands in vi that are started with a : are based on the underlying editor ed and they are also available in sed. You will use those commands without the : and they are, by default, applied to the entire file. For ...
Only top voted, non community-wiki answers of a minimum length are eligible