nnoremap <leader>c :Ack '^class ' <c-r>=&path<cr><home><right><right><right><right>< ;right><right><right><right><right><right><right><right>
The general idea is to use Ack to search for pattern.
under the &path path.The n*<right>
in this mapping is so ugly. How can it be optimized?
After help from the community, I put the final method below:
" help input
function! AckClass()
let l:classPattern = input('Pattern: ')
execute " Ack '^class " . l:classPattern . "' " . &path
endfunction
command! AckClass call AckClass()
PHPz2017-05-16 16:40:35
I don’t know how far you want to interact
function! ChangeFileencoding()
let encodings = ['GB18030', 'GBK', 'cp936', 'utf-8', 'big5', "latin1", "euc-kr", "euc-jp", "ucs-bom", "shift-jis"]
let prompt_encs = []
let index = 0
while index < len(encodings)
call add(prompt_encs, index.'. '.encodings[index])
let index = index + 1
endwhile
let choice = inputlist(prompt_encs)
if choice >= 0 && choice < len(encodings)
execute 'e ++enc='.encodings[choice].' %:p'
endif
endf
This is my vimrc function that changes the encoding and opens the file. It will display a list of options for your reference