星期三, 11月 23, 2011

Copy and Past words from OS's clipborad in vim.

In actually, it’s a problem for me when I copy and past words to vim from OS's clipboard.

So I write a simple vim script to support switching modes between autoindent and noautoindents and set keymap “\ i”.


function! SwitchAutoIndent()
if &autoindent  
    set noautoindent
else
    set autoindent
endif
endfunction

nmap <LEADER>i :call SwitchAutoIndent()<CR>

I think it can resolve my problem temporary. Maybe I have to use MacVim because it has no the problem. XD


---
Take notes.



godfat mentioned to use past mode when we want to past words. So I founded some information about pastmode from vim wikiJust set command as the following.


nmap <LEADER>p :set invpaste paste?<CR>

2 則留言:

Lin Jen-Shin (godfat) 提到...

if you just want to paste something, why not use paste mode? use `set paste` and `set nopaste` to switch them

yen3 提到...

I don't know there is past mode in vim. I will rewrite the small function. Thank your suggestion. : )