2017-07-03 47 views
2
let username = input('Enter username: ') 
let passw = input('Enter password: ') 

在vim輸入字段中輸入密碼時,不應該顯示它(或者應該顯示類似*******的東西)。我如何實現這一目標?如何在vimscript中輸入像'輸入'密碼?

+1

對不起,是「那個人」,但應考慮不這樣做! https://www.nngroup.com/articles/stop-password-masking/ – JeffUK

回答

2

你可以嘗試使用inputsecret()功能:從:h inputsecret(功能的

let username = inputsecret('Enter username: ') 
let passw = inputsecret('Enter password: ') 

說明:

inputsecret({prompt} [, {text}])   *inputsecret()* 
    This function acts much like the |input()| function with but 
    two exceptions: 
    a) the user's response will be displayed as a sequence of 
    asterisks ("*") thereby keeping the entry secret, and 
    b) the user's response will not be recorded on the input 
    |history| stack. 
    The result is a String, which is whatever the user actually 
    typed on the command-line in response to the issued prompt. 
    NOTE: Command-line completion is not supported.