This is notes for using the vim with the configurations inside this repo. Also this includes notes about how to use vim with this configurations.
https://github.com/mhinz/vim-galore
- Check if
make
is installed in terminal, If make is not installed, A window pops up instructing you to install the developer tools:
make --version
- Download from git:
git clone https://github.com/vim/vim
- Configure:
cd vim
cd src
./configure --with-features=huge --enable-python3interp=yes
- Build and install:
make; make install
- Check if
brew
is installed in terminal, otherwise install Homebrew using:
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)
- Remove previous vim and install:
brew remove vim
brew cleanup
brew install vim --with-python3
cd ~
mkdir .vim
cd .vim
git clone https://github.com/typoman/vimconfig
Install fzf:
brew install fzf
cd ~/.vim
git init # only needed for the first time
git add *
git commit -am "New changes to the configurations"
git remote add origin https://github.com/typoman/vimconfig.git # only needed for the first time
git push origin master
After running the above commands, updating the repo can be achieved using
<space>gr
shortcut inside the vim. Of course you need to change the URL if
you're copying this repo for yourself.
- Change Caps lock to in
System Preferences> Keyboard> Modifier keys
. - Install Karabiner-Elements and add the following rule in the
Complex Modifications
:
Change caps-lock to control if pressed with other keys, to escape if pressed alone
Terminal:
defaults write -g InitialKeyRepeat -int 10 # normal minimum is 15 (225 ms)
defaults write -g KeyRepeat -int 1 # normal minimum is 2 (30 ms)
Then restart OS X.
Vim is a modal editor. It operates in three different main modes: Normal
which
is for editing the text using commands, Insert
which is for inserting or
typing text and Visual
which is for selecting text. If shortcuts are memorized
well this guarantees more efficient keystrokes and less hand movements while
editing text. I have changed default Vim shortcuts to suit my configuration
which is also dependent on the plugins I've installed.
<space>h
Fuzzy search help tags<ctrl>]
jump to the topic surrounded by|
Esc
go to normal modei
insert modea
insert mode and put cursor after the characterv
visual mode (select characters)V
visual line mode (select lines):map <shorcut combination>
check if a shortcut exist<space>?
fuzzy find shortcuts`:q
exit vim<space>vr
update the configuration form the vimrc file<space>gr
update the git repo and this readme:PlugClean
clean removed plugins from vimrc:PlugUpdate
update the plugins added to the vimrc:PlugInstall
install the plugins added to the vimrc
Most of the keys are meant for Normal mode but most likely they work for Visual mode too.
h
move cursor to the leftj
cursor downk
cursor upl
cursor rightH
start of the lineJ
end of the line}
next paragraph{
previous paragraphG
end of the filegg
first character in the fileg;
prvious editing positiong,
next editing position/
easy motion fuzzy search the file, after hitting enter type the highlighted character on the view to jump to that position (including regular expressions)*
go to next occurence of the word under cursor#
for previous<space>ag
fuzzy find the word under cursor in the current project files (uses Ag aka the sliver searcher)n
next match term in searchN
previous matchw
start of the next worde
end of the next wordb
previous word%
go to the other mathes of the following pair [],{},()[s
previous bad spelling''
previous cursor position, or you can use``
fa
find the next character 'a' on the current line using easy motion, then type the highlighted character to jump, use ';' to move to next oneta
find the previous character 'a' on the current line42gg
line 42ma
mark the position of cursor and store it ina
'a
jump to the mark positiona
<space>/
fuzzy find the current file (buffer)<space>j
show list of previous cursor position which can be selected by typing a number (includes prevous position in all the files too)<space>w
toggle wrap lines<Ctrl-I>
and jumping to previous and next cursor positions<Ctrl-a>
select all[-
Move to previous line of lesser indent than the current line.[+
Move to previous line of greater indent than the current line.[=
Move to previous line of same indent as the current line that is separated from the current line by lines of different indents.]-
Move to next line of lesser indent than the current line.]+
Move to next line of greater indent than the current line.]=
Move to next line of same indent as the current line that is separated from the current line by lines of different indents.
Generally going to visual mode is the selection mode and if you start navigating, the selection is from the position of the cursor before the visual mode until the current position. Although there are more shortcuts:
+
expand selection region_
shrink selection regionvii
select the indentation scope, adding more ii increases the indentation levelo
Go to Other end of highlighted text
<Ctrl-n>
select the next word matching the pattern under cursor/selection<Ctrl-j>
or<Ctrl-k>
add one cursor up or down{
or}
go to previous cursor or next one[
or]
add next match or previous matchq
remove next match\a
select all the matches of the selection/word under cursor<tab>
switch between multi visual/normal mode<Esc>
exit multiple cursors
<Ctrl>h
backspacecw
delete the word and go to insert mode.
repeat last sequence of commandsD
cut characters from cursor until end of the linecc
delete the character until end of the line and go to insert modeC
delete characters from cursor until end of the line and go to insert modex
delete the character under the cursors
delete the character under the cursor and go to insert modeO
create a new line above the cursoro
create a new line below the cursorVx
delete the linedd
cut the current line<space>a
match all the words under cursory
yank selection (copy)yy
yank the lineY
yank from the cursor until end of the lineysiw<t>
adds a <t> around the current word, <t> could be anythingds'
cut the character ' surrounding the word under the cursorci'
change the text inside the quotes1z=
fix the spelling under the cursorzg
learn spelling of the word under cursorda)
cut all the text inside and including the parentheses, same goes for brackets or bracesysiw<tag>
yank surrounding inner word with (add to the word boundaries)ct
change the text enclosed by the tag (e.g: html, xml)di>
cut the tag infodi}
cut everything inside the curly bracescii
change the indentation scope (delete the indentation scope and go to insert mode)dii
cut the indentation scope~
swap case, can be combined with other motions (e.g:g~iw
will swap case for the current word)<ctrl>j
or<ctrl>k
move selection or current line up or down (it doesn't work in multiple cursor mode)gq}
auto wrap the paragraph,gqq
autowrap the current line.
Use vimdiff f1 f2
in bash to see the difference between file f1
and f2
.
<space>s
save the file<space>cc
close the file without saving<space>c
close the file\window<space>re
show most recent opened files<space>b
explore buffers in fuzzy mode<space>n
new untitled file<space>t
Open the NerdTree plugin:e fileName
edit filename. You can use for auto completion:w fileName
write (save) the current file as the filenameZZ
save and closetab
go to next tab of opened files (buffers)<shift>tab
go to previous tab of opened files (buffers):SS
save the current session:SL
load a saved session
First hit <ctrl>w
and then any of these keys for the following action:
<ctrl>w
twice to cycle through the windowsh
orj
ork
orl
for switching to another windowv
split the current tab vertically<shift>j
swap the direction of split to horizontal direction
<space>r
run in python<space>rf
run in Robofont>
increase indentation<
decrease indentation<space>gu
undo the git gutter hunk to the last commit]g
go to previous git gutter hunk[g
go to next git gutter hunkgd
go to definition of the object under the cursorzi
toggle foldingzo
open foldzc
close fold
- 'vr' reload vimrc file