3 ms·
Amazingly, this is the first I've heard of fx/tx/Fx. How ridiculously awesome.
by lanstein 17y ago
Amazingly, this is the first I've heard of fx/tx/Fx. How ridiculously awesome.
- latortuga 17y agoThis is especially powerful when trying to move small chunks of code around. Say you have something like document.getElementById('asweetid') and you want to grab just the id for use elsewhere. In command mode pressing f' will move your cursor to the quote, yf' will put 'asweetid' into your yank register and a p anywhere else will paste it. I also make heavy use of ctx where x is a character on a line that I want to replace up to. The best part about vim, I think, is how I think about the commands in my head and they just kind of flow out of my fingers. "Hmm I want to change (press c) to (press t) that closing paren (press shift 0)." Even just typing that my left hand instinctively moved toward the caps lock to go to command mode.
- nostrademons 17y agoYeah, I use 'dt,' or 'dt)' all the time to move single arguments of functions around, and 'd%' to move the function calls themselves.
- puffythefish 17y agoyi' will also work in this example.
- joshuaxls 17y agoI have this printed out and taped up right next to my monitor: http://wint1.kaist.ac.kr/files/attach/images/59/450/vi-vim-cheat-sheet.gif http://wint1.kaist.ac.kr/files/attach/images/59/450/vi-vim-c... It's helped me polish off those last few vim commands that I never got used to. I recommend looking at it daily.
- chewbranca 17y agoI've got that cheat sheet saved on my computer and I've looked at it several times before, but today was the first time I realized that you can hit '&' to repeat the last :s command on the current line. Very slick!!
- joshuaxls 17y agoYep, and 'g&' is really helpful. It runs the last substitute across the entire file, preserving flags.
- sofal 17y agoI thought I was a Vim master and I just looked at that and discovered once again how stupid and inefficient I've been this whole time. This sort of thing keeps happening to me with Vim.
- mhansen 17y agoSource: http://www.viemu.com/a_vi_vim_graphical_cheat_sheet_tutorial.html http://www.viemu.com/a_vi_vim_graphical_cheat_sheet_tutorial... That's the tutorial that fed me that chart in easy-to-manage pieces, easing me into vim nicely. Also highly recommended, the rant by the same guy: http://www.viemu.com/a-why-vi-vim.html http://www.viemu.com/a-why-vi-vim.html