← Back to Upcase

Surviving Your First Week in Vim (and beyond) | Upcase


(Upcase ) #1
Ben & Chris give some tips and tricks on how to survive your first week in Vim. A great cheat sheet (Remember, you need this one and your own smaller one). Start with this minimal vimrc
This is a companion discussion topic for the original entry at https://thoughtbot.com/upcase/videos/surviving-your-first-week-in-vim

(Cyle Hunter) #2

I’ve made the switch to Vim about a month ago. I was in love with Sublime, but I spend so much time in the console and on remote CLIs that it really warranted the switch. So far no regrets, the only minor complaint that I have is the 256 colour limitation, haven’t found a work around for that one just yet and it wouldn’t make any sense for me to use gvim over Sublime for reasons stated above. This means slightly less colour scheme options, but definitely not anything progress stopping.

For anybody using Sublime looking to make the switch but can’t quite wean themselves off: just to get your feet wet with the idea of less mouse interactions try working in full screen mode. They have various keystrokes that will allow you to navigate tabs/files just as efficiently as if you were to use your mouse. They even have a vim mode for sublime, I haven’t tried it myself, but perhaps a good introduction.


(PAUL R BROADFOOT) #3

I switched to Vim two months ago thanks to Ben Orenstein’s advice, and have become vastly more productive than I ever was using Sublime. It’s painful for the first 2 days, but stick with it, and you will have no regrets. After you’ve been using it at least a week, check out tpope’s vim-rails plugin and Chris Toomey’s tmux trail on Upcase.


(Anthony) #4

One drawback, when starting to use Vim, is that you start using the Vim key shortcuts in other program’s too. Every now and then I catch myself wanting to use the direction keys (hjkl) in my email client, or some other sofware tool. Anyone else had that experience?


(Thom Obarski) #5

Hey all; we have some great additional Vim resources on our Youtube Channel from various meetups we’ve filmed. Enjoy!


(Aaron Mc Adam) #6

Yep, vim has worked its way so far into my muscle memory that I try to use its key mappings everywhere such as when typing a url into the address bar or writing an email or GitHub comment, hammering esc wondering why I can’t delete 2 lines at once hah :smiley:


(Denis Pankratov) #7

Yes. Same here. Great that Chrome has a “Vimium” extension that uses Vim motion commands.
Besides, if you use Gmail via web they also have “j” and “k”.


(mciul) #8

The cheat sheet is great! I’m curious about one thing I saw: _ is labeled as “soft” bol down, but when I try it out, it seems to do the same as ^ - going to the first nonblank character on the current line and not the next line. Is something wrong with my configuration or is that expected behavior?


(Hassan Khalid) #9

Hi @benorenstein and @christoomey Thanks for the encouragement!

I’ve had a on off love affair with vim for about 10 years and have finally now just started using it as my only editor! So thanks to Ben who first awed me by showing off mad vim skills in his talk at the RubyBath Conference and then Chris for introducing tmux!

one thing that I found really useful have the http://vim-adventures.com/ game. It really kept challenging me! (although it was difficult to convince my managing director that it was training for work). Also one other thing I wanted to add was instead of pressing Esc I use Ctrl + c to exit INSERT mode. It makes such a big difference, specially if you map the CapLock key as a Ctrl as well! It keeps my on the home row a lot more i find :smile:.

@benorenstein while at the BathRuby conference you were showing off how to run tests with vim and how the pane should hide itself if all tests are passing. I manage to run the tests with vim-rspec, but was hoping you could reveal the secret of auto-hiding the pane if its all green and display the failure?

Many thanks, and keep it up!!!
– Hassan


(Chris Toomey) #10

Hey @hass_isnull, the plugin @benorenstein used in the video is vim-dispatch from tpope. It handles running commands from Vim and will detect and use tmux if present.


(Anthony Lee) #11

@christoomey what is a best way to configure vim so it can copy/paste from Tmux and iTerm? I still haven’t found a good solution to do so… I thought you wrote an article about it a while ago. Does it still apply?


(Chris Toomey) #12

Hey @antwonlee, the post I wrote about tmux copy and paste is still relevant and is in fact how I copy and paste in tmux.

I’ve seen a number of people who connect Vim to the system clipboard, e.g. how @gabe does in his dotfiles by using the unnamed clipboard.

Personally I like the clipboard interaction to be more explicit, so I use the following to set up pasting:

nnoremap <leader>p :r!pbpaste<cr>

And a plugin I wrote to allow copying to the system clipboard via text-objects and motions, vim-system-copy.


(Anthony Lee) #13

@christoomey you are a true tmux jedi master. It is working and it just changed my life. :stuck_out_tongue_winking_eye:


(Aaron Mc Adam) #14

Hey @christoomey, thanks for this, it’s a much better binding than the one I was using before.

I know I can use :! to call any shell command, but what does :r! do?


(Chris Toomey) #15

@antwonlee thanks for the kind words!

@aaronmcadam in general :r is short for :read which will read in the contents of a file. :r! or :read! will read in the output of a shell command, e.g. :r! ls will read into the buffer the output of ls.


(Aaron Mc Adam) #16

Ah, that’s really cool, thanks!


(Geoff Harcourt) #17

@christoomey, slightly related question:

I have had zero luck finding this in the vim documentation or on Google, so apologies if there’s some easy source I’ve missed.

Is there a way to send a command with arguments to :read!? I’m trying to build a vim alias to paste a timestamp using the shell date command in a file, but date takes an argument, and I can’t seem to get the quoting or backticks right. I’d like to do something like this:

inoremap <C-t> <C-o>:read! date +%Y%m%d%H%M%S<CR>

but I’m not having any luck.


(Chris Toomey) #18

Hey @geoffharcourt,

No easy source that I know of. For this I would use the expression register rather than trying to use :read!. The expression register is activated by typing <C-r>= in insert mode (<C-r> waits for a register to paste from, = goes into the expression register sub-mode). You can then use system() to call out to date. All together as a map (with a substitute to chop off the trailing newline):

inoremap <C-t> <C-r>=substitute(system("date +%Y%m%d%H%M%S"), '\n$', '', '')<cr>

(Geoff Harcourt) #19

@christoomey, works great, and now I know something new. Thanks again.


(Luke Bacon) #21

Hey all, does anyone have the link for the fuzzy search plugin mentioned?

Thanks for your help!