-
Notifications
You must be signed in to change notification settings - Fork 3
Vim Tips
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 shift+enter
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
jj...
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.