First you'll just use it for reformatting and doing quick edits on a server, then you'll realize it's good enough for everything else as well. Simple as.
If you think "is there a way to make this process faster?" then the answer is yes and you should always act on this impulse. This is how you get better organically. Getting lazy or passive during these moments is common but they are ideal learning opportunities and one should be aware of this.
I’ve only seen Luke “Let me give you a 20 minute lecture about how living in the countryside lowers your living costs despite the fact every moron knows this obvious fact” Smith using Vim and even then he only does it because he thinks anything that makes him look like more of a boomer stereotype is based.
>How do I get good at playing the guitar? >How do I get good at baking bread? >How do I get good at speaking Spanish? >How do I get good at digital photography? >How do I get good at chess? >How do I get good at calling OP a gay? >How do I get good at public speaking? >How do I get good at yoga? >How do I get good at programming in Python? >How do I get good at gardening? >How do I get good at drawing? >How do I get good at swimming? >How do I get good at knitting? >How do I get good at playing piano? >How do I get good at woodworking? >How do I get good at investing in stocks? >How do I get good at writing poetry? >How do I get good at running? >How do I get good at cooking Italian cuisine? >How do I get good at video editing? >How do I get good at playing soccer? >How do I get good at meditation? >How do I get good at playing chess? >How do I get good at solving puzzles? >How do I get good at making israeliteelry? >How do I get good at playing the violin? >How do I get good at cycling? >How do I get good at singing? >How do I get good at interior design? >How do I get good at playing basketball? >How do I get good at calligraphy? >How do I get good at acting? >How do I get good at surfing?
I'm hijacking this thread to ask a specific vim question!!!!
// Comment1
// Comment2
// Comment3
foo = 1;
bar = 2;
baz = 3;
What is the best way to append each comment after each line WITH a blank space separating them?
I currently get by with >Start at first comment, first column >CTRL+V (enters visual block mode) >2j (select first column of all 3 comments) >$ (select up until end of line for all 3 comments) >h (remove newline from the selection) >y (yank) >4j (go to foo) >A (to append to end of current line) >space (to insert the blank space) >ESC (return to normal mode, or CTRL+O for normal mode for only one command) >p (paste the default register)
just something sloppy like that yeah, if there are only three lines it will take more time to figure out an efficient than to just do it
but if there are like 7+ lines i would record a macro that does 1 line and then repeat however many times you want
What do you mean? This approach is completely independent of the number of lines because the operation is the same. It's a one and done. You don't need to keep repeating it
My question is if this is as efficient as it gets for this particular use case or if there's some way I could >Grab a whole visual block >Yank it >Paste it as is and auto-inserting a space since it's going beyond what is currently in the destination lines
just something sloppy like that yeah, if there are only three lines it will take more time to figure out an efficient than to just do it
but if there are like 7+ lines i would record a macro that does 1 line and then repeat however many times you want
I'm hijacking this thread to ask a specific vim question!!!!
// Comment1
// Comment2
// Comment3
foo = 1;
bar = 2;
baz = 3;
What is the best way to append each comment after each line WITH a blank space separating them?
I currently get by with >Start at first comment, first column >CTRL+V (enters visual block mode) >2j (select first column of all 3 comments) >$ (select up until end of line for all 3 comments) >h (remove newline from the selection) >y (yank) >4j (go to foo) >A (to append to end of current line) >space (to insert the blank space) >ESC (return to normal mode, or CTRL+O for normal mode for only one command) >p (paste the default register)
If it's a lot of rows I might do something like
:g///.m5 | -j
If there's more stuff in the file than just those lines you may have to visual select the lines first (or put 1,7 or whatever the line numbers are, before the g)
if you want it to be as few keystrokes as possible (if you're playing vimgolf or something) you could just type it as
:g'/'m5|-j
And to break down what it does:
:g'<pattern>'<action> finds all lines with <pattern> and performs <action> for each of those lines. So in this case it finds all lines with a / (this assumes none of the variable names contain forward-slashes, otherwise the pattern would need to be different or longer (or using a range instead)). And then it moves that line 5 lines down (m5) and then (the vertical bar separates several commands) goes one line up with the - and joins that line with the next with the j.
if you want it to be as few keystrokes as possible (if you're playing vimgolf or something) you could just type it as
:g'/'m5|-j
And to break down what it does:
:g'<pattern>'<action> finds all lines with <pattern> and performs <action> for each of those lines. So in this case it finds all lines with a / (this assumes none of the variable names contain forward-slashes, otherwise the pattern would need to be different or longer (or using a range instead)). And then it moves that line 5 lines down (m5) and then (the vertical bar separates several commands) goes one line up with the - and joins that line with the next with the j.
That's insane, thank you. And here I was happy with my new solution here
[...]
[...]
I think I have found my own answer. The key is in an option called 'virtualedit' (thanks vim manual).
:set ve=all
>ctrl+v >2j >$ >h >d >"_d3j >$ >l >p
Less steps and also we've made sure the comments in their original form were deleted above, along with not leaving a bunch of newlines.
Also learning about the black hole register (_) was fun.
How do you make it so that this last command also cleans up the newline at the top when it's done?
I'd probably start by deleting the blank line. So then the full command is
:4d|g'/'m4|-j
Maybe there's some way to reduce the keystrokes even more, but I'd have to think. Really though, the way you wrote it first is how I'd do it in the moment. This is just if it were a lot more lines or I'd need to put it in a script or something.
2 weeks ago
Anonymous
Makes sense. Thanks anon, you've taught me something new.
i was on a g4 powerbook and couldn't get a better editor for it.
it takes like ten seconds to learn. OooOoOhh hjkl except the arrow keys work. Press i to get a normal editor, esc then :w<enter> to save, everything else is just bonus, you can pick it up slowly over time.
>having 3 seperate interaction modes instead of just holding shift to do something will somehow make my workflow much faster
I've read tons of posts on the internet that apparently being good at vim will grant massive efficiency gains, now I'm really tempted to try but honestly it sounds like a load of bullshit
I can't see how this shit would be much faster than fully utilizing VSCodium shortcuts + command pallete
if you just get some vscode vim extension you still have vsc's shortcuts and command pallete, just with a normal mode you can drop into when u dont feel like pressing shift right repeatedly
I will never not find it funny that the quickfix list shortcut is
:cope
Because cope is what you're gonna be doing going through your compile errors with it. It's short for "quickfix window open" I guess.
Which by the way, I seriously hope you're not jumping to a different terminal/tmux tile to do your compiling. You can just do it in vim with :make
Literally just run vimtutor. I don't know why people overcomplicate learning vim so much--it is honestly not that difficult at all. I'd say 80% of my understanding of vim stems from spending 30 minutes on vimtutor a decade ago, and that's more than enough to be reasonably proficient with vim (or to leverage vim keybindings in other IDEs/editors/applications). The other 20% has just come organically over time, either from picking up on little tricks or functions here or there, or from having a particular need and thinking to myself "there's probably a specific way to do this in vim", then looking it up and learning it. You don't need to know every little bullshit feature built into vim, nor do you need to be a hardcore terminal-only vim autist to derive benefit from learning vim keybindings.
I wasn't referring to gvim, I was referring more broadly to using vim keybindings in other applications. I constantly see people dismiss learning vim because they think it's just some autistic terminal editor or whatever--but my point is that even if you aren't doing all of your work in vim specifically, vim keybindings are very portable and you can leverage them in other applications.
doesn't really matter. neovim has slightly better defaults and all of the development/plugin focus is on neovim these days (if you have the desire to turn it into a bloated monstrosity)
im coming from vscode, would the plugin ecosystem be more familiar with neovim?
all I need currently is python and Go plugins for highlighting and static error catching and whatnot
also a minimalist solarized theme
If you're not going to be SSHing into other machines and whatnot, do whatever you want.
If you are going to SSH into other machines, then vim is the sane option because it's everywhere. A simple config file is all you need to feel right at home (or something like Tim Pope's sensible defaults https://github.com/tpope/vim-sensible/ )
necessary, but not sufficient
There are tons of people who do things all the time and still suck at them because they never stop to explore and optimize. This happens especially if you are old or low iq
what else do i need to know?
i know:
movement
ctrl-i/o
search/replace
registers but i never use any except the default one
how to make and replay a macro
probably other stuff but i don't realize now.
oh and i have a shit ton of plugins and options.
i don't know vimscript like at all, how important is it?
you need [f]oward and un[t]il if that isn't already included in "movement"
i.e. dfO deletes everything from the cursor to the next O
same for "in" and "around" as in ci( to change in brackets, diw to delete in word, yi" yank in quotes.
Important to note is that if the cursor isn't inside a pair of quotes, or brackets or whatever it will look ahead and do the action in/around the next pair it can find.
. repeats the last action you did.
* searches for the current word under the cursor.
>how do people
They don't.
They just use kate and IDEs
just use it regurally, and whenever you came across something you odnt know how to do just google it. That's the only way to learn it
First you'll just use it for reformatting and doing quick edits on a server, then you'll realize it's good enough for everything else as well. Simple as.
most did not, pine & irssi it was
vimtutor and actually use it
Genuinely makes no intuitive sense whatsoever
Just don't. Wasted years on this garbage just to revert back to chording. If you must use modal editing go with xah-fly-keys
>xah-fly-keys
>NOOOO you have to use the latest and greatest one guys opinion for moving you cursor, tasukete Black person man, I'm going INSANENEEE
If you think "is there a way to make this process faster?" then the answer is yes and you should always act on this impulse. This is how you get better organically. Getting lazy or passive during these moments is common but they are ideal learning opportunities and one should be aware of this.
Mods are asleep, post shortcuts
ZZ saves and quits so you can open a better editor
gj and gk go down/up a wrapped line
J appends the next line to the current line
I’ve only seen Luke “Let me give you a 20 minute lecture about how living in the countryside lowers your living costs despite the fact every moron knows this obvious fact” Smith using Vim and even then he only does it because he thinks anything that makes him look like more of a boomer stereotype is based.
>How do I get good at playing the guitar?
>How do I get good at baking bread?
>How do I get good at speaking Spanish?
>How do I get good at digital photography?
>How do I get good at chess?
>How do I get good at calling OP a gay?
>How do I get good at public speaking?
>How do I get good at yoga?
>How do I get good at programming in Python?
>How do I get good at gardening?
>How do I get good at drawing?
>How do I get good at swimming?
>How do I get good at knitting?
>How do I get good at playing piano?
>How do I get good at woodworking?
>How do I get good at investing in stocks?
>How do I get good at writing poetry?
>How do I get good at running?
>How do I get good at cooking Italian cuisine?
>How do I get good at video editing?
>How do I get good at playing soccer?
>How do I get good at meditation?
>How do I get good at playing chess?
>How do I get good at solving puzzles?
>How do I get good at making israeliteelry?
>How do I get good at playing the violin?
>How do I get good at cycling?
>How do I get good at singing?
>How do I get good at interior design?
>How do I get good at playing basketball?
>How do I get good at calligraphy?
>How do I get good at acting?
>How do I get good at surfing?
so what's your answer, smart guy?
I'm hijacking this thread to ask a specific vim question!!!!
// Comment1
// Comment2
// Comment3
foo = 1;
bar = 2;
baz = 3;
What is the best way to append each comment after each line WITH a blank space separating them?
I currently get by with
>Start at first comment, first column
>CTRL+V (enters visual block mode)
>2j (select first column of all 3 comments)
>$ (select up until end of line for all 3 comments)
>h (remove newline from the selection)
>y (yank)
>4j (go to foo)
>A (to append to end of current line)
>space (to insert the blank space)
>ESC (return to normal mode, or CTRL+O for normal mode for only one command)
>p (paste the default register)
Output:
foo = 1; // Comment1
bar = 2; // Comment2
baz = 3; // Comment3
Surely there's a better way???
just something sloppy like that yeah, if there are only three lines it will take more time to figure out an efficient than to just do it
but if there are like 7+ lines i would record a macro that does 1 line and then repeat however many times you want
What do you mean? This approach is completely independent of the number of lines because the operation is the same. It's a one and done. You don't need to keep repeating it
My question is if this is as efficient as it gets for this particular use case or if there's some way I could
>Grab a whole visual block
>Yank it
>Paste it as is and auto-inserting a space since it's going beyond what is currently in the destination lines
I think I have found my own answer. The key is in an option called 'virtualedit' (thanks vim manual).
:set ve=all
>ctrl+v
>2j
>$
>h
>d
>"_d3j
>$
>l
>p
Less steps and also we've made sure the comments in their original form were deleted above, along with not leaving a bunch of newlines.
Also learning about the black hole register (_) was fun.
gj
Your solution is probably how I'd do it it too.
If it's a lot of rows I might do something like
:g///.m5 | -j
If there's more stuff in the file than just those lines you may have to visual select the lines first (or put 1,7 or whatever the line numbers are, before the g)
if you want it to be as few keystrokes as possible (if you're playing vimgolf or something) you could just type it as
:g'/'m5|-j
And to break down what it does:
:g'<pattern>'<action> finds all lines with <pattern> and performs <action> for each of those lines. So in this case it finds all lines with a / (this assumes none of the variable names contain forward-slashes, otherwise the pattern would need to be different or longer (or using a range instead)). And then it moves that line 5 lines down (m5) and then (the vertical bar separates several commands) goes one line up with the - and joins that line with the next with the j.
That's insane, thank you. And here I was happy with my new solution here
How do you make it so that this last command also cleans up the newline at the top when it's done?
I'd probably start by deleting the blank line. So then the full command is
:4d|g'/'m4|-j
Maybe there's some way to reduce the keystrokes even more, but I'd have to think. Really though, the way you wrote it first is how I'd do it in the moment. This is just if it were a lot more lines or I'd need to put it in a script or something.
Makes sense. Thanks anon, you've taught me something new.
by using it, like you get good in everything.
holy shit just spend a while in vimtutor until you get the hang of it.
open the terminal, type vimtutor and press enter
A more important question WHY do people git gud at vim?
i was on a g4 powerbook and couldn't get a better editor for it.
it takes like ten seconds to learn. OooOoOhh hjkl except the arrow keys work. Press i to get a normal editor, esc then :w<enter> to save, everything else is just bonus, you can pick it up slowly over time.
It's in the saying moron. Buy l use git. Git gud!
Why would you use Vim instead of something normal like Xed or Notepad++?
>having 3 seperate interaction modes instead of just holding shift to do something will somehow make my workflow much faster
I've read tons of posts on the internet that apparently being good at vim will grant massive efficiency gains, now I'm really tempted to try but honestly it sounds like a load of bullshit
I can't see how this shit would be much faster than fully utilizing VSCodium shortcuts + command pallete
if you just get some vscode vim extension you still have vsc's shortcuts and command pallete, just with a normal mode you can drop into when u dont feel like pressing shift right repeatedly
p.s. the real gains aren't in speed, but in incredible comfy and lazy
by learning a 1 new keybind every day and sticking with it
I will never not find it funny that the quickfix list shortcut is
:cope
Because cope is what you're gonna be doing going through your compile errors with it. It's short for "quickfix window open" I guess.
Which by the way, I seriously hope you're not jumping to a different terminal/tmux tile to do your compiling. You can just do it in vim with :make
Post handy random things you have in your .vimrc
https://hastebin.com/share/ilozuwofar.xml
vimtutor
bot thread
>git gud at vim
>all distributions switch their default editor to nano
fake it till you make it
We're getting into the real wacky shit now
https://alok.github.io/2018/04/26/using-vim-s-conceal-to-make-languages-more-tolerable/
>install neovim
>:Tutor
>remap hjkl to jkl;
>spend a week writing code in nvim
>???
>welcome to gigachad club
how are so many Black folk don't get this
hjkl to jkl;
are you moronic perchance?
>The Joy of Vim, parts 1 through 3, by Jerry Peek
https://www.jpeek.com/articles/linuxmag/2006-09/
https://www.jpeek.com/articles/linuxmag/0610.pdf
https://www.jpeek.com/articles/linuxmag/0611.pdf
Other than vimtutor, are there any games or websites that help learn the shortcuts?
Vimtutor and practice
Literally just run vimtutor. I don't know why people overcomplicate learning vim so much--it is honestly not that difficult at all. I'd say 80% of my understanding of vim stems from spending 30 minutes on vimtutor a decade ago, and that's more than enough to be reasonably proficient with vim (or to leverage vim keybindings in other IDEs/editors/applications). The other 20% has just come organically over time, either from picking up on little tricks or functions here or there, or from having a particular need and thinking to myself "there's probably a specific way to do this in vim", then looking it up and learning it. You don't need to know every little bullshit feature built into vim, nor do you need to be a hardcore terminal-only vim autist to derive benefit from learning vim keybindings.
>hardcore terminal-only vim autist
Who even uses graphical vim
Graphical emacs I totally understand, but graphical vim?
I wasn't referring to gvim, I was referring more broadly to using vim keybindings in other applications. I constantly see people dismiss learning vim because they think it's just some autistic terminal editor or whatever--but my point is that even if you aren't doing all of your work in vim specifically, vim keybindings are very portable and you can leverage them in other applications.
type 'man vim' in your terminal then practice using vim.
if I want to get into vim should I go with vim or neovim?
doesn't really matter. neovim has slightly better defaults and all of the development/plugin focus is on neovim these days (if you have the desire to turn it into a bloated monstrosity)
im coming from vscode, would the plugin ecosystem be more familiar with neovim?
all I need currently is python and Go plugins for highlighting and static error catching and whatnot
also a minimalist solarized theme
If you're not going to be SSHing into other machines and whatnot, do whatever you want.
If you are going to SSH into other machines, then vim is the sane option because it's everywhere. A simple config file is all you need to feel right at home (or something like Tim Pope's sensible defaults https://github.com/tpope/vim-sensible/ )
just use it
necessary, but not sufficient
There are tons of people who do things all the time and still suck at them because they never stop to explore and optimize. This happens especially if you are old or low iq
what else do i need to know?
i know:
movement
ctrl-i/o
search/replace
registers but i never use any except the default one
how to make and replay a macro
probably other stuff but i don't realize now.
oh and i have a shit ton of plugins and options.
i don't know vimscript like at all, how important is it?
you need [f]oward and un[t]il if that isn't already included in "movement"
i.e. dfO deletes everything from the cursor to the next O
same for "in" and "around" as in ci( to change in brackets, diw to delete in word, yi" yank in quotes.
Important to note is that if the cursor isn't inside a pair of quotes, or brackets or whatever it will look ahead and do the action in/around the next pair it can find.
. repeats the last action you did.
* searches for the current word under the cursor.
this was a good guide for scripting
https://learnvimscriptthehardway.stevelosh.com/
by having no life and no job