Vim ways of adding a character to the end of the line
Ok, so in these annoying little languages that require a
;
at the end of the line or they piss and cry, how can I add that easily? I mean in situation when I finish writing my code and the cursor isn't at the end of the line, like when you have a function or a string that pair ()
""
is added automatically so your cursor ends up before those characters like in the picture, how do I add the ;
at the end of the line in the easiest way?35 Replies
using the arrow keys is annoying and not really the vim way of doing things, but going into normal mode like
<esc>$a;
is so much work, maybe there's some hidden command I don't know about?
ok nvm I remembered there's uppercase letters too and uh... <esc>A;
does the job without using $
, is that the shortest method?that's what I was going to suggest, but you could look for a plugin. I got one for when I use vscode so that alt+; adds a semicolon at the end of the line regardless of where I am.
I have this shortcut added that does that, as well as for commas, useful when editing objects/lists/dicts
Just tap
;
twice while in insert mode and it will append it to the end of the line.I am definitely stealing that one
Full credit goes to Jess Archer: https://github.com/jessarcher/dotfiles
GitHub
GitHub - jessarcher/dotfiles: $HOME sweet $HOME
$HOME sweet $HOME. Contribute to jessarcher/dotfiles development by creating an account on GitHub.
in case anyone needs this in vimscript instead of lua:
also, wow, Discord has highlighting for vim
I think it uses highlight.js for syntax highlighting
Brilliant
remaps
I personally use a n map and use leader ; ,
Something about the delay in insert bugs me for stuff like this. Same with jk escapes
I also used ; to exit insert for a long time, recently been trying to kick the habit 😂
delay?
I didn't feel any
you used
;
to EXIT insert mode?
what in the JS developer is wrong with youYea I mean I always just hit
;
leader ;
if I need one or if it needs to be at the end of a word ;
leader leader ;
I am trying to break away from using ;
to exit insert though cause it screws with me if I'm without my binds xD
its really nice though >.>;;
I think you can set the time to accept next combo it but there is
forget how it screwed with me but it did xDidk what my timing is but the whole thing happens pretty fast, even if I try to immediately do something else it works fine
so we good 😎
the way it works for me, is that there's a delay before inserting the first ; if you don't press the second, but if you tap it twice it immediately inserts the semicolon at the end as soon as you press it
oooh didn't try that
but yeah I'll just be pressing it immediately since I know when I want it to happen
unless my brain shuts down
what if you just need one after a word then
you have to pause for it to insert
esc
leader ;
❤️
stays in normal mode and i just roll tidethen I have to
esc
typing
hello ; world
produces exactly that, even if you don't waityeah just tried it, I can see the delay, it's small but it is there
how often are you just in insert after ending a line though?
;
isn't a shortcut, so it defaults to just entering both charactersit does keep writing as you would expect it to tho
oh that's true good point
I mean, every line needs a
;
in Rust so... I gotta add it but I need to keep writingthe delay is visible until you press space, there's no actual difference in entering characters or timing on your part
I think my issue was more with
jj
jk
bindings I never could get used to them for esc
ah I just use o
xD
like same amount of keypress if I was in insert still and hitting enter 🤷♂️as for how often? often enough that I installed plugins for it in vscode so that I don't have to do
[end];
and can just do alt+;
or alt+shift+;
for "semicolon at the end, new line"this is what I love about keybinds hah everyone has a personal preference, its neat to see how others do things
in languages where they're required, and if you're used to it in javascript too, there's a lot of times where your (I|P)DE will autocomplete the closing brackets and quotes, and you have to add stuff to the end. When I'm writing PHP, it's at least every other line I'd use something like this
I'm experimenting cause I forget what I normally do lol, right now the keybind is
;;
<Esc>A;<Esc>
so I do end up in normal mode
this was my issue yes
I didn't think about just adding a bind for it in insert mode
good thing Jao shared that linkI didn't even really consciously know that was an option
I might add some more, there's a bunch of commands that I'd love to shorten
ci"
or ci(
might be nice to just have as cc
dangerous though cause you get in those habits you only have them in your env xD
I do
shift+hjkl
for word movement and it always screws me with J hah start merging lines
cib and ciB do b=()
and B={}
too if you didn't know, probably easier to type for most.I'm fine with just
;;
because it's a character that doesn't happen besides the end of a line, I'm not really writing them all over the place (except the occasional for loop) but if I start adding more letters I would notice that delay and it would bother me even if I can just keep typing normally
this is what a dotfiles repo is for sure I do that for ssh too but I'm talking all over
codepen i.e.
ah, I forget you can set that to use vim keybinds too
codepen?
TIL
not that I use it anyway with vim keybinds pretty good tho 👍