← Back to Upcase


(Upcase ) #1
Configuration Nearly everything in Vim can be configured and customized to match your preferences. Now that you have an understanding of core Vim and the power it has, we can dive into discussing how to go about configuring it to match your prefe...
This is a companion discussion topic for the original entry at https://thoughtbot.com/upcase/videos/onramp-to-vim-configuration

(eternal44) #2

Just in case anyone else needs it, you some times need to manually reload $MYVIMRC configs:

:source $MYVIMRC

(thedanotto) #3

Hey… I’m having trouble with getting to recognize my symbolic link

these are my exact commands
cd ~
rm -rf code
rm .vimrc
mkdir -p code/dotfiles/vimrc
ln -s ~/code/dotfiles/vimrc ~/.vimrc

ERROR: Cannot source a directory: “$HOME/.vimrc”

FIX?: ln -s ~/code/dotfiles/vimrc/.vimrc ~/.vimrc

in your writeup below the video it says this…

$ ln -s ~/code/dotfiles/vimrc ~/.vimrc

in your video you run

$ ln -s ~/code/dotfiles/vim/vimrc ~/.vimrc

either way I do it…

it returns the following error when I open vim

Cannot source a directory: “$HOME/.vimrc”

I think it’s a problem in your video, but I got it to work. And sorry for the crappy formatting of this response…

(Chris Toomey) #4

Hey @thedanotto, sorry for the confusion. The symbolic link needs to be created to point at your existing vimrc file, whereever that is on your computer. The second argument, .vimrc will always be the same as Vim always looks to the same file, specifically ~/.vimrc for configuration.

As an example:

$ pwd
$ ls
$ cd ~
$ pwd
$ ln -s ~/other-code/vim/vimrc .vimrc

After making the symlink you can confirm it is set by running

$ ls -laFG .vimrc                                                                                                                                                                                                                                                                                         
lrwxr-xr-x  1 christoomey  staff  42 Jul  1 11:58 .vimrc@ -> /Users/christoomey/code/dotfiles/vim/vimrc

It should point to the actual file. You can also cat the file from your home dir to confirm.

I’ve also updated the video notes to match the video. Thanks for the heads up on that!

(thedanotto) #5

Thanks, Chris. But in my case I didn’t have an existing vimrc file. That started my confusion, I suppose. But to really beat this horse to death…

vimrc in ln -s ~/other-code/vim/vimrc should be a file and not a directory? And that’s the file I edit?

One other thing that didn’t work as seamlessly as the video…

nmap <leader>so  :source $MYVIMRC<CR>

wasn’t refreshing $MYVIMRC, I would have to exit vim and restart it. But the following line did work.

nmap <leader>so :w <cr> <bar> :source $MYVIMRC<CR>

And lastly… the whole reason I’m watching this video right now is in this video at 7:57 he types RTcontroller todos and it automagically opens up the todos controller. Could you provide the config for that?

(thedanotto) #6

YESSSSSSSSSSSSSS, figured it out.

had to install this…

but the new version uses


instead of


(Chris Toomey) #7

Hi @thedanotto, glad you got it all sorted it out! Just for completeness sake, your vimrc file should already exist before running a symlink command. A symlink exists to take an existing file in some alternate directory, and make it seem as if it lives in the target directory.

(Sean Luckett) #8

@benorenstein That binding.pry mapping is genius. I’ll be trying that one and the rd for running rspec. Thanks for showing some of your file!

(John) #9

Hey I’m having no success in getting imap <C-s> <esc>:w<cr> to work at all-it just doesn’t do anything.

System spec:

  • OSX Elcapitan
  • Terminal 2.6.1(361.1)
  • Vim 7.4.936

(Geoff Harcourt) #10

Hi @nguyenj, Control-S has special use with relation to flow control. In order to use it as a Vim shortcut, you’ll need to disable flow control in the shell that launches Vim. Here’s a snippet from @benorenstein’s dotfiles where he does that for zsh.

Once you change that setting in your shell you should be able to map Control-S in Vim.

(Eric Ti-Yu Chiang) #11

Hi @geoffharcourt, on mapping I had the same issue @nguynj had. The solution I found was to add stty -ixon in my .zshrc based on this SO post. My understanding is it disables XON/XOFF flow control. Not sure if that’s equivalent to stty start undef and stty stop undef.

(Geoff Harcourt) #12

I’m not a shell expect, but from man stty that looks like it has the same effect.

(Geoff Harcourt) #13

FWIW, I found after a while that I stopped using that <C-s> mapping and just relied on :w for saves and on saving the current buffer whenever I ran a test.

(Dean Tambling) #14

One thing I’ve noticed: :browse set doesn’t behave as shown in the video by default. On my clean Vim install, :browse set brings up a list of options and their current values, whereas :opt brings up the list of all possible options. Is this behavior that’s changed recently? The :help page for :opt says it’s aliased as :browse set, but in practice this isn’t the case.

(Chris Toomey) #15

Hmm, not sure what to make of that. You can check if any custom plugin commands are overriding by running verbose command set and check the output, but otherwise I’m not sure what’s going on here.

(Dean Tambling) #16

How incredibly odd. verbose command set didn’t show anything, and I was able to replicate the incorrect browse set behavior on another computer’s Vim installation. I’ll do some more digging and see if I can’t get to the bottom of this– any recommendations on where to look?

(Jerome Dalbert) #17

I have noticed in Ben’s dotfiles that he remaps , to the leader key.

In an earlier episode you guys mention that ; and , are very useful to repeat a find forwards or backwards. But with this mapping, you can’t repeat backwards. Do you just not use them at all, or how do you manage them?

(Chris Toomey) #18

Hey @jeromedalbert, I’m not sure if Ben currently does this, but I’ve personally moved away from it a while back. In general I prefer to not map over existing functionality whenever possible these days.

That said, if anyone is doing this (or a similar mapping that takes over an built in mapping), you can actually swap them such that ; would be :, and : would be ;. This makes entering commands, possibly the more common case, easier since you don’t have to hold shift, but also still allows “repeat most recent f,F,t,T motion” by using shift.

" Swap ; and :
nnoremap ; : 
nnoremap : ; 

(Jerome Dalbert) #19

Cool, I used to use , too, but to avoid remapping over existing functionality, and also because I found it much easier on the fingers in the long run, I have personally mapped Leader to Space.

By the way, repeatedly using the VIM default shortcuts started giving me slight RSI symptoms (!) so I went way overboard by remapping my MBP keys to behave like the ADM-3A terminal keyboard used by the creator of Vi.
Caps lock becomes Ctrl, Tab becomes Escape (I tab with Ctrl+i) and in normal mode - becomes :. Way easier on my fingers in the long run, and the symptoms have disappeared. Also the hands are always on the home row now.

(Akshay Arora) #20

Firstly, geat trail!

There are two problems I am facing:
1 - I have set Space as my leader key, but while I specify these insert maps:
imap <leader>jk <esc>
imap <leader>kj <esc>

There is a delay every time I hit space while typing.

2 - I am trying to move from Atom, where all the project files are displayed on the left, which I hugely miss, but any type of file explorer is deemed anti-pattern here, so what would be the workaround for the incompleteness feeling without a file explorer always visible?