1. Setup vim
-
Install Vundle
git clone [GitHub - VundleVim/Vundle.vim: Vundle, the plug-in manager for Vim](https://github.com/VundleVim/Vundle.vim.git) ~/.vim/bundle/Vundle.vim
-
color scheme setup
-
And simply add line
color jellybean
in .vimrc
mkdir -p ~/.vim/colors
cd ~/.vim/colors
curl -O https://raw.githubusercontent.com/nanotech/jellybeans.vim/master/colors/jellybeans.vim
-
write .vimrc
-
wget https://raw.githubusercontent.com/jjeaby/jscript/master/.vimrc
-
Added
Plugin 'preservim/nerdcommenter'
-
-
install plugins in vimrc
:PluginInstall
-
Shell
# install Vundle
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
# setup jellybean color scheme
mkdir -p ~/.vim/colors
cd ~/.vim/colors
curl -O https://raw.githubusercontent.com/nanotech/jellybeans.vim/master/colors/jellybeans.vim
# copy .vimrc
cp ~/configuration/vim/.vimrc ~/.vimrc
vim -c 'PluginInstall' -c 'qa!'
-
Reference
2. shortcuts
-
Normal Model
-
Change Mode
-
:
: change mode to the CommandMode (before the cursor) -
i
: change mode to the InsertMode (before the cursor) -
a
: change mode to the InsertMode (append) -
v
: change mode to the VisualMode-
ctrl+v
: change mode to VisualBlockMode -
shift+v
: change mode to VisualLineMode
-
-
-
Move cursor
-
^
: move cursor to the front of the line -
$
: move cursor to the back of the line -
x
: remove character -
dd
: remove line -
u
: undo
-
-
-
Insert Mode
ESC
# shift to command modectrl + t
: add indentctrl + d
: remove indent
-
Command Mode (
:
in lastline):w
: save (write on the disk):q
: in command mode, quit
-
Visual Mode (
--VISUAL--
in lastline)y
: copy in visual moded
: cut in visual modeyy
: copy line in visual moedp
: paste in visual mode<
: indent selected lines>
: un-indent selected lines
-
Commands for multiple windows
- :split # split in horizontal
- :vsplit # split in vertical
- ctrl + w + w # move to next window
- ctrl + w + p # move to previous window
- Fold and Expand
- :set foldmethod=indent # in .vimrc
- zi # toggle folding
3. Further Techniques
-
3.1 Comment-Out multiple lines
- (1)
ctrl+v
: enter into the VISUAL_BLOCK mode and select lines to comment out - (2)
shift+i
: change editor to INSERT mode and put#
- this will add a hash to the first line
- (3) Then press
esc
, it will insert a#
character on all other selected lines
- (1)
-
3.2 Coping from vim to clipboard over SSH
- TBD
9. Plugins
- NerdTree
:nerd + tab # turn on nerdtree
ctrl+w+w # move focus between editor and file tree
m + a # add a child file