Vim Tips Wiki
Register
Advertisement
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
Tip 535 Printable Monobook Previous Next

created August 19, 2003 · complexity basic · author Gnaphos · version 6.0


Sometimes you can only work with a single terminal/console, or you hate having too many windows open and need to switch between them, or QuickFix does not work on your favourite languages? This simple, yet powerful key stroke (Ctrl-Z) might be very useful to you.

For example, let's say you are composing an email using vim on mutt, or you want to compile your <insert your favourite language> file, you can simply press Ctrl-Z, gives you the prompt back, do multiple commands and whatever you want, and goes back to vim editing by typing "fg" again.

If you need to admin some machine that only have vi instead of vim on some reason, you can edit multiple files by suspend them, using "jobs" to list them and "fg %n" (n is the job number) to load them back.

So by using the simple Ctrl-Z, not only that you can edit multiple files in the same vim, you can edit multiple groups of files in different vim.

Although it is a shell feature, but it goes together nicely with vim.

Just in case for people that do not know, if all you want is to run a single external command, use ":!cmd", or "!<motion><filter>" to filter <motion> text throught the command.

For example, if you have a line "1 + 1 * 2", position cursor on it, and type "!}bc", you got "3" for you answer back.

Or another example, position your cursor at the first line of your paragraph and type "!}fmt", now the paragraph is nicely formatted.

With all these in hand, you don't need to waste key strokes to switch between different windows anymore, the only drawback is it only works in *nix.

Comments

I like to use GNU screen in only one terminal/console. Pressing C-a C-a can quickly switch between different "windows" . And C-a C-c opens a new window. http://www.gnu.org/software/screen/screen.html


Advertisement