Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I insert a linebreak where the cursor is without entering into insert mode in VSCodeVim? #3636

Closed
liby opened this issue Mar 29, 2019 · 4 comments

Comments

@liby
Copy link

liby commented Mar 29, 2019

Is your feature request related to a problem? Please describe.
Is possible to insert a line break where the cursor is in Vim without entering into insert mode?
Sometimes, I might want to type more code.I press I into insert mode, press Enter to insert a newline character, and then I start typing code
I've been doing this a while, but there's surely a better way to do it?

Describe the solution you'd like
After adding a new line after the current cursor, split the current line, similar to "J" will merge multiple lines of code without entering insert mode!

Describe alternatives you've considered
Map keys like Vimrc

Additional context
Is there a similar (or relatively short) one-key command that splits a line at a given cursor position?
Similar problem links

@vernvandamn
Copy link

Maybe this is what you've already considered but it does work.
This assigns +f (change that to be whatever you like) to do what you're looking for. If you don't want to enter insert mode add , "" to the after property.
Add this to your settings.json:
"vim.normalModeKeyBindingsNonRecursive": [
{
"before": [ "", "f" ],
"after": ["i", ""]
}
],

@liby
Copy link
Author

liby commented Mar 29, 2019

@vernvandamn Perfect solution,thx!

"vim.normalModeKeyBindingsNonRecursive": [{
        "before": ["f"],
        "after": ["i", "<Enter>", "Esc"]
    }]

@liby liby closed this as completed Mar 29, 2019
@vernvandamn
Copy link

@liby I'm glad you got what I was trying to say I just realized looking back that parts of my comment were filtered out.
f is used to find a character in the line you're in (e.g. f-m finds the next "m" in the current line). You might still want to use that.
Maybe even better than using "f" something like this could work:
"vim.normalModeKeyBindingsNonRecursive": [{ "before": ["<leader>", "i"], "after": ["i", "<Enter>", "Esc"] }]

@liby
Copy link
Author

liby commented Mar 30, 2019

Great, thank you.I learned something new. @vernvandamn
China is particular about drawing inferences from one example,The ideas you've provided have helped me a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants