Skip to content

KlemensKittan/vim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Git clone with submodules

The list of steps required to clone a Git repository with submodules is:

# git clone https://github.com/KlemensKittan/vim.git .vim
# cd .vim
# git submodule init
# git submodule update

There is actually an alternative to going through these three steps. You can use the --recurse-submodules switch on the clone. This approach, shown below, might be easier.

# git clone --recurse-submodules https://github.com/KlemensKittan/vim.git .vim

Configuring

Installing the Software

The following packages have to be installed:

aptitude install vim vim-doc vim-nox vim-scripts ack fonts-powerline

Your personal Vim initializations: ~/.vim/vimrc

Commands

The commands are grouped into categories.

Cursor movement

Command Description
h move cursor left
j move cursor down
k move cursor up
l move cursor right
H move to top of screen
M move to middle of screen
L move to bottom of screen
w jump forwards to the start of a word
W jump forwards to the start of a word (words can contain punctuation)
e jump forwards to the end of a word
E jump forwards to the end of a word (words can contain punctuation)
b jump backwards to the start of a word
B jump backwards to the start of a word (words can contain punctuation)
% move to matching character (default supported pairs: '()', '{}', '[]'
0 jump to the start of the line
^ jump to the first non-blank character of the line
$ jump to the end of the line
gg go to the first line of the document
G go to the last line of the document
5G go to line 5
fx jump to next occurrence of character x
tx jump to before next occurrence of character x
; repeat previous f or t movement
, repeat previous f or t movement backwards
) jump to next sentence
( jump to previous sentence
} jump to next paragraph (or function/block, when editing code)
{ jump to previous paragraph (or function/block, when editing code)
Ctrl + b move back one full screen
Ctrl + u move back 1/2 a screen
Ctrl + f move forward one full screen
Ctrl + d move forward 1/2 a screen

Jump list

Command Description
:jumps list of jumps
Ctrl + o jump back to the previous position
Ctrl + i jump to the next position

Insert mode - inserting/appending text

Command Description
i insert before the cursor
I insert at the beginning of the line
a insert (append) after the cursor
A insert (append) at the end of the line
o append (open) a new line below the current line
O append (open) a new line above the current line

Editing

Command Description
r replace a single character
R replace characters until you press ESC
J join line below to the current one with one space in between
gJ join line below to the current one without space in between
cc change (replace) entire line
cw change (replace) to the end of the word
c$ change (replace) to the end of the line
cfx change (replace) to next occurrence of character x
ctx change (replace) to before next occurrence of character x
u undo
Ctrl + r redo
. repeat last command
Ctrl + X Ctrl + N word complition
Ctrl + X Ctrl + F file complition
:! command execute an external command
:r! command output of the command is inserted
:r file content of the file is inserted

Cut and paste

Command Description
yy copy a line
yw copy the characters of the word from the cursor position to the start of the next word
y$ copy to end of line
p paste the clipboard after cursor
P paste the clipboard before cursor
dd delete a line
D delete to the end of the line
dw delete the characters of the word from the cursor position to the start of the next word
daw delete the current word
das delete the current sentence
dap delete the current paragraph
x delete character

Visual mode

Command Description
v start visual mode
V start visual mode linewise
Ctrl + v start visual block mode
>> shift text right
<< shift text left
d delete only the highlighted text
D delete rows under highlighted text
y copy only the highlighted text
Y copy rows under highlighted text
~ switch case

Working with multiple files

Command Description
:e file edit a file in a new buffer
:bn go to the next buffer
:bp go to the previous buffer
:bd delete a buffer (close a file)
:ls list all open buffers
:sp file open a file in a new buffer and split window
:vsp file open a file in a new buffer and vertically split window
Ctrl + ws split window
Ctrl + wv split window vertically
Ctrl + wh move cursor to the left window (vertical split)
Ctrl + wl move cursor to the right window (vertical split)
Ctrl + wj move cursor to the window below (horizontal split)
Ctrl + wk move cursor to the window above (horizontal split)
Ctrl + > increase current buffer
Ctrl + < decrease current buffer
Ctrl + w| current buffer maximize
Ctrl + + increase current buffer
Ctrl + - decrease current buffer
Ctrl + w_ current buffer maximize
Ctrl + w= divide all buffers equally

Tabs

Command Description
:tabnew file open a file in a new tab
Ctrl + wT move the current split window into its own tab
gt move to the next tab
gT move to the previous tab
#gt move to tab number #
:tabmove # move current tab to the #th position (indexed from 0)
:tabc close the current tab and all its windows
:tabo close all tabs except for the current one

Search and replace

Command Description
/pattern search for pattern
?pattern search backward for pattern
n repeat search in same direction
N repeat search in opposite direction
:%s/old/new/g replace all old with new throughout file
:%s/old/new/gc replace all old with new throughout file with confirmations
:%s/his/her/g standard subsitution
:%s/\<his\>/her/ whole word subsitution
:%s/\(good\|nice\)/awesome/g substitute either word1 or word2
:s/\(\d\+\) \(\d\+\)/\2 \1/ swap two numbers separated by space
:g/pattern/d delete all lines matching a pattern
:noh remove highlighting of search matches

Macros

Command Description
qa record macro a
q stop recording macro
@a run macro a
@@ rerun last run macro
:g/.*/normal @a run macro a on all lines

Registers

Register Description
% name of the current file
: most recently executed command
. last inserted text
0 store the most recent copy
1-9 store the most recent deletion
Command Description
:reg show buffer content
"ay copy into named buffer a
"Ay append to named buffer a
"ayy copy current line into named buffer a
"ap paste content from buffer a after the cursor

Marks

Command Description
:marks list of marks
ma set current position for mark a
`a jump to position of mark a
'a jump to the beginning of the line containing the bookmark a
y`a copy text to position of mark a

Folding

Command Description
zf#j creates a fold from the cursor down # lines
zf/string creates a fold from the cursor to string
zj moves the cursor to the next fold
zk moves the cursor to the previous fold
zo opens a fold at the cursor
zO opens all folds at the cursor
zc closes a fold at the cursor
zM closes all open folds
zR open all closed folds
za toggle operate on one level of folding
zd deletes the fold at the cursor
zE deletes all folds

Exiting

Command Description
:w write the file but don't exit
:wq write the file and quit
:q quit (fails if there are unsaved changes)
:q! quit and throw away unsaved changes

Plugins

vim-plug, a modern Vim plugin manager, downloads plugins into separate directories for you and makes sure that they are loaded correctly. It allows you to easily update the plugins, review (and optionally revert) the changes, and remove the plugins that are no longer used.

Plugin list

  • onedark.vim
    Adaptation of one-light and one-dark colorschemes for Vim

  • vim-airline
    Will draw a nice statusline at the bottom

  • vim-airline-themes
    Will draw a nice statusline at the bottom

  • ack.vim
    Run your favorite search tool from Vim, with an enhanced results list

  • ctrlp.vim
    Full path fuzzy file, buffer, tag, ... finder for vim

  • nerdcommenter
    Comment functions so powerful

  • nerdtree
    File system explorer for vim

  • syntastic
    Syntax checking plugin

  • vim-fugitive
    A complement to command line git

Resources

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors