Newer Entries Older Entries

vim 시작 시 임의(random) 컬러 스킴(color scheme)으로 설정하기

View Comments

gvim을 사용하다가 몇가지 맘에는 컬러 스키마중에서 고민이 되더라구요.
그러다가 random colors vim 으로 검색을 했더니 짠 하고 나오는게 있더군요.

아래 코드를 vimrc 에 등록하고 gvim 을 다시 켜보면! 랜덤하게 색상이 변경되는 것을 볼 수 있습니다.

" Create the comma-separated list of colorscheme files
let s:colors = substitute(globpath(&runtimepath, 'colors/*.vim'), '\n', ',', 'g')
if strlen(s:colors)
  " Count the number of color schemes
  let s:num = strlen(substitute(s:colors, '[^,]\+', '', 'g')) + 1
  if s:num > 1
    let s:loop = localtime() % s:num
    " Rotate the list s:loop times
    while s:loop
      let s:colors = substitute(s:colors, '^\([^,]\+\),\(.*\)$', '\2,\1', '')
      let s:loop = s:loop - 1
    endwhile
  endif
  let s:color = matchstr(s:colors, '^[^,]\+')
  unlet! g:colors_name
  execute 'source' s:color
  " Prevent the message from disappearing
  redraw
  " 스킨이름을 보고 싶으면 아래 주석을 푸세요~
  "echomsg 'Color applied: '.(exists('g:colors_name') ? g:colors_name : '').' ('.s:color.')'
endif
unlet! s:colors s:color s:num s:loop
[edit] - [startup settings] 에 등록하시고 :wq! 하고 실행하면 짠~ 하고 계속 바뀝니다 ^^

출처 : http://vim.wikia.com/wiki/Set_a_random_color_scheme_at_startup

크리에이티브 커먼즈 라이센스
Creative Commons License
2008/10/23 16:36 2008/10/23 16:36

댓글0 Comments (+add yours?)

트랙백0 Tracbacks (+view to the desc.)

FreeBSD Apache 2.0/2.2 extra/ 설정 파일들 vim Syntax hightlight 사용하기

View Comments

FreeBSD에서 apache 2.2를 설치하고 httpd.conf 가 아닌... extra/httpd-vhost.conf 등을 vim 으로 열게 되면 Syntax highlight가 되지 않습니다.

이것은 filetype.vim 에 등록된 내용하고 맞지 않기 때문인데요.
아래 처럼 수정해주시면 문법 강조가 잘 될 것입니다.

/usr/local/share/vim/vim72/filetype.vim 을 열어서 114 줄로 이동 또는 httpd.conf 로 검색하여 해당 부분을 찾아서 아래 내용 처럼 수정합니다. ※ vim72는 설치된 vim의 버전에 따라서 다릅니다. /usr/local/share/vim 으로 가서 확인해보세요~
일반적인 설정
au BufNewFile,BufRead httpd.conf*,srm.conf*,access.conf*,apache.conf*,apache2.conf*,/etc/ap     ache2/*.conf* call s:StarSetf('apache')
#1 apache22 디렉토리를 몽땅 설정
au BufNewFile,BufRead httpd.conf*,/usr/local/etc/apache22/*.conf*,srm.conf*,access.conf*,apache.conf*,apache2.conf*,/etc/ap     ache2/*.conf* call s:StarSetf('apache')
#2 httpd-*.conf 를 인식하도록 설정
au BufNewFile,BufRead httpd.conf*,httpd-*.conf,srm.conf*,access.conf*,apache.conf*,apache2.conf*,/etc/ap     ache2/*.conf* call s:StarSetf('apache')
그리고 :wq! 후에 vim /usr/local/etc/apache22/extra/httpd-vhost.conf 등을 열어봅시다~



크리에이티브 커먼즈 라이센스
Creative Commons License
2008/08/28 11:27 2008/08/28 11:27

댓글0 Comments (+add yours?)

트랙백0 Tracbacks (+view to the desc.)

vim 에서 인코딩 자동으로 설정하기

View Comments

.vimrc 파일에 아래 내용을 추가 해 놓으면 문서을 열때 자동으로 cp949, utf8 등을 선택해서 보여줍니다.
gvim이라면 편집→StartupSettings 에 추가하세요~

" vim 에서 UTF-8, euc-kr 한글문서 그냥 열기.
" {{{ Locale settings
" Try to come up with some nice sane GUI fonts. Also try to set a sensible
" value for fileencodings based upon locale. These can all be overridden in
" the user vimrc file.
if v:lang =~? "^ko"
set fileencodings=euc-kr
set fileencoding=euc-kr
set guifontset=-*-*-medium-r-normal--16-*-*-*-*-*-*-*
elseif v:lang =~? "^ja_JP"
set fileencodings=euc-jp
set fileencoding=euc-jp
set guifontset=-misc-fixed-medium-r-normal--14-*-*-*-*-*-*-*
elseif v:lang =~? "^zh_TW"
set fileencodings=big5
set fileencoding=big5
set guifontset=-sony-fixed-medium-r-normal--16-150-75-75-c-80-iso8859-1,-taipei-fixed-medium-r-normal--16-150-75-75-c-160-big5-0
elseif v:lang =~? "^zh_CN"
set fileencodings=gb2312
set fileencoding=gb2312
set guifontset=*-r-*
endif

" If we have a BOM, always honour that rather than trying to guess.
if &fileencodings !~? "ucs-bom"
set fileencodings^=ucs-bom
set fileencoding=ucs-bom
else
set fileencodings+=ucs-bom
endif

" Always check for UTF-8 when trying to determine encodings.
if &fileencodings !~? "utf-8"
set fileencodings^=utf-8
set fileencoding=utf-8
else
set fileencodings+=utf-8
endif
" }}}

크리에이티브 커먼즈 라이센스
Creative Commons License
2008/08/28 10:29 2008/08/28 10:29

댓글0 Comments (+add yours?)

트랙백0 Tracbacks (+view to the desc.)

Tip #108: Toggle a fold with a single keystroke

View Comments

tip karma   Rating 90/41, Viewed by 5472

created:  September 6, 2001 2:51     complexity:  intermediate
author:  Max Ischenko     as of Vim:  6.0

When viewing/editing a folded file, it is often needed to inspect/close some fold.
To speed up these operation use the following (put in your $HOME/.vimrc):

" Toggle fold state between closed and opened.
"
" If there is no fold at current line, just moves forward.
" If it is present, reverse it's state.
fun! ToggleFold()
if foldlevel('.') == 0
normal! l
else
if foldclosed('.') < 0
. foldclose
else
. foldopen
endif
endif
" Clear status line
echo
endfun

" Map this function to Space key.
noremap <space> :call ToggleFold()<CR>


See :help folding for more information about folding.


vim.org에서 내가 가장 좋아하는 팁..
http://www.vim.org/tips/tip.php?tip_id=108


 

크리에이티브 커먼즈 라이센스
Creative Commons License
2008/02/26 11:48 2008/02/26 11:48

댓글0 Comments (+add yours?)

트랙백0 Tracbacks (+view to the desc.)

Vim:netrw

View Comments

vim 에서 ftp 파일을 로드하는 모듈
기본 설치 버전(gvim7.0) 에서 에러가 뜨기 때문에 다시 설치 해줘야한다

download sites:
http://mysite.verizon.net/astronaut/vim/index.html#VimFuncs
http://vim.sourceforge.net/scripts/script.php?script_id=1075
 netrw.vba.gz

* vba 파일 설치중에 [[[1 에러 뜨면 다 없애버릴것. 6 lines.


아래는 vim tips의 설명
====================

netrw.vim : Network oriented reading, writing, and browsing (keywords: netrw ftp scp)


script karma  Rating 336/102, Downloaded by 4297
created by
Charles Campbell


script type
utility

description
               STARTING WITH v66, NETRW REQUIRES VIM 7.0

Netrw supports reading and writing files across networks.  One may use urls for filenames or one may use netrw's Nread and Nwrite commands. Netrw as provided here supports remote and local directory browsing, and supports  editing files across the network using a variety of methods.  Please report any bugs to NdrOchip@ScampbellPfamily.AbizM - NOSPAM.

   Example:  vim ftp://user@machine/path

(the following table should be columnar if fixed-width fonts are used in your browser)

   REMOTE EDITING
       :e dav://machine[:port]/path                    uses cadaver
       :e fetch://[user@]machine/path                  uses fetch
       :e ftp://[user@]machine[[:#]port]/path          uses ftp   autodetects <.netrc>
       :e http://[user@]machine/path                   uses http  uses wget
       :e rcp://[user@]machine/path                    uses rcp
       :e rsync://[user@]machine[:port]/path           uses rsync
       :e scp://[user@]machine[[:#]port]/path          uses scp
       :e sftp://[user@]machine/path                   uses sftp

   REMOTE READING
       :Nread ?                                        give help
       :Nread "machine:path"                           uses rcp
       :Nread "machine path"                           uses ftp   with <.netrc>
       :Nread "machine id password path"               uses ftp
       :Nread "dav://machine[:port]/path"              uses cadaver
       :Nread "fetch://[user@]machine/path"            uses fetch
       :Nread "ftp://[user@]machine[[:#]port]/path"    uses ftp   autodetects <.netrc>
       :Nread "http://[user@]machine/path"             uses http  uses wget
       :Nread "rcp://[user@]machine/path"              uses rcp
       :Nread "rsync://[user@]machine[:port]/path"     uses rsync
       :Nread "scp://[user@]machine[[:#]port]/path"    uses scp
       :Nread "sftp://[user@]machine/path"             uses sftp

   REMOTE WRITING
       :Nwrite ?                                       give help
       :Nwrite "machine:path"                          uses rcp
       :Nwrite "machine path"                          uses ftp   with <.netrc>
       :Nwrite "machine id password path"              uses ftp
       :Nwrite "dav://machine[:port]/path"             uses cadaver
       :Nwrite "ftp://[user@]machine[[:#]port]/path"   uses ftp   autodetects <.netrc>
       :Nwrite "rcp://[user@]machine/path"             uses rcp
       :Nwrite "rsync://[user@]machine[:port]/path"    uses rsync
       :Nwrite "scp://[user@]machine[[:#]port]/path"   uses scp
       :Nwrite "sftp://[user@]machine/path"            uses sftp
       http: not supported!

   REMOTE DIRECTORY BROWSING
       :e [protocol]://[user]@hostname/path/
       :Nread [protocol]://[user]@hostname/path/

   LOCAL DIRECTORY BROWSING
       :e /some/path/to/a/directory

Netrw supports browsing both local and remote directories.  For remote directory browsing, one must include a trailing slash (/) on the path!  The interface resembles the file explorer that comes with vim v6.3 and earlier.  Variables which control netrw's optional behavior are named differently, however.

For remote directory browsing, the [protocol]://[user]@hostname/path/ is user-directory relative.  If you want to specify a full path, use another slash before the path: [protocol]://[user]@hostname//path/.

Netrw supports many file-explorer maps, such as o v d D etc.  Look at the help for netrw-o, for example.  One may also use :Explore and relatives to explore directories with the current file.

The netrw.tar package supports the "x" key to execute a file handler for various filetypes.  The file-handling is done in various ways:

   * Under Windows, rundll32 is used with the FileProtocolHandler
   * If unix and kfmclient exists and is executable, it is used
   * If unix and gnome-open exists and is executable, it is used
   * Otherwise, the NetrwFileHandler.vim file handling script is
     used

With this feature, one may press the "x" key when the cursor is atop a filename and invoke an extension-based file handler to do things like display image files, invoke ghostscript on PostScript files, run OpenOffice or Word, etc.

STARTING WITH v66, NETRW REQUIRES VIM 7.0

install details
netrw is now distributed as a vimball!  (see :help vimball)
You'll need a vimball plugin v18 or later (see vimscript#1502).

(if you're updating from the vim 7.0 distribution, please remove all runtime plugin/netrw*.vim and autoload/netrw*.vim first)

vim netrw.vba.gz
:so %
:q

and that's it!



크리에이티브 커먼즈 라이센스
Creative Commons License
2008/02/26 11:43 2008/02/26 11:43

댓글0 Comments (+add yours?)

트랙백0 Tracbacks (+view to the desc.)

Newer Entries Older Entries