Some user wrote:

Tim Chase-2 wrote:
I'm new to Vim. I want to change the character before commands. For
example
saving is done by:

:w <enter>

Can it be made slightly easier by just pressing 'g' or some other key
that's
not taken? I don't know why every command has to be pre-pended by a
difficult to reach character like colon. In an old text editor (I think
one
by Borland), you could save by pressing just one key, i.e. F2.
yes, the Borland IDE used to use <F2> to save.

This isn't a flame.. I just want to do simple commands like save, quit,
save
and quit, etc. with fewer than four keys. One key like 'g' or F2 or
something would be awesome. Ctrl + key would be nice too.
Most of the common letters and control-keys are occupied by existing[1]/useful[1]/non-portable commands[2]. However, the F# keys should be available. You want "mappings", so to save, you'd want something like this:

        :nnoremap <f2> :w<cr>

(with all less-than and greater-than signs).

For save+quit, there's "ZZ" in normal mode, and for abandon+quit, there's "ZQ". I don't use either of them as discussed on the list a month or two ago (I like the intentionality of building it piece-by-piece regarding whether to quit, confirm, all files, and save/overwrite in the process) but they might be easier to use. However, you _can_ do things like

        :nnoremap <f4> :wq<cr>

to save+quit.


[1] like the "g" you suggest...very useful
[2] such as control+[SQ] which is available in some versions, but is terminal flow-control or control+Z which can suspend/minimize vim


Just my $0.02 adjusted for inflation, minus taxes, social security, and medicare.

-tim





Thank you very much, Tim. You are a true vim genius. The reason I don't like
ZZ is that I still have to press shift with z. :( If only it worked without
shift... But then again, like you said most keys are already bound to
functions that are useful in general (though I've never used regular z
function).

---- RANT ----
Though I don't really get the reason why every command is preceded by colon.
It should be one keypress, like maybe semi-colon. I'm sure the writers of
vim were pretty aware of that, so there must be a design issue they faced or
something that prevented one keypress instead of two (maybe they wanted to
prevent accidental press?). This was just a rant.

With the exception of the letters themselves, which characters require Shift varies from one keyboard layout to the next. For instance, on my fr_BE AZERTY keyboard, the colon is unshifted, but the digits are shifted. IIUC, on en_US QWERTY keyboards it's the opposite.

---- END RANT ----

One quick question, please if you could answer: what if I want to map
something like a two keys in succession to something, like gg for save, gz
for quitting and saving. How would it change?

You may. The {lhs} of a mapping can be any number of characters (greater or equal to one, of course). If you start typing the characters of a multi-character mapping, they will appear at bottom right if you have 'showcmd' set (which is the 'nocompatible' default). As soon as you hit a key which is not part of the mapping, what you typed will be acted upon. Or once you complete the mapping, it will be executed.

For instance, let's imagine you create the mapping:
        :map gg :w<CR>

to use gg for Save. This will of course disable the usual meaning of gg (go to top) but you can use 1G for that. Now when you hit g (in Normal mode) you will see it at bottom right of your screen, "waiting" to know what you want to do with it. If you follow it by a second g, your file will be saved. If you follow it by something else, let's say j, Vim will execute the Normal-mode command gj (go to next screen line, which may be another part of the current "file" line if it is longer than 'columns' and you have 'wrap' on).


I'm sorry if my English is bad.. it's not my first language.

Regards,

Neither is it mine, but as we say in my mother language (French), "by working the smithy one becomes a smith".


Best regards,
Tony.
--
Why is it called "Windows"?  "Gates" would be more appropriate...

Reply via email to