Welcome, Guest. Please login or register.
+  Linux Soft Forum
|-+  Învaţă» Tips&Tricks» $HOME/.vimrc
[Picture 161] [Picture 160] [Picture 159]
Username:
Password:
 
Pages: [1] 2   Go Down
  Print  
Author Topic: $HOME/.vimrc  (Read 5463 times)
0 Members and 2 Guests are viewing this topic.
cristiv
Expert
***


WWW
« on: November 17, 2006, 01:47:13 AM »

Un exemplu simplu de personalizare VIM

"for security reasons
set nomodeline

"tabs and other prefs:
set tabstop=4
set shiftwidth=4

"show line numbers
set nu
set autoindent
set visualbell

" make doesn't like expanded tabs
au BufNewFile,BufRead Makefile\|makefile set noexpandtab

" allways expand tabs to chars  when editing C++ source code
au BufNewFile,BufRead *\.cpp\|*\.c\|*\.h\|*\.y set expandtab

" ditto for configure.ac, etc
au BufNewFile,BufRead *.ac set expandtab
Logged

oblio
Admini
**


WWW
« Reply #1 on: November 17, 2006, 04:01:56 AM »

"stop Vi compatibility mode - allows multiple undo, ...
set nocompatible
"shows line numbers
set nu
"incremental search - search as you type
set incsearch
"automatic indent, great for programming
set autoindent
"set backup
"show current line and other details in the bottom row
set ruler
"shows current command in the bottom row, before execution
set showcmd
"detect and highlight syntax
set syntax=on
"set line wrapping
set wrap
"filetype detection and textwidth
autocmd FileType text setlocal textwidth=80
"filetype specifiv indent
filetype plugin indent on
"use backspace as usual
set backspace=eol,indent,start
"command history
set history=1000
"a tab is 4 spaces wide
set shiftwidth=4
"not very sure about this
set tabstop=4
"same here
set softtabstop=4
"folding method
set foldmethod=marker
"foldmarker, so Vim will know where to fold
set foldmarker={{{,}}}
"not sure about this
set showfulltag
"show possible completion on the bottom command line
set wildmenu
set wildmode=list:full
"console vim gets to use the mouse Smiley vim ~ gvim this way Smiley
set mouse=a
"scroll ahead, to prevent ugly line scrolling
set scrolloff=3
"no beep
set visualbell
"colorscheme - relaxing
colo oceandeep
"c comment - rather crude Smiley must make it use multipliers
map! <F2> ^[0i/* ^[$a */
"c uncommment, same thing
map! <F3> ^[0xx^[$xxi
"folding marker, for automatic folding
imap <F4>> ^[0i/* {{{ ^[$a */
imap <C-F4> ^[0i/* }}} ^[$a */
"nice Windows font, good for Linux too
  set guifont=Courier\ New\ Bold\ 13 

"tab completion
"Tab = Ctrl-P - complete previous
"Shift-Tab = Ctrl-N - complete next
"Ctrl-Tab = Tab
"omnisense tab completion
imap <Tab> <C-x><C-o>
imap <C-Tab> <Space><Space><Space><Space>
"HTML.vim plugin
let g:html_tag_case="lowercase"
"moving between tabs with Alt-number
imap <A-1> <Esc>:tabn 1<CR>i
imap <A-2> <Esc>:tabn 2<CR>i
imap <A-3> <Esc>:tabn 3<CR>i
imap <A-4> <Esc>:tabn 4<CR>i
imap <A-5> <Esc>:tabn 5<CR>i
imap <A-6> <Esc>:tabn 6<CR>i
imap <A-7> <Esc>:tabn 7<CR>i
imap <A-8> <Esc>:tabn 8<CR>i
imap <A-9> <Esc>:tabn 9<CR>i

map <A-1> :tabn 1<CR>
map <A-2> :tabn 2<CR>
map <A-3> :tabn 3<CR>
map <A-4> :tabn 4<CR>
map <A-5> :tabn 5<CR>
map <A-6> :tabn 6<CR>
map <A-7> :tabn 7<CR>
map <A-8> :tabn 8<CR>
map <A-9> :tabn 9<CR>

.vimrc-ul meu.
E comentan în engleză pentru că încerc să mă obişnuiesc să comentez totul în engleză Smiley

O să pun şi schema mea de culori, oceandeep - este o temă preluată de pe www.vim.org, şi puţin modificată. Am modificat un pic şi pluginul HTML.vim (nu cel default, ci unul găsit pe net), ca să fie mai XHTML-compliant.
« Last Edit: November 17, 2006, 04:03:07 AM by oblio » Logged

Distribuţie: ubuntu | Localitate: Bucureşti | Vârstă: 24

Oh! Everything has a point, and if it doesn't, then there's a point to it.

Oblio's
cristiv
Expert
***


WWW
« Reply #2 on: November 17, 2006, 08:12:23 PM »

Ha, folosim acelasi tabwidth de 4 caractere Smiley Ce face foldmarker, pardon de ignoranta?
Logged

oblio
Admini
**


WWW
« Reply #3 on: November 17, 2006, 08:43:17 PM »

Permite foldingul (strângerea blocurilor de cod) scriind {{{ pentru început fold, şi }}} pentru sfârşit fold. Ca să nu am erori, îl bag în comentarii:

/* {{{ Descriere bloc */
[... cod]
/* }}} */
sau
// {{{ Descriere bloc
// }}}
Cu za strângi şi desfaci fold-urile.

Mi-e mai comod să strâng blocurile de cod care nu mă interesează. Cat despre tabwidth, mă gândesc să pun mai mic chiar, dar de... obişnuinţa (2 e prea mic, 3 mi se pare ciudat Smiley ).
« Last Edit: November 17, 2006, 08:45:00 PM by oblio » Logged

Distribuţie: ubuntu | Localitate: Bucureşti | Vârstă: 24

Oh! Everything has a point, and if it doesn't, then there's a point to it.

Oblio's
~Empathy~
Veteran
**

Decadence is Bliss...


« Reply #4 on: May 29, 2007, 12:11:25 PM »

.vimrc-ul meu uber-l337.

Are autocomplete la tasta <Tab> in insert mode, syntax highlighting etc. De asemenea e foarte destept, tasta <Tab> merge normal, nu e nevoie de artificii Smiley. Detecteaza singura daca e nevoie de autocomplete sau nu.

" **************************
" * vim general options ****
" **************************
set nocompatible
set history=1000
set mouse=a

" don't have files trying to override this .vimrc:
set nomodeline

" have <F1> prompt for a help topic, rather than displaying the introduction
" page, and have it do this from any mode:
nnoremap <F1> :help<Space>
vmap <F1> <C-C><F1>
omap <F1> <C-C><F1>
map! <F1> <C-C><F1>

set title

" **************************
" * set visual options *****
" **************************
set nu
set ruler
" syntax highlighting for colour enabled terminals
if has('syntax') && (&t_Co > 2)
  syntax on
endif

" set background=dark

set wildmenu
set wildmode=list:longest,full

" use "[RO]" for "[readonly]"
set shortmess+=r

set scrolloff=3

" display the current mode and partially-typed commands in the status line:
set showmode
set showcmd

" don't make it look like there are line breaks where there aren't:
set nowrap

" **************************
" * set editing options ****
" **************************
set autoindent
filetype plugin indent on
set backspace=eol,indent,start
autocmd FileType text setlocal textwidth=80
autocmd FileType make set noexpandtab shiftwidth=8

" * Search & Replace
" make searches case-insensitive, unless they contain upper-case letters:
set ignorecase
set smartcase
" show the `best match so far' as search strings are typed:
set incsearch
" assume the /g flag on :s substitutions to replace all matches in a line:
set gdefault

" ***************************
" * tab completion **********
" ***************************
setlocal omnifunc=syntaxcomplete#Complete
imap <Tab> <C-x><C-o>
inoremap <tab> <c-r>=InsertTabWrapper()<cr>

" ***************************
" * keyboard mapping ********
" ***************************
imap <A-1> <Esc>:tabn 1<CR>i
imap <A-2> <Esc>:tabn 2<CR>i
imap <A-3> <Esc>:tabn 3<CR>i
imap <A-4> <Esc>:tabn 4<CR>i
imap <A-5> <Esc>:tabn 5<CR>i
imap <A-6> <Esc>:tabn 6<CR>i
imap <A-7> <Esc>:tabn 7<CR>i
imap <A-8> <Esc>:tabn 8<CR>i
imap <A-9> <Esc>:tabn 9<CR>i

map <A-1> :tabn 1<CR>
map <A-2> :tabn 2<CR>
map <A-3> :tabn 3<CR>
map <A-4> :tabn 4<CR>
map <A-5> :tabn 5<CR>
map <A-6> :tabn 6<CR>
map <A-7> :tabn 7<CR>
map <A-8> :tabn 8<CR>
map <A-9> :tabn 9<CR>

" ***************************
" * Utilities Needed ********
" ***************************
function InsertTabWrapper()
      let col = col('.') - 1
      if !col || getline('.')[col - 1] !~ '\k'
          return "\<tab>"
      else
          return "\<c-p>"
      endif
endfunction

" end of .vimrc
Logged

mudrii
Veteran
**

« Reply #5 on: June 01, 2007, 08:59:08 AM »

cred ca ma remut si eu pe vim Wink
Logged
BiThian
Membru
*

The boy with the OS with the flag


« Reply #6 on: June 01, 2007, 12:45:02 PM »

Exista cumva un builtin cu ajutorul caruia sa pot afla numele fisierului pe care-l editez? Am cautat prin documentatie, dar n-am gasit nimic util.

PS: % , %< nu sunt recunoscute intr-o functie.
Logged

"A man who would not die for something is not fit to live." - Martin Luther King
coder_gus
Veteran
**

« Reply #7 on: June 01, 2007, 01:06:22 PM »

La % ar trebui sa mearga in .vimrc. Fara extensie e %:t:r.
Stiu ca le am mapate tastele si % folosesc.
Logged
BiThian
Membru
*

The boy with the OS with the flag


« Reply #8 on: June 01, 2007, 01:17:42 PM »

PS: % , %< nu sunt recunoscute intr-o functie.

Prin functie, inteleg:

Code:
function Kiki()
     let lola = %
     echo lola
endfunction
« Last Edit: June 01, 2007, 01:21:23 PM by BiThian » Logged

"A man who would not die for something is not fit to live." - Martin Luther King
mapleoin
Admini
**

mapleoin@jabber.org


WWW
« Reply #9 on: June 14, 2008, 06:20:30 PM »

* mapleoin casts ressurect!

am furat și eu de pe la voi:

set expandtab " replaces tabs with spaces
set tabstop=4
set shiftwidth=4
set autoindent
set guifont=Monospace\ 9
set lines=44
set columns=161 " 2*80px vertical windows
set ignorecase " case insensitive search
set smartcase
if has("autocmd")
    autocmd BufEnter * :cd %:p:h
endif
colo oceandeep " http://www.vim.org/scripts/script.php?script_id=368


Scrinșot

Mai aveți?
« Last Edit: June 14, 2008, 06:20:46 PM by mapleoin » Logged

Master of the Darkside
Membru
*

almost retired


« Reply #10 on: June 24, 2008, 12:20:28 AM »

.vimrc

Code:
set nomodeline
set paste
set nu
set autoindent
set visualbell
set ruler
set wrap
set tabstop=4
set expandtab
set shiftwidth=4
map <F2> :w!<CR>
"map <F3> :edit .<CR>
"map <F4> :enew<CR>
map <F5> :bprevious<CR>
map <F6> :bnext<CR>
map <F7> :vsplit<CR>
map <F8> :split<CR>
map <F11> :runtime syntax/2html.vim<CR>
map <F12> :q!<CR>
:colo asu1dark
":colo baycomb
set mouse=a
set ttymouse=xterm2

Screenshotul e cam irelevant:

« Last Edit: June 24, 2008, 12:22:39 AM by Master of the Darkside » Logged

oblio
Admini
**


WWW
« Reply #11 on: July 02, 2008, 05:51:55 PM »

Ma astept sa fuga lumea cu furci si topoare dupa mine, dar recent am mai hacuit prin .vimrc. Ce-a iesit (e destul de comentat Smiley ):
Code:
"stop beeping when errors occur - set visual bell
set vb
"show invisible characters
set list
"set list of invisible characters
set listchars=eol:$,tab:>-,nbsp:%,precedes:(,extends:),trail:<
"stop making backup files
set nobackup
set nowritebackup
"stop Vi compatibility mode - allows multiple undo, ...
set nocompatible
"shows line numbers
set nu
"highlights the current line
set cursorline
"incremental search - search as you type
set incsearch
"automatic indent, great for programming
set autoindent
"show current line and other details in the bottom row
set ruler
"shows current command in the bottom row, before execution
set showcmd
"detect and highlight syntax
syntax on
"set no line wrapping
set nowrap
"filetype detection and textwidth
filetype on
"autocmd FileType text setlocal textwidth=80
"filetype specific options
filetype plugin on
"filetype specific indent
filetype plugin indent on
"use backspace as usual
set backspace=eol,indent,start
"command history
set history=1000
"replace tabs inserted with space
set expandtab
"tabs from indentation will be 2 spaces long
set shiftwidth=4
"tabs inserted will be 2 spaces long
set tabstop=4
"consecutive spaces will be treated as tabs
set softtabstop=4
"folding method
set foldmethod=marker
"foldmarker, so Vim will know where to fold
set foldmarker={{{,}}}
"not sure about this
set showfulltag
"show possible completion on the bottom command line
set wildmenu
set wildmode=list:full
"console vim gets to use the mouse :) vim ~ gvim this way :)
set mouse=a
"scroll ahead, to prevent ugly line scrolling
set scrolloff=3
"colorscheme - relaxing
colo oceandeep
"c comment
imap <F2> <Esc>0i/* <Esc>$a */
map <F2> <Esc>0i/* <Esc>$a */<Esc>
"c uncommment
imap <C-F2> <Esc>0xxx<Esc>$xxxi
map <C-F2> <Esc>0xxx<Esc>$xxx
"folding marker, for automatic folding
imap <F3> <Esc>i/* {{{ <Esc>a */
imap <F3> <Esc>i/* }}} <Esc>a */
"easy gui paste, with Ctrl-C
vmap <C-c> "+y
"unmap and remap Ctrl-A, for selecting all
map <C-a> <Esc>ggVG
"nice Windows font, good for Linux too
set guifont=Courier\ New\ Bold\ 13
"always show tabbar
set showtabline=2
"disable menubar & toolbar
set guioptions-=m
set guioptions-=T
"label on tabs, for Gvim and Vim
set guitablabel=%<%-20.40F\ %y
set tabline=%<%-20.40F\ %y
"tab completion
"Ctrl-Tab = Ctrl-X Ctrl-N - complete next
"Shift-Tab = Ctrl-X Ctrl-P - complete previous
"Tab = Tab (4 spaces)
imap <C-Tab> <C-X><C-N>
imap <S-Tab> <C-X><C-P>
imap <Tab> <Tab>
" Highlight spaces
highlight Spaces gui=underline guifg=Black
match Spaces /\s/
"start fullscreen on Windows (sends Alt-Space x)
au GUIEnter * simalt ~x

Da, folosesc Ctrl-C in Vim, o blasfemie (copiez chestii ca sa le dau paste in messenger sau mail, de exemplu) Scoate limba
« Last Edit: July 02, 2008, 05:53:57 PM by oblio » Logged

Distribuţie: ubuntu | Localitate: Bucureşti | Vârstă: 24

Oh! Everything has a point, and if it doesn't, then there's a point to it.

Oblio's
~Empathy~
Veteran
**

Decadence is Bliss...


« Reply #12 on: December 06, 2008, 03:24:34 PM »

Noul meu vimrc:

" Use Vim settings, rather then Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible

" the GUI version gets more coloured options then the CLI version
if has("gui")
   colorscheme oceandeep "http://www.vim.org/scripts/script.php?script_id=368
   set background=dark
   
   " disable menus and toolbars in GUI mode
   " unfortunately this doesn't work with MacVim
   set guioptions=-m
   set guioptions=-T

   set lines=50
   set columns=85 " 80 text columns + 5 line number columns

   set cursorline
   set cursorcolumn
else
   colorscheme delek
   set background=dark
endif

" display settings
set nowrap
set scrolloff=2
set number              " show line numbers
set showmatch           " show matching bracket
set showmode            " show mode in status bar
set showcmd             " display incomplete commands
set title
set ruler               " show the cursor position all the time
set laststatus=2        " use 2 lines for the status bar
set wildmenu            " completion with menu
set wildmode=list:longest,full
set bs=indent,eol,start " allow backspacing over everything in insert mode

" editor settings
set ignorecase          " ignore case in seacrhes...
set smartcase           " ...unless they contain upper case letters
set gdefault            " assume the g flag to :s substitutions
set magic               " change the way backslashes are used in search pattern

" misc settings
set nomodeline
set history=1024        " keep 1024 lines of command line history
set incsearch           " do incremental searching
" Suffixes that get lower priority when doing tab completion for filenames.
set suffixes=.bak,~,.swp,.o,.obj,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out.toc,.class

" mark as an error everything after 80 characters in a line
2match ErrorMsg /\%>80v.\+/   
" mark as an error all tabs that are not at the beginning of a line
3match ErrorMsg /[^\t]\zs\t\+/

if has("vms")
   set nobackup    " do not keep a backup file, use versions instead
else
   set backup      " keep a backup file
endif

" Don't use Ex mode, use Q for formatting
map Q gq

" In many terminal emulators the mouse works just fine, thus enable it.
if has('mouse')
   set mouse=a
endif

" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
   syntax on
   set hlsearch
endif

" Keybindings

" have <F1> prompt for a help topic, rather than displaying the introduction
" page, and have it do this from any mode:
nnoremap <F1> :help<Space>
vmap <F1> <C-C><F1>
omap <F1> <C-C><F1>
map! <F1> <C-C><F1>

" CTRL-U in insert mode deletes a lot.  Use CTRL-G u to first break undo,
" so that you can undo CTRL-U after inserting a line break.
inoremap <C-U> <C-G>u<C-U>

" file type specific settings
if has("autocmd")

   " Enable file type detection.
   " Use the default filetype settings, so that mail gets 'tw' set to 72,
   " 'cindent' is on in C files, etc.
   " Also load indent files, to automatically do
   " language-dependent indenting.
   filetype plugin indent on

   " Put these in an autocmd group, so that we can delete them easily.
   augroup vimrcEx
      au!

      " For all text files set 'textwidth' to 78 characters.
      autocmd FileType text setlocal textwidth=78

      " When editing a file, always jump to the last known cursor
      " position. Don't do it when the position is invalid or when
      " inside an event handler (happens when dropping a file
      " on gvim). Also don't do it when the mark is in the first
      " line, that is the default position when opening a file.
      autocmd BufReadPost *
      \ if line("'\"") > 1 && line("'\"") <= line("$") |
      \     exe "normal! g`\"" |
      \ endif

   augroup END
else
   set autoindent        " always set autoindenting on
   set smartindent
endif " has("autocmd")

" Really fancy status line from Sven Guckes
set statusline=Vim-%{Version()}\ %{getcwd()}\ \ %1*[%02n]%*\ %(%M%R%H%)\ %2*%F%*\ %=%{Options()}\ %3*<%l,%c%V>%*

fu! Version()
   return version
endf

fu! Options()
   let opt=""

   if &ai|            let opt=opt." ai"              |endif " autoindent
   if &et|            let opt=opt." et"              |endif " expandtab
   if &hls|           let opt=opt." hls"             |endif " hlsearch
   if &paste|         let opt=opt." paste"           |endif " paste
   if &shiftwidth!=8| let opt=opt." sw=".&shiftwidth |endif " shiftwidth

   let opt=opt." tw=".&tw  "  textwidth - show always!

   return opt
endf

" Smart autocomplete
setlocal omnifunc=syntaxcomplete#Complete
imap <Tab> <C-x><C-o>
inoremap <tab> <c-r>=InsertTabWrapper()<cr>

function InsertTabWrapper()
   let col = col('.') - 1
   if !col || getline('.')[col - 1] !~ '\k'
      return "\<tab>"
   else
      return "\<c-p>"
   endif
endfunction

" Load AutoClose script to close matched tokens automatically
source $HOME/.vim/scripts/autoclose.vim
AutoCloseOn

" Convenient command to see the difference between the current buffer and the
" file it was loaded from, thus the changes you made.
" Only define it when not defined already.
if !exists(":DiffOrig")
   command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
       \ | wincmd p | diffthis
endif

Logged

mapleoin
Admini
**

mapleoin@jabber.org


WWW
« Reply #13 on: December 06, 2008, 03:52:50 PM »

noul meu vimrc, care se schimbă foarte des:

Code:
set title
set autoindent
set expandtab " replaces tabs with spaces
set tabstop=4
set softtabstop=4
set shiftwidth=4
set guifont=Monospace\ 9
if has("gui")
    set guioptions-=m " no menu
    set guioptions-=T " no toolbar
    set lines=49
    set columns=161 " 2*80px vertical windows + scrollbars
    " colo oceandeep " http://www.vim.org/scripts/script.php?script_id=368
    " colo desert
     colo moria " http://www.vim.org/scripts/script.php?script_id=1464
     Colo dark
endif
set ignorecase " case insensitive search
set smartcase
if has("autocmd")
    autocmd BufEnter * :cd %:p:h
endif

set nosmartindent
set cindent
set copyindent
filetype plugin indent on
set wildmode=longest,list " smart autocomplete for commands/files on tab
set wildmenu
set nocompatible " undo and other things
set isk+=_,$,@,%,#,- " none of these should be word dividers
set ruler " always show current position along the bottom
" set number " line numbering
" set mouse=a " use mouse even in command line vim
set noerrorbells " don't make noise
" splitters between windows are blank:
set fillchars=vert:\ ,stl:\ ,stlnc:\
set wildmode=list:longest " tab-completion list
" set nohlsearch " do not highlight searched for phrases
set incsearch " BUT do highlight as you type you search phrase
" 2 visible whitespace with 's'
set listchars=tab:>-,trail:·,eol:$

nmap <silent> <leader>s :set nolist!<CR>
map <up> <ESC>:bp<RETURN> " left arrow (normal mode) switches buffers
map <down> <ESC>:bn<RETURN> " right arrow (normal mode) switches buffers

autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS

:abbr DATE <C-r>=strftime("%Y-%m-%d")<CR>
:abbr TIME <C-r>=strftime("%H:%M:%S")<CR>
map <C-b> :FuzzyFinderBuffer<CR>
« Last Edit: December 06, 2008, 03:53:09 PM by mapleoin » Logged

Master of the Darkside
Membru
*

almost retired


« Reply #14 on: December 07, 2008, 12:28:01 PM »

Noul meu vimrc:
...
   set cursorline
   set cursorcolumn
...


I has you in my crosshair! wow

PS: thanks for sharing
Logged

Pages: [1] 2   Go Up
  Print  
 
Jump to: