Skip to main content

Vim Basics

Installation#

sudo apt-get update -y \
&& sudo apt-get install -y vim-gtk3

Manually build#

sudo apt install libncurses5-dev libgtk2.0-dev libatk1.0-dev \
libcairo2-dev libx11-dev libxpm-dev libxt-dev \
python3-dev ruby-dev lua5.2 liblua5.2-dev libperl-dev git
git clone https://github.com/vim/vim.git \
&& cd vim
./configure --with-features=huge \
--enable-multibyte \
--enable-rubyinterp=yes \
--enable-python3interp=yes \
--with-python3-config-dir=$(python3-config --configdir) \
--enable-perlinterp=yes \
--enable-luainterp=yes \
--enable-gui=gtk3 \
--enable-cscope \
--prefix=/usr/local
make VIMRUNTIMEDIR=/usr/local/share/vim/vim82 -j$(expr $(expr $(nproc) \* 6) \/ 5)
sudo make install
sudo update-alternatives --install /usr/bin/editor editor /usr/local/bin/vim 1
sudo update-alternatives --set editor /usr/local/bin/vim
sudo update-alternatives --install /usr/bin/vi vi /usr/local/bin/vim 1
sudo update-alternatives --set vi /usr/local/bin/vim

With Vundle#

https://raw.githubusercontent.com/hhk7734/conf/master/.vimrc

wget https://raw.githubusercontent.com/hhk7734/conf/master/.vimrc -O ~/.vimrc
sudo apt-get install -y git cmake python3-dev g++ \
&& git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim \
&& vim +PluginInstall +qall \
&& echo -e "\ncolor dracula" >> ~/.vimrc \
&& cd ~/.vim/bundle/YouCompleteMe \
&& python3 ./install.py --clang-completer

https://raw.githubusercontent.com/hhk7734/conf/master/.ycm_extra_conf.py

wget https://raw.githubusercontent.com/hhk7734/conf/master/.ycm_extra_conf.py -O ~/.vim/.ycm_extra_conf.py \
&& printf "\nlet g:ycm_global_ycm_extra_conf = '%s/.vim/.ycm_extra_conf.py'" $HOME >> ~/.vimrc

Without Vundle#

https://raw.githubusercontent.com/hhk7734/conf/master/without_vundle_vimrc/.vimrc

wget https://raw.githubusercontent.com/hhk7734/conf/master/without_vundle_vimrc/.vimrc -O ~/.vimrc

Normal mode#

  • :h key-notation: key notation

  • u: undo
  • <C-R>: redo

  • =: align ex) gg=G, =3
  • <C-K>: clang-format (μ„€μ •ν•œ 경우)

  • :! <command>: shellμ—μ„œ \<command>λ₯Ό μ‹€ν–‰ν•©λ‹ˆλ‹€.
  • :r[ead]! <command>: stdout -> vim
  • :w[rite]! <command>: vim -> stdin
  • :sh: μ‰˜λ‘œ κ°€κΈ°
  • <C-D>: μ‰˜μ—μ„œ λŒμ•„μ˜€κΈ°

  • <C-A>: 숫자 증가
  • <C-X>: 숫자 κ°μ†Œ

Visual mode#

  • u: μ†Œλ¬Έμžλ‘œ λ³€ν™˜
  • U: λŒ€λ¬Έμžλ‘œ λ³€ν™˜
Last updated on