I used to remember that we can add some vim cmd line in the file’s head, and they will be executed when vim open the file.
I tried to add head line like this:
#vim map <F4> :close<CR>
But it did not work.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can’t add vim cmd line at the file head. If you have
where N>0 then lines like
at the start/end of the file (not more then N lines from the start/end) will set option tw (textwidth) to 40. You can write it in a fuller form:
, but it still accepting only options (
sethere is just ignored). It does not even accept all options (some of them are stated in the doc as “cannot be set from a modeline … for security reasons”). Without plugins you can’t have generic command here. Note that if you find one that allows running:mapcommand I will suggest not using it: it is very unsecure. I’ve seen only those that allow doing:letin modelines.By the way,
:closecommand can be typed as<C-w>cin close mode which is much faster then moving hands to<F4>.mapwithoutnorefor no reason. Plainmapmakes you think “what will the new mapping I add break” before adding it.*noremapwill make all mappings immune to breaking by any other mapping with different{lhs}.