Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What autocmd FileType is in .vimrc?

Tags:

vim

I started using twitvim and found this code code for .vimrc.

But I am not sure what the last part of code is trying to do.

autocmd FileType twitvim call s:twitvim_my_settings()
function! s:twitvim_my_settings()
  set nowrap
endfunction

And this is the original code. I deleted all of <C-u>, <C-w> and j.

""" twitvim
let twitvim_count = 40
nnoremap ,tp :<C-u>PosttoTwitter<CR>
nnoremap ,tf :<C-u>FriendsTwitter<CR><C-w>j
nnoremap ,tu :<C-u>UserTwitter<CR><C-w>j
nnoremap ,tr :<C-u>RepliesTwitter<CR><C-w>j
nnoremap ,tn :<C-u>NextTwitter<CR>
autocmd FileType twitvim call s:twitvim_my_settings()
function! s:twitvim_my_settings()
  set nowrap
endfunction
like image 967
shin Avatar asked Nov 28 '22 15:11

shin


1 Answers

While Kent's answer is correct and very detailed, I thought I'd submit a visual version.

autocmd FileType twitvim call s:twitvim_my_settings()
|______________________| |__| | |___________________|
           |               |  |          |
           1               2  3          4   

1. Automatically do something when the FileType (the file extension) matches .twitvim
2. call (Vim's way to run a function)
3. Refers to a function local to the current script file
4. The function to be ran
like image 54
krystah Avatar answered Dec 05 '22 00:12

krystah