annika-w
5/29/2017 - 1:55 PM

Vim

Installing and setting up my own Vim (incl. Plugins, Themes etc.) in a heartbeat. Also, other stuff I need to remember atm.

Basics

Search and Replace

:%s/foo/bar/g

Insert Mode Text Navigation

CTRL-B       cursor to beginning of command-line \n
CTRL-E       cursor to end       of command-line
 
CTRL-H       delete the character  in front of the cursor (same as <Backspace>)
CTRL-W       delete the word       in front of the cursor
CTRL-U       delete all characters in front of the cursor

RegEx

[a-zA-Z]    # Any char

Sessions

# Make session from within vim
mksession! ~/.vim/session_name.vim
# Restore session
source ~/.vim/session_name # 1
vim -S ~/.vim/session_name # 2

View HEX File

:%!xxd

View last messages

:messages

Copy multiple lines at once

:g/COMMON LINE PATTERN/normal "Ayy
"ap # to paste

Plugin Mappings

Surround.vim

cs"'    # Replace " with ' from anywhere within the original "
ds"     # Delete surrounding "
ysiw[   # Put [ word ] around current "inner word"
ysiw]   # Put [word] around current "inner word", no spaces
yss)    # Put () around entire line (ss)

CtrlP


Setup and Installation

sudo apt-get install vim
sudo apt-get install git
git clone https://github.com/AnnikaWierichs/vim_config
cp vim_config/.vimrc .
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
git clone https://github.com/flazz/vim-colorschemes.git
mkdir .vim/colors
cp vim-colorschemes/colors/* ~/.vim/colors
vim .vimrc
    :PluginInstall
sudo apt-get install build-essential cmake
sudo apt-get install python-dev python3-dev   # Python headers
~/.vim/bundle/YouCompleteMe/install.py --clang-completer   # C support