This is a companion discussion topic for the original entry at https://thoughtbot.com/upcase/videos/onramp-to-vim-configuration
Just in case anyone else needs it, you some times need to manually reload $MYVIMRC configs:
:source $MYVIMRC
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
vim
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ā¦
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
/Users/christoomey/other-code/vim
$ ls
vimrc
$ cd ~
$ pwd
/Users/christoomey
$ 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!
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?
YESSSSSSSSSSSSSS, figured it out.
had to install thisā¦
but the new version uses
Econtroller
instead of
RTcontroller
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.
@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!
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
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.
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
.
Iām not a shell expect, but from man stty
that looks like it has the same effect.
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.
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.
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.
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?
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?
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 : ;
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.
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?
Cheers!