Wednesday, 16 December 2009

vim notes 2

Paragraph forward / back: ESC { and ESC }


pasting:

vim --version

Check whether xterm_clipboard has a + or - preceding it. If -, add it by running
a version with it enabled. gvim has it enabled. I installed vim-python, to install
gvim, which then affected my normal vim.

Once enabled,

ESCAPE " + p

pastes from the xterm clipboard.

From http://vim.wikia.com/wiki/Accessing_the_system_clipboard

* "+2yy – copy two lines to X11 clipboard
* "+dd – cut line to X11 clipboard
* "+p – paste X11 clipboard

-----------------


Code folding.

V
select block
ZF

marks the code for folding

-------------------

multiple tabs:

vi -p *.tex

or

:tabnew filename

tab navigate with CTRL pg-up and pg-down

Gavin: tabdo command

executes command on all tabs.
-----------------------

Bookmarking:

m a : set a mark
` a : jump to mark. `a' can be anything.

-------------------

Mapping keys in Vim:

To map to control-V, the paste function whilst in insert mode:

 

:imap pi



or something like that
-----------------

Search / replace (from http://www.linux.com/learn/tutorials/8255-vim-tips-the-basics-of-search-and-replace):

:/string search
:?string backwards search
n next
N previous

:8,10 s/search/replace/g from line 8 to 10, g(lobal = repeats on lines)

Or, use visual select and execute the search. v is visual, V is line visual, CRTL-v is block visual.

:%s/search/replace/g over entire file

----------------------

Vim white spaces on pasting from GUI

Pre paste, do

:set paste

Post paste, do

:set nopaste

to prevent automatic indentation. From http://aymanh.com/a-collection-of-vim-tips

-------------------------

Copy, paste multiple buffers.


" a y to place into register `a'.
" a p to place into register `a'.

So, the `+' is the global buffer....

--------------------------

To pull the results of a command into the editor:

:r ! command

for example

:r ! ls gabvo*

;)
----------------------------

Speech marks when using vim-latex:

Insert mode, CTRL-V, "

CTRL-V indicates literal mode, I think.

http://vim-latex.sourceforge.net/index.php?subject=faq&title=FAQ#faq-not-loaded-vim7

-------------

5 comments:

  1. You've missed an < Esc > you code snaffling simpleton!

    ReplyDelete
  2. This comment has been removed by a blog administrator.

    ReplyDelete
  3. Juvenile comments will not be tolerated, Gavbo.

    ReplyDelete
  4. Your details have been passed to my lawyers!

    ReplyDelete