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

Split lines in normal mode (opposite of Shift + J) #4541

Closed
fillipe-gsm opened this issue Oct 31, 2022 · 2 comments
Closed

Split lines in normal mode (opposite of Shift + J) #4541

fillipe-gsm opened this issue Oct 31, 2022 · 2 comments
Labels
C-enhancement Category: Improvements

Comments

@fillipe-gsm
Copy link

fillipe-gsm commented Oct 31, 2022

For merging multiple lines there is the J keymap. For instance, if I have

def my_function(
    variable: int
) -> int:

if my cursor is on the first line I can press J twice and get

def my_function(variable: int) -> int:

all of this in normal mode.
But for the opposite I have to move the cursor right before variable, go to Insert mode, press the return key, go back to Normal mode, and repeat. This gets tedious really quickly on multiple formatting.

On Vim and Neovim I managed to map Ctrl + j to the <nl> command, but any other combination on normal mode should be fine.
Is it possible to do the same with Helix?

Edit: replace Shift + j with simply J.

@fillipe-gsm fillipe-gsm added the C-enhancement Category: Improvements label Oct 31, 2022
@the-mikedavis
Copy link
Member

What is <nl> in Vim? It inserts a newline?

Macro key-bindings would be a solution for this - you could bind a key to enter insert mode, add a newline, and go back to normal mode #1383

@fillipe-gsm
Copy link
Author

Thanks for the quick response.
So instead of an actual macro key-binding I follow your suggestion and added a new key mapping:

# config.toml
[keys.normal]
C-j = ["insert_mode", "insert_newline", "normal_mode"]

so I can now add line breaks in specific points without leaving normal mode.

Thank you once more!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Improvements
Projects
None yet
Development

No branches or pull requests

2 participants