我想做 vim snipMate 像 TextMate 一样
我使用 vim 和 snipMate 但我
if (true) {|};
在按 Enter 键后在 TextMate 中 发现这个问题键..在vim中查看光标
if (true) {
|
};
按Enter键后..查看光标
if (true) {
|};
如何制作vim,例如TextMate
感谢
编辑
这是我的vimrc
filetype on " Enable filetype detection
filetype indent on " Enable filetype-specific indenting
filetype plugin on " Enable filetype-specific plugins
" New Tab
nnoremap <silent> <C-t> :tabnew<CR>
" Next Tab
nnoremap <silent> <C-Right> :tabnext<CR>
" Previous Tab
nnoremap <silent> <C-Left> :tabprevious<CR>
abbrev ff :! Open -a Firefox.app %:p<cr>
abbrev gc :! Open -a Chrome.app %:p<cr>
" Set off the other paren
highlight MatchParen ctermbg=4
" }}}
"{{{Look and Feel
" Favorite Color Scheme
colorscheme sunburst
set guioptions-=T
" When I close a tab, remove the buffer
set nohidden
" Highlight things that we find with the search
set hlsearch
" Incremental searching is sexy
set incsearch
" This is totally awesome - remap jj to escape in insert mode. You'll never type jj anyway, so it's great!
inoremap jj <Esc>
" And so is Artificial Intellegence!
set smartcase
" Enable mouse support in console
set mouse=a
" Got backspace?
set backspace=2
" Line Numbers PWN!
set number
" Ignoring case is a fun trick
set ignorecase
" Who wants an 8 character tab? Not me!
set shiftwidth=3
set softtabstop=3
" Spaces are better than a tab character
set expandtab
set smarttab
" Who doesn't like autoindent?
set autoindent
set smartindent
set tabstop=4
set shiftwidth=4
set expandtab
" Needed for Syntax Highlighting and stuff
filetype on
filetype plugin on
syntax enable
set grepprg=grep\ -nH\ $*
set foldmethod=indent
set foldnestmax=10
set nofoldenable
set foldlevel=1
" This shows what you are typing as a command. I love this!
set showcmd
set cul
hi CursorLine term=none cterm=none ctermbg=3
set tabstop=2
set ruler " show the line number on the bar
set autoread " watch for file changes
set backspace=indent,eol,start
set cmdheight=2 " command line two lines high
set undolevels=1000 " 1000 undos
"map a change directory in desktop
nmap ,d :cd C:\Users\Tarek\Desktop<cr>:e.<cr>
""""""""""""""""""""""""""""""
" => Visual mode related
""""""""""""""""""""""""""""""
" Really useful!
" In visual mode when you press * or # to search for the current selection
vnoremap <silent> * :call VisualSearch('f')<CR>
vnoremap <silent> # :call VisualSearch('b')<CR>
" When you press gv you vimgrep after the selected text
vnoremap <silent> gv :call VisualSearch('gv')<CR>
map <leader>g :vimgrep // **/*.<left><left><left><left><left><left><left>
function! CmdLine(str)
exe "menu Foo.Bar :" . a:str
emenu Foo.Bar
unmenu Foo
endfunction
" From an idea by Michael Naumann
function! VisualSearch(direction) range
let l:saved_reg = @"
execute "normal! vgvy"
let l:pattern = escape(@", '\\/.*$^~[]')
let l:pattern = substitute(l:pattern, "\n$", "", "")
if a:direction == 'b'
execute "normal ?" . l:pattern . "^M"
elseif a:direction == 'gv'
call CmdLine("vimgrep " . '/'. l:pattern . '/' . ' **/*.')
elseif a:direction == 'f'
execute "normal /" . l:pattern . "^M"
endif
let @/ = l:pattern
let @" = l:saved_reg
endfunction
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Command mode related
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Smart mappings on the command line
cno $h e ~/
cno $d e ~/Desktop/
cno $j e ./
cno $c e <C-\>eCurrentFileDir("e")<cr>
cno $u e ftp://[email protected]/www/
" $q is super useful when browsing on the command line
cno $q <C-\>eDeleteTillSlash()<cr>
" Bash like keys for the command line
cnoremap <C-A> <Home>
cnoremap <C-E> <End>
cnoremap <C-K> <C-U>
cnoremap <C-P> <Up>
cnoremap <C-N> <Down>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Opens file in buffer in Chrome
abbrev ch :! @start "" /b "C:\Program Files\Google\Chrome\Application\chrome.exe" %:p
"Opens file in buffer in Firefox
abbrev fc :! @start "" /b "C:\Program Files\Mozilla Firefox\firefox.exe" %:p
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
imap <C-e> <C-y>,
imap <C-j> <C-x><C-o>
"" set guifont=Inconsolata\ 16
set nocp
if version >= 600
filetype plugin indent on
endif
let g:netrw_alto = 1
" Use menu to show command-line completion (in 'full' case)
set wildmenu
" Set command-line completion mode:
" - on first <Tab>, when more than one match, list all matches and complete
" the longest common string
" - on second <Tab>, complete the next full match and show menu
set wildmode=list:longest,full
" Show the bookmarks table on startup
let NERDTreeShowBookmarks=1
let b:surround_indent = 1
au BufRead,BufNewFile jquery.*.js set ft=javascript syntax=jquery
let g:js_indent_log = 0
i use vim with snipMate But I find this problem
if (true) {|};
in TextMate After pressing Enter key .. Look at the cursor
if (true) {
|
};
in vim After pressing Enter key .. Look at the cursor
if (true) {
|};
How to Make vim , such as TextMate
thanks
edit
this is my vimrc
filetype on " Enable filetype detection
filetype indent on " Enable filetype-specific indenting
filetype plugin on " Enable filetype-specific plugins
" New Tab
nnoremap <silent> <C-t> :tabnew<CR>
" Next Tab
nnoremap <silent> <C-Right> :tabnext<CR>
" Previous Tab
nnoremap <silent> <C-Left> :tabprevious<CR>
abbrev ff :! Open -a Firefox.app %:p<cr>
abbrev gc :! Open -a Chrome.app %:p<cr>
" Set off the other paren
highlight MatchParen ctermbg=4
" }}}
"{{{Look and Feel
" Favorite Color Scheme
colorscheme sunburst
set guioptions-=T
" When I close a tab, remove the buffer
set nohidden
" Highlight things that we find with the search
set hlsearch
" Incremental searching is sexy
set incsearch
" This is totally awesome - remap jj to escape in insert mode. You'll never type jj anyway, so it's great!
inoremap jj <Esc>
" And so is Artificial Intellegence!
set smartcase
" Enable mouse support in console
set mouse=a
" Got backspace?
set backspace=2
" Line Numbers PWN!
set number
" Ignoring case is a fun trick
set ignorecase
" Who wants an 8 character tab? Not me!
set shiftwidth=3
set softtabstop=3
" Spaces are better than a tab character
set expandtab
set smarttab
" Who doesn't like autoindent?
set autoindent
set smartindent
set tabstop=4
set shiftwidth=4
set expandtab
" Needed for Syntax Highlighting and stuff
filetype on
filetype plugin on
syntax enable
set grepprg=grep\ -nH\ $*
set foldmethod=indent
set foldnestmax=10
set nofoldenable
set foldlevel=1
" This shows what you are typing as a command. I love this!
set showcmd
set cul
hi CursorLine term=none cterm=none ctermbg=3
set tabstop=2
set ruler " show the line number on the bar
set autoread " watch for file changes
set backspace=indent,eol,start
set cmdheight=2 " command line two lines high
set undolevels=1000 " 1000 undos
"map a change directory in desktop
nmap ,d :cd C:\Users\Tarek\Desktop<cr>:e.<cr>
""""""""""""""""""""""""""""""
" => Visual mode related
""""""""""""""""""""""""""""""
" Really useful!
" In visual mode when you press * or # to search for the current selection
vnoremap <silent> * :call VisualSearch('f')<CR>
vnoremap <silent> # :call VisualSearch('b')<CR>
" When you press gv you vimgrep after the selected text
vnoremap <silent> gv :call VisualSearch('gv')<CR>
map <leader>g :vimgrep // **/*.<left><left><left><left><left><left><left>
function! CmdLine(str)
exe "menu Foo.Bar :" . a:str
emenu Foo.Bar
unmenu Foo
endfunction
" From an idea by Michael Naumann
function! VisualSearch(direction) range
let l:saved_reg = @"
execute "normal! vgvy"
let l:pattern = escape(@", '\\/.*$^~[]')
let l:pattern = substitute(l:pattern, "\n$", "", "")
if a:direction == 'b'
execute "normal ?" . l:pattern . "^M"
elseif a:direction == 'gv'
call CmdLine("vimgrep " . '/'. l:pattern . '/' . ' **/*.')
elseif a:direction == 'f'
execute "normal /" . l:pattern . "^M"
endif
let @/ = l:pattern
let @" = l:saved_reg
endfunction
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Command mode related
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Smart mappings on the command line
cno $h e ~/
cno $d e ~/Desktop/
cno $j e ./
cno $c e <C-\>eCurrentFileDir("e")<cr>
cno $u e ftp://[email protected]/www/
" $q is super useful when browsing on the command line
cno $q <C-\>eDeleteTillSlash()<cr>
" Bash like keys for the command line
cnoremap <C-A> <Home>
cnoremap <C-E> <End>
cnoremap <C-K> <C-U>
cnoremap <C-P> <Up>
cnoremap <C-N> <Down>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Opens file in buffer in Chrome
abbrev ch :! @start "" /b "C:\Program Files\Google\Chrome\Application\chrome.exe" %:p
"Opens file in buffer in Firefox
abbrev fc :! @start "" /b "C:\Program Files\Mozilla Firefox\firefox.exe" %:p
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
imap <C-e> <C-y>,
imap <C-j> <C-x><C-o>
"" set guifont=Inconsolata\ 16
set nocp
if version >= 600
filetype plugin indent on
endif
let g:netrw_alto = 1
" Use menu to show command-line completion (in 'full' case)
set wildmenu
" Set command-line completion mode:
" - on first <Tab>, when more than one match, list all matches and complete
" the longest common string
" - on second <Tab>, complete the next full match and show menu
set wildmode=list:longest,full
" Show the bookmarks table on startup
let NERDTreeShowBookmarks=1
let b:surround_indent = 1
au BufRead,BufNewFile jquery.*.js set ft=javascript syntax=jquery
let g:js_indent_log = 0
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将其放入您的 .vimrc 文件中:
Put this into your .vimrc file:
这不是 SnipMate 问题,而是缩进问题。可能与
set autoindent
有关。对我来说,它按你想要的方式工作。这是我所有与缩进相关的设置:
It's not a SnipMate problem but an indentation problem. probably related to
set autoindent
. For me it works as you want.Here are all my indentation related settings: