What is the meaning of 'g'?
Note: this question has two sort of answers on StackOverflow but I thought perhaps a better answer would come from here, and, if not, at least it will be documented where it should be:
- What are the vim commands that start with g?
- Use of g key in vim normal mode
What is the semantic meaning of the letter g
in normal mode commands? I have used the heck out of gg
, G
, and <n>G
, but until today, I had never thought to find out what the semantics of g
are in the larger Zen of Vi.
Today I had to lowercase a bunch of constants in my code, and I figured there had to be a better way than character by character (since <n>~
doesn't work, for whatever odd reason that I am unaware of). I found it in g~
, specifically g~iw
.
This led me to find the linked answers, but they have less than satisfying explanations, and are on StackOverflow, and not vi.SE, to boot.
So,
What is the vi-semantic meaning of g
?
By vi-semantic meaning, I expect people to understand, as ciw
means change in word, so c
means change, i
, means inner text item, and w
means word delineated by space or punctuation excluding _
.
P.S., how do I tag this?
key-bindings normal-mode
add a comment |
Note: this question has two sort of answers on StackOverflow but I thought perhaps a better answer would come from here, and, if not, at least it will be documented where it should be:
- What are the vim commands that start with g?
- Use of g key in vim normal mode
What is the semantic meaning of the letter g
in normal mode commands? I have used the heck out of gg
, G
, and <n>G
, but until today, I had never thought to find out what the semantics of g
are in the larger Zen of Vi.
Today I had to lowercase a bunch of constants in my code, and I figured there had to be a better way than character by character (since <n>~
doesn't work, for whatever odd reason that I am unaware of). I found it in g~
, specifically g~iw
.
This led me to find the linked answers, but they have less than satisfying explanations, and are on StackOverflow, and not vi.SE, to boot.
So,
What is the vi-semantic meaning of g
?
By vi-semantic meaning, I expect people to understand, as ciw
means change in word, so c
means change, i
, means inner text item, and w
means word delineated by space or punctuation excluding _
.
P.S., how do I tag this?
key-bindings normal-mode
add a comment |
Note: this question has two sort of answers on StackOverflow but I thought perhaps a better answer would come from here, and, if not, at least it will be documented where it should be:
- What are the vim commands that start with g?
- Use of g key in vim normal mode
What is the semantic meaning of the letter g
in normal mode commands? I have used the heck out of gg
, G
, and <n>G
, but until today, I had never thought to find out what the semantics of g
are in the larger Zen of Vi.
Today I had to lowercase a bunch of constants in my code, and I figured there had to be a better way than character by character (since <n>~
doesn't work, for whatever odd reason that I am unaware of). I found it in g~
, specifically g~iw
.
This led me to find the linked answers, but they have less than satisfying explanations, and are on StackOverflow, and not vi.SE, to boot.
So,
What is the vi-semantic meaning of g
?
By vi-semantic meaning, I expect people to understand, as ciw
means change in word, so c
means change, i
, means inner text item, and w
means word delineated by space or punctuation excluding _
.
P.S., how do I tag this?
key-bindings normal-mode
Note: this question has two sort of answers on StackOverflow but I thought perhaps a better answer would come from here, and, if not, at least it will be documented where it should be:
- What are the vim commands that start with g?
- Use of g key in vim normal mode
What is the semantic meaning of the letter g
in normal mode commands? I have used the heck out of gg
, G
, and <n>G
, but until today, I had never thought to find out what the semantics of g
are in the larger Zen of Vi.
Today I had to lowercase a bunch of constants in my code, and I figured there had to be a better way than character by character (since <n>~
doesn't work, for whatever odd reason that I am unaware of). I found it in g~
, specifically g~iw
.
This led me to find the linked answers, but they have less than satisfying explanations, and are on StackOverflow, and not vi.SE, to boot.
So,
What is the vi-semantic meaning of g
?
By vi-semantic meaning, I expect people to understand, as ciw
means change in word, so c
means change, i
, means inner text item, and w
means word delineated by space or punctuation excluding _
.
P.S., how do I tag this?
key-bindings normal-mode
key-bindings normal-mode
edited Jan 31 at 20:27
malan
asked Jan 30 at 15:57
malanmalan
2057
2057
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
g is a little bit of a weird key in vim. A lot of other keys have a specific word to describe their category:
h
,j
,k
,l
,}
,{
,w
,e
, etc. are all motions. They tell your cursor to move.d
,c
,y
, etc. are all operators. They change the text they operate on in a specific way, and you tell them what text to operate on by giving a motion.
g
does not have a name like this. If I had to come up with a name, I would call it a namespace. Bram Moolenaar and Bill Joy I'm sure had many useful operations (such as go the beginning/end of the file, or go to [line]
) that make sense to create a shortcut for in default vim, but they're not going to be used often enough to justify giving them a one-key shortcut, since these are reserved for the more useful/frequently used things like hjkl
, or d
and p
, and there's only 95 keys to pick from. There are tons of keyboard shortcuts that all start with g
. What do they have in common? Absolutely nothing. They just happen to be useful things to have that aren't worth giving a one-key shortcut for.
So really, gg
is a motion just like all the other motions I listed, it just happens to use a two-key sequence. g~
is an operator just like all the other operators I listed, it just happens to use a two-key sequence.
There are several other "namespace" like keys in vim. For example, look up in help
:h z
(Commands that start with 'z')
:h [
(Commands that start with '[')
2
Sog
is like a system leader, as opposed to a user leader. Just have to memorize the combos. Thank you.
– malan
Jan 30 at 16:58
6
g and z and really like namespaces for the next character. That's because we have been slowly running out of keys on a keyboard, so commands that are useful, had been added to those keys
– Christian Brabandt
Jan 30 at 17:08
@ChristianBrabandt Yes, namespace is a great word for that.
– DJMcMayhem♦
Jan 30 at 17:11
1
IMHO this answer should not use the word leader since a leader key exists in vim and should not be confused withg
,z
,[
,]
, and<C-w>
. I would usenamespace key
as suggested.
– Hotschke
Jan 31 at 8:28
1
More importantly,g
andz
were two keys not used in normal mode by vi. Given how few keys were available, using them as prefixes for Vim-specific commands was really the only way to add a lot of new normal mode commands without resorting to chording.
– jamessan
Feb 1 at 0:43
|
show 1 more comment
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "599"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fvi.stackexchange.com%2fquestions%2f18744%2fwhat-is-the-meaning-of-g%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
g is a little bit of a weird key in vim. A lot of other keys have a specific word to describe their category:
h
,j
,k
,l
,}
,{
,w
,e
, etc. are all motions. They tell your cursor to move.d
,c
,y
, etc. are all operators. They change the text they operate on in a specific way, and you tell them what text to operate on by giving a motion.
g
does not have a name like this. If I had to come up with a name, I would call it a namespace. Bram Moolenaar and Bill Joy I'm sure had many useful operations (such as go the beginning/end of the file, or go to [line]
) that make sense to create a shortcut for in default vim, but they're not going to be used often enough to justify giving them a one-key shortcut, since these are reserved for the more useful/frequently used things like hjkl
, or d
and p
, and there's only 95 keys to pick from. There are tons of keyboard shortcuts that all start with g
. What do they have in common? Absolutely nothing. They just happen to be useful things to have that aren't worth giving a one-key shortcut for.
So really, gg
is a motion just like all the other motions I listed, it just happens to use a two-key sequence. g~
is an operator just like all the other operators I listed, it just happens to use a two-key sequence.
There are several other "namespace" like keys in vim. For example, look up in help
:h z
(Commands that start with 'z')
:h [
(Commands that start with '[')
2
Sog
is like a system leader, as opposed to a user leader. Just have to memorize the combos. Thank you.
– malan
Jan 30 at 16:58
6
g and z and really like namespaces for the next character. That's because we have been slowly running out of keys on a keyboard, so commands that are useful, had been added to those keys
– Christian Brabandt
Jan 30 at 17:08
@ChristianBrabandt Yes, namespace is a great word for that.
– DJMcMayhem♦
Jan 30 at 17:11
1
IMHO this answer should not use the word leader since a leader key exists in vim and should not be confused withg
,z
,[
,]
, and<C-w>
. I would usenamespace key
as suggested.
– Hotschke
Jan 31 at 8:28
1
More importantly,g
andz
were two keys not used in normal mode by vi. Given how few keys were available, using them as prefixes for Vim-specific commands was really the only way to add a lot of new normal mode commands without resorting to chording.
– jamessan
Feb 1 at 0:43
|
show 1 more comment
g is a little bit of a weird key in vim. A lot of other keys have a specific word to describe their category:
h
,j
,k
,l
,}
,{
,w
,e
, etc. are all motions. They tell your cursor to move.d
,c
,y
, etc. are all operators. They change the text they operate on in a specific way, and you tell them what text to operate on by giving a motion.
g
does not have a name like this. If I had to come up with a name, I would call it a namespace. Bram Moolenaar and Bill Joy I'm sure had many useful operations (such as go the beginning/end of the file, or go to [line]
) that make sense to create a shortcut for in default vim, but they're not going to be used often enough to justify giving them a one-key shortcut, since these are reserved for the more useful/frequently used things like hjkl
, or d
and p
, and there's only 95 keys to pick from. There are tons of keyboard shortcuts that all start with g
. What do they have in common? Absolutely nothing. They just happen to be useful things to have that aren't worth giving a one-key shortcut for.
So really, gg
is a motion just like all the other motions I listed, it just happens to use a two-key sequence. g~
is an operator just like all the other operators I listed, it just happens to use a two-key sequence.
There are several other "namespace" like keys in vim. For example, look up in help
:h z
(Commands that start with 'z')
:h [
(Commands that start with '[')
2
Sog
is like a system leader, as opposed to a user leader. Just have to memorize the combos. Thank you.
– malan
Jan 30 at 16:58
6
g and z and really like namespaces for the next character. That's because we have been slowly running out of keys on a keyboard, so commands that are useful, had been added to those keys
– Christian Brabandt
Jan 30 at 17:08
@ChristianBrabandt Yes, namespace is a great word for that.
– DJMcMayhem♦
Jan 30 at 17:11
1
IMHO this answer should not use the word leader since a leader key exists in vim and should not be confused withg
,z
,[
,]
, and<C-w>
. I would usenamespace key
as suggested.
– Hotschke
Jan 31 at 8:28
1
More importantly,g
andz
were two keys not used in normal mode by vi. Given how few keys were available, using them as prefixes for Vim-specific commands was really the only way to add a lot of new normal mode commands without resorting to chording.
– jamessan
Feb 1 at 0:43
|
show 1 more comment
g is a little bit of a weird key in vim. A lot of other keys have a specific word to describe their category:
h
,j
,k
,l
,}
,{
,w
,e
, etc. are all motions. They tell your cursor to move.d
,c
,y
, etc. are all operators. They change the text they operate on in a specific way, and you tell them what text to operate on by giving a motion.
g
does not have a name like this. If I had to come up with a name, I would call it a namespace. Bram Moolenaar and Bill Joy I'm sure had many useful operations (such as go the beginning/end of the file, or go to [line]
) that make sense to create a shortcut for in default vim, but they're not going to be used often enough to justify giving them a one-key shortcut, since these are reserved for the more useful/frequently used things like hjkl
, or d
and p
, and there's only 95 keys to pick from. There are tons of keyboard shortcuts that all start with g
. What do they have in common? Absolutely nothing. They just happen to be useful things to have that aren't worth giving a one-key shortcut for.
So really, gg
is a motion just like all the other motions I listed, it just happens to use a two-key sequence. g~
is an operator just like all the other operators I listed, it just happens to use a two-key sequence.
There are several other "namespace" like keys in vim. For example, look up in help
:h z
(Commands that start with 'z')
:h [
(Commands that start with '[')
g is a little bit of a weird key in vim. A lot of other keys have a specific word to describe their category:
h
,j
,k
,l
,}
,{
,w
,e
, etc. are all motions. They tell your cursor to move.d
,c
,y
, etc. are all operators. They change the text they operate on in a specific way, and you tell them what text to operate on by giving a motion.
g
does not have a name like this. If I had to come up with a name, I would call it a namespace. Bram Moolenaar and Bill Joy I'm sure had many useful operations (such as go the beginning/end of the file, or go to [line]
) that make sense to create a shortcut for in default vim, but they're not going to be used often enough to justify giving them a one-key shortcut, since these are reserved for the more useful/frequently used things like hjkl
, or d
and p
, and there's only 95 keys to pick from. There are tons of keyboard shortcuts that all start with g
. What do they have in common? Absolutely nothing. They just happen to be useful things to have that aren't worth giving a one-key shortcut for.
So really, gg
is a motion just like all the other motions I listed, it just happens to use a two-key sequence. g~
is an operator just like all the other operators I listed, it just happens to use a two-key sequence.
There are several other "namespace" like keys in vim. For example, look up in help
:h z
(Commands that start with 'z')
:h [
(Commands that start with '[')
edited Jan 31 at 22:07
answered Jan 30 at 16:46
DJMcMayhem♦DJMcMayhem
10.8k12862
10.8k12862
2
Sog
is like a system leader, as opposed to a user leader. Just have to memorize the combos. Thank you.
– malan
Jan 30 at 16:58
6
g and z and really like namespaces for the next character. That's because we have been slowly running out of keys on a keyboard, so commands that are useful, had been added to those keys
– Christian Brabandt
Jan 30 at 17:08
@ChristianBrabandt Yes, namespace is a great word for that.
– DJMcMayhem♦
Jan 30 at 17:11
1
IMHO this answer should not use the word leader since a leader key exists in vim and should not be confused withg
,z
,[
,]
, and<C-w>
. I would usenamespace key
as suggested.
– Hotschke
Jan 31 at 8:28
1
More importantly,g
andz
were two keys not used in normal mode by vi. Given how few keys were available, using them as prefixes for Vim-specific commands was really the only way to add a lot of new normal mode commands without resorting to chording.
– jamessan
Feb 1 at 0:43
|
show 1 more comment
2
Sog
is like a system leader, as opposed to a user leader. Just have to memorize the combos. Thank you.
– malan
Jan 30 at 16:58
6
g and z and really like namespaces for the next character. That's because we have been slowly running out of keys on a keyboard, so commands that are useful, had been added to those keys
– Christian Brabandt
Jan 30 at 17:08
@ChristianBrabandt Yes, namespace is a great word for that.
– DJMcMayhem♦
Jan 30 at 17:11
1
IMHO this answer should not use the word leader since a leader key exists in vim and should not be confused withg
,z
,[
,]
, and<C-w>
. I would usenamespace key
as suggested.
– Hotschke
Jan 31 at 8:28
1
More importantly,g
andz
were two keys not used in normal mode by vi. Given how few keys were available, using them as prefixes for Vim-specific commands was really the only way to add a lot of new normal mode commands without resorting to chording.
– jamessan
Feb 1 at 0:43
2
2
So
g
is like a system leader, as opposed to a user leader. Just have to memorize the combos. Thank you.– malan
Jan 30 at 16:58
So
g
is like a system leader, as opposed to a user leader. Just have to memorize the combos. Thank you.– malan
Jan 30 at 16:58
6
6
g and z and really like namespaces for the next character. That's because we have been slowly running out of keys on a keyboard, so commands that are useful, had been added to those keys
– Christian Brabandt
Jan 30 at 17:08
g and z and really like namespaces for the next character. That's because we have been slowly running out of keys on a keyboard, so commands that are useful, had been added to those keys
– Christian Brabandt
Jan 30 at 17:08
@ChristianBrabandt Yes, namespace is a great word for that.
– DJMcMayhem♦
Jan 30 at 17:11
@ChristianBrabandt Yes, namespace is a great word for that.
– DJMcMayhem♦
Jan 30 at 17:11
1
1
IMHO this answer should not use the word leader since a leader key exists in vim and should not be confused with
g
, z
, [
, ]
, and <C-w>
. I would use namespace key
as suggested.– Hotschke
Jan 31 at 8:28
IMHO this answer should not use the word leader since a leader key exists in vim and should not be confused with
g
, z
, [
, ]
, and <C-w>
. I would use namespace key
as suggested.– Hotschke
Jan 31 at 8:28
1
1
More importantly,
g
and z
were two keys not used in normal mode by vi. Given how few keys were available, using them as prefixes for Vim-specific commands was really the only way to add a lot of new normal mode commands without resorting to chording.– jamessan
Feb 1 at 0:43
More importantly,
g
and z
were two keys not used in normal mode by vi. Given how few keys were available, using them as prefixes for Vim-specific commands was really the only way to add a lot of new normal mode commands without resorting to chording.– jamessan
Feb 1 at 0:43
|
show 1 more comment
Thanks for contributing an answer to Vi and Vim Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fvi.stackexchange.com%2fquestions%2f18744%2fwhat-is-the-meaning-of-g%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown