Is there an emacs command to go to end of code line (before line comment and whitespaces start)
say you have that:
stuff
indented stuff # commented stuff
We already got move-beginning-of-line
and back-to-indentation
for the left side. Now, for the right side...
I'd love to know if you are aware of a function that goes at the end of the code line (square position)
stuff
indented stuff□ # commented stuff
should be able to understand the comment symbol depending on mode I guess.
comment motion
migrated from superuser.com Mar 1 at 18:24
This question came from our site for computer enthusiasts and power users.
add a comment |
say you have that:
stuff
indented stuff # commented stuff
We already got move-beginning-of-line
and back-to-indentation
for the left side. Now, for the right side...
I'd love to know if you are aware of a function that goes at the end of the code line (square position)
stuff
indented stuff□ # commented stuff
should be able to understand the comment symbol depending on mode I guess.
comment motion
migrated from superuser.com Mar 1 at 18:24
This question came from our site for computer enthusiasts and power users.
add a comment |
say you have that:
stuff
indented stuff # commented stuff
We already got move-beginning-of-line
and back-to-indentation
for the left side. Now, for the right side...
I'd love to know if you are aware of a function that goes at the end of the code line (square position)
stuff
indented stuff□ # commented stuff
should be able to understand the comment symbol depending on mode I guess.
comment motion
say you have that:
stuff
indented stuff # commented stuff
We already got move-beginning-of-line
and back-to-indentation
for the left side. Now, for the right side...
I'd love to know if you are aware of a function that goes at the end of the code line (square position)
stuff
indented stuff□ # commented stuff
should be able to understand the comment symbol depending on mode I guess.
comment motion
comment motion
edited Mar 9 at 18:14
Dan♦
21.3k549113
21.3k549113
asked Mar 1 at 10:04
v.oddouv.oddou
1284
1284
migrated from superuser.com Mar 1 at 18:24
This question came from our site for computer enthusiasts and power users.
migrated from superuser.com Mar 1 at 18:24
This question came from our site for computer enthusiasts and power users.
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
The package mwim offers this functionality. By setting
(global-set-key (kbd "C-e") 'mwim-end)
you get behavior similar to what you described. The package also offers the corresponding mwim-beginning
command which you can add using
(global-set-key (kbd "C-a") 'mwim-beginning)
See the package README for more.
add a comment |
Here's a quick command, lightly tested, that does what you're looking for.
(defun eol-dwim ()
"Go to the end of the line, ignoring comments and trailing
whitespace."
(interactive)
(let ((bol (line-beginning-position 1))
(eol (line-end-position 1)))
(if (condition-case nil
(comment-search-forward eol)
(error nil))
(re-search-backward comment-start bol nil)
(end-of-line 1))
(skip-syntax-backward " " bol)))
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "583"
};
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%2femacs.stackexchange.com%2fquestions%2f48121%2fis-there-an-emacs-command-to-go-to-end-of-code-line-before-line-comment-and-whi%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
The package mwim offers this functionality. By setting
(global-set-key (kbd "C-e") 'mwim-end)
you get behavior similar to what you described. The package also offers the corresponding mwim-beginning
command which you can add using
(global-set-key (kbd "C-a") 'mwim-beginning)
See the package README for more.
add a comment |
The package mwim offers this functionality. By setting
(global-set-key (kbd "C-e") 'mwim-end)
you get behavior similar to what you described. The package also offers the corresponding mwim-beginning
command which you can add using
(global-set-key (kbd "C-a") 'mwim-beginning)
See the package README for more.
add a comment |
The package mwim offers this functionality. By setting
(global-set-key (kbd "C-e") 'mwim-end)
you get behavior similar to what you described. The package also offers the corresponding mwim-beginning
command which you can add using
(global-set-key (kbd "C-a") 'mwim-beginning)
See the package README for more.
The package mwim offers this functionality. By setting
(global-set-key (kbd "C-e") 'mwim-end)
you get behavior similar to what you described. The package also offers the corresponding mwim-beginning
command which you can add using
(global-set-key (kbd "C-a") 'mwim-beginning)
See the package README for more.
edited Mar 4 at 16:43
answered Mar 4 at 16:04
clemeraclemera
1,875623
1,875623
add a comment |
add a comment |
Here's a quick command, lightly tested, that does what you're looking for.
(defun eol-dwim ()
"Go to the end of the line, ignoring comments and trailing
whitespace."
(interactive)
(let ((bol (line-beginning-position 1))
(eol (line-end-position 1)))
(if (condition-case nil
(comment-search-forward eol)
(error nil))
(re-search-backward comment-start bol nil)
(end-of-line 1))
(skip-syntax-backward " " bol)))
add a comment |
Here's a quick command, lightly tested, that does what you're looking for.
(defun eol-dwim ()
"Go to the end of the line, ignoring comments and trailing
whitespace."
(interactive)
(let ((bol (line-beginning-position 1))
(eol (line-end-position 1)))
(if (condition-case nil
(comment-search-forward eol)
(error nil))
(re-search-backward comment-start bol nil)
(end-of-line 1))
(skip-syntax-backward " " bol)))
add a comment |
Here's a quick command, lightly tested, that does what you're looking for.
(defun eol-dwim ()
"Go to the end of the line, ignoring comments and trailing
whitespace."
(interactive)
(let ((bol (line-beginning-position 1))
(eol (line-end-position 1)))
(if (condition-case nil
(comment-search-forward eol)
(error nil))
(re-search-backward comment-start bol nil)
(end-of-line 1))
(skip-syntax-backward " " bol)))
Here's a quick command, lightly tested, that does what you're looking for.
(defun eol-dwim ()
"Go to the end of the line, ignoring comments and trailing
whitespace."
(interactive)
(let ((bol (line-beginning-position 1))
(eol (line-end-position 1)))
(if (condition-case nil
(comment-search-forward eol)
(error nil))
(re-search-backward comment-start bol nil)
(end-of-line 1))
(skip-syntax-backward " " bol)))
answered Mar 2 at 1:08
Dan♦Dan
21.3k549113
21.3k549113
add a comment |
add a comment |
Thanks for contributing an answer to Emacs 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%2femacs.stackexchange.com%2fquestions%2f48121%2fis-there-an-emacs-command-to-go-to-end-of-code-line-before-line-comment-and-whi%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