-
Notifications
You must be signed in to change notification settings - Fork 3
Vim Tips
http://stackoverflow.com/questions/1218390/what-is-your-most-productive-shortcut-with-vim
http://stackoverflow.com/questions/1497958/how-to-use-vim-registers?rq=1
http://vim.wikia.com/wiki/Resize_splits_more_quickly
http://stackoverflow.com/questions/1675688/make-vim-show-all-white-spaces-as-a-character
Typing :!<command>
will open a console window
Pause Vim with Ctrl+z
, play in the terminal, then return to Vim with the command fg
.
Select a block of text and press =
to fix formatting
ma
set a mark called referenced with a
mz
set a mark referenced with z
`a
jump to mark a
`z
jump to mark z
'a
jump to start of line for mark a
'z
jump to start of line for mark z
Hit Ctrl+v
to select a column then shift+I
to enter the text. Press Esc
shows inserted text.
Copy word (when cursor is anywhere within word) with yiw
Paste text and replace word with viwp
By adding the following lines to the .vimrc file
nmap <S-Enter> O<Esc>
nmap <CR> o<Esc>
We can hit shiftenter whilst in normal mode.
di( or di{ or di[ or di' or di"
space and space space
http://vim.wikia.com/wiki/Delete_all_lines_containing_a_pattern
For example, to delete all lines containing "profile" (remove the /d to show the lines that the command will delete):
:g/profile/d
http://stackoverflow.com/questions/594448/how-can-i-add-a-string-to-the-end-of-each-line-in-vim
ctrl v to enter column highlight mode
j to select the columns
$ to select each end of line
A to start 'appending'
<your text>
add your text
esc to escape, et voilà!
OR
Select your lines. Press : which will pre-fill with <,'>
you can then add norm A<your text>
so it would like :<,'>norm A<your text>
http://vim.wikia.com/wiki/Switching_case_of_characters
Toggle case "HellO" to "hELLo" with g~ then a movement.
Uppercase "HellO" to "HELLO" with gU then a movement.
Lowercase "HellO" to "hello" with gu then a movement.
Alternatively, you can visually select text then press ~ to toggle case, or U to convert to uppercase, or u to convert to lowercase.
Use:
:%y+
to yank all lines.
Explanation:
-
%
to refer the next command to work on all the lines -
y
to yank those lines -
+
to copy to the system clipboard
NB: In Windows, +
and *
are equivalent see this answer.